akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int i;
char s[200005];
int main(){
    cin>> s + 1;
    for(i = 1; s[i] != 0; i++){
        if(s[i] == '?'){
            cout<<'D';
        }
        else{
            cout<< s[i];
        }
    }
}


Measured memory_bytes: 3828
#include <iostream>

using namespace std;
using ll = long long;

int main(){
   ll n, m;

   cin >> n >> m;
   if(m > n * 2){
       m -= n * 2;
       cout << n + m / 4 << endl;
   }else{
       cout << m / 2 << endl;
   }
}


Measured memory_bytes: 3580
/**
 *      ABC 94 A
 *      author : kyomukyomupurin
 *      created : 2018/8/27
**/


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int A, B, X;
    cin >> A >> B >> X;
    A + B >= X && A <= X ? cout << "YES" << endl : cout << "NO" << endl;

    return 0;
}




Measured memory_bytes: 256
X, N = input().split()
p = list(map(int, input().split()))
Z = list(range(0, 102))

q = [i for i in Z if i not in p]
t = []

for i in range(0, len(q)):
    t.append(abs(int(X)-q[i]))

print(q[(t.index(min(t)))])

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a,b,S=0;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> a >> b;
    S = S + (b - a + 1);
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
// package atcoder.tokio_marine_insurance_2020;

import java.io.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "takahashi";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); char[] A = nca();

        bw.write(""+A[0]+A[1]+A[2]);
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

Measured memory_bytes: 37016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main(){
  string s;
  string t;
  cin >> s;
  cin >> t;
  int N = s.size();
  s = s + s;
  bool f = false;
  rep(i,N){
    if(t == s.substr(i,N)) f = true;
  }
  answer(f);
}
  





Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = [-int(i) for i in input().split()]
li = sorted(li)

