akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int n; cin >> n&&n;) {
		rep(i, 0, n) {
			int pm, pe, pj; cin >> pm >> pe >> pj;
			if (pm == 100 || pe == 100 || pj == 100)cout << "A" << endl;
			else if (pm + pe >= 180)cout << "A" << endl;
			else if (pm + pe + pj >= 240)cout << "A" << endl;
			else if (pm + pe + pj >= 210)cout << "B" << endl;
			else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80))cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3052
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
char num_str[1002];
int num;
long sum = 0;
int i;
char tmp;

    while (1)

  {
   fgets(num_str, sizeof(num_str), stdin);
      if (num_str[0] == '0')
 break; 
     for (i = 0; i < strlen(num_str)-1; i++)  
 {  
  tmp = num_str[i];
    num = atoi(&tmp); 
   sum = sum + num; 
  }    
  printf("%ld\n", sum); 
     sum=0;   
memset(num_str, 1002,0); 
 }   
 return 0; 
}

Measured memory_bytes: 532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	ll n;
	cin >> n;
	int ans = INT_MAX;
	for (ll a = 1; a <= sqrt(n); a++) {
		if (n % a == 0) {
			ll b = n / a;
			int f = max(to_string(a).size(), to_string(b).size());
			ans = min(ans, f);
		}
		else continue;
	}
	cout << ans << endl;
}


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

class Dice{
private:
    int d[6];
public:
    Dice(int n0, int n1, int n2, int n3, int n4, int n5){ //Constructor
        d[0]=n0; d[1]=n1; d[2]=n2; d[3]=n3; d[4]=n4; d[5]=n5;
    }
    int get_top(){
        return d[0];
    }
    void Roll(){
        string op;
        cin >> op;
        for(unsigned int i=0;i<op.length();i++){
            switch(op[i]){
                case 'N': RollN(); break;
                case 'E': RollE(); break;
                case 'W': RollW(); break;
                case 'S': RollS(); break;
            }
        }
    }
    void RollN(){
        int tmp=d[0];
        d[0]=d[1];
        d[1]=d[5];
        d[5]=d[4];
        d[4]=tmp;
    }
    void RollE(){
        int tmp=d[0];
        d[0]=d[3];
        d[3]=d[5];
        d[5]=d[2];
        d[2]=tmp;
    }
    void RollW(){
        int tmp=d[0];
        d[0]=d[2];
        d[2]=d[5];
        d[5]=d[3];
        d[3]=tmp;
    }
    void RollS(){
        int tmp=d[0];
        d[0]=d[4];
        d[4]=d[5];
        d[5]=d[1];
        d[1]=tmp;
    }
};

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    Dice di(a, b, c, d, e, f);
    di.Roll();
    cout << di.get_top() << endl;
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S;
	cin >> N >> S;
	int cnt = 0;
	REP(i, N)if (S[i] == 'R')cnt++;
	int ans = cnt;
	REP(i, cnt)if (S[i] == 'R')ans--;
	cout << ans << endl;



	return 0;
}



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

