akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

public class Main 
{
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) 
	{
		while(true)
		{
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a == 0 && b == 0) {return;}
			ArrayList<Integer> l1 = new ArrayList<Integer>();
			ArrayList<Integer> l2 = new ArrayList<Integer>();
			int ans = 999999999;
			
			for(int i = 1; i*i <= a; i++)
			{
				if(a%i == 0)
				{
					l1.clear();
					l1.add(i);
					l1.add(a/i);
					
					for(int j = 1; j*j <= b; j++)
					{
						if(b%j == 0)
						{
							l2.clear();
							l2.add(j);
							l2.add(b/j);
							
							ArrayList<Integer> l3 = new ArrayList<Integer>();
							l3.add(l1.get(0));
							l3.add(l1.get(1));
							l3.add(l2.get(0));
							l3.add(l2.get(1));
							l3.sort(null);
							
							
//							System.out.println("Size  "+ l3.size());
							int temp = 0;
							int pair = (l3.get(0) - l3.get(1));
							temp += (pair*pair);
							pair = (l3.get(1) - l3.get(2));
							temp += (pair*pair);
							pair = (l3.get(2) - l3.get(3));
							temp += (pair*pair);
							
							ans = Math.min(ans, temp);
						}
					}
				}
			}
			
			System.out.println(ans);
		}
	}

}



Measured memory_bytes: 39592
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        
        if(n == 1) System.out.println("Hello World");
        else{
            System.out.println(scan.nextInt() + scan.nextInt());
        }
    }
}


Measured memory_bytes: 22608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  1000005