for _ in range(m):
	x = heapq.heappop(li)
	#print(x)
	if x % 2 == 0:
		heapq.heappush(li, x // 2)
	else:
		heapq.heappush(li, x // 2 + 1)
	#print(li)
print(-sum(list(li)))



Measured memory_bytes: 59800
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// llの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
void dfs(){ 
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  ll n,k; cin >> n >>k;
  vector<ll> a=vector<ll>(n);
  vector<ll> time=vector<ll>(n+1,-1);
  vector<ll> mitisuzi;
  REP(i,n) cin >> a[i];
  ll v=0;
  mitisuzi.PB(0);
  do{
    time[v]=SIZE(mitisuzi); 
    mitisuzi.PB(a[v]-1);
    v=a[v]-1;
  }while(time[v]==-1); 
  ll c=SIZE(mitisuzi)-time[v];
  ll l=time[v];
  //cout << c << l;
  //for(int i:mitisuzi) cout << i << endl;
  if(k<=l) cout << mitisuzi[k]+1 << endl;
  else{
    k=k-l;
    k%=c;
    cout << mitisuzi[l+k]+1<< endl;
  }
  

  return 0;
}


Measured memory_bytes: 8408
#include <stdio.h>
 
int main(void){
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if((a + b) % 2 == 1)a = a + 1;
	
	printf("%d\n",(a + b) / 2);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,m,i,c[100005],a,b,v,k,t[100005];
set<int> g[100005];
vector<int>first_half;
vector<int>second_half;
vector<int>total;
int par[209],group[209];
int arra[150000];
vector<int>arr;
map<char,int>cp;
map<int,int>mp;
deque<char>stp1;
deque<char>stp2;
map<int,int>pos;
map<string,int>check;
map<string,string>server;
vector<string>ans1;
vector<string>ans2;
vector<string>ans3;
string server1[1009];
string ip1[1009];
string server2[1009];
string ip2[1009];
ll cashier[109];
ll fir[109];
ll sec[100009];
vector<ll>sl1;
vector<ll>sl2;
#define pi acos(-1)
int main()
{
  	
  ll a,b,c=0,d,e,f,g,h,i,j,k,l,n,s1=1,s2=1,m1=5,m2=15,t,m,mod=1000000007;
  //cin>>t;
  
  double R,to=2,piR;
  cin>>R;
  piR=to*pi*R;
  printf("%.22lf",piR);
       
  
  
  
 
  
  
    	
  }
  
  
  
  	

Measured memory_bytes: 8592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    vector<int> sorted(n);
    rep(i,n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    sort(ALL(sorted));
    int max = sorted[n-1];
    int semimax = sorted[n-2];
    rep(i,n){
        if(a[i] == max) cout << semimax << endl;
        else cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
N,M = map(int,input().split())
if N % 4 in [1,2]:
    odd_pair = [N//2//2 , N//2//2+1]
    even_pair = [N-N//2//2-1,N-N//2//2+1]
elif N%4==3:
    odd_pair = [N-N//2//2-1 , N-N//2//2]
    even_pair = [N//2//2,N//2//2+2]
elif N%4==0:
    odd_pair = [N-N//2//2 , N-N//2//2+1]
    even_pair = [N//2//2,N//2//2+2]
cnt = 0
while True:
    print(*odd_pair)
    cnt += 1
    if cnt == M:
        break
    odd_pair[0] -= 1
    odd_pair[1] += 1
    print(*even_pair)
    cnt += 1
    if cnt == M:
        break
    even_pair[0] -= 1
    even_pair[1] += 1
    

Measured memory_bytes: 9256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * The largest number should become less than n
 * 
 * If k <= 10^16 + 1000 we can directly take a single element of k - 1
 * Take everything as multiples of n
 * n * x1 +  
 * whenever there are a few numbers you can keep on subtracting n from a number until it's
 * value is less than n
 * that should be ai/n ops and ai/n should be added to others and ai = ai % n
 * until all the values are less than n
 * 
 * 4 4 and n = 2
 * (2 5) -> (3 3) -> (1 4) -> (2 2) -> (0 3) -> (1 1)
 * 5 5 and n = 2
 * (3 6) -> (4 4)
 * 4 4 4 and n = 3
 * (2 5 5) -> (3 3 6) -> (4 4 3)
 *
 * (49/50)*(49/50) * MX 
 * */

int main() {
	int n;
	cin >> n;
	vector <ll> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	ll ans = 0;
	while(true) {
		int pos = -1;
		for (int i = 0; i < n; i++) {
			if (A[i] < n) continue;
			pos = 1; 
			for (int j = 0; j < n; j++) {
				if (i != j) {
					A[j] += (A[i] / n);
				}
			}
			ans += (A[i] / n);
			A[i] = A[i] % n;
		}
		if (pos == -1) {
			break;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
void merge(int *,int,int,int);
void mergesort(int*,int,int);
long long cnt=0;
int L[100002],R[100002];
int main(){
  int A[200000],i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergesort(A,0,n);
  printf("%ld\n",cnt);
  return 0;
}
void merge(int *a,int left,int mid,int right){
  int i,k,j,n1=mid-left,n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=2147483647;
  R[n2]=2147483647;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j])a[k]=L[i++];
    else{
      a[k]=R[j++];
      cnt+=n1-i;
    }
  }
  return;
}
void mergesort(int *a,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(a,left,mid);
    mergesort(a,mid,right);
    merge(a,left,mid,right);
  }
  else return;
}



Measured memory_bytes: 4316
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define foreach(e, v) for (auto e : v)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y, x%y);
}

int main(){
    int n, k; cin >> n >> k;
    vector<double> expected_sum(n+1);
    expected_sum[0] = 0;
    reps(i,1,n){
        double p; cin >> p;
        expected_sum[i] = expected_sum[i-1] + (p+1)/2;
    }
    double res = -1;
    rep(i,n-k+1){
        res = max(res, expected_sum[i+k]-expected_sum[i]);
    }
    printf("%f\n",res);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long

vector<int>prime(1000005,0);
bool mark[1000005];
int nprime;

void sieve(int n)///FINDING PRIME
{
    int limit=sqrt(n*1.0)+1,s=0;nprime=0;
    mark[1]=true;///true if not prime.
    mark[2]=false;
    prime[nprime++]=2;
    for(int i=3;i<=n;i+=2){
        if(!mark[i]){prime[nprime++]=i;
            if(i<=limit){///karon limit er upor theke n porjonto not prime gula already cuta hoise.
                for(int j=i*i;j<=n;j+=i*2){
                    mark[j]=true;
                }
            }
        }
    }
}

ll nod(ll n)///Number of divisors
{
    ll nod=1,x3=1,sqrtN=sqrt(n)+1;
    for(int i=0;prime[i]<=sqrtN&&i<nprime;i++){
        if(n%prime[i]==0){
            while(n%prime[i]==0){
                n/=prime[i];
                x3++;
            }nod*=x3;x3=1;
        }
    }
    if(n>1)nod*=2;

    return nod-1;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll dg[201]={0};
    for(int i=1;i<=200;i++){
        for(int j=i;j<=200;j+=i){
            dg[j]++;
        }
    }
    ll n;
    cin>>n;
    ll s=0;
    for(int i=1;i<=n;i+=2){
        if(dg[i]==8)s++;
    }
    cout<<s;
}


Measured memory_bytes: 7060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 4010
using namespace std;
ll n,dp[N][4][4],ans=0;//'R'->0 'G'->1 'B'->2
vector<ll> v;
int main(){
	ll i,j,k,l;
	char c;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>c;
		if(c=='R')
		{
			v.push_back(0);
		}
		else if(c=='G')
		{
			v.push_back(1);
		}
		else
		{
			v.push_back(2);
		}
	}
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;i++)
	{
		dp[i][v[i]][1]++;
		for(j=0;j<i;j++)
		{
			if(v[j]==v[i])
			{
				continue;
			}
			k=3;
			l=j-(i-j);
			if(l<0)
			{
				dp[i][v[j]][k]+=dp[j][0][k-1]+dp[j][1][k-1]+dp[j][2][k-1];
			}
			else if(v[l]==v[j]||v[l]==v[i])
			{
				dp[i][v[j]][k]+=dp[j][0][k-1]+dp[j][1][k-1]+dp[j][2][k-1];
			}
			else
			{
				dp[i][v[j]][k]+=dp[j][0][k-1]+dp[j][1][k-1]+dp[j][2][k-1]-1;
			}
			dp[i][v[j]][k]-=dp[j][v[i]][k-1];
			k=2;
			dp[i][v[j]][k]+=dp[j][v[j]][k-1];
		}
	}
	for(i=0;i<n;i++)
	{
		ans+=dp[i][0][3]+dp[i][1][3]+dp[i][2][3];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4152
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]
    d = i[3]

    if not (0 <= a and a < b and b <= 100 and 0 <= c and c < d and d <= 100):
        return
    if not (isinstance(a, int) and isinstance(b, int) and isinstance(c, int) and isinstance(d, int)):
        return
    
    if(b <= c or d <= a):
        print(0)
    elif(a <= c and c < b and b <= d):
        print(b - c)
    elif(c <= a and a < d and d <= b):
        print(d - a)
    elif(a <= c and d <= b):
        print(d - c)
    elif(c <= a and b <= d):
        print(b - a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;



int main(){
  int64_t N,M;
  cin>>N>>M;
  map<int64_t,int64_t> kaz;
  for(int i=0;i<M;i++){
    int64_t a,b;
    cin>>a>>b;
    if(min(a,b)==1){
      kaz[max(a,b)]++;
    }
    if(max(a,b)==N){
      kaz[min(a,b)]++;
    }
  }
  for(auto & x:kaz){
    if(x.second>=2){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  
}

Measured memory_bytes: 15960
#include<bits/stdc++.h>
using namespace std;

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  
  if(a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n;
    cin >> n;

    vector<int> x(n);
    for(int i = 0; i < n;i++) cin >> x[i];
    vector<int> t = x;
    lsort(t);

    for(int i = 0; i < n; i++){
        if(x[i] <= t[(n - 1) / 2]) cout << t[(n - 1) / 2 + 1] << "\n";
        else cout << t[(n - 1) / 2] << "\n";
    }

    return 0;
}

Measured memory_bytes: 3840
from itertools import permutations

a_list = [int(x) for x in input().split()]

ans = sum(a_list)
for temp in list(permutations(a_list)):
    temp_ans = abs(temp[1] - temp[0]) + abs(temp[2] - temp[1])
    if temp_ans < ans:
        ans = temp_ans
print(ans)

Measured memory_bytes: 3060
import sys

rl=lambda:next(sys.stdin)
rfs=lambda:rl().split()
ris=lambda:map(int,rfs())

N,M,K=ris()

adj=[{*()} for _ in range(N)]
for _ in range(M):
    A,B=ris()
    A,B=A-1,B-1
    adj[A].add(B)
    adj[B].add(A)

c=-1
cs=[c]*N
ct={}
for u in range(N):
    if cs[u]!=-1:
        continue
    c+=1
    cs[u]=c
    stk=[u]
    while stk:
        u=stk.pop()
        if c not in ct:
            ct[c]=0
        ct[c]+=1
        for v in adj[u]:
            if cs[v]!=-1:
                continue
            cs[v]=c
            stk.append(v)

ans=[0]*N
for u in range(N):
    g=ct[cs[u]]-1
    f=len(adj[u])
    ans[u]=g-f

for _ in range(K):
    A,B=ris()
    A,B=A-1,B-1
    if cs[A]==cs[B]:
        ans[A]-=1
        ans[B]-=1

print(*ans)


Measured memory_bytes: 117036
#include<stdio.h>
#include<stdlib.h>

void swap(int *a,int *b){
	int temp=*a;
	*a=*b;
	*b=temp;
}

int main(void){
	int w,n,i,m,k;
	int *a;

	scanf("%d", &w);
	a=calloc(w,sizeof(int));
	for(i=0;i<w;i++) a[i]=i+1;

	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d,%d", &m,&k);
		swap(&a[m-1],&a[k-1]);
	};
	for(i=0;i<w;i++) printf("%d\n",a[i]);
	return (0);
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N, K;
    cin >> N >> K;
    int n = K;
    int cnt = 1;
    bool a = true;\
    if(N == 1){cout << 1;return 0;}
    while(a){
        K *= n;
        cnt++;
        if(K > N){cout << cnt;break;}
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int x;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x;
	int div = x / 500;
	cout << div * 1000 + 5 * ((x % 500) / 5) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int t, n, a;
    cin >> n >> t >> a;
    int h;
    pii menor = {INFINITO, -1};

    fo(i, n) {
        cin >> h;
        int dist = abs(1000 * a - (1000 * t - h * 6));
        if ( dist < menor.ff ) {
            menor.ff = dist;
            menor.ss = i + 1;
        }
    }

    cout << menor.ss << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n,k; cin >> n >> k;
  int r,s,p; cin >> r >> s >> p;
  string t; cin >> t;
  int ans = 0;
  rep(i,n){
    if(t[i] == 'r'){
      ans += p;
      if(t[i+k] == 'r' && i+k < n) t[i+k] = '*';
    }
    if(t[i] == 's'){
      ans += r;
      if(t[i+k] == 's' && i+k < n) t[i+k] = '*';
    }
    if(t[i] == 'p'){
      ans += s;
      if(t[i+k] == 'p' && i+k < n) t[i+k] = '*';
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define FOR(i,n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;

#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int main(){
	int x,a;
	cin >> x >> a;
	if(x<a) cout << 0;
	else cout << 10;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace Q2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).OrderByDescending(i => i);

            var longest = l.First();
            var sumOfOther = l.Skip(1).Sum();

            var answer = longest < sumOfOther ? "Yes" : "No";

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
bingo1 = list(input().split())
bingo2 = list(input().split())
bingo3 = list(input().split())


for i in range(3):
    bingo1[i] = int(bingo1[i])
    bingo2[i] = int(bingo2[i])
    bingo3[i] = int(bingo3[i])
n = int(input())

atari = []
for i in range(n):
    a = int(input())
    atari.append(a)

if bingo1[0] in atari:
    bingo1[0] = 'y'
if bingo1[1] in atari:
    bingo1[1] = 'y'
if bingo1[2] in atari:
    bingo1[2] = 'y'
if bingo2[0] in atari:
    bingo2[0] = 'y'
if bingo2[1] in atari:
    bingo2[1] = 'y'
if bingo2[2] in atari:
    bingo2[2] = 'y'
if bingo3[0] in atari:
    bingo3[0] = 'y'
if bingo3[1] in atari:
    bingo3[1] = 'y'
if bingo3[2] in atari:
    bingo3[2] = 'y'

if bingo1[0] == bingo2[0] == bingo3[0] == 'y':
    print('Yes')
elif bingo1[1] == bingo2[1] == bingo3[1] == 'y':
    print('Yes')
elif bingo1[2] == bingo2[2] == bingo3[2] == 'y':
    print('Yes')

elif bingo1[0] == bingo1[1] == bingo1[2] == 'y':
    print('Yes')
elif bingo2[0] == bingo2[1] == bingo2[2] == 'y':
    print('Yes')
elif bingo3[0] == bingo3[1] == bingo3[2] == 'y':
    print('Yes')

elif bingo1[0] == bingo2[1] == bingo3[2] == 'y':
    print('Yes')
elif bingo1[2] == bingo2[1] == bingo3[0] == 'y':
    print('Yes')

else:
    print('No')


Measured memory_bytes: 3188
N = int(input())
a =0
b = 0
ans = 0
cnt = 0
for i in range(N):
  s = input()
  if s[0]=="B":
    b+=1
  if s[-1]=="A":
    a+=1
  if s[0]=="B" and s[-1]=="A":
    cnt+=1
  ans+=s.count("AB")
if max(a,b)>cnt or cnt==0:
	print(ans+min(a,b))
else:
    print(ans+min(a,b)-1)

Measured memory_bytes: 3064
dic = {}
for s in raw_input().split():
	dic[s] = dic.get(s, 0) + 1
val = dic.items()
most = sorted(val, key=lambda i:i[1], reverse=True)[0][0]
length = sorted(val, key=lambda i:len(i[0]), reverse=True)[0][0]
print most, length

Measured memory_bytes: 4216
#include<iostream>
using namespace std;
int main(){
  
  //変数
  string s;
  
  //入力
  cin >> s;
  
  //トッピングの数
  int count = 0;
  for(int i = 0; i < 3; i++) if( s[i] == 'o' ) count++;
  
  //出力
  cout << (700 + count*100) << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end(), greater<int>());
    
    int A_sum = accumulate(A.begin(), A.end(), 0);
    double line = (A_sum+(4*M)-1) / (4 * M);
    for (int i = 0; i < M; i++) {
        if (A.at(i) < line) {
            cout << "No" << endl;
            return 0;
        }    
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main()
{
  int n;
  
  cin>>n;
  
  bool flag=false;
  
  for(int i=1;i<10;i++)
  {
    for(int k=1;k<10;k++)
    {
      if(n==(i*k))
      {
        flag=true;
      }
    }
  }
  
  if(flag)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int A[200];
int N;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    sort(A, A+N);

    int res = A[N - 1] - A[0];
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>
#include<math.h>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}

lli check(vector<lli>& vec, lli n,lli cmp, lli num) {
	if (num > 26)return -1;
	if (vec[n] == cmp)return 1;
	else return check(vec, vec[n], cmp, num + 1);
}

int main() {
	lli n;
	cin >> n;
	string s;
	lli num = 0,k=1;
	while (num != n) {
		if (((n-num) % (lli)pow(2, k)+ (lli)pow(2, k))% (lli)pow(2, k) == 0) {
			s = "0"+s;
			num += 0;
		}
		else {
			if ((n % (lli)pow(2, k) + (lli)pow(2, k)) % (lli)pow(2, k) == ((num + (lli)pow(2, k-1)) % (lli)pow(2, k) + (lli)pow(2, k)) % (lli)pow(2, k) ){
				num += (lli)pow(-2, k-1);

			}else num -= (lli)pow(-2, k-1);
			s = "1" + s;
		}
		k++;

	}
	if (n == 0)s += "0";
	cout << s;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>

#define endl '\n'

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, temp;
    cin >> N;
    int balls[N+1];
    long long int counts[N+1];
    for(int i = 0; i < N+1; ++i) {
        counts[i] = 0;
    }
    for(int i = 1; i <= N; ++i) {
        cin >> balls[i];
        counts[balls[i]] += 1;
    }
    long long int total_sum = 0;
    for(int i = 1; i <= N; ++i) {
        total_sum += (counts[i] * (counts[i] - 1) / 2);
    }
    long long int sum = 0;
    for(int i = 1; i <= N; ++i) {
        long long int num_1 = counts[balls[i]];
        long long int num_2 = counts[balls[i]] - 1;
        sum = total_sum - (num_1 * (num_1 - 1) / 2) + (num_2 * (num_2 - 1) / 2);
        cout << sum << endl;

    }
    // for(int i = 1; i < N+1; ++i)
    //     cout << counts[i] << " ";
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
 
        long cnt = b/x - a/x;
        if (a%x==0) cnt++;
 
        System.out.println(cnt);
 
        sc.close();
 
    }
 
}

Measured memory_bytes: 9684
var
	H,W,i,j,x:Longint;
	S,T:String[100];
	dp:Array[1..100]of Longint;
begin
	readln(H,W);
	S[1]:='.';
	for j:=2 to W do dp[j]:=100000;
	for i:=1 to H do begin
		readln(T);
		for j:=1 to W do if S[j]>T[j]then inc(dp[j]);
		S:=T;
		for j:=2 to W do begin
			x:=dp[j-1];
			if S[j-1]>S[j]then inc(x);
			if x<dp[j]then dp[j]:=x;
		end;
	end;
	writeln(dp[W]);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N), point(N, K - Q);
    rep(i, Q)
    {
        int a;
        cin >> a;
        point.at(a - 1)++;
    }
    rep(i, N)
    {
        if (point.at(i) > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cout.precision(7);

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n;
  cout << (((double)n - n / 2) / (double)n);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;

int X, A, B;
int ans;
void input(void){
    cin >> X >> A >> B;
}

void solve(void){
    ans = X - (A + ((X - A) / B) * B);
    cout << ans << endl;
}

int main(void){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }else{
            if(x < y){
                cout << x << " " << y << '\n';
            }else{
                cout << y << " " << x << '\n';
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;

const int N = 1 << 20;

long long dp[1100][110000];
int v[N], w[N], vv[N], L[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> v[i] >> w[i];
	for (int i = 1; i < 1024; i++) {
		for (int j = 0; j <= 100000; j++) {
			dp[i][j] = max(dp[i][j], dp[i / 2][j]);
			if (j + w[i] <= 100000) dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i / 2][j] + v[i]);
		}
	}
	int Q; cin >> Q;
	for (int i = 1; i <= Q; i++) {
		int u, L; cin >> u >> L;
		long long ans = 0;
		if (u < 1024) ans = dp[u][L];
		else {
			vector<pair<int, int>> vec;
			while (u >= 1024) {
				vec.emplace_back(w[u], v[u]);
				u /= 2;
			}
			for (int i = 0; i < 1 << vec.size(); i++) {
				long long totw = 0, totv = 0;
				for (int j = 0; j < vec.size(); j++) if (i >> j & 1) totw += vec[j].first, totv += vec[j].second;
				if (totw <= L) {
					ans = max(ans, totv + dp[u][L - totw]);
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}



Measured memory_bytes: 809000
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <map>
using namespace std;

int main() {
	string S; cin >> S;
	if (S == "ani") cout << "square1001" << endl;
	else cout << "e869120" << endl;
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<string>
using namespace std;

int main(){
    char a;
    cin >> a;

    if(a == 'A'){
        cout << "T" << endl;
    }else if(a == 'T'){
        cout << "A" << endl;
    }else if(a == 'G'){
        cout << "C" << endl;
    }else{
        cout << "G" << endl;
    }
}

Measured memory_bytes: 256
data class Edge(var a: Int, var b: Int) {
    constructor(v: List<Int>): this(v[0], v[1])
}
fun tra(node: Int, save: Array<Int>, children: Array<MutableList<Int>>): Int {
    children[node].forEach { save[node] += tra(it, save, children) }
    return save[node]
}

fun main(args: Array<String>){
    val (N, M) = listOfInt()
    val connect = Array<MutableList<Int>>(N, {mutableListOf()})
    val edges = Array<Edge>(M, { it -> Edge(listOfInt(-1))})
    if (M % 2 == 1) { println(-1); return }

    for (n in 0 until M) {
        val a = edges[n].a
        val b = edges[n].b
        connect[a].add(b)
        connect[b].add(a)
    }

    val queue = mutableListOf<Int>(0)
    val parent = Array<Int>(N, { -1 })
    val save = Array<Int>(N, { 0 })
    val exist = Array<Boolean>(N, { false })
    val children = Array<MutableList<Int>>(N, { mutableListOf() })
    exist[0] = true

    while (queue.size != 0) {
        val now = queue.removeAt(0)
        for (c in connect[now]) {
            if (c != parent[now] && (c > now || !exist[c])) {
                save[now] += 1
                if (!exist[c]) {
                    parent[c] = now
                    children[now].add(c)
                    exist[c] = true
                    queue.add(c)
                }
            }
        }
    }

    tra(0, save, children)

    for (e in edges) {
        if (parent[e.a] == e.b) {
            if (save[e.a] % 2 == 0) {
                println("${e.b+1} ${e.a+1}")
            } else {
                println("${e.a+1} ${e.b+1}")
            }
        } else if (parent[e.b] == e.a) {
            if (save[e.b] % 2 == 0) {
                println("${e.a+1} ${e.b+1}")
            } else {
                println("${e.b+1} ${e.a+1}")
            }
        } else {
            if (e.a > e.b) {
                println("${e.b+1} ${e.a+1}")
            } else {
                println("${e.a+1} ${e.b+1}")
            }
        }
    }
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 108500
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
        scanf("%d%d",&a,&b);
	int maxx=max(a+b,a-b);
	maxx=max(maxx,a*b);
	printf("%d\n",maxx);
	return 0;
}

Measured memory_bytes: 384
def main():
    N = int(input())
    vs = [int(x) for x in input().split()]
    while len(vs) > 1:
        vs = sorted(vs)
        x , y = vs[0], vs[1]
        vs[1] = (x + y) / 2
        vs.pop(0)
    print(vs[0])
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int mode_num(vector<int>& a, int& x, int& y, int size);

int main()
{
    int n;
    cin >> n; 
    vector<int> v;
    vector<int> w;

    for(int i=0; i<n; i++)
    {
        int a;
    	cin >> a;
    	if(i%2==0) v.push_back(a);
    	else w.push_back(a); 
    }   
    
    int x1, y1, x2, y2;
    int d1, d2;
    d1 = mode_num(v, x1, y1, n/2);
    d2 = mode_num(w, x2, y2, n/2); 

    if(d1!=d2) cout<< n- x1 - x2 << endl;
    else cout << min(n-x1-y2, n-x2-y1) << endl;
	return 0;
}

int mode_num(vector<int>& a, int& x, int& y, int size)
{
    int max1 = 0, max2 = 0;
    int ans;
	map<int,int> mp;
    for(int i=0; i<size; i++)
    {
         mp[a[i]]++;
         if(mp[a[i]]>max1) 
         {
           max1 = mp[a[i]];
           ans = a[i];
         }
         else if(mp[a[i]]>max2)
         {
           max2 = mp[a[i]];
         }
    }

    x = max1;
    y = max2;
       
    return ans;
}

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define  ll  long long int
#define  sz   200010

using namespace std;


ll num[sz];
ll n;

/*ll tani(ll m)
{
    ll i,x=0,d;

    for(i=1;i<=n;i++)
    {
        x+=(m%num[i]);
    }

    cout<<m<<" "<<x<<endl;


    return x;


}*/

int main()
{


    ll i,j,k,m,a,b,c,d,p;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>num[i];
    }

    sort(num+1,num+n+1);

    ll mx=0;

    for(i=1;i<=n;i++)
    {
        a=num[i]-1;
        //b=tani(a);

       // mx=max(mx,b);
       mx+=a;
    }

    cout<<mx<<endl;


    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

bool sortFirst(pair<pair<string, int>, int> f, pair<pair<string, int>, int> s)
{
    // cout << "strings: " << f.f.s << " " << s.f.s << endl;
    // cout << "somethign: " << (int)(f.f.f == s.f.f) << endl;
    if (f.f.f == s.f.f)
        return f.f.s > s.f.s;
    else
    // cout << f.f.f.compare(s.f.f) << endl;
        if (f.f.f.compare(s.f.f) > 0)
            return false;
        else
            return true;
    // return f.f.f.compare(s.f.f);
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    deque<pair<pair<string, int>, int>> l;

    int N;
    cin >> N;

    int P;
    string S;
    // pair<pair<string, int>, int> r;
    // pair<string, int> s;

    F0R (i, N)
    {
        cin >> S >> P;
        
        pair<pair<string, int>, int> r;
        pair<string, int> s;

        s.f = S;
        s.s = P;
        r.f = s;
        r.s = i + 1;

        l.pb(r);
    }

    sort(l.begin(), l.end(), sortFirst);

    F0R (i, N)
    {
        cout << l.at(i).s << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(){
  int a, b, count = 0;
  cin >> a >> b;

  if (b == 1){
    cout << 0 << endl;
    return 0;
  }
  

  while (b > 0){
    if (count == 0){
      b -= a;
    }else{
      b -= (a - 1);
    }
    count += 1;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys,math
input=sys.stdin.readline
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(1000):
    x=math.cos(2*math.pi*i/1000)
    y=math.sin(2*math.pi*i/1000)
    ax=0
    ay=0
    for dx,dy in xy:
        if x*dx+y*dy>=0:
            ax+=dx
            ay+=dy
    ans=max(ans,(ax**2+ay**2)**0.5)
print(ans)


Measured memory_bytes: 40176
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  bool flag = false;
  if(a + b == c) flag = true;
  if(b + c == a) flag = true;
  if(c + a == b) flag = true;
  YesorNo(flag);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int N;
int C[510], F[510], S[510];

int time(int t, int i) {
    if (i == N-1) return 0;
    else if (t < S[i]) return (S[i]+C[i]-t)+time(S[i]+C[i],i+1);
    else {
        int X = (t+F[i]-1)/F[i]*F[i];
        return (X+C[i]-t)+time(X+C[i],i+1);
    }
}

int main(void) {
    cin >> N;
    for (int i=0;i<N-1;i++) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i=0;i<N;i++) {
        cout << time(0,i) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  //DPで総和で回す?
  int N,A; cin >> N >> A;
  int x[50];
  for(int i=0; i<N; i++) cin >> x[i];
  
  long long dp[60][60][3000];
  long long all=0;
  for(int sum=A; sum<=N*A; sum+=A){
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0; i<N; i++){
      for(int j=0; j<=sum/A; j++){
        for(int k=0; k<=sum; k++){
          dp[i+1][j][k]=dp[i][j][k]
            +((k>=x[i])?dp[i][j-1][k-x[i]]:0);
        }
      }
    }
    all+=dp[N][sum/A][sum];
  }
  cout << all << endl;
}

Measured memory_bytes: 84736
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return {i for i in range(self.n) if self.find(i) == root}

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list(map(int,input().split()))
uf = UnionFind(N)
p = list(map(int,input().split()))
L = []
for i in range(M):
    x,y = map(int,input().split())
    uf.union(x - 1,y - 1)
cnt = 0
for i in range(N):
    if uf.same(i,p[i]-1):
        cnt+=1
print(cnt)


Measured memory_bytes: 84620
#include<bits/stdc++.h>
using namespace std;
char s[200005]; int yu[200005][15];
int num[2077],vis[2077], sum[200005];
int main(){
	int n, ans = 0;
	scanf( "%s", s );
	n = strlen( s );
	yu[1][1] = 1;
	for( int i = 1; i <= n + 2; i ++ ){
		for( int j = 1; j <= 10; j ++ ){
			if( j == 1 && i != 1 ) yu[i][j] = yu[i - 1][10];
			if( j >= 2 ) yu[i][j] = yu[i][1] * j % 2019;
			//printf( "%d ", yu[i][j] );
		}
		//puts("");
	}
	for( int i = 1; i <= n; i ++ ) sum[i] = (sum[i - 1] + yu[n - i + 1][s[i - 1] - '0']) % 2019;
	for( int i = 1; i <= n; i ++ ) num[sum[i]]++;
	for( int i = 1; i <= n; i ++ )
		if( num[sum[i]] >= 2 && !vis[sum[i]] && sum[i] != 0 ){
			//printf( "%d\n", sum[i] );
			//printf( "%d %d %d\n", i, sum[i], num[sum[i]] );
			ans += (num[sum[i]] - 1) * num[sum[i]] / 2;
			vis[sum[i]] = 1;
		}
	ans += ( num[0] + 1 ) * num[0] / 2;
	//for( int i = 1; i <= n; i ++ ) printf( "%d ", sum[i] );
	printf("%d\n",ans);
	return 0;
}/*
18171181711817118171
1 2 3 4 5 6 7 8 9 10
10 20 30 40 50 60 70 80 90 100
100 200 300 400 500 600 700 800 900 1000
1000 2000 981 1981 962 1962 943 1943 924 1924
1924 1829 1734 1639 1544 1449 1354 1259 1164 1069
1069 119 1188 238 1307 357 1426 476 1545 595
595 1190 1785 361 956 1551 127 722 1317 1912
1912 1805 1698 1591 1484 1377 1270 1163 1056 949
949 1898 828 1777 707 1656 586 1535 465 1414
1414 809 204 1618 1013 408 1822 1217 612 7
7 14 21 28 35 42 49 56 63 70
70 140 210 280 350 420 490 560 630 700
700 1400 81 781 1481 162 862 1562 243 943
943 1886 810 1753 677 1620 544 1487 411 1354
1354 689 24 1378 713 48 1402 737 72 1426
*/

Measured memory_bytes: 16468
import Data.List (sort)
  
isSecond::[Int] -> Bool
isSecond pn = (pn !! 1) == ((sort pn) !! 1)

answer::[Int] -> Int
answer y@(x:xs) | length y < 3 = 0
                | otherwise = if isSecond (take 3 y) then 1 + answer xs else answer xs

main = do
  getLine
  pn <- map read . words <$> getLine::IO[Int]
  print $ answer pn


Measured memory_bytes: 508
N = int(input())
robots = []
for _ in range(N):
    x, dis = map(int, input().split())
    robots.append([x-dis,x+dis])
    
robots = sorted(robots, key=lambda x: x[1])
    
cnt = 0
now = -float("inf")
for left, right in robots:
    if left >= now:
        cnt += 1
        now = right
        
print(cnt)

Measured memory_bytes: 22104
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<int> a(5);
    int m=0;
    int ans=0;
    rep(i,5){
        cin >> a[i];
    }
    rep(i,5){
        if(a[i]%10==0){
            ans+=a[i];
        }
        else{
            int l = 10-a[i]%10;
            ans+=a[i]+l;
            m = max(m,l);
        }
    }
    cout << ans-m;
    



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int turncheck(char s) {
	if (s == 'a')
		return 1;
	else if (s == 'b') {
		return 2;
	}
	else if (s == 'c') {
		return 3;
	}
}
int main()
{
	string SA, SB, SC;
	cin >> SA;
	cin >> SB;
	cin >> SC;
	int turn = 1;
	int ta=0, tb=0, tc=0;
	int al, bl, cl;
	al = SA.size();
	bl = SB.size();
	cl = SC.size();
	while (1) {
		if(turn==1){
			if (ta == al) {
				cout << 'A';
				break;
			}
			turn = turncheck(SA[ta]);
			ta++;

		}
		else if (turn == 2) {
			if (tb == bl) {
				cout << 'B';
				break;
			}
			turn = turncheck(SB[tb]);
			tb++;
		}
		else if (turn == 3) {
			if (tc == cl) {
				cout << 'C';
				break;
			}
			turn = turncheck(SC[tc]);
			tc++;
		}
		
	}

	return 0;
}


Measured memory_bytes: 256