int main()
{
    string T;
    cin >> T;
    for (int i = 0; i < T.size(); i++)
    {
        if (T.at(i) == '?')
            T.at(i) = 'D';
    }
    cout << T << endl;
    return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vec<pair<ll,ll>> a(n);
    rep(i,n) cin>>a[i].first>>a[i].second;
    sort(ALL(a));
    
    rep(i,n){
        k-=a[i].second;
        if(k<=0) {
            cout<<a[i].first<<endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){
   int n,u,v,k,inf = -1;
   cin >> n;
   vector<int> a(n,0),D(n,inf);
   vector<vector<int> > edges(n,a); 
   for(int i = 0;i < n;i++){
       cin >> u;
       cin >> v;
       for(int ii = 0;ii < v;ii++){
           cin >> k;
           edges[u-1][k-1] = 1;
       }
   }
   queue<int> Q;
   Q.push(0);
   D[0] = 0;
   while(!Q.empty()){
        int cur = Q.front();
        Q.pop();//最初の要素を削除、詰める
        for(int dst = 0;dst < n;dst++){
            if(edges[cur][dst] == 1 && D[dst] == inf){
                D[dst] = D[cur] + 1;
                Q.push(dst);
            }
        }
   }
   for(int i = 0;i < n;i++){
       cout << i+1 << " " << D[i] << endl;
   }
}


Measured memory_bytes: 3176
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read


#n,m,*ab = [int(i) for i in read().split()]

n = input()[-1]
if n in "24579":
    print("hon")
elif n in "0168":
    print("pon")
else:
    print("bon")


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read(a,n) rep(i,n)cin>>a[i]

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, d, x;
li a[1111];

int main() {
    cin >> n >> d >> x;
    read(a, n);
    li res = 0;
    rin{
        res += (d - 1) / a[i] + 1;
    }
    cout << res + x << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

int main( )
{
	string str;
	int i;
	
	while( true ) {
		getline(  cin, str );
		if( '0' == str[0] ) { break; }
		
		int sum = 0;
		for( i=0; '\0'!=str[i]; i++ ) {
			if( isdigit( str[i] ) ) {
				sum += ( str[i]-'0' );
			}
		}
		cout<<sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>

int main() {
	std::uint16_t a, b, c;
	std::cin >> a >> b >> c;

	if (a + c == b || a + b == c || b + c == a) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <cctype>
using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

long long read(){
	long long i;
	cin >> i;
	return i;
}

map<char, int> MapInit() {
	const string atoz("abcdefghijklmnopqrstuvwxyz");
	map<char, int> m;
	REP(i, atoz.size()) {
		m[atoz[i]] = 0;
	}
	return m;
}

void AToZCount(map<char, int> *counter) {
	map<char, int> &m = *counter;
	char ch;
	while(cin >> ch) {
		if (isalpha(ch)) {
			m[tolower(ch)]++;
		}
	}
	return;
}

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

	map<char, int> counter(MapInit());
	AToZCount(&counter);
	map<char, int>::iterator itr = counter.begin();
	for(; itr != counter.end(); ++itr) {
		cout << itr->first << " : " << itr->second << endl;;
	}
	return 0;
}



Measured memory_bytes: 3192
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] p = new int[n];
        for (int i=0;i<q;i++)p[sc.nextInt()-1]++;
        for (int i=0;i<n;i++){
            if (k-q+p[i]>0)System.out.println("Yes");
            else System.out.println("No");
        }
    }
}


Measured memory_bytes: 59860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String n = sc.next();
		int ans = 0;
		switch(n.length()) {
		case 1:
			ans = Integer.parseInt(n);
			break;
		case 2:
			ans = 9;
			break;
		case 3:
			ans = 9 + Integer.parseInt(n) - 99;
			break;
		case 4:
			ans = 9 + 900;
			break;
		case 5:
			ans = 9 + 900 + Integer.parseInt(n) - 9999;
			break;
		case 6:
			ans = 9 + 900 + 90000;
			break;
		}
		System.out.println(ans);
	}
}

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << "\n";
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
A = list(map(int,input().split()))

tmp = [0]*N
tmp2 = [0]*N
tmp2[0] = A[0]

for i in range(1,N):
    tmp2[i] = A[i] + tmp2[i-1]
sum_A = sum(A)

for i in range(N):
    tmp[i] = sum_A - tmp2[i]

ans = 0
mod = 10**9+7
for i in range(N):
    ans += (A[i]*tmp[i])%mod
    ans = ans%mod
    
print(ans)

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

using namespace std;
typedef long long ll;

int N, T, t[200010];

int main() {
    cin >> N >> T;
    for (int i = 0; i < N; i++)
        scanf("%d", &t[i]);
    
    ll ans = 0;
    for (int i = 0; i < N - 1; i++)
        ans += min(T, t[i + 1] - t[i]);
    ans += T;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long eps = 1e-9;
bool IsPrimeSlow(long long x)
{
    if(x<=1) return false;
    if(x<=3) return true;
    if (!(x%2) | !(x%3)) return false;
    long long s=(long long)(sqrt((double)(x))+eps);
    for(long long i=5 ; i<=s ; i+=6)
        if (!(x%i) || !(x%(i+2)))
            return false;

    return true;
}
vector <int>v;
void f (int n){
    for(int i =1 ; i*i<=n ; i++){
        if(n % i ==0){
            v.push_back(i);
            if(i*i != n);
            v.push_back(n/i);

        }
    }
}
main(){
    int n;
    scanf("%d" , &n);
    f(n);
    int cnt =0;

    for(int i =1 ; i<=n ; i++){
        v.clear();
        if(i & 1 && !IsPrimeSlow(i)){
            f(i);
            if(v.size() ==8) cnt++;
        }
    }
    printf("%d" , cnt);
}



Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
m = H*60 + M
r_a = m / 720
r_b = m / 60
r = abs(r_a - r_b)
if r > 1:
  r = abs(r - int(r))
if r > 0.5:
  r = abs(1 - r)
c = math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(360*r)))
print(c)