ll spf[N];
void sieve()
{
    rep(i,0,N)
    spf[i]=i;
    for(int i=4;i<N;i+=2)
        spf[i]=2;
    for(ll i=3;i*i<N;i++)
    {
        if(spf[i]==i)
        {
            for(ll j=i*i;j<N;j+=i)
            {
                if(spf[j]==j)
                    spf[j]=i;
            }
        }
    }
}
bool prime[N];
void solve()
{
    ll n;
    cin>>n;
    sieve();
    vi v;
    ll g=0;
    rep(i,0,n)
    {
        ll x;
        cin>>x;
        g=__gcd(g,x);
        v.pb(x);
    }
    bool f=1;
    rep(i,0,n)
    {
        set<ll>s;
        ll x=v[i],y;
        while(x!=1)
        {
            y=spf[x];
            s.insert(y);
            x=x/y;
        }
        // cout<<i<<endl;
        for(auto u:s)
        {
            // cout<<u<<endl;
            if(u!=1)
            {
                if(prime[u]==1)
                {
                    f=0;
                    break;
                }
                else
                {
                    prime[u]=1;
                }
            }
        }
        if(f==0)
            break;
    }
    if(f)
    {
        cout<<"pairwise coprime"<<endl;
        return;
    }
    if(g==1)
    {
        cout<<"setwise coprime"<<endl;
        return;
    }
    cout<<"not coprime"<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 19396
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;

int main() {
	int a, b;
	cin >> a >> b;
	int x = b - a;
	ll ans;
	ans = (ll)x*(x - 1) / 2LL - (ll)a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
typedef int64_t lint;
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

int main() {
	int N;
	string X;
	cin >> N >> X;
	int a=0, b=0, c=0, x, y, z;
	vector<int> v(200002);
	rep1(i, 200000) {
		x = i;
		for (z=1; ;z++){
			bitset<20> t(x);
			y = t.count();
			x = x % y;
			if (x == 0) break;
		}
		v.at(i) = z;
	}

	bitset<200000> bits(X);
	c = bits.count();
	vector<int> m1(200002);
	vector<int> m2(200002);
	vector<int> m3(200002);
	x = 1;
	y = 1;
	z = 1;
	rep(i, N) {
		m1.at(i) = x;
		m2.at(i) = y;
		m3.at(i) = z;
		x = (x*2) % max(c-1, 1);
		y = (y*2) % max(c, 1);
		z = (z*2) % (c+1);
	}
	x = 0;
	y = 0;
	z = 0;
	rep(i, N) {
		if (bits.test(i)) {
			x += m1.at(i);
			y += m2.at(i);
			z += m3.at(i);
			x %= max(c-1, 1);
			y %= max(c, 1);
			z %= (c+1);
		}
	}
	rep1(i, N) {
		if (bits.test(N-i)) {
			a = (x - m1.at(N-i) + c-1) % max(c-1, 1);
		} else {
			a = (z + m3.at(N-i) + c+1) % (c+1);
		}
		if (c == 1 && bits.test(N-i)) std::cout << "0" << '\n';
		else std::cout << v.at(a)+1 << '\n';
	}
}


Measured memory_bytes: 6812
#include <cstdio>
#include <cstring>
const int DOTS = 3;
const int MAXS = 105;
char S[MAXS];
int K;

int main() {
  scanf("%d", &K);
  scanf(" %s", S);
  if (strlen(S) > K) {
    for (int i = 0; i < DOTS; ++i) {
      S[K+i] = '.';
    }
    S[K+DOTS] = '\0';
  }
  puts(S);
  return 0;
}

Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long[] a = new long[N];
		for (int i = 0; i < N; i++) {
			a[i] = in.nextLong();
		}
		long[] b = new long[N + 1];
		for (int i = 0; i < N; i++) {
			b[i + 1] = b[i] + a[i];
		}
		long ans = Long.MAX_VALUE;
		for (int i = 0; i < N - 1; i++) {
			ans = Math.min(ans, Math.abs(b[i + 1] - (b[b.length - 1] - b[i + 1])));
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 65688
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

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

	double d,t,s;
	cin>>d>>t>>s;
	if(d/s<=t){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	return 0;
}


Measured memory_bytes: 3728
#include<stdio.h>
#include<string.h>
#define N 100005
int min(int a,int b){
  if(a<b){
    return a;
  }
  else return b;
}
typedef struct pp{
  char name[100];
  int t;
}P;

P Q[N+1];
int head, tail, n;

void pupu(P x){
  Q[tail]=x;
  if(tail==N){
    tail=1;
  }
  else tail=tail+1;
}

P mainasu(){
  P x=Q[head];
  if(head==N)head=1;
  else head++;
  return x;
}


int main(){
  int mimi= 0, c;
  int i, q;
  P u;
  scanf("%d %d",&n,&q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail=n+1,head=1;
  }
  while(head!=tail){
    u=mainasu();
    c=min(q,u.t);
    u.t-=c;;
    mimi+=c;
    if(u.t>0){
      pupu(u);
    }
    else{
      printf("%s %d\n",u.name,mimi);
    }
  }
  return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;

  string r = s;
  reverse(r.begin(), r.end());
  ll c = 0;
  for (ll i = 0; i < s.size()/2; ++i) {
    if (s[i] != r[i]) ++c;
  }

  ll ans = c;
  c = 0;
  for (ll i = s.size()/2; i < s.size(); ++i) {
    if (s[i] != r[i]) ++c;
  }

  ans = min(ans, c);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
    $input_line = trim(fgets(STDIN));
    
    $num = explode(" ",$input_line);
    
    $num[0] = intval($num[0]);
    $num[1] = intval($num[1]);
    $num[2] = intval($num[2]);
    
    sort($num);
    
    echo $num[0];
    echo " ";
    echo $num[1];
    echo " ";
    echo $num[2];
    echo "\n";

?>


Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int,int> P;

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

int main(){
	int A,B,K;
	cin>>A>>B>>K;
	REP(i,K){
		cout<<A+i<<endl;
		if(A+i==B) return 0;
	}
	if(B-K>=A+K){
	REP(i,K){
		cout<<B-K+1+i<<endl;
	}
	}
	else{
		REP(i,K){
			cout<<A+K+i<<endl;
			if(A+K+i==B)return 0;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

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


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int h,w,k;
  cin>>h>>w>>k;
  char mp[h][w];
  PII mpp[h][w];//first->残り移動回数 second->残り壁枚数
  int ans[h][w];
   rep(i,h){
    rep(j,w){
      ans[i][j]=0;
    }
    }
  int ANS=INF;
  PII st;
  queue<PII> bfs,bfs2;
  rep(i,h){
    rep(j,w){
      cin>>mp[i][j];
      if(mp[i][j]=='S'){
	st.F=i;st.S=j;
	bfs.push(st);
	mpp[i][j]=make_pair(k,0);
	ans[i][j]=1;
      }
    }
  }
  while(!bfs.empty() ){
    PII p=bfs.front();
    bfs.pop();
    bfs2.push(p);
    rep(i,4){
      int X=p.F+dx[i],Y=p.S+dy[i];
      if(X>=0 && X<h && Y>=0 && Y<w){
	if(mp[X][Y]=='.'){
	  if(mpp[p.F][p.S].F!=0 && ans[X][Y]==0){
	    mpp[X][Y].F=mpp[p.F][p.S].F-1;
	    mpp[X][Y].S=mpp[p.F][p.S].S;
	    ans[X][Y]=ans[p.F][p.S];
	    bfs.push(make_pair(X,Y));
	  }
	}
      }
    }
  }
  while(!bfs2.empty() ){
    PII p=bfs2.front();
    bfs2.pop();
    rep(i,4){
      int X=p.F+dx[i],Y=p.S+dy[i];
      if(X>=0 && X<h && Y>=0 && Y<w){
	
	if(ans[X][Y]==0){
	  //cout<<X<<" "<<Y<<endl;
	  if(mp[X][Y]=='.'){
	    if(mpp[p.F][p.S].F!=0){
	      mpp[X][Y].F=mpp[p.F][p.S].F-1;
	      mpp[X][Y].S=mpp[p.F][p.S].S;
	      ans[X][Y]=ans[p.F][p.S];
	      bfs2.push(make_pair(X,Y));
	    }else{
	      mpp[X][Y].F=k-1;
	      mpp[X][Y].S=mpp[p.F][p.S].S+k;
	      ans[X][Y]=ans[p.F][p.S]+1;
	      bfs2.push(make_pair(X,Y));
	    }
	  }else if(mp[X][Y]=='#'){
	    if(mpp[p.F][p.S].S!=0){
	      if(mpp[p.F][p.S].F!=0){
		mpp[X][Y].F=mpp[p.F][p.S].F-1;
		mpp[X][Y].S=mpp[p.F][p.S].S-1;
		ans[X][Y]=ans[p.F][p.S];
		bfs2.push(make_pair(X,Y));
	      }else{
		mpp[X][Y].F=k-1;
		mpp[X][Y].S=mpp[p.F][p.S].S+k-1;
		ans[X][Y]=ans[p.F][p.S]+1;
		bfs2.push(make_pair(X,Y));
	      }
	    }else{
	      mpp[X][Y].F=k-1;
	      mpp[X][Y].S=mpp[p.F][p.S].S+k-1;
	      ans[X][Y]=ans[p.F][p.S]+1;
	      bfs2.push(make_pair(X,Y));
	    }
	  }
	}
      }
    }
  }
  /* rep(i,h){
    rep(j,w){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
    }*/

  /* rep(i,h){
    rep(j,w){
      cout<<'('<<mpp[i][j].F<<","<<mpp[i][j].S<<") ";
    }
    cout<<endl;
    }*/
  rep(i,h){
    ANS=min(ANS,min(ans[i][0],ans[i][w-1]));
  }
  rep(i,w){
     ANS=min(ANS,min(ans[0][i],ans[h-1][i]));
  }
  cout<<ANS<<endl;
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,D,X;
    cin>>N>>D>>X;

    rep(i,N){
        int a;cin>>a;
        X+=(D-1)/a+1;
    }
    cout<<X<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
int main(){
    ll a; cin>>a;
    int x,y; scanf("%d.%d",&x,&y);
    ll b = x * 100 + y;
    cout<<a*b/100<<endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
    int n;
    cin >> n;
    vector<int>  x(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    vector<int> num=x;
    sort(x.begin(),x.end());
    for(int i=0; i<n; i++){
        if(num[i]<=x[n/2-1])cout << x[n/2] << endl;
        else cout << x[n/2-1] << endl;
    }
}

Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<string>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i,n) reps(i,0,n)
#define fr first
#define sc second
#define INF (1 << 28)
typedef pair< int , int > Pt;
int main(){
  int n;
  cin >> n;
  vector<Pt> vc(n);
  int dp[n+1];
  rep(i,n) cin >> vc[i].sc >> vc[i].fr;
  sort(vc.begin(),vc.end());
  int ret = 0;
  fill_n(dp+1,n+1,INF);
  dp[0] = 0;
  rep(i,n){
    if(vc[i].sc > vc[i].fr) continue;
    for(int j = i ; j >= 0 ; --j ){
      if(dp[j] == INF || dp[j] + vc[i].sc > vc[i].fr) continue;
      if(dp[j+1] > dp[j] + vc[i].sc){
        dp[j+1] = dp[j] + vc[i].sc;
        ret = max(ret,j+1);
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1204
#include <iostream>

u_long gcd(u_long num1, u_long num2);

int main() {
    u_long N = 0, min_gcd_1 = 0, min_gcd_2 = 0, min_gcd_i = 0, answer = 0, result_gcd = 1;
    u_long *A, *L, *R;
    int flag = 0;

    // input
    std::cin >> N;

    A = new u_long[N];
    L = new u_long[N];
    R = new u_long[N];

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

    // process
    for (u_long i = 0; i < N; i++) {
        if (i == 0) {
            L[i] = A[i];
            R[i] = A[N - 1 - i];
        } else {
            L[i] = gcd(L[i - 1], A[i]);
            R[i] = gcd(R[i - 1], A[N - 1 - i]);
        }
    }

    for (u_long i = 0; i < N; i++) {
        if (i == 0) {
            result_gcd = R[N - 1 - i - 1];
        } else if (i == N - 1) {
            result_gcd = L[i - 1];
        } else {
            result_gcd = gcd(L[i - 1], R[N - 1 - i - 1]);
        }

        if (i == 0) {
            answer = result_gcd;
        } else if (result_gcd > answer) {
            answer = result_gcd;
        }
    }

    // output
    std::cout << answer << std::endl;

    return 0;
}

u_long gcd(u_long num1, u_long num2) {
    if (num2 == 0) {
        return num1;
    } else {
        return gcd(num2, num1 % num2);
    }
}

Measured memory_bytes: 2560
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())

def run():
    S = input()
    if S[-1] == 's':
        print(S + 'es')
    else:
        print(S + 's')

if __name__ == "__main__":
    run()


Measured memory_bytes: 8992
#!/usr/bin/env python3

X, Y = list(map(int, input().split()))

# a + 2b = X
# 2a + b = Y
b = (2 * X - Y) / 3  # 下2、右1移動の回数
a = X - 2 * b  # 下1、右2移動の回数
mod = 10 ** 9 + 7

if int(b) != b or int(a) != a:
    ans = 0
elif b < 0 or a < 0:
    ans = 0
else:
    fact_list = []
    N = int(a + b)
    R = int(min(a, b))

    if R != 0:
        for i in range(1, N + 1):
            if i == 1:
                fact_n = 1 % mod
            else:
                fact_n = fact_list[i - 2] * i % mod
            fact_list.append(fact_n)

        fact_n_r = fact_list[N - R - 1]
        fact_r = fact_list[R - 1]

        w = pow(fact_n_r * fact_r % mod, (mod - 2), mod)

        ans = fact_n * w % mod
    else:
        ans = 1 % mod

print(ans)


Measured memory_bytes: 29464
import numpy as np
a,b,x = map(int,input().split())
water = x/a
bottle = a*b
if water >= bottle * 0.5:
    margin = bottle - water
    tate = margin * 2 / a
    ans = np.degrees(np.arctan2(tate, a))
else:
    height = 2 * water / b
    beta = np.degrees(np.arctan2(height, b))
    ans = 2*(45 - beta/2)
print(ans)


Measured memory_bytes: 12620
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    x, y = map(int, input().split())

    crane = (4 * x) - y
    turtle = y - (2 * x)

    if crane >= 0 and turtle >= 0 and crane % 2 == 0 and turtle % 2 == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll N;
  cin >> N;

  vector<ll> A(N);
  ll MAX1 = 0, MAX2 = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  MAX1 = *max_element(A.begin(), A.end());

  ll countMax = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < MAX1) {
      MAX2 = max(MAX2, A[i]);
    } else if (A[i] == MAX1) {
      countMax++;
    }
  }

  if (countMax > 1)  {
    for (int i = 0; i < N; i++) {
      cout << MAX1 << BR;
    }
  } else {
    for (int i = 0; i < N; i++) {
      if ( A[i] == MAX1 ) {
        cout << MAX2 << BR;
      } else {
        cout << MAX1 << BR;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e6 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n = N;
   vector<char> is_prime(n+1, true);
   is_prime[0] = is_prime[1] = false;
   for (int i = 2; i <= n; i++) {
       if (is_prime[i] && (long long)i * i <= n) {
           for (int j = i * i; j <= n; j += i)
               is_prime[j] = false;
       }
   }
   vector<int> prime;
   f(i,1,N){
      if(is_prime[i]) prime.pb(i);
   }
   cin >> n;
   cout << *lower_bound(all(prime),n) << '\n';
   return 0;
}

Measured memory_bytes: 2424
#include<iostream>
#include <algorithm>
#include <string>
#include<stack>
using namespace std;

int main() {
	int A[3];
	for(int i = 0; i < 3; i++){
			cin >> A[i];
	}
	sort(A, A+3);

	if(A[0] == 5 && A[1] == 5 && A[2] == 7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}


	return 0;
}



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


int main()
{
    int n; ll L;
    cin >> n >> L;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    int start = -1;
    rep(i,n-1) {
        if(a[i]+a[i+1] >= L) {
            start = i;
            break;
        }
    }

    if(start == -1) {cout << "Impossible\n"; return 0;}

    cout << "Possible\n";
    for(int i = 0; i < start; i++) cout << i+1 << endl;
    for(int i = n-2; i >= start; --i) cout << i+1 << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int a[4];
string s;
int n;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s[0]=='A')a[0]++;
		if(s[0]=='W')a[1]++;
		if(s[0]=='T')a[2]++;
		if(s[0]=='R')a[3]++;
	}
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3];
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using edge = struct { int src, dst, cost; };
using edges = vector<edge>;

bool operator < (const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}

int N;
edges es;

struct UnionFind {
  vector<int> data;
  UnionFind(int n) : data(n, -1) {}
  int root(int x) {
    return (data[x] < 0) ? x : data[x] = root(data[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int rank(int x) {
    -data[root(x)];
  }
};

int kruskal() {
  sort(es.begin(), es.end());
  UnionFind uf(N);
  int res = 0;
  for (auto&& ei : es) {
    edge e = ei;
    if (!uf.same(e.src, e.dst)) {
      uf.unite(e.src, e.dst);
      res += e.cost;
    }
  }
  return res;
}

main() {
  cin >> N;
  vector<P> px(N), py(N);
  for (int i = 0; i < N; i++) {
    int x, y; cin >> x >> y;
    px[i] = {x, i};
    py[i] = {y, i};
  }

  sort(px.begin(), px.end());
  for (int i = 0; i < N - 1; i++) {
    int l = abs(px[i].first - px[i + 1].first);
    es.push_back({px[i].second, px[i + 1].second, l});
  }
  sort(py.begin(), py.end());
  for (int i = 0; i < N - 1; i++) {
    int l = abs(py[i].first - py[i + 1].first);
    es.push_back({py[i].second, py[i + 1].second, l});
  }

  cout << kruskal() << endl;
}


Measured memory_bytes: 6516
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int n,q;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    cin>>q;
    int tp1,a,b;
    while(q--){
        cin>>tp1>>a>>b;
        if(tp1){
            cout<<*max_element(&v[a],&v[b])<<endl;
        }
        else {
            cout<<*min_element(&v[a],&v[b])<<endl;
        }
    }

}
//list<int> lit;
//list<int>::iterator it;
//int main()
//{
//    lit.clear();
//    int t,tp,a;
//    it=lit.begin();
//    cin>>t;
//    while(t--){
//        cin>>tp;
//        switch(tp){
//        case 0:
//            cin>>a;
//            lit.insert(it,a);
//            break;
//    case 1:
//            cin>>a;
//            if(a<0){
//                while(a++){
//                    if(it!=lit.end())it++;
//                }
//            }
//            else if(a>0){
//                while(a--){
//                    if(it!=lit.begin())it--;
//                }
//            }
//        break;
//    case 2:
//        lit.erase(--it);
//        break;
//        }
//    }
//    lit.reverse();
//    for(it=lit.begin();it!=lit.end();it++){
//
//        cout<<*it<<"\n";
//    }
//}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MAX = 100001;
    vector<bool> is_prime(MAX);
    rep (i, 1, MAX) {
        if (i <= 1) {
            is_prime[i] = true;
            continue;
        }
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                is_prime[i] = true;
                break;
            }
        }
    }
    vector<int> s(MAX);
    rep (i, MAX - 1) s[i] = s[i - 1] + ((i % 2 == 1) && !is_prime[i] && !is_prime[(i + 1) / 2]);
    // eprintf("%d\n", (7 % 2 == 1) && !is_prime[7] && !is_prime[4]);
    rep (i, 100) eprintf("%d ", s[i]); eprintf("\n");
    int q; cin >> q;
    rep (_, q) {
        int l, r; cin >> l >> r;
        cout << s[r] - s[l - 1] << "\n";
    }
    return 0;
}

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

using namespace std;

int main(void)
{
    int n, m;
    cin >> n >> m;

    int deg[n + 1] = {};

    int a, b;

    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        deg[a]++; deg[b]++;
    }

    for(int i = 1; i <= n; i++)
    {
        cout << deg[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;
using System.Globalization;

namespace ConsoleApp2
{
    class Program
    {
        static long K;
        static long N;
        static long[] A;
        static void Main(string[] args)
        {
            //var UV = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var N = long.Parse(Console.ReadLine());
            long ans = 0;

            for (int i = 1; i <= N; i++)
            {
                if (!(i%3 == 0 || i%5 == 0))
                {
                    ans += i;
                }
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 17644
N,M = map(int,input().split())
S,C = [],[]
for _ in range(M):
  s,c = map(int,input().split())
  S.append(s)
  C.append(c)


for i in range(1000):
  i = str(i)
  if len(i) != N: continue

  flg = True
  for j in range(M):
    if i[S[j]-1] != str(C[j]):
      flg = False
  if flg:
    print(i)
    exit()

print(-1)

Measured memory_bytes: 39536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  long n;
  cin >> n;
  
  vector<long> yks;
  for(long i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      yks.push_back(i);
      yks.push_back(n/i);
    }
  }
  sortv(yks);

  cout << yks[yks.size()/2 -1] + yks[yks.size()/2] - 2 << endl;

}

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

int main(void) {
    int64_t N;
    int64_t maxa = 0;
    int64_t maxpos;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
        if(maxa < A[i]) {
            maxa = A[i];
            maxpos = i;
        }
    }

    sort(A.begin(),A.end());
    for(int i=0;i<N;i++) {
        if(i==maxpos) {
            cout << A[N-2] << "\n";
        } else {
            cout << maxa << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

int cmp(int *A, int *B)
{
	return (*B - *A);
}

int main(void)
{
	int i, n;
	int array[128];
	int avr;
	
	while (scanf("%d", &n), n){
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		qsort(array, n, sizeof(int), cmp);
		
		avr = 0;
		for (i = 1; i < n - 1; i++){
			avr += array[i];
		}
		
		avr /= (n - 2);
		
		printf("%d\n", avr);
	}
	
	return (0);
}

Measured memory_bytes: 604
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<unordered_map>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
const int inf = 0x3f3f3f3f;
bool ok; char ch;
void read(int& x) {
	for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar()) if (ch == '-') ok = 1;
	for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	if (ok) x = -x;
}
void write(int x)
{
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
	return;
}
const int maxn = 1e6 + 5;
double s[maxn];
double dp[maxn];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i] = s[i] * (1 + s[i]) / 2/s[i];
		s[i] += s[i - 1];
	}
	double ans = 0;
	for (int i = k; i <= n; i++) {
		ans = max(s[i] - s[i - k], ans);
	}
	printf("%.7lf", ans);
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    string s;
    cin >> s;
    rep(i, 3){
        if(s[i] =='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(void){
	int N,K;
	scanf("%d %d",&N,&K);
	int A[N];
	int i,j,a;
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
        for (i = 0; i < N; ++i)
    {
        for (j = i + 1; j < N; ++j)
        {
            if (A[i] < A[j])
            {
                a = A[i];
                A[i] = A[j];
                A[j] = a;
            }
        }
    }
    int Value;
    for(i=0;i<K;i++){
    	Value = Value + A[i];
    }
    printf("%d",Value);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  long double n;
  cin >> n;
  long double m;
  cin >> m;
 
  
  long long ans = n*m;
  cout << ans << endl;
  
  
  
}
  
  



Measured memory_bytes: 3704
N, M = map(int, input().split())
a = {}
b = {}
c = {}
d = {} 

for i in range(N):
    a[i],b[i] = map(int, input().split())
for i in range(M):
    c[i],d[i] = map(int, input().split())

for i in range(N):
    m = 100000000000
    index = 0
    for j in range(M):
        tmp = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if tmp < m:
            m = tmp 
            index = j
    print(index + 1)



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

    int main(){

        string s; cin >> s;
        
        int n = (int)s.size();

        for(int i = 0; i < n - 2; i++){
            if(s[i] == s[i + 1]){
                cout << i + 1 << " " << i + 2 << endl;
                return 0;
            }else if(s[i] == s[i + 2]){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }

        if(s[n - 2] == s[n - 1]){
            cout << n-1 << " " << n << endl;
            return 0;
        }

        cout << -1 << " "  << -1 <<  endl;
        return 0;
    }

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

int n;
int r,c,q;
int r1,c1,r2,c2;
int tmp;
vector< vector<int> > seg;

int query(int x, int a, int b, int k, int l, int r){
  if(r<=a || b<=l)return (1<<31) - 1;
  if(a<=l && r<=b)return seg[x][k];
  else{
    return min(query(x,a,b,2*k+1,l,(l+r)/2),query(x,a,b,2*k+2,(l+r)/2,r));
  }
}

int main(){
  while(1){
    cin >> r >> c >> q;
    if(!r && !c && !q)break;

    if(r>c){
      seg.resize(c);
      n = 1;
      while(n<r)n *= 2;
      for(int i=0;i<c;i++){
	seg[i].clear();
	for(int j=0;j<2*n-1;j++)seg[i].push_back( (1<<31)-1 );
      }
      for(int i=0;i<r;i++){
	for(int j=0;j<c;j++){
	  cin >> tmp;
	  int k = i;
	  k += n-1;
	  seg[j][k] = tmp;
	  while(k>0){
	    k = (k-1) / 2;
	    seg[j][k] = min(seg[j][k*2+1], seg[j][k*2+2]);
	  }
	}
      }
      while(q--){
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = (1<<31) - 1;
	for(int i=c1;i<=c2;i++)ans = min(ans,query(i,r1,r2+1,0,0,n));
	cout << ans << endl;
      }
    }else{
      seg.resize(r);
      n = 1;
      while(n<c)n *= 2;
      for(int i=0;i<r;i++){
	seg[i].clear();
	for(int j=0;j<2*n-1;j++)seg[i].push_back( (1<<31)-1 );
      }
      for(int i=0;i<r;i++){
	for(int j=0;j<c;j++){
	  cin >> tmp;
	  int k = j;
	  k += n-1;
	  seg[i][k] = tmp;
	  while(k>0){
	    k = (k-1) / 2;
	    seg[i][k] = min(seg[i][k*2+1], seg[i][k*2+2]);
	  }
	}
      }
      while(q--){
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = (1<<31) - 1;
	for(int i=r1;i<=r2;i++)ans = min(ans,query(i,c1,c2+1,0,0,n));
	cout << ans << endl;
      }
    }
  }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    string n;
    cin>>n;
    long long sum=0;
    for(int i=0; i<n.length(); i++){
        sum+=n[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3732
#include "bits/stdc++.h"

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;


//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cout << x[i] << " ";
        }
        cout << x[x.size()-1] <<endl;
    }
}

template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cout << q.front() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

int main(void) {
    int n;
    cin >> n;
    
    vector<LL> vd(n, 0);
    REP(i, n) cin >> vd[i];
    
    LL ans = 0;
    REP(i, n) {
        FOR(j, i+1, n) {
            ans += vd[i] * vd[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>

const int MOD = 1e9 + 7;

int main(void){
    int n, k;
    std::cin >> n >> k;
    std::vector<std::vector<int>> edge(n);
    std::vector<int> used(n);
    std::queue<int> q;

    for(int i = 0; i < n-1; i++){
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    long long ans = k;
    used[0] = 1;
    int res_color = k - 1;
    for(int next : edge[0]){
        ans = ans * res_color % MOD;
        used[next] = 1;
        res_color--;
        q.push(next);
    }
    while(!q.empty()){
        int now = q.front();
        q.pop();
        res_color = k - 2;
        for(int next : edge[now]){
            if(used[next]) continue;
            ans = ans * res_color % MOD;
            used[next] = 1;
            res_color--;
            q.push(next);
        }
    }
    std::cout << ans << std::endl;

    return 0;
}

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

int main()
{
	int a,b,c;
	
	cin>>a>>b>>c;
	
    if(a==c&&c!=b)
	  cout<<"Yes";
	
	else if(b==c&&b!=a)
	  cout<<"Yes";
	  
	else if(a==b&&a!=c)
	  cout<<"Yes";
	
	else  
	  cout<<"No";
	  
	return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define meme(a,v)    memset((a), (v), sizeof (a))
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
//const double PI = acos(-1.0);
typedef long long ll;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  

int main(){
I_AM_SPEED;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
       
     int arr[5];
     for(int i = 0; i < 5; i++) cin >> arr[i];

     for(int i = 0; i < 5; i++){
         if(arr[i] == 0){
            cout << i + 1;
            break;
         }
     }
     
      
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

return  0 ;      
}        





Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main()
{
    int h,w;

    cin >> h >> w;

    while((h!=0)||(w!=0)){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if ((i==0)||(i==(h-1)))
                    cout << '#';
                else if ((j==0)||(j==(w-1)))
                    cout <<'#';
                else
                    cout <<'.';
            }
            cout<<endl;
        }
        cout<<endl;
        cin >> h >> w;
    }


    return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>

int main()
{
	int x,i,k;
	while(scanf("%d",&x)!=EOF)
	{
		k=0;
		for(i=0;;i++)
		{
			k=k+i;
			if(k>=x) {printf("%d\n",i);break;}

		}
	}
}


Measured memory_bytes: 128
def az17():
    a = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
    n = input()
    for i in range(n):
        xs = map(int,raw_input().split())
        a[xs[0]-1][xs[1]-1][xs[2]-1] = a[xs[0]-1][xs[1]-1][xs[2]-1] + xs[3]
    for b in range(0,4):
        for f in range(0,3):
            print "",
            for r in range(0,10):
                print a[b][f][r],
            print
        if not b == 3:
            print "#"*20

az17()

Measured memory_bytes: 4248
h,w=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]
a=[list(map(int,input().split())) for i in range(h)]

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])

spell=0
for wist in a:
  for val in wist:
    if val==-1:continue
    spell+=c[val][1]
print(spell)

Measured memory_bytes: 40540
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n & 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    while(n > 0) {
        n /= 5;
        ans += n / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 510
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn][maxn];
ll sum1[maxn][maxn],sum2[maxn][maxn],f[maxn][maxn];
int n;
ll query1(int l1,int r1,int l2,int r2){return sum1[r1][r2]-sum1[r1][l2-1]-sum1[l1-1][r2]+sum1[l1-1][l2-1];}
ll query2(int l1,int r1,int l2,int r2){return sum2[r1][r2]-sum2[r1][l2-1]-sum2[l1-1][r2]+sum2[l1-1][l2-1];}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)a[i][j]=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			sum1[i][j]=sum1[i][j-1]+sum1[i-1][j]-sum1[i-1][j-1];
			sum2[i][j]=sum2[i][j-1]+sum2[i-1][j]-sum2[i-1][j-1];
			if(i<j)sum1[i][j]+=a[i][j];
			else sum2[i][j]+=a[i][j];
		}
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;i++)
		f[i][1]=query1(1,i,1,i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			for(int k=1;k<j;k++)
				f[i][j]=std::min(f[i][j],f[j-1][k]+query1(j,i,j,i)+query2(i+1,n,k,j-1));
	ll ans=(1ll<<60);
	for(int i=1;i<=n;i++)
		ans=std::min(ans,f[n][i]);
	writeln(ans);
	// for(int i=1;i<=n;i++){
	// 	for(int j=1;j<=n;j++)
	// 		writesp(f[i][j]);
	// 	putchar('\n');
	// }
	return 0;
}

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

namespace agc018_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int>[] list = new List<int>[x[0]];
            for (int i = 0; i < x[0]; i++) list[i] = new List<int>();
            for (int i = 0; i < x[0]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < x[1]; j++) list[i].Add(a[j]);
            }
            int ret = int.MaxValue;
            while (list[0].Count > 0)
            {
                Dictionary<int, int> dic = new Dictionary<int, int>();
                for (int i = 0; i < x[0]; i++)
                {
                    if (!dic.ContainsKey(list[i][0])) dic[list[i][0]] = 0;
                    dic[list[i][0]]++;
                }
                int max = 0;
                List<int> remove = new List<int>();
                foreach (var item in dic)
                {
                    if (item.Value > max)
                    {
                        remove.Clear();
                    }
                    if (item.Value >= max)
                    {
                        max = item.Value;
                        remove.Add(item.Key);
                    }
                }
                ret = Math.Min(ret, max);
                for (int i = 0; i < x[0]; i++)
                {
                    foreach (var item in remove) list[i].Remove(item);
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 18124
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };



int main() {
	int a, b;
	cin >> a >> b;

	if (b % a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}



	return 0;
}

Measured memory_bytes: 256
//IOI 2021
//this will accept, By the order of the peaky fucking blinders
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

int n;
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		int tmp = s[i] - 'A';
		tmp += n;
		tmp %= 26;
		cout << char(tmp + 'A');
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int r;
    cin >> r;
    cout << setprecision(12) << 2 * r * M_PI << endl;
    return 0;
}

Measured memory_bytes: 3784