anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
import java.util.*;
public class Main{
public static void main(String[] args){
double ans = 0;
Scanner sc = new Scanner(System.in);
double t = sc.nextInt();
double x = sc.nextInt();
ans = t / x;
System.out.println(ans);
}
} | #include <stdio.h>
int main() {
float t, x, a;
scanf("%f%f", &t, &x);
a = t / x;
printf("%f\n", a);
} |
import java.io.*;
import java.util.*;
public class D1 {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
int b;
int decode(int x, int y) {
return x * b + y;
}
static final String DIRS = "ULDR";
static final int[] DX = { 0, -1, 0, 1 };
static final int[] DY = { 1, 0, -1, 0 };
stati... | #include <bits/stdc++.h>
using namespace std;
template <class T>
void setmin(T &a, T b) {
if (b < a) a = b;
}
template <class T>
void setmax(T &a, T b) {
if (b > a) a = b;
}
template <class T>
T gcd(T a, T b) {
return b == 0 ? a : gcd(b, a % b);
}
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
... |
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+... | T = int(raw_input())
for case_ in xrange(T):
n = int(raw_input())
ts = map(int, raw_input().split())
ss = map(int, raw_input().split())
dp = [0 for i in xrange(n)]
for i in xrange(n):
for j in xrange(i - 1, -1, -1):
if ts[i] == ts[j]:
continue
delta... |
import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;
p... | #include <bits/stdc++.h>
using namespace std;
struct node {
int l, r, x;
node *L, *R;
pair<int, int> v;
} nd[100100], *nil = &nd[100099], *root;
pair<int, int> p[100100];
int n, k, m, l, r;
long long a, b, c, d;
pair<int, int> upd(pair<int, int> l, pair<int, int> r) {
return make_pair(l.second + r.second,
... |
#include <bits/stdc++.h>
using namespace std;
int O[50000 + 5], on[50000 + 5], C;
map<int, int> Edge[50000 + 2];
vector<int> H[50000 + 2], gr[50000 + 2];
void On(int u) {
on[u] = 1;
if (gr[u].size() < C) {
for (int it = 0; it < gr[u].size(); it++)
if (gr[u][it] > 0) O[gr[u][it]]++;
}
}
void Off(int u) {... | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
im... |
#include <bits/stdc++.h>
int ind[10];
using namespace std;
int main() {
int n;
int a[100100];
int s = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
ind[a[i]]++;
}
if (ind[0] == 0) {
cout << -1;
return 0;
}
int kt = 1;
if (s % 3 != 0)
for (int j = 1; j <= ... | //package CodeForces;
import java.util.HashMap;
import java.util.Scanner;
public class Hometask {
static StringBuilder solve(int arr[])
{
if(arr[0]==0)
{
StringBuilder ans=new StringBuilder("-1");
return ans;
}
int temp=arr[1]+arr[4]+arr[7]+2*(arr[2]+arr[5]+arr[8]);
int x=temp%3;
if(x==1)
... |
while True:
H, W = map(int, input().split())
if H == 0 and W == 0:
break
for x in range(H):
for y in range(W):
if (x + y) % 2 == 0: print('#', end='')
else: print('.', end='')
print()
print()
| import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
Scanner sc = new Scanner(System.in);
int i, j;
// 最初の文字の固まりを整数値と想定して読み込む
while (true) {
int H = sc.nextInt();
int W= sc.nextInt();
if (H == 0 && W == 0) {
break; }
for(i=0; i<H; i++){
for(j=0; j<W; j++){
... |
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
template <typename first>
inline first abs(const first& a) {
return a < 0 ? -a : a;
}
template <typename first>
inline first sqr(const first& a) {
return a * a;
}
const int INF = INT_MAX / 2;
const long double EPS = 1e-9;
const... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ProblemC {
static int[][] board;
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String[] num = ... |
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class A {
public static int gcd(int a, int b) {
if(a == 0 || b == 0) return a+b; // base case
return gcd(b,a%b);
}
public static void main(Stri... | #include <bits/stdc++.h>
using namespace std;
int GCD(int A, int B) {
if (B == 0)
return A;
else
return GCD(B, A % B);
}
int main() {
int n;
cin >> n;
if (n % 2 == 0) {
int i = n / 2 - 1;
int j = n / 2 + 1;
while (GCD(i, j) != 1) {
i--;
j++;
}
cout << i << " " << j;
}... |
import sys
sys.setrecursionlimit(10**9)
n=int(input())
l=[[] for i in range(n)]
C=[0]*n
for i in range(n-1):
a,b,c=map(int,input().split())
a-=1
b-=1
l[a].append([b,c])
l[b].append([a,c])
def dfs(now,par,cost):
C[now]=cost
L=l[now]
for i in range(len(L)):
if L[i][0]==par:
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
vector<pair<int,int>> gra[100010];
ll dist[100010];
void dfs(ll x,ll y){
for(const auto& it:gra[x]){
ll s=it.first,len=it.second;
if(dist[s]!=-1)continue;
dist[s]=y+len;
dfs(s,dist[s]);
}
}
i... |
def solve():
from sys import stdin
f_i = stdin
while True:
N, T, L, B = map(int, f_i.readline().split())
if N == 0:
break
skip = {}
sq_attr = [None] * N
for i in range(L):
sq = int(f_i.readline())
sq_attr[sq] = 'Lose'
... | import java.util.Scanner;
public class Main {
Scanner in = new Scanner(System.in);
int N, T, L, B;
double[][] dp;
boolean[] lose, back;
public void run() {
while (true) {
N = in.nextInt();
T = in.nextInt();
L = in.nextInt();
B = in.nextInt();
if (B == 0 && N == 0 && T == 0 && L == 0) break;
... |
while True:
r, c, q = map(int, input().split())
if r == 0: break
querys = [list(map(int, input().split())) for _ in range(q)]
querys.reverse()
r_used = [False] * r
c_used = [False] * c
r_cnt = c
c_cnt = r
ans = 0
for a, b, o in querys:
if a == 0:
if not r_used[b]:
r_used[b] = True
... | import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
while (true) {
int r = sc.nextInt();
int c = sc.nextInt();
int q = sc.nextInt();
if ((r | c | q) == 0)
... |
#include <bits/stdc++.h>
using namespace std;
int n;
int a[8][3], b[8][3], pos[8][3];
bool ok = 0;
bool isCube() {
map<long long int, long long int> mp;
for (int i = 0; i < n - 1; ++i) {
for (int j = i + 1; j < n; ++j) {
long long int dt = (((long long int)a[i][0] - (long long int)a[j][0]) *
... | //package com.company;
import java.io.*;
import java.util.*;
public class Main {
static long TIME_START, TIME_END;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
// Scanner sc = new Scanner(new FileInputStream("Test.in"));
PrintWriter pw... |
import java.util.*;
import java.io.*;
public class BrokenSequence {
public static void main(String[] args) throws IOException {
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(rd.readLine());
StringTokenizer st = new StringTokenizer(rd.readLine());
int numMissing... | M=10**9+7
n=input()
a=[0]*n
l=map(int,raw_input().split())
for v in l:a[v-1]|=v>0
z=[0,0]
for x,y in zip(a,l):z[x]+=y<0
n,m=z
a=0;b=1
for i in range(m):b=b*-~i%M
for i in range(n):a,b=b,(a*i+b*(i+m))%M
print b
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int dp[N], ans[N];
int cumxor[N];
int lo(int n, int k) {
if (k % 2) {
if (n % k) return 0;
int ans = n / k - k / 2;
if (ans <= 0) ans = 0;
return ans;
} else {
if ((2 * n) % k) return 0;
int mid = 2 * n / k;
if (mid % 2... | import math
from collections import Counter
n = int(input())
g = [0 for i in range(n + 1)]
prefix_xor = g.copy()
def in_range(d, k):
if (2 * k - d * d + d) % (2 * d) != 0:
return -1
x = (2 * k - d * d + d) / (2 * d)
return int(x) if x > 0 else -1
def mex(arr):
counter = Counter()
for i ... |
#include <bits/stdc++.h>
using namespace std;
const int MN = 360360;
long long dp[MN + 1], a, b, k, lol, dp2[MN + 1];
long long solve(long long st, long long en) {
memset(dp2, 0, sizeof(dp2));
for (long long i = st + 1; i <= en; i++) {
dp2[i - st] = 1LL << 60;
for (int j = 2; j <= k; j++) {
long long ... | import java.util.*;
public class f {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
long a = input.nextLong(), b = input.nextLong();
int k = input.nextInt();
int lcm = 1;
for(int i = 2; i<=k; i++) lcm = lcm(lcm, i);
int[] dp = new int[2*lcm];
int start = (in... |
from collections import deque
n = int(input())
g = [[] for _ in range(n)]
for i in range(n):
_, _, *edge = map(lambda x: int(x)-1, input().split())
g[i] = edge
q = deque()
q.append(0)
dist = [-1 for _ in range(n)]
dist[0] = 0
while(len(q) > 0):
v = q.popleft()
for nv in g[v]:
if(dist[nv] !=... | //template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;
import java.util.*;
class Graph {
private int totalVertex;
private LinkedList<LinkedList<Integer>> adjList;
//adjacency list of edges
public Graph() { totalVertex = 0; }
public void loadAdjList() {
Scann... |
from math import *
n = int(input())
dx1 = 0
dx2 = 0
dy1 = 0
dy2 = 0
a = []
for i in range(n):
x,y = [int(x) for x in input().split()]
a.append([x,y,i])
a.sort(key = lambda item: atan2(item[1],item[0]))
a.append(a[0])
dx1 = (a[0][0]*a[1][0]+a[0][1]*a[1][1])
dy1 = abs(a[0][0]*a[1][1]-a[1][0]*a[0][1])
minx = (dx1)... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
public class Main_Educational1_C {
public static void main(String[] args) {
Scanner s... |
/**
* @author derrick20
*/
import java.io.*;
import java.util.*;
public class NavigationSystem {
public static void main(String args[]) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
N = sc.nextInt();
M = sc.nextInt();
... | #include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[200007];
int f[200007];
int cnt[200007];
int len;
int seq[200007];
void bfs(int st) {
queue<int> q;
f[st] = 1;
cnt[st] = 0;
q.push(st);
while (q.empty() == false) {
int x = q.front();
q.pop();
int sz = v[x].size();
for (int ... |
#!/usr/bin/env python
from __future__ import division, print_function
import io
import os
import sys
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
else:
from io import BytesIO as StringIO... |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class GraphWithoutLong... |
import java.util.*;
import java.awt.geom.*;
public class Main {
double EPS = 1.0e-08;
int INF = 1 << 24;
Comparator< Point2D > com = new Comparator< Point2D >() {
public int compare(Point2D o1, Point2D o2) {
if(o1.getX() < o2.getX()) return -1;
else if(o1.getX() > o2.getX()) return 1;
else if(o1.getY() <... | from heapq import heappush, heappop
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def dot3(O, A, B):
ox, oy = O; ax, ay = A; bx, by = B
return (ax - ox) * (bx - ox) + (ay - oy) * (by - oy)
def cross3(O, A, B):
ox, oy = O; ax, ay = A; bx, by = B
return (ax - ox) * (by - oy) - (bx - o... |
import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.util.Arrays.fill;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStrea... | #include <bits/stdc++.h>
using namespace std;
long long kk[10] = {1, 10, 100, 1000, 10000,
100000, 1000000, 10000000, 100000000, 1000000000};
map<long long, int> flag;
int id[11], a[11], n, ans;
long long Cantor(int p[]) {
long long tmp = 0;
for (int i = 1; i <= n; i++) tmp =... |
N = int(input())
for i in range(N):
L = []
while 1:
*s, = map(int, input().split())
if s[-1] == 0:
L.extend(s[:-1])
break
L.extend(s)
G = []
st = []
cur = 0
for s in L:
if s > 0:
G.append([])
if st:
u... | import java.util.*;
public class Main {
//0140 start
//0200 end
//0430 restart
//0442 sample match WA
//0509 WA * 2
//0920 WA * 2
//0921 AC
class C{
int count, rest;
ArrayList<Integer> list;
public C(int count, int rest) {
this.count = count;
this.rest = rest;
this.list = new ArrayList<Integer>... |
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
public class C {
static class Task {
private boolean isPrime(int num) {
int end = (int) Math.sqrt(num);
for (int i = 2; i <= end; i++) {
... | #include <bits/stdc++.h>
using namespace std;
void solve(int n, int x, int y) {
if (n == 2) {
cout << x << " " << y << endl;
return;
}
int val = y - x;
int ans = INT_MAX;
int ind_x, ind_y;
for (int i = 1; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
if (val % (j - i) == 0) {
in... |
import java.io.*;
import java.util.*;
public class H {
public static void main(String[] args) {
try {
new H().solve();
} catch (Exception e) {
e.printStackTrace();
}
}
void solve() throws IOException {
// Scanner sc = new Scanner(System.in);
... | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * (b / (gcd(a, b))); }
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
inline long long toL... |
#include <iostream>
using namespace std;
#define NM 20000
int main()
{
bool p[NM] = {0};
p[0]=p[1]=1;
for(int i=2; i*i<NM; i++)
{
if(!p[i])
for(int j=i*2; j<NM; j+=i)
{
p[j] = 1;
}
}
int n;
while(cin >> n)
{
int c=0;
for(int i=1; i<n+1; i++)
{
if((!p[i]) && (!p[n-i+1]))
{
c++;
... | import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String is;
while((is = in.readLine()) != null){
int a = Integer.par... |
n=int(input())
a,b=map(int,input().split())
c=int(input())
d=sorted([int(input()) for _ in [0]*n],reverse=True)
for i in d:
if c/a<(c+i)/(a+b):
c+=i
a+=b
else:
break
print(c//a)
| // 2012/11/19 Tazoe
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int N;
cin >> N;
int A, B;
cin >> A >> B;
int C;
cin >> C;
int D[100];
for(int i=0; i<N; i++){
cin >> D[i];
}
sort(D, D+N);
int c_sum = C;
int p_sum = A;
for(int i=N-1; i>=0; i--){
if(c_sum/p_sum>(c_s... |
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws FileNotFoundException {
//Scanner sc = new Scanner(new FileReader(new File("input")));
//System.setOut(new PrintStream(new FileOutp... | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, a[105], n, max_n = 0, m, x, maxm = 0, sum = 0;
cin >> n >> m;
for (i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
if (a[i] > maxm) {
maxm = a[i];
max_n = 1;
} else if (a[i] == maxm) {
max_n++;
}
}
sum = max... |
N = int(input())
A = list(map(int, input().split()))
print(sum([i&1 and a&1 for i,a in enumerate(A,1)])) | #include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
int n,a,ans=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a;
if(i%2==1&&a%2==1) ans++;
}
cout<<ans<<"\n";
} |
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
u64 arr[] = {
2,
3,
2,
395069,
2,
83,
2,
3,
2,
7,
2,
17,
2,
3,
2,
11,
2,
5,
2,
3,
2,
103,
2,
7,
2,
3,
2,
5,
2,
... | import java.math.*;
class Main{
public static void main(String[]z){
BigInteger b=BigInteger.ONE;
int i=2,n=new java.util.Scanner(System.in).nextInt();
for(;i<1501;i++)b=b.multiply(new BigInteger(String.valueOf(i)));System.out.println(b.add(new BigInteger("2")));
for(i=0;i<n;i++)System.out.println(i+2);
}
} |
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
def main():
n,m = map(int,input().split())
MOD = 998244353
adjList = []
dist = []
ans = []
for _ in range(n):
adjList.append([])
for _ in range(m):
a,b = map(int,input().split())
adjList[a - 1... | #include <bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define F(i, j, k) for (int i = j; i <= k; ++i)
#define DF(i, j, k) for (int i = j; i >= k; --i)
using namespace std;
template <typename T> inline void read(T &n) {
T w = 1;
n = 0;
char ch = getchar();
while (!isdigit(ch) &&... |
#include "bits/stdc++.h"
using namespace std;
long long int N,M,K,L,R,H,W;
const long long int MOD=1000000007;
int main(){
while(cin>>N,N){
M=0;
for(int i=2;i<=N;i++){
if((N*2)%i)continue;
K=N*2/i;
R=K+i-1;
if(R&1)continue;
R/=2;
L=R-i+1;
if(R+L==K&&L>=1)M++;
}
cout<<M<<endl;
}
ret... | while True:
n=input()
if n==0:break
cnt=0
for i in range(1,n):
temp=0
for j in range(i,n):
temp+=j
if temp==n:
cnt+=1
elif temp>n:
break
print cnt |
import java.util.Scanner;
public class codefo {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner ob =new Scanner(System.in);
int t=ob.nextInt();
while(t-->0)
{
int n=ob.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=ob.nextInt();
}
... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = n - 1; i >= 0; i--) cout << a[i]... |
import java.io.*;
import java.util.*;
public class Template implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws FileNotFoundException {
try {
in = new BufferedReader(new FileReader("input.txt"));
o... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2 * MOD;
int n, m;
int main() {
std::ios_base::sync_with_stdio(false);
set<int> zeros[17];
cin >> n >> m;
vector<int> a(n + 1);
for (int i = 0; i < 17; ++i) {
zeros[i].insert(0);
zeros[i].insert(n + 1... |
import sys
from array import array # noqa: F401
def readline(): return sys.stdin.buffer.readline().decode('utf-8')
def build_bridge_tree(v_count, edge_count, adj, edge_index):
from collections import deque
preorder = [0]
parent, order, low = [0]+[-1]*v_count, [0]+[-1]*(v_count-1), [0]*v_count
stac... | #include <bits/stdc++.h>
using namespace std;
static inline void canhazfast() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
T x0 = 1, y0 = 0, x1 = 0,... |
#include <bits/stdc++.h>
using namespace std;
string a, b;
int n;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> a >> b;
cin >> n;
cout << a << " " << b << '\n';
while (n--) {
string x, y;
cin >> x >> y;
if (x == a)
a = y;
else
b = y;
cout << a <... | import java.util.*;
import java.util.Arrays;
public class Main
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
String na=sc.next();
String nb=sc.next();
String a , b;
int n=sc.nextInt();
for(int i=0;i<n;i++)
{
... |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF... |
import java.util.*;
public class Main {
//1140 start
private void doit(){
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
int m = sc.nextInt();
int K = sc.nextInt();
if((n|m|K) == 0)break;
long [][] dp = new long[n+1][n * m + 1];
for(int i = 1; i < m+1; i++){
dp[1]... |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll t;
cin>>t;
while(t--){
ll x=0,y=0,n,c=0,sum=0,d,k;
cin>>d>>k;
while(1){
x+=k;
if(x*x+y*y>d*d)
break;
sum++;
y+=k;
if... | import java.util.*;
import java.io.*;
public class D{
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main (String[] args) throws IOException{
int t = Inte... |
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[100000 + 10];
int t[100000 + 10];
void solve() {
int res = 0;
for (int i = 0; i < n; i++) {
if (t[i]) res += a[i];
}
int tmp = 0, sum = 0;
for (int i = 0; i < k; i++) {
if (t[i] == 0) tmp += a[i];
}
for (int i = 0; i + k <= n; i++) {
... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CF0961B_LectureSleep {
static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
... |
t = int(input())
for _ in range(t):
n, x = map(int, input().split())
# n is the length of binary string. x is the balance: count of 0 - count of 1
s = input()
# prefix balance array
pref = [0]*n
pref[0] = 1 if s[0] == '0' else -1
x_found = 0
# infinite case
for i in range(n):... | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
string itos(int n) {
stringstream ss;
ss << n;
string second = ss.str();
return second;
}
long long ppow(long long x, long long y, long long mod) {
long long res = 1;
while (y) {
if (y & 1) res = res * x % mod;
y >>= 1;
x =... |
import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
import sys
letters = ascii_letters
input = stdin.readline
#print = stdout.write
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
need = sum([i for i in arr if i >= 0]... | #include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return fa... |
n= map(int, raw_input().split())
a = map(int, raw_input().split())
a1 = [0]*len(a)
table = {}
for i,x in enumerate(a):
if x-1 in table:
tmp = table[x-1]
table[x] = [tmp[1], i+1, tmp[2]+1]
a1[i] = tmp[1]-1
else:
table[x] = [-1,i+1,1]
a1[i] = -1
maxlen = 0
k = -1
for key, val in table.iteritems():
if val[2]... | /*
"जय श्री कृष्णा"
*/
import java.util.*;
import java.io.*;
public class Consecutive_Subsequences implements Runnable
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
this.br = new BufferedReader(new InputStreamReade... |
import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
static Scanner in = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
// Scanner in = new Scanner(new BufferedReader(new FileReader("input.txt")));
// PrintWriter out = new PrintWriter(new FileWriter("o... | '''
Created on Oct 11, 2015
@author: Ismael
'''
n=int(input())
l=[int(c) for c in input().split()]
count = 0
i=0
direc=1
change=0
while(count < n):
v = l[i]
if v <= count:
#print(i,"grab")
l[i] = n+1
count += 1
if count == n:
break
if (i == 0 and direc == -1) or (i == n-... |
//package round93;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;
public class E {
InputStream is;
PrintWriter out;... | #include <bits/stdc++.h>
using namespace std;
const int le = 20, ri = 21;
char z[] = "BRWY";
set<int> U;
int a[7][8], P[4][4], L[10], R[10], A[10], B[10], T = -1, p[22][22];
bool v[7][8], w[10][10], r2[7][8], d2[7][8], u[22];
char s[13][15], S[13][15];
void add(int x, int y) {
static int t = 0;
P[x][y] = P[y][x] = ... |
import sys
from collections import defaultdict as di
range = range
input = raw_input
class LazySegmentTree:
def __init__(self, data, default=0, func=max):
"""initialize the lazy segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._... | #include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 35100;
int n, k;
long long tree[60][4 * maxn];
long long lazy[64][4 * maxn];
int tail[maxn];
void push_up(int st, int pos) {
tree[st][pos] = max(tree[st][pos << 1] + lazy[st][pos << 1],
tree[... |
import sys
from collections import deque
from bisect import bisect_left
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
Ps = list(map(int, input().split()))
downs = []
for i in range(N-1):
if Ps[i+1] < Ps[i]:
downs.append(i)
if not downs:
print(1)
exit()
min_wait = deque()
max... | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
static InputStream is;
static PrintWriter out;
static String INPUT = "";
static void solve()
{
int n = ... |
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
if a <= sum(map(int, list(str(i)))) <= b:
ans += i
print(ans) | #include <iostream>
using namespace std;
int main(){
int n,a,b;
cin>>n>>a>>b;
int s=0;
for(int i=1; i<=n; i++){
int t=i,s1=0;
while(t!=0){
s1+=t%10;
t=t/10;
}
if(s1>=a && s1<=b){
s+=i;
}
}
cout<<s<<endl;
return 0;
} |
GetNetPeeringIdOk returns a tuple with the NetPeeringId field value if set, nil otherwise and a boolean to check if the value has been set. | func (o *CreateRouteRequest) GetNetPeeringIdOk() (*string, bool) {
if o == nil || o.NetPeeringId == nil {
return nil, false
}
return o.NetPeeringId, true
} |
WithAddr returns Option that sets addr | func WithAddr(addr string) Option {
return func(c *gatewayClient) {
if len(addr) != 0 {
c.addr = addr
}
}
} |
NewModExpr evaluates a % b, given two Numbers. | func NewModExpr(scanner parser.Scanner, a, b Expr) Expr {
return newArithExpr(scanner, a, b, "%%", func(a, b float64) float64 {
return math.Mod(a, b)
})
} |
Deprecated: Use Evidence.ProtoReflect.Descriptor instead. | func (*Evidence) Descriptor() ([]byte, []int) {
return file_tendermint_types_evidence_proto_rawDescGZIP(), []int{0}
} |
UnmarshalJSON supports json.Unmarshaler interface | func (v *Ingredient) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonD2b7633eDecodeBackendInternalModels8(&r, v)
return r.Error()
} |
AWSCloudFormationType returns the AWS CloudFormation resource type | func (r *AWSCodeDeployDeploymentGroup_AutoRollbackConfiguration) AWSCloudFormationType() string {
return "AWS::CodeDeploy::DeploymentGroup.AutoRollbackConfiguration"
} |
kubePutFn is entry point for `kube.put' callable. TODO(dmitryilyevskiy): Return Status object from the response as Starlark dict. | func (m *kubePackage) kubePutFn(t *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var name, namespace, apiGroup, subresource string
data := &starlark.List{}
unpacked := []interface{}{
"name", &name,
"data", &data,
"namespace?", &namespace,
// TOD... |
StringSliceContains returns if a string slice contains a particular string | func StringSliceContains(haystack []string, needle string) bool {
for _, str := range haystack {
if str == needle {
return true
}
}
return false
} |
wrapping struct: cel.Env export cel_Env_CTor | func cel_Env_CTor() CGoHandle {
return CGoHandle(handleFromPtr_cel_Env(&cel.Env{}))
} |
Transact invokes the (paid) contract method with params as input values. | func (_Hello *HelloTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Hello.Contract.contract.Transact(opts, method, params...)
} |
Replace replaces all nonoverlapping matches of the left pattern of t with the results of applying the right pattern of t. | func (t *T) Replace(needle string) (string, error) {
var out strings.Builder
cur := 0
if err := t.Search(needle, func(start, end int, match string) error {
out.WriteString(needle[cur:start])
out.WriteString(match)
cur = end
return nil
}); err != nil {
return "", err
}
return out.String(), nil
} |
RunJSONSerializationTestForCacheExpirationActionParameters_STATUS runs a test to see if a specific instance of CacheExpirationActionParameters_STATUS round trips to JSON and back losslessly | func RunJSONSerializationTestForCacheExpirationActionParameters_STATUS(subject CacheExpirationActionParameters_STATUS) string {
// Serialize to JSON
bin, err := json.Marshal(subject)
if err != nil {
return err.Error()
}
// Deserialize back into memory
var actual CacheExpirationActionParameters_STATUS
err = js... |
ChangeAdmin is a paid mutator transaction binding the contract method 0x8f283970. Solidity: function changeAdmin(admin_ address) returns() | func (_EtherDelta *EtherDeltaTransactorSession) ChangeAdmin(admin_ common.Address) (*types.Transaction, error) {
return _EtherDelta.Contract.ChangeAdmin(&_EtherDelta.TransactOpts, admin_)
} |
IsScriptRenderDelaying returns true if the node has one of these values for attribute 'customelement': ampdynamiccssclasses, ampexperiment, ampstory. | func IsScriptRenderDelaying(n *html.Node) bool {
if n.DataAtom != atom.Script {
return false
}
if IsScriptAMPViewer(n) {
return true
}
if v, ok := htmlnode.GetAttributeVal(n, "", AMPCustomElement); ok {
// TODO(b/77581738): Remove amp-story from this list.
return (v == AMPDynamicCSSClasses ||
v == AMPEx... |
createContext creates a new context based on transactionId, actionId, actionName, threadId, threadName, ProcessName | func createContext(transactionID, actionID, actionName, threadID, threadName, ProcessName string) context.Context {
ctx := context.Background()
ctx = context.WithValue(ctx, common.TransactionID, transactionID)
ctx = context.WithValue(ctx, common.ActionID, actionID)
ctx = context.WithValue(ctx, common.ActionName, ac... |
ToPatchRequestInformation update the navigation property journalLines in financials | func (m *CompaniesItemJournalsItemJournalLinesJournalLineItemRequestBuilder) ToPatchRequestInformation(ctx context.Context, body ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.JournalLineable, requestConfiguration *CompaniesItemJournalsItemJournalLinesJournalLineItemRequestBuilderPatchRequestConfigur... |
ShortNames implements the ShortNamesProvider interface. Returns a list of short names for a resource. | func (r *REST) ShortNames() []string {
return []string{"pvc"}
} |
IsNativeResource returns true if the resource name is in the kubernetes.io/ namespace. Partiallyqualified (unprefixed) names are implicitly in the kubernetes.io/ namespace. | func IsNativeResource(name corev1.ResourceName) bool {
return !strings.Contains(string(name), "/") ||
strings.Contains(string(name), corev1.ResourceDefaultNamespacePrefix)
} |
Serialize serializes information the current object | func (m *ManagementTemplateStepTenantSummary) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {
err := m.Entity.Serialize(writer)
if err != nil {
return err
}
{
err = writer.WriteInt32Value("assignedTenantsCount", m.GetAssign... |
Status used to set new status of record domain: Domain name recordID:The specified record ID that you want to get information enable:Status of the record to set, if incoming false, parsing does not take effect. | func (p *RecordAPI) Status(domain string, recordID int64, enable Enable) (err error) {
params := url.Values{}
params.Set("login_token", p.loginToken)
params.Set("format", "json")
params.Set("domain", domain)
params.Set("record_id", strconv.FormatInt(recordID, 10))
params.Set("status", enable.String())
res, err... |
Get returns expanded value of section's option. Panics if section or option are not found or if there's any Eval error. | func Get(section, option string) string {
return cfg.Get(section, option)
} |
Where adds a new predicate for the InstanceRuntimeQuery builder. | func (irq *InstanceRuntimeQuery) Where(ps ...predicate.InstanceRuntime) *InstanceRuntimeQuery {
irq.predicates = append(irq.predicates, ps...)
return irq
} |
DeleteAlbum will delete a given album | func DeleteAlbum(albumDeleteHash string, clientID string) {
url := "https://api.imgur.com/3/album/" + albumDeleteHash
method := "DELETE"
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
err := writer.Close()
if err != nil {
fmt.Println(err)
}
client := &http.Client{}
req, err := http.NewRe... |
WaitTime sets the basic wait time | func (r *Retry) WaitTime(waitTime time.Duration) dataflow.Retry {
r.waitTime = waitTime
return r
} |
how many paths from idx to the end? | func pathsFrom(idx int) int {
// are we already at the end? there's only one path then.
if idx == len(numbers)-1 {
return 1
}
// did we already calculate the paths from idx to the end? not calculate
// again.
paths, alreadyCalculated := pathsFromIndex[idx]
if alreadyCalculated {
return paths
}
for nxt :=... |
HasInterval returns a boolean if a field has been set. | func (o *ActionRunStatsInputProperties) HasInterval() bool {
if o != nil && o.Interval != nil {
return true
}
return false
} |
LoadUserLoggedProfile Load the user profile | func LoadUserLoggedProfile(w http.ResponseWriter, r *http.Request) {
cookie, _ := cookies.Read(r)
userID, _ := strconv.ParseUint(cookie["id"], 10, 64)
user, err := models.SearchCompleteUser(userID, r)
if err != nil {
responses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})
return... |
EngineClient returns a client to the Unsure Engine. | func (s *State) EngineClient() engine.Client {
return s.engineClient
} |
marshalStationviewsStationUploadViewToStationUploadResponseBody builds a value of type StationUploadResponseBody from a value of type stationviews.StationUploadView. | func marshalStationviewsStationUploadViewToStationUploadResponseBody(v *stationviews.StationUploadView) *StationUploadResponseBody {
res := &StationUploadResponseBody{
ID: *v.ID,
Time: *v.Time,
UploadID: *v.UploadID,
Size: *v.Size,
URL: *v.URL,
Type: *v.Type,
}
if v.Blocks != nil {... |
SparseCollectionToInterface casts a slice of interfaces to an interface of the correct type for the provided sparse collection. This should be used for sparse as it should be faster for larger arrays. | func SparseCollectionToInterface(elms []interface{}, indexes []int, size int) (interface{}, error) {
if len(elms) == 0 {
return nil, nil
}
first := elms[0]
var ok bool
switch v := first.(type) {
case bool:
arr := make([]bool, size)
for i, idx := range indexes {
e := elms[i]
if e == nil {
continu... |
ResolveReferences of this LBTargetGroup. | func (mg *LBTargetGroup) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)
var rsp reference.ResolutionResponse
var err error
rsp, err = r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.VpcID),
Extract: ... |
Passing an arrays between functions | func PassingArraysToFunctions() {
// Passing an array between functions can be an expensive operation in terms of memory and performance.
// When you pass variables between functions, they’re always passed by value. When your variable is an array,
// this means the entire array, regardless of its size, is copied and... |
NewGetUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient creates a new GetUserIssueSearchOptionsOfProjectVersionParams object with the default values initialized, and the ability to set a custom HTTPClient for a request | func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient(client *http.Client) *GetUserIssueSearchOptionsOfProjectVersionParams {
var ()
return &GetUserIssueSearchOptionsOfProjectVersionParams{
HTTPClient: client,
}
} |
SetShowsuppressed adds the showsuppressed to the list issue group of project version params | func (o *ListIssueGroupOfProjectVersionParams) SetShowsuppressed(showsuppressed *bool) {
o.Showsuppressed = showsuppressed
} |
culls the dead servers from vs.servers and returns the mostrecently pinged idle server | func (vs *ViewServer) cullDead() string {
mostRecentPing := ""
for key, element := range vs.servers {
if age := time.Since(element); age > (DeadPings * PingInterval){
if key == vs.thisView.Primary{
vs.mustReplacePrimary = true
} else if key == vs.thisView.Backup {
vs.mustReplaceBackup = true
}
d... |
calcID calculates the message ID for the given message node. The ID changes if the text content or meaning attribute changes. It is invariant to changes in description. | func calcID(n *ast.MsgNode) uint64 {
var buf bytes.Buffer
writeFingerprint(&buf, n, false)
var fp = fingerprint(buf.Bytes())
if n.Meaning != "" {
var topbit uint64
if fp&(1<<63) > 0 {
topbit = 1
}
fp = (fp << 1) + topbit + fingerprint([]byte(n.Meaning))
}
return fp & 0x7fffffffffffffff
} |
ExpandEnv like os.ExpandEnv, except supports `_FILE` vars as well | func ExpandEnv(s string) string {
fsys := datafs.WrapWdFS(osfs.NewFS())
return expandEnvVFS(fsys, s)
} |
NewTopic generates a new Topic for a given project and topic name. | func NewTopic(project, name string) Topic {
return Topic(newResource(project, "topics", name))
} |
HasFilter returns if a logger has a given filter by name. | func (l *Logger) HasFilter(flag, filterName string) bool {
l.Lock()
defer l.Unlock()
if l.Filters == nil {
return false
}
filters, ok := l.Filters[flag]
if !ok {
return false
}
_, ok = filters[filterName]
return ok
} |
GetSessionKeyInfo returns session key expiration info | func GetSessionKeyInfo(sessionKey string, clientCode string, client HttpClient) (*SessionKeyInfo, error) {
requestUrl := fmt.Sprintf(common.BaseUrl, clientCode)
params := url.Values{}
params.Add("sessionKey", sessionKey)
params.Add("request", "getSessionKeyInfo")
params.Add("clientCode", clientCode)
req, err := ... |
QueryUsers finds users in the DB that match parameters given in the 'query' map | func (stor *arrayUserStorage) Query(query map[string]interface{}) (out []User) {
stor.lock.RLock()
defer stor.lock.RUnlock()
if query == nil {
out = make([]User, len(stor.db))
copy(out, stor.db)
return
}
for _, user := range stor.db {
if matchesQuery(query, user) {
out = append(out, user)
}
}
return... |
Write writes content to a file named by path. A successful call returns err == nil | func (f FileManager) Write(path string, content []byte) error {
return ioutil.WriteFile(path, content, os.ModePerm)
} |
rename tmp file to final file | func renameFile(oldName string, newName string) bool {
err := os.Rename(oldName, newName)
if err != nil {
_ = os.Remove(oldName)
log.Println("Failed to rename file")
return false
}
return true
} |
Scatter returns false for diffuse light materials. | func (dl *DiffuseLight) Scatter(_ ray.Ray, _ *hitrecord.HitRecord, _ *fastrandom.LCG) (*ray.RayImpl, *scatterrecord.ScatterRecord, bool) {
return nil, nil, false
} |
getProvider looks up the registered openidconnect auth provider with the given ID. | func getProvider(id string) *provider {
if mockGetProviderValue != nil {
return mockGetProviderValue
}
p, _ := auth.GetProviderByConfigID(auth.ProviderConfigID{Type: providerType, ID: id}).(*provider)
return p
} |
WithProxyConfig returns a proxy config functional option | func WithProxyConfig(cfg config.Proxy) GRPCOption {
return func(h *GRPCHandler) {
h.proxyCfg = cfg
}
} |
ReadContent read the content of the csv file , handler func(string) | func ReadContent(file *os.File) (header []string, body [][]string, err error) {
r := csv.NewReader(file)
// 逐行读取
records, err := r.ReadAll()
if err != nil {
return nil, nil, err
}
header = records[0]
body = records[1:]
return header, body, nil
} |
NewLanguages returns a list of supported programming languages. NOTE: The 'timeout' value zero is passed into each New call as it's only useful during the `compute build` phase and is expected to be provided by the user via a flag on the build command. | func NewLanguages(kits config.StarterKitLanguages) []*Language {
// WARNING: Do not reorder these options as they affect the rendered output.
// They are placed in order of language maturity/importance.
//
// A change to this order will also break the tests, as the logic defaults to
// the first language in the li... |
/ Userdata set/get. Sets a user value that the DSP object will store internally. Can be retrieved with "DSP.UserData". This function is primarily used in case the user wishes to 'attach' data to an FMOD object. It can be useful if an FMOD callback passes an object of this type as a parameter, and the user does not know... | func (d *DSP) SetUserData(userdata interface{}) error {
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_DSP_SetUserData(d.cptr, unsafe.Pointer(&data))
return errs[res]
} |
shared by Put and Append. you can send an RPC with code like this: ok := ck.servers[i].Call("KVServer.PutAppend", &args, &reply) the types of args and reply (including whether they are pointers) must match the declared types of the RPC handler function's arguments. and reply must be passed as a pointer. | func (ck *Clerk) PutAppend(key string, value string, op string) {
// You will have to modify this function.
args := PutAppendArgs{
ClerkId: ck.clerkId,
Key: key,
Value: value,
Op: op,
}
if !ck.reSendFlag {
ck.opId++
}
args.OpId = ck.opId
reply := PutAppendReply{}
ok := ck.servers[ck.leader]... |
OnEndpointsUpdate is called whenever modification of an existing endpoints object is observed. | func (proxier *Proxier) OnEndpointsUpdate(oldEndpoints, endpoints *api.Endpoints) {
namespacedName := types.NamespacedName{Namespace: endpoints.Namespace, Name: endpoints.Name}
if proxier.endpointsChanges.Update(&namespacedName, oldEndpoints, endpoints) && proxier.isInitialized() {
// proxier.syncRunner.Run()
prox... |
ownerToString generate a string to identify the owner matches nodeToString format | func ownerToString(node *yaml.RNode) (string, error) {
meta, err := node.GetMeta()
if err != nil {
return "", err
}
namespace := meta.Namespace
owners, err := node.Pipe(yaml.Lookup("metadata", "ownerReferences"))
if err != nil {
return "", err
}
if owners == nil {
return "", nil
}
elements, err := own... |
DeleteOrgHook deletes and existing org level webhook. | func (c *client) DeleteOrgHook(org string, id int, req HookRequest) error {
c.log("DeleteOrgHook", org, id)
path := fmt.Sprintf("/orgs/%s/hooks/%d", org, id)
return c.deleteHook(org, path)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.