Measured memory_bytes: 9504
X,N=map(int,input().split())
P=list(map(int,input().split()))
if X not in P:
    print(X)
    exit()
for i in range(1,100):
    if X-i not in P:
        print(X-i)
        exit()
    elif X+i not in P:
        print(X+i)
        exit()

Measured memory_bytes: 9176
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n,m = list(map(int, input().split()))
from collections import defaultdict
ns = defaultdict(list)
for _ in range(m):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].append(v)
    ns[v].append(u)
    
dp = [[-1]*n for _ in range(11)]
q = int(input())
qs = [None]*q
for i in range(q):
    v,d,c = tuple(map(int, input().split()))
    v -= 1
    qs[i] = (i,v,d,c)
    dp[d][v] = i
from itertools import product
for i,u in product(range(10,0,-1), range(n)):
    if dp[i][u]>=0:
        dp[i-1][u] = max(dp[i-1][u], dp[i][u])
        for v in ns[u]:
            dp[i-1][v] = max(dp[i-1][v], dp[i][u])

write("\n".join(map(str, ((qs[dp[0][u]][3] if dp[0][u]>=0 else 0) for u in range(n)))))

Measured memory_bytes: 130372
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string S;
	cin>>S;
	
	if((S[0]=='0'&&S[1]=='0')||!((S[0]=='0'&&S[1]!=0)||S[0]=='1'&&(S[1]=='0'||S[1]=='1'||S[1]=='2')))
	{
		if((S[2]=='0'&&S[3]=='0')||!((S[2]=='0'&&S[3]!=0)||S[2]=='1'&&(S[3]=='0'||S[3]=='1'||S[3]=='2')))
			cout<<"NA";
		else
			cout<<"YYMM";
	}
	else
	{
		if((S[2]=='0'&&S[3]=='0')||!((S[2]=='0'&&S[3]!=0)||S[2]=='1'&&(S[3]=='0'||S[3]=='1'||S[3]=='2')))
			cout<<"MMYY";
		else
			cout<<"AMBIGUOUS";
	}
	return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int ans;
	if (K > N) {
		OUT(N*X);
	}
	else {
		OUT(K*X + (N - K)*Y);
	}
	return 0;
}

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

using namespace std;

int n, m;
int my_find(int val, int res[])
{
	for(int i = 0; i < m; i++){
		if(res[i] == val){
			return i;
		}
	}
	return 0;
}

int main()
{
	int ank[1000][100];
	int max, place;
	
	for(;;){
		cin >> n;
		cin >> m;
		if(n == 0 && m == 0){
			break;
		}
		
		vector<int> result_sort(m, 0);
		vector<int> result(m, 0);
		int sub[1000] = {0};
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin  >> ank[i][j];
			}
		}
		
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				result[i] += ank[j][i];
			}
		}
		
		for(int i = 0; i < m; i++){
			max = *max_element(result.begin(), result.end());		//±Ì_ÅÌÅålðo
			for(int j = 0; j < m; j++){
				sub[j] = result[j];
			}
			place = my_find(max, sub);
			
			result_sort[i] = place;									//êðãü
			result[place] = 0;										//ÅålÌ Á½êð0Å«·¦é
		}
		int a;
		for(int i = 0; i < m-1; i++){
			cout << result_sort[i]+1 << " ";
			a = i;
		}
		cout << result_sort[a + 1]+1;
		printf("\n");
	}
			
}

Measured memory_bytes: 1276
/* 
 * ??????????´???°????´????????????\????????????
 * ?????§???????????£??????????????????????????????????????????????????????
 * ??????????????£???????????????????¨???????????´???????????±???????????????????
 * 
 */

using System;

namespace _053_SumofPrimeNumbers
{
	class Program
	{
		static void Main ( string[] args )
		{
			int inputNum;

			//0????????¨?????????
			int[] primeSumArray = new int[10000 + 1];
			primeSumArray[1] = 2;

			int number = 3;
			int contentIndex = 1;//??????????????????????????§??\??£????????????

			while ((inputNum = int.Parse (Console.ReadLine ())) != 0)
			{
				int result;

				//???????´???????????±??????????????????´???
				if (contentIndex < inputNum)
				{
					//???????????????????´???????????±???????
					while (contentIndex < inputNum)
					{
						//?´???°??????????????????
						if (IsPrimeNumber (number))
						{
							primeSumArray[contentIndex + 1] = primeSumArray[contentIndex] + number;
							contentIndex++;
						}

						number += 2;
					}
				}

				//?´???°???????¨?????´??????????????????£?????????
				result = primeSumArray[inputNum];
				Console.WriteLine (result);
			}
		}

		static bool IsPrimeNumber ( int number )
		{
			int loop = 3;
			while (loop <= Math.Sqrt (number))
			{
				if (number % loop == 0)
				{
					return false;
				}

				loop += 2;
			}
			return true;
		}
	}
}

Measured memory_bytes: 9192
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	

	int n,m;

	scanf("%d %d",&n,&m);
	std::vector<tuple<int,int,int>> edges(m,tuple<int,int,int>(0,0,0));
	for(int i=0,a,b,c;i<m;i++)scanf("%d %d %d",&a,&b,&c),edges[i]=make_tuple(a,b,c);

	std::vector<ll> dist(n+1,-1e18);
	
	dist[1]=0;
	for(int i=1;i<n;i++){
		for(auto e : edges){
			int a,b,c;
			tie(a,b,c) = e;
			if(dist[b]<dist[a]+c){
				dist[b]=dist[a]+c;
			}
		}

	}
	for(int i=1;i<n;i++)
	for(auto e : edges){
		int a,b,c;
		tie(a,b,c) = e;

		if(b==n && dist[n]<dist[a]+c){
			return !printf("inf\n");
		}
		if(dist[b]<dist[a]+c)dist[b]=dist[a]+c;	
	}

	printf("%lld\n",dist[n] );
}		


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	
	int max = 0;
	int n, m;
	cin >> n;
	

	vector<string> vs(n);
	REP(i, n) {
		cin >> vs[i];
	}
	cin >> m;

	vector<string> vt(m);
	REP(i, m) {
		cin >> vt[i];
	}

	REP(i, n) {
		int ans = 0;
		REP(j, n) {
			if (vs[i]==vs[j]) {
				ans++;
			}
		}
		REP(k, m) {
			if (vs[i] == vt[k]) {
				ans--;
			}
		}
		if (ans > max) {
			max = ans;
		}
		
	}

	ANS(max);


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

int64_t ri64()
{
	int64_t x;
	scanf("%lld", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int main()
{
	string yes = "Yes";
	string no = "No";

	int N = ri();
	int M = ri();

	string str;
	cin >> str;

	vector<vector<int> > adj(N, vector<int>());
	vector<int> nb(N, 0);
	vector<int> nw(N, 0);

	for (int i = 0; i < M; i++)
	{
		int x = ri() - 1;
		int y = ri() - 1;

		adj[x].push_back(y);
		adj[y].push_back(x);

		if (str[x] == 'B')
			nb[y]++;
		else
			nw[y]++;

		if (str[y] == 'B')
			nb[x]++;
		else
			nw[x]++;
	}

	vector<bool> dead(N, false);

	queue<int> q;
	for (int i = 0; i < N; i++)
		if (nb[i] == 0 || nw[i] == 0)
		{
			dead[i] = true;
			q.push(i);
		}

	while (!q.empty())
	{
		int x = q.front();
		q.pop();

		for (int i = 0; i < adj[x].size(); i++)
		{
			int y = adj[x][i];
			if (dead[y])
				continue;

			if (str[x] == 'B')
				nb[y]--;
			else
				nw[y]--;

			if (nb[y] == 0 || nw[y] == 0)
			{
				dead[y] = true;
				q.push(y);
			}
		}
	}

	bool ok = false;
	for (int i = 0; i < N; i++)
		if (!dead[i])
			ok = true;

	if (ok)
		cout << yes << endl;
	else
		cout << no << endl;

	return 0;
}


Measured memory_bytes: 12164
#include<bits/stdc++.h>
using namespace std;
struct Data{

  int team;
  int c_num;
  int w_num[11];
  int time;

  bool operator<(const Data& data)const{
    if(data.c_num != c_num)return c_num > data.c_num;
    if(data.time != time)return time < data.time;
    return team > data.team;
  }
  
};
void Init(Data *data,int T,int P){

  for(int i=1 ; i <= T ; i++){
    data[i].team=i;
    data[i].c_num=0;
    data[i].time=0;
    for(int j=1 ; j <= P ; j++){
      data[i].w_num[j]=0;
    }
  }
  
}
bool isSame(Data *data,int a,int b){

  if(data[a].c_num == data[b].c_num && data[a].time == data[b].time)return true;

  return false;
  
}
int main(){
  
  int M,T,P,R;
  
  while(1){

    cin >>M>>T>>P>>R;
    if(M==0 && T==0 && P==0 && R==0)break;

    Data data[T+1];
    Init(data,T,P);
    
    int m,t,p,j;
    for(int i=0 ; i < R ; i++){
      cin >>m>>t>>p>>j;
      if(j == 0){
	data[t].c_num++;
	data[t].time+=m+20*data[t].w_num[p];
      }else{
	data[t].w_num[p]++;
      }
    }

    sort(data+1,data+T+1);

    for(int i=1 ; i <= T ; i++){
      cout <<data[i].team;
      if(i+1 <= T){
	if(isSame(data,i,i+1)){
	  cout <<"="; 
	}else{
	  cout <<",";
	}
      }
    }
    cout <<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1184
N = int(input())
L = []
M = []
for _ in range(N):
    l = list(map(int,input().split()))
    if l[2] != 0:
        L.append(l)
    else:
        M.append(l)

for i in range(101):
    for j in range(101):
        tmp = -1
        for x in L:
            H = abs(x[0]-i) + abs(x[1]-j) + x[2]
            if H < 1:
                break
            if tmp != -1 and tmp != H:
                break
            else:
                tmp = H
        else:
            for x in L:
                if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                    pass
                else:
                    break
            else:
                for x in M:
                    if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                        pass
                    else:
                        break
                else:
                    print(i,j,H)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int somaDigito (int n) {
    int soma = 0;
    while (n != 0) {
        soma += n % 10;
        n /= 10;
    }
    return soma;
}

int main (void) {
    
    int N;

    cin >> N;

    if (N % 2 == 0 && N % 5 == 0) {
        N /= 2;
        cout << (2 * somaDigito(N)) << endl;
    }
    else {
        cout << somaDigito(N) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define endl "\n"
#define ll long long
#define N ((int)(1e5 + 5))
#define MAX ((int)(1e9 + 5))
#define MOD ((int)(7901 + 0))


using namespace std;


/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/



int main()
{
    int t;
    t = 1;
    while(t--){
        int arr[5][5];
        for(int i = 1 ; i<4 ; i++){
            for(int j = 1 ; j<4 ; j++) cin>>arr[i][j];
        }
        int b[5] , a[5];
        a[1] = 0;
        for(int i = 1 ; i<4 ; i++) b[i] = arr[1][i] - a[1];
        for(int i = 2 ; i<4 ; i++){
            a[i] = arr[i][1] - b[1];
            for(int j = 2 ; j<4 ; j++){
                if( a[i] != arr[i][j] - b[j] ){
                    cout<<"No\n";
                    return 0;
                }
            }
        }
        cout<<"Yes\n";
    }
    return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	rep(i,G[0].size()){
		int next=G[0][i];
		rep(j,G[next].size()){
			if(G[next][j]==N-1){
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 12016
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
    string str;
    cin >> str;
    ll point=0;
    vector<ll> A, C;
    A.push_back(0);
    for(int i=0; i<str.size(); i++){
        if(str[i] == 'R'){
            if(point%2==0)A[point]++;
            else{
                A.push_back(1);
                point++;
                }
            }
        else{
            if(point%2==0){
                A.push_back(1);
                point++;
            }
            else A[point]++;
            }
    }
    for(int i=0; i<A.size()/2; i++){
        ll L_count=0, R_count=0;
        if(A[2*i]%2==0){
            L_count += A[2*i]/2;
            R_count += A[2*i]/2;
            }
        else{
            L_count += A[2*i]/2+1;
            R_count += A[2*i]/2;
            }
        if(A[2*i+1]%2==0){
            L_count += A[2*i+1]/2;
            R_count += A[2*i+1]/2;
            }
        else{
            L_count += A[2*i+1]/2;
            R_count += A[2*i+1]/2+1;
            }
        for(int k=0; k<A[2*i]-1; k++){
            C.push_back(0);
            }
            C.push_back(L_count);
            C.push_back(R_count);
        for(int k=0; k<A[2*i+1]-1; k++){
            C.push_back(0);
            }


        }

    for(int i=0; i<C.size(); i++){
        if(i != C.size()-1)
         cout << C[i] << " ";
         else cout << C[i];
        }
}

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

dic = {'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}


def func(x, y):

    if dic[x] > dic[y]:
        result = '>'
    elif dic[x] < dic[y]:
        result = '<'
    else:
        result = '='
    return result


X, Y = input().split()
print(func(X, Y))

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

lint solve(lint h,lint w){
	lint res=h*w;
	rep(i,h-1){
		lint a=(i+1)*w,b=(h-i-1)*w;
		lint c=((i+1)/2)*w;
		lint d=(i+1)*(w/2);
		res=min(res,max({b,c,a-c})-min({b,c,a-c}));
		res=min(res,max({b,d,a-d})-min({b,d,a-d}));
	}
	return res;
}

int main(){
	lint h,w; cin>>h>>w;
	cout<<min(solve(h,w),solve(w,h))<<endl;
	return 0;
}


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

using namespace std;

const int N = 100050;

vector <pair<int, int> > a, b;
int F[N];
struct Edge
{
    int u, v, w;
}edge[N << 4];
int tol;
void addedge(int u,int v,int w)
{
    edge[tol].u=u;
    edge[tol].v=v;
    edge[tol++].w=w;
}
bool cmp(Edge a,Edge b)
{
    return a.w<b.w;
}
int find(int x)
{
    if(F[x]==-1) return x;
    else return F[x]=find(F[x]);
}
long long Kruskal(int n)
{
    memset(F,-1,sizeof(F));
    sort(edge,edge+tol,cmp);
    int cnt=0;
    long long ans=0;
    for(int i=0;i<tol;i++)
    {
        int u=edge[i].u;
        int v=edge[i].v;
        int w=edge[i].w;
        int t1=find(u);
        int t2=find(v);
        if(t1!=t2)
        {
            ans+=w;
            F[t1]=t2;
            cnt++;
        }
        if(cnt==n-1) break;
    }
    if(cnt<n-1) return -1;
    else return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        a.push_back({x, i});
        b.push_back({y, i});
    }
    sort(a.begin(), a.end(), [](pair<int, int> x, pair<int, int> y) { return x.first < y.first;});
    sort(b.begin(), b.end(), [](pair<int, int> x, pair<int, int> y) { return x.first < y.first;});
    
    for(int i = 1; i < n; ++i)
    {
        addedge(a[i - 1].second, a[i].second, a[i].first - a[i - 1].first);
        addedge(b[i - 1].second, b[i].second, b[i].first - b[i - 1].first);
    }
    
    cout << Kruskal(n) << endl;
    
    return 0;
}

Measured memory_bytes: 6508
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            list.add(new ArrayList<>());
        }
        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            list.get(a).add(b);
            list.get(b).add(a);
        }
 
        for (int i = 0; i < N; ++i) {
            _out.println(list.get(i).size());
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    string s;
    int ans = 0;
    REP(i,n){
        cin >> s;
        if(s == "E869120") ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define N 100
using namespace std;
int n,a[N][N],ans;

bool checkx(int y,int x,int p){
  for(int i=0;i<n;i++)
    if(x!=i&&p>a[y][i])return false;
  return true;
}

bool checky(int y,int x,int p){
  for(int i=0;i<n;i++)
    if(y!=i&&p<a[i][x])return false;
  return true;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)cin>>a[i][j];
    ans=0;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	if(checkx(i,j,a[i][j])&&checky(i,j,a[i][j]))
	  ans=a[i][j];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val sc = new Scanner(System.in)
    val n = sc.nextInt
    val list = List.fill(n)(sc.nextInt)

    var minr = 1e10.toInt
    var ans = -1e10.toInt
    for (r <- list) {
      ans = math.max(ans, r - minr)
      minr = math.min(minr, r)
    }
    println(ans)
  }
}

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

const int N = 100010;

int a[N];

int main(){
	int n;
	scanf("%d", &n);
	long long sum = 0;
	int now = 0;
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
		sum += a[i];
		now ^= a[i] & 1;
		if (!a[i]){
			sum -= now;
			now = 0;
		}
	}
	printf("%lld\n", sum >> 1);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  int cnt = 0;
  cin >> a >> b;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      if (b - i - j <= a && b >= i + j) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
sosu = 10 ** 9 + 7
X, Y = map(int, input().split())
amari = (X + Y) % 3
sho = (X + Y) // 3
x = 2 * sho - X
if amari == 0 and x >= 0 and x <= sho:
    fac = [1 for i in range(sho+1)]
    finv = [1 for i in range(sho+1)]
    inv = [1 for i in range(sho+1)]
    for i in range(2, sho+1):
        fac[i] = fac[i-1] * i % sosu
        inv[i] = sosu - inv[sosu%i] * (sosu//i) % sosu
        finv[i] = finv[i-1] * inv[i] % sosu
    #print(fac)
    #print(finv)
    ans = int(fac[sho] * (finv[x] * finv[sho-x] % sosu) % sosu)
else:
    ans = 0
print(ans)


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

int main(){
	int n,r,p,c;

	while(true){
		vector<int> cards;
		int check[50]={0};
		cin >> n >> r;
		if(n == 0 && r == 0){
			break;
		}

		
		for(int i=n;i!=0;i--){
			cards.push_back(i);
		}
		vector<int> buf;
		for(int i=0;i<r;i++){
			cin >> p >> c;
			for(int j=0;j<c;j++){
				buf.push_back(cards[p+j-1]);
				check[p+j-1] = 1;
			}
			for(int j=0;j<n;j++){
				if(check[j] == 0){
					buf.push_back(cards[j]);
				}else{
					check[j] = 0;
				}
			}
			cards.clear();
			for(int j=0;j<n;j++){
				cards.push_back(buf[j]);
			}
			buf.clear();
		}

		cout << cards[0] << endl;
	}
}

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

int main() {
	long long N;

	cin >> N;

	for (long long i = 1; i < 3501; i++) {
		if (4 * i < N || N * (1 + 2*i) < 4 * i) continue;
		for (long long j = i; j < 3501; j++) {
			if (4 * i * j < N * (i + j) || N * (i + j + i*j) < 4 * i * j) continue;
			for (long long k = j; k < 3501; k++) {
				if (N * (i*j + j*k + k*i) == 4 * i * j * k) {
					cout << i << " " << j << " " << k << endl;
					return 0;
				} 
			}
		}
	}	
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int n,i,k,j,s,dust;
  int G[100][100];
  
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      G[i][j]=0;
    }
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d",&dust,&k);
    for(j=0; j<k; j++){
      scanf("%d",&s);
      G[i][s-1]=1;
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      if(j)printf(" ");
      printf("%d",G[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

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

    map<char, long long> T;

    for(long long i = 0; i < s.size(); i++){
        if(T.find(s[i]) == T.end()){
            T[s[i]] = 1;
        }
        else{
            T[s[i]]++;
        }
    }

    map<char, long long>::iterator it;

    for(it = T.begin(); it != T.end(); it++){
        if(it->second % 2 != 0){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    cout << fixed << setprecision(10);

    ll N;
    cin >> N;
    vector<double> x(N), y(N);
    Rep (i, N) {
        cin >> x[i] >> y[i];
    }

    vector<ll> order;
    Rep (i, N) {
        order.push_back(i);
    }

    auto dist = [](double x1, double y1, double x2, double y2) {
        return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    };

    double cnt = 0; double tmp = 0;
    do {
        Rep (i, N-1) {
            tmp += dist(x[order[i]], y[order[i]], x[order[i+1]], y[order[i+1]]);
        }
        cnt++;
    } while (next_permutation(order.begin(), order.end()));

    // cout << cnt << "\n";

    tmp /= cnt;
    cout << tmp << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int x,y,r,W,H;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  /*
  -100<=x;
   y<=100;
  0<W<=100;
  0<H<=100; 
  0<r<=100;
  */

  if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }



  return 0;
}

Measured memory_bytes: 584
K = int(input())

import queue
q = queue.Queue()

for i in range(1, 10):
    q.put(i)

cnt = 0

while True:
    n = q.get()
    cnt += 1
    if cnt == K:
        break
    if n % 10 != 0:
        q.put(n * 10 + n % 10 - 1)
    q.put(n * 10 + n % 10)
    if n % 10 != 9:
        q.put(n * 10 + n % 10 + 1)
print(n)

Measured memory_bytes: 57428
#include<cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1], t[n+1];
    scanf("%s %s", s, t);
    char ans[2*n+1];
    for(int i = 0; i < n; i++){
        ans[2*i] = s[i];
        ans[2*i+1] = t[i];
    }
    for(int i = 0; i < 2*n; i++){
        printf("%c", ans[i]);
    }
    puts("");
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;

//ここから書く
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  //[0,i)の和
  T sum(int i) {
    i--;
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  //[l,r)の和
  T sum(int l, int r) {
    return sum(r) - sum(l);
  }
};

int tentou(ivec &v){
  int n=v.size();
  int res=0;
  BIT<int> b(n);
  rep(i,n){
    res+=i-b.sum(v[i]);
    b.add(v[i],1);
  }
  return res;
}
signed main(){
  int n,k;cin>>n>>k;
  ivec s(n+1);
  map<int,int> ma;
  rep(i,n){
    int x;cin>>x;
    x-=k;
    s[i+1]=s[i]+x;
  }
  ivec t=s;
  ivec po(n+1);
  sort(all(t));
  rep(i,n+1){
    po[i]=lower_bound(all(t),s[i])-t.begin();
    po[i]+=ma[s[i]];
    ma[s[i]]++;
  }
  cout<<n*(n+1)/2-tentou(po)<<endl;
  return 0;
}

Measured memory_bytes: 21964
#!/usr/bin/env python3
import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    A = LI()
    A.sort()
    MAX = 10**6+1
    All = [0] * MAX

    setA = set(A)
    for i in A:
        k = i
        All[k] += 1
        k += i
        if All[i] >= 2:
            continue
        while k < MAX:
            All[k] += 1
            k += i

    ans = 0
    for i in range(1, MAX):
        if All[i] == 1 and i in setA:
            ans += 1

    print(ans)

    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()


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




Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    map<int, int> start;
    multiset<int> vals;
    for(int i = 0; i < W; i++) {
        start[i] = i;
        vals.insert(0);
    }
    for(int i = 0; i < H; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        auto it = start.lower_bound(l);
        int mxr = -1;
        while(it != start.end() && it->first <= r) {
            chmax(mxr, it->second);
            vals.erase(vals.find(it->first - it->second));
            start.erase(it++);
        }
        if(mxr != -1 && r < W) {
            vals.insert(r - mxr);
            start[r] = mxr;
        }
        int ans = -1;
        if(!vals.empty()) {
            ans = *vals.begin();
            ans += i + 1;
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 22384
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    std::cin >> s;
    int ans=0;
    for (int i = 1; i < n; i++) {
        int cnt=0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            for (int j = 0; j < i; j++) {
                if(s[j]==c)left=true;
            }
            for(int j=i;j<n;j++){
                if(s[j]==c)right=true;
            }
            if(left&&right)cnt++;
        }
        if(ans<cnt)ans=cnt;
    }
    std::cout << ans << std::endl;
}


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

int main(void){
	
	int N,sum=1,check;//sumは該当旅館の個数、	checkが0ならsum++、それ以外ではなにもしない
	
	cin>>N;
	
	int H[N];
	
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	
	for(int i=1;i<N;i++){
		check=0;//
		for(int j=0;j<i;j++){
			if(H[i]<H[j]){
				check=1;
				continue;
			}
		}
		if(check==0)
			sum++;
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 3e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int a, b;
  cin >> a >> b;
  if(a < 6) {
    cout << 0;
  } else if(a <= 12) {
    cout << b / 2;
  } else {
    cout << b;
  }
  return 0;
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define MAX 1000000001





int main(){
    string s;
    cin>>s;
    int n=s.size();
    int j1=0,j2=0,j3=0;


    rep(i,((n+1)/2)-1){
        if(s.at(i)!=s.at(((n+1)/2)-2-i)){
            j1=1;
            break;
        }
    }
    for(int i=((n+3)/2)-1;i<n;i++){
        if(s.at(i)!=s.at(n-1-i+(n+1)/2)){
            j2=1;
            break;
        }
    }
    for(int i=0;i<n;i++){
        if(s.at(i)!=s.at(n-1-i)){
            j3=1;
            break;
        }
    }
    if(j1==0&&j2==0&&j3==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
using namespace std;
int main(){
  int n,k=0;
  cin>>n;
  vector<int> d(n);
  rep(i,n){cin>>d[i];}
  REP(i,1,n-1){
    if(max(max(d[i-1],d[i]),d[i+1])!=d[i]&&
       min(min(d[i-1],d[i]),d[i+1])!=d[i]){k++;}}
  cout<<k<<endl;
}

Measured memory_bytes: 256