akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.buffer.readline().rstrip()
def resolve():
    n,w=map(int,input().split())
    W=[0]*(n+1)
    V=[0]*(n+1)
    for i in range(n):
        W[i+1],V[i+1]=map(int,input().split())
    dp=[[0]*(w+1) for _ in range(n+1)]
    for i in range(1,n+1):
        for k in range(w+1):
            if(k-W[i]>=0):
                dp[i][k]=max(dp[i-1][k-W[i]]+V[i],dp[i-1][k])
            else:
                dp[i][k]=dp[i-1][k]
    print(dp[n][w])
resolve()

Measured memory_bytes: 118128
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N, A;
    cin >> N >> A;
    cout << N * N - A << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication59
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> a = new List<int>();
            List<int> b = new List<int>();
            List<int> h = new List<int>();
            string c = Console.ReadLine();
            for (int d = 0; d < c.Length; d++)
            {
                if (c[d] == 'A')
                    a.Add(d);
                if (c[d] == 'Z')
                    b.Add(d);
            }
            Console.WriteLine(b[b.Count - 1] - a[0] + 1);
        }
    }
}


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

using namespace std;

//map<string,int>
//stringを引数（key）に、配列を構築できる。大きさはほぼ無限？
//map内のkeyですでにソートされている

int main(){
    int n;
    cin >> n;
    map<string,int> memo;
    string s;

    rep(i,n){
        cin >> s;
        memo[s]++;    
    }
    int mx = 0;
    for(auto p : memo) mx = max(mx,p.second); // for(変数宣言：範囲）　p.second　keyがfirstに入っているため
    for(auto p : memo){
        if(p.second != mx) continue;
        cout << p.first << endl;
    }

    return 0;    
}

Measured memory_bytes: 25216
def count2(n)
  ret = 0
  while n % 2 == 0
    ret += 1
    n /= 2
  end
  ret
end

gets # N
ans = 1000
gets.chomp.split.map(&:to_i).each do |n|
  ans = [ans, count2(n)].min
end

puts ans


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int a[Sz];
                
int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  
  int cur = 0;
  ll ans = 0;   
  
  if (a[1] != 0) {
    cout << -1;
    return 0;
  }
 
  for (int i = n; i >= 1; i--) {
    if (cur > a[i]) { 
      cout << -1;
      return 0;
    }         
    if (cur != a[i])
      ans += a[i];
    cur = max (0, a[i] - 1);
  }
  cout << ans;     
  return 0;
}






// Coded by Z..



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
  fast;
  ll n,x,t;
  cin>>n>>x>>t;
  ll ans=0;
  ans=n/x;
  if(n%x!=0)
    ans++;
  cout<<ans*t;
    

    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 3636
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 1)
            {
                Console.WriteLine(0);
            }
            else
            {
                ulong sum = 0;
                for(int i = 1; i < n; i++)
                {
                    sum += (ulong)i;
                }
                Console.WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 27496
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #include<boost/multiprecision/cpp_int.hpp>
// using boost ::multiprecision::cpp_int;
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    boost;
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    if(s[0]== '2' || s[0]== '7' || s[0]== '5' ||  s[0]== '4' || s[0]== '9' )
    cout<<"hon\n";
    else if(s[0]=='3')
    cout<<"bon\n";
    else 
    cout<<"pon\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}
/* AnsHuman_7 || Anshuman Gaur */

Measured memory_bytes: 3656
def spaceinput():
    return list(map(int,input().split(" ")))

N,P=list(map(int,input().split(" ")))
a=spaceinput()

dp=[[0,0] for i in range(N)]

if a[0]%2==0:
    dp[0][0]=2
    dp[0][1]=0
else:
    dp[0][0]=1
    dp[0][1]=1


for k in range(1,len(a)):
    if a[k]%2==0:
        dp[k][0]=dp[k-1][0]*2
        dp[k][1]=dp[k-1][1]*2
    else:
        dp[k][0]=dp[k-1][1]+dp[k-1][0]
        dp[k][1]=dp[k-1][0]+dp[k-1][1]


print(dp[N-1][P])


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define ull unsigned long long
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    FIO;
    double a, b, c;  cin >> a >> b >> c;
    double e = a / c;
    if(e <= b) cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 3732
#include <cstdio>
#include <cstring>
#include <cmath>
int main(){
	int a, n, b;
	scanf("%d",&n);
	a = 1;
	b = 0;
	if(n>=1 && n<=100){
	for(a = 0; a <= n; a++)
	{
	    b = b + a;
	}
	printf("%d",b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int A, B;
  cin >> A >> B;

  int flag = 0;
  REP(i,1251){
    int a = i * 108 / 100 - i;
    int b = i * 110 / 100 - i;
    if(a == A&&b == B){
      cout << i << endl;
      flag = 1;
      break;
    }
  }

  if(flag == 0){
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/16/20 07:31:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> P(n); for(auto& p:P) cin>>p;
  int ans = 0;
  for (int i = 1; i < n-1; i++) {
    int a=i>0?P[i-1]:0;
    int b=P[i];
    int c=i<n-1?P[i+1]:0;
    if ((a>b and b>c) or (a<b and b<c)) {
      ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
	// your code goes here
	int a,b;
	cin>>a>>b;
	if((a==1 && b==2) || (a==2 && b==1) )
	cout<<3<<endl;
	else if((a==3 && b==2) || (a==2 && b==3) )
	cout<<1<<endl;
	else
	cout<<2<<endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':break
    if op == '+':print(a+b)
    if op == '-':print(a-b)
    if op == '*':print(a*b)
    if op == '/':print(int(a/b))


Measured memory_bytes: 5596
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()

if S[:4] == "YAKI":
	print("Yes")
else:
	print("No")

Measured memory_bytes: 10444
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    int len = s.length();
    for(int i=0; i<len; i++)
    {
        char x;
        x = s[i] - 'A';
        x = (x + n)%26;
        x += 'A';
        cout << x;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	int ans = 0;
	if (2 * n <= m) {
		ans += n;
		m -= 2 * n;
		ans += m / 4;
	}
	else {
		ans += m / 2;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))

import bisect
ans=0
for i in b:
    x=bisect.bisect_left(a,i)
    y=n-bisect.bisect(c,i)
    ans+=x*y
print(ans)

Measured memory_bytes: 24096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 comb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}
i64 dp[1001][1001];
int main() {
    i64 n, k;
    cin >> n >> k;
    dp[0][0] = 1;
    for (i64 i = 1; i <= n; ++i) {
        for (i64 j = 1; j <= i; ++j) {
            dp[i][j] = (j * dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
        }
    }
    i64 ans = 0;
    for (i64 i = 1; i <= k; ++i) ans += dp[n][i];
    cout << ans % mod << endl;
    return 0;
}


Measured memory_bytes: 9984
x=int(input())
if(400<=x and x<=599):
	print(8)
if(600<=x and x<=799):
	print(7)
if(800<=x and x<=999):
	print(6)
if(1000<=x and x<=1199):
	print(5)
if(1200<=x and x<=1399):
	print(4)
if(1400<=x and x<=1599):
	print(3)
if(1600<=x and x<=1799):
	print(2)
if(1800<=x and x<=1999):
	print(1)

Measured memory_bytes: 9196
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  if(A<=8&&B<=8) printf("Yay!\n");
  else printf(":(\n");
  return 0;

}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 305;

long long g[N][N], dist[N][N], g2[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m, l;
	cin >> n >> m >> l;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) dist[i][j]=1e16;
	for(int i=0;i<n;i++) dist[i][i]=0;
	for(int i=0;i<m;i++) {
		int u, v, x;
		cin >> u >> v >> x;
		u--;
		v--;
		g[u][v]=x;
		g[v][u]=x;
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(g[i][j]) dist[i][j]=g[i][j];
		}
	}
	for(int k=0;k<n;k++) {
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(dist[i][j] > dist[i][k] + dist[k][j]) dist[i][j] = dist[i][k] + dist[k][j];
			}
		}
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(i==j) continue;
			g2[i][j]=1e16;
		}
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(dist[i][j] <= l) g2[i][j]=g2[j][i]=1;
		}	
	}
	for(int k=0;k<n;k++) {
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(g2[i][j] > g2[i][k] + g2[k][j]) g2[i][j] = g2[i][k] + g2[k][j];
			}
		}
	}
	int q;
	cin >> q;
	while(q--) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;		
		if(g2[u][v] >= 1e16) cout << -1 << "\n";
		else cout << g2[u][v]-1 << "\n";
	}
	return 0;
}


Measured memory_bytes: 2688
N, M = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(M)]
ab.sort(key=lambda x: x[1])

a, b = ab[0]
ans = 1
prev = b - 1
for a, b in ab[1:]:
    if prev >= a:
        continue
    ans += 1
    prev = b - 1
print(ans)


Measured memory_bytes: 65240
N = int(input())
dp = [float('inf') for i in range(N+1)]
dp[0] = 0
if N >= 6:
    dp[6] = 1
def below_power(n,a):
    "n以下になるa**xのxの最大値を求める"
    x = 0
    while n >= a**x:
        x += 1
    return x-1
nine = below_power(N,9)
six = below_power(N,6)
for i in range(six,0,-1):
    for j in range(N+1):
        if j - 6**i >= 0:
            dp[j] = min(dp[j],dp[j-6**i]+1)
for i in range(nine,0,-1):
    for j in range(N+1):
        if j - 9**i >= 0:
            dp[j] = min(dp[j],dp[j-9**i]+1)       
ans = dp[N]
for i in range(1,min(N+1,6)):
    ans = min(ans,dp[N-i]+i)
print(ans)

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n)*(n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool isprime[1000001] = {false};
int primes[80000] = {0};

int getval(int n){
  int maxn = 0;
  set<int> list;
  int i = 0;
  while(n != 1){
    // LOG("%d %d %d \n",i,primes[i], n);
    while(n % primes[i] == 0){
      maxn = max(maxn, primes[i]);
      list.insert(primes[i]);
      n /= primes[i];
    }
    i++;
  }

  int sum = maxn * 2;
  for(auto m : list){
    sum -= m;
  }
  return sum;
}

int main() {
  int cnt = 0;
  FOR(i, 2, 1000001){
    if(isprime[i]) continue;
    primes[cnt++] = i;
    for(int j = i * 2; j < 1000001; j += i){
      isprime[j]=true;
    }
  }

  int a, b;
  while(cin>>a>>b,a|b){
    if(getval(a)<getval(b)){
      cout << 'b' << endl;
    }else{
      cout << 'a' << endl;
    }
  }
}

Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
int n;
bool che(){
	while(n){
		if(n%10==9)	return 1;
		n/=10;
	}
	return 0;
}
int main(){
	IOS;
	cin>>n;
	if(che())	cout<<"Yes\n";
	else		cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, cnt=1;
    cin >> n;
    string s;
    cin >> s;
    for (int i=1; i<n; i++){
        cnt++;
        if(s[i] == s[i-1]) cnt--;
    }

    out(cnt);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
 using namespace std;
 
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0)
#define mod                     1000000007
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
typedef  long long                   ll;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  unordered_map<int, int>    mii;
typedef  vector<ll>                 vll;

const int N=5e5+5;

int dsum(int n)
{
    int sum=0;
    while(n)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}


int main()
{
  FIO;
  
 
 string s;
 cin>>s;
 int t=0;
 for(char c: s)
 {
    if(c=='+')
        t++;
    else
        t--;
 }

 cout<<t;
 

 return 0;
}

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = (x2 - x1);
    int y = (y2 - y1);
    printf("%d %d %d %d\n", x2 - y, y2 + x, x1 - y, y1 + x);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
c = str(input())

head = 0
tail = -1
count = 0

while head < N:
    if c[head] == "W":
        while tail >= -N and c[tail] == "W":
            tail -= 1
        if head >= N + tail:
            print(count)
            exit()
        tail -= 1
        count += 1
    head += 1
print(count)

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    int cnt = 0;
    while(N > 0) N /= K, cnt++;
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;

int main(){
	
	int n, m, h, k;
	
	while(true){
		cin >> n >> m >> h >> k;
		if(n == 0 && m == 0 && h == 0 && k == 0){
			break;
		}
		
		int cost[2000];
		int cost_ex[2000];
		
		for(int i = 0; i < n; i++){
			cin >> cost[i];
		}
		
		vector<P> v_pos;
		for(int i = 0; i < m; i++){
			P p;
			cin >> p.second >> p.first;
			v_pos.push_back(p);
		}
		
		sort(v_pos.begin(), v_pos.end());
		
		int index[10000];
		
		for(int i = 0; i < 10000; i++){
			index[i] = i;
		}
		
		vector<P> v_edge;
		for(int i = 0; i < m; i++){
			int index_edge = v_pos[i].second;
			P p_edge;
			p_edge.first = index[index_edge - 1];
			p_edge.second = index[index_edge];
			if(p_edge.first > p_edge.second){
				swap(p_edge.first, p_edge.second);
			}
			v_edge.push_back(p_edge);
			swap(index[index_edge], index[index_edge - 1]);
		}
		
		for(int i = 0; i < n; i++){
			cost_ex[index[i]] = cost[i];
		}
		
		int ans = 0;
		
		for(int i = 0; i < m; i++){
			P p_edge = v_edge[i];
			if(p_edge.first < k && p_edge.second >= k){
				if(ans > cost_ex[p_edge.second] - cost_ex[p_edge.first]){
					ans = cost_ex[p_edge.second] - cost_ex[p_edge.first];
				}
			}
		}
		
		int sum = 0;
		
		for(int i = 0; i < k; i++){
			sum += cost_ex[i];
		}
		
		cout << sum + ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 5244
import Control.Monad
import Control.Applicative

main :: IO ()
main = do
	n <- readLn :: IO Int
	lines <- replicateM 2 getLine
	let xs = map read $ words (lines !! 0) :: [Double]
	let ys = map read $ words (lines !! 1) :: [Double]
	let ds = zipWith (-) xs ys
	
	let p1 = sum $ map abs ds
	let p2 = (** (1/2)) $ sum $ map (** 2) ds
	let p3 = (** (1/3)) $ sum $ map (\x -> (abs x) ** 3) ds
	let pinf = foldr1 max $ map abs ds
	
	putStrLn $ show p1
	putStrLn $ show p2
	putStrLn $ show p3
	putStrLn $ show pinf

Measured memory_bytes: 4472
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    void Solve()
    {
        int N = cin.Nextint;
        var S = cin.Next;

        int max = 0;
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
            if (S[i] == 'I')
            {
                sum++;
            }
            else
            {
                sum--;
            }
            max = Math.Max(sum, max);
        }
        Console.WriteLine(max);
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 2648
//
//  main.cpp
//  Practice
//
//  Created by 石川　敬規 on 2017/08/11.
//  Copyright © 2017年 石川　敬規. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int n, a;
    
    cin >> n;
    
    int m4, m2, m;
    m4 = m2 = m = 0;
    
    for ( int i = 0; i < n; i++ ) {
        cin >> a;
        if ( a % 4 == 0 ) m4++;
        else if ( a % 2 == 0 ) m2++;
        else m++;
    }
    
    if ( m2 > 0 ) {
        if ( m <= m4 ) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if ( m4 + 1 >= m ) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
//文字列をシャッフルする
using namespace std;
string shuffle(string cards, int index){
	string left, right;
	left = cards.substr(0, index);
	right = cards.substr(index);
	return right + left;
}
int main(){
	string cards;
	int count;
	while(true){
		cin >> cards;
		if(cards == "-") return 0;
		cin >> count;
		for(int i = 0; i < count; i++){
			int index;
			cin >> index;
			cards = shuffle(cards, index);
		}
		cout << cards << endl;
	}
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N, M, C; cin >> N >> M >> C;
  vector<int> B(M);
  for(int i = 0; i < M; i++) cin >> B[i];

  int A[21][21];
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    int sum = 0;
    for(int j = 0; j < M; j++){
      sum += A[i][j] * B[j];
    }
    if((sum + C) > 0) ans ++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
# 埋める配列
# dp[w] : 入っている重さがwのときの価値の最大値

# 計算方法
# dp[0][0] = 0
# dp[w] = max(dp[w - wi] + vi)

# 埋める順序
# 後ろから

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [0] * (W + 1)
for i in range(N):
    wi, vi = wv[i]
    for j in range(W, -1, -1):
        if j - wi >= 0:
            dp[j] = max(dp[j], dp[j - wi] + vi)
            
print(dp[-1])

Measured memory_bytes: 42092
// 177

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int ans = INT_MAX;
    for(int i=0; i+t.length() <= s.length(); i++){
        int count = 0;
        for(int j=0; j<t.length(); j++){
            if(s.at(i+j) != t.at(j)) count++;
        }
        if(ans > count) ans = count;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;    
int n;
vector<double> p;
vector<vector<double> > m;
double fun(int idx, int cnt){
    if(cnt + idx <= n/2) return 0;
    if(idx == 0){        
        return 1;
    }
    if(m[idx][cnt] != -1) return m[idx][cnt];
    double temp1 = p[idx]*fun(idx-1, cnt +1);
    double temp2 = (1-p[idx])*fun(idx-1, cnt);
    double ans = temp1 + temp2;
    m[idx][cnt]= ans;
    return ans;
}
int main(){
    cin >> n;
    m = vector<vector<double> >(n+1, vector<double>(n+1, -1));
    p = vector<double>(n+1);
    for(int i = 1; i <= n; i++) cin >> p[i];
    cout << fixed << setprecision(10) << fun(n, 0);
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	string s,t;
	int ans=1000;
	cin >> s;
	REP(i,s.size()-2){
		t=s.substr(i, 3);
		ans=min(ans,abs(753-stoi(t)));
	}
	cout << ans << endl;
/////////////////////////////////////////////
}

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


def check(num):
    n=num
    digit_list=[]
    
    while num != 0:
        digit_list += [num % 10]
        num //= 10
    
    for i in range( len(digit_list) // 2 + 1*(len(digit_list)%2) ):
        if digit_list[i] != digit_list[len(digit_list)-1-i]:
            return False
    
    return True

#----------
a,b = list(map(int, input().rstrip().split()))

count=0
for i in range(a,b+1):
    if check(i):
        count += 1

print(count)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(input()) for _ in range(2**N)]
    for i in range(N):
        B = [0] * 2**(N-i-1)
        for j in range(2**(N-i-1)):
            if A[j*2] == A[j*2+1]:
                B[j] = A[j*2]
            else:
                B[j] = abs(A[j*2]-A[j*2+1])
        A = B
    print(A[0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 55260
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
const lld MAX=1100;
const lld MOD=1000000007;
vector<lld> conn[MAX];
priority_queue<lld> prior;
struct edge{
    lld x,y,w,w_min;
    bool operator<(const edge &k){
        return w<k.w;
    }
};
edge graph[MAX+1000];
lld w[MAX][MAX],v_chk[MAX],same[MAX],cnt1,cnt2,ans;
lld n,m,k;
lld pow(lld a,lld b){
    if(b==0) return 1;
    if(b==1) return a;
    lld t=pow(a,b/2);
    if(b%2) return (t*t%MOD)*a%MOD;
    return t*t%MOD;
}
void mypush(lld x){
    for(lld i=0;i<conn[x].size();i++) prior.push(-conn[x][i]);
}
int main(){
    scanf("%lld%lld%lld",&n,&m,&k);
    for(lld i=0;i<m;i++){
        lld t1,t2,t3;
        scanf("%lld%lld%lld",&t1,&t2,&t3);
        w[t2][t1]=w[t1][t2]=t3;
        graph[i]={t1,t2,t3,t3};
    }
    sort(graph,graph+m);
    for(lld i=0;i<m;i++){
        conn[graph[i].x].push_back(i);
        conn[graph[i].y].push_back(i);
    }
    for(lld i=0;i<m;i++){
        v_chk[graph[i].x]=1,v_chk[graph[i].y]=1;
        mypush(graph[i].x),mypush(graph[i].y);
        while(!prior.empty()){
            lld t=-prior.top();
            prior.pop();
            if(v_chk[graph[t].x]+v_chk[graph[t].y]==1){
                if(v_chk[graph[t].x]==0){
                    v_chk[graph[t].x]=1;
                    mypush(graph[t].x);
                }
                else{
                    v_chk[graph[t].y]=1;
                    mypush(graph[t].y);
                }
                graph[i].w_min+=graph[t].w;
            }
        }
        for(lld j=1;j<=n;j++) v_chk[j]=0;
    }
    for(lld i=0;i<m;i++){
        if(graph[i].w_min>k) cnt1++;
        else if(graph[i].w_min==k) cnt2++;
    }
    //printf("%d %d\n",cnt1,cnt2);
    if(cnt2==0) printf("0\n");
    else{
        if(cnt1+cnt2==m) ans=(pow(2,cnt2)-2)*pow(2,cnt1)%MOD;
        else ans=2*(pow(2,cnt2)-1)*pow(2,cnt1)%MOD;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {
	private static int count = 0;

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		System.out.println(count753(N,""));

	}

	private static int count753(int N, String str) {
		long strNum = 0;
		if(!str.equals("")) {
			strNum = Long.parseLong(str);
		}
		if (strNum <= N) {
			if (is753(str)) {
				count++;
			}
			count753(N,str+"3");
			count753(N,str+"5");
			count753(N,str+"7");
		}
		return count;
	}

	private static boolean is753(String str) {
		boolean has7 = false;
		boolean has5 = false;
		boolean has3 = false;
		boolean hasAnother = false;

		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == '7') {
				has7 = true;
			} else if (str.charAt(i) == '5') {
				has5 = true;
			} else if (str.charAt(i) == '3') {
				has3 = true;
			} else {
				hasAnother = true;
				break;
			}
		}
		if (hasAnother) {
			return false;
		}
		return has7 && has5 && has3;
	}
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  int now = n % 10;
  if (now == 2 || now == 4 || now == 5 || now == 7 || now == 9) {
    cout << "hon" << endl;
  } else if (now == 0 || now == 1 || now == 6 || now == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
string s,t,p;
int a,b;
bool cmp(string _i,string j)
{
	if(_i.size()==j.size())
	{
		for(int i=0;i<_i.size();i++)if(_i[i]!=j[i])return 0;
		return 1;
	}
	return 0;
}
int main()
{
	cin>>s>>t;
	scanf("%d%d",&a,&b);
	cin>>p;
	if(cmp(p,s))a--;
	else b--;
	printf("%d %d",a,b);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
inputs = input().split()
nums = [int(n) for n in inputs]

def hoge(nums):
    for i in range(len(nums)-1, 0, -1):
        temp = nums[i] - nums[i-1]
        if temp < 0:
            if temp == -1:
                nums[i-1] = nums[i-1] - 1
            else:
                return 'No'
    return 'Yes'

result = hoge(nums)
print(result)

Measured memory_bytes: 14396
uses crt;
var a,b,c:qword;
begin
        clrscr;
        readln(a,b,c);
        if (c>a)and(c-a<b)and(c>=b)then write('0 ',b-(c-a)) else
        if (c=a+b)then write('0 0') else
        if(a>=c)then write(a-c,' ',b) else
        if (c>a)and(c>b)and(c-a>=b)then write('0 0') else
        if (c>a)and(c-a<b)and(c< b)then write('0 ',b-(c-a));
        readln
end.





Measured memory_bytes: 128
//【ライブラリここから】
// 1. 入力の容易化（https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8）
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//【ライブラリここまで】

fn main() {
    input! {n: i32};
    println!("{}", (1000 - n % 1000) % 1000);
}


Measured memory_bytes: 2116
N = input()
rates = [tuple(map(int, raw_input().split())) for i in range(N)]

votes = rates[0]
for i in range(1,N):
    rate_t = rates[i][0]
    rate_a = rates[i][1]
    min_t = votes[0] / rate_t + (1 if votes[0] % rate_t > 0 else 0)
    min_a = votes[1] / rate_a + (1 if votes[1] % rate_a > 0 else 0)
    mag = max(min_t, min_a)
    votes = (rate_t * mag, rate_a * mag)

print sum(votes)

Measured memory_bytes: 2692
#include<iostream>
#include<queue>
#include<cstring>
#include<vector>

using namespace std;
typedef long long ll;
const int N = 1e6+5,M=N*2;
ll h[N],st[N],dist[N],cnt,n,m;
const ll inf = 0x3f3f3f3f3f3f3f3f;
struct node {
	ll to,nxt,w;
}eg[M*2];
void add(ll u,ll v,ll w){
	eg[cnt].w=w;eg[cnt].to=v;eg[cnt].nxt=h[u];h[u]=cnt++;
}
priority_queue<ll,vector<ll>,greater<ll> >q;
ll dijkstra(ll u){
	memset(st,0,sizeof(st));
//	memset(dist,0x3f,sizeof(dist));
	for(ll i=1;i<=n;i++) dist[i]=inf;
	dist[u]=0;
	q.push(u);
	while(!q.empty()){
		ll u=q.top();
		q.pop();
// 		if(st[u]) continue;
// 		st[u]=1;
		for(ll i=h[u];i!=-1;i=eg[i].nxt){
			ll v = eg[i].to;
//			if(st[v]) continue;
			if(dist[v]>dist[u]+eg[i].w){
				dist[v]=dist[u]+eg[i].w;
				q.push(v);
			} 
		}
	}
	if(dist[n]==inf) return -1;
	return dist[n];
}

int main(){
	memset(h,-1,sizeof(h));
	cnt=0;
	cin>>n>>m;
	for(ll i=1;i<=n;i++) add(i,i-1,0);
	for(ll i=0;i<m;i++){
		ll u,v,w;
		cin>>u>>v>>w;
		add(u,v,w);
	}
	cout<<dijkstra(1)<<endl;
	
	return 0;
}

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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))
#define pi              acos(-1.0)
#define NUM             200005

typedef long long ll;

vector<ll>parent,nodes;

int fi(ll a)
{
    if(parent[a]==a)
        return a;
    return parent[a] = fi(parent[a]);
}

void uni(ll a, ll b)
{
    ll u = fi(a);
    ll v = fi(b);

    if(u!=v)
    {
        if(nodes[u]<nodes[v])
            swap(u,v);
        parent[v] = u;

        nodes[u] += nodes[v];
    }
}


int main()
{
    FastRead

    ll n,m,sum=0,ans=0;

    cin>>n>>m;

    parent.resize(n+1);
    nodes.resize(n+1);

    for(ll i=1;i<=n;i++)
    {
        parent[i] = i;
        nodes[i] = 1;
    }

    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;

        uni(x,y);
    }

    for(ll i=1;i<=n;i++)
        ans = max(ans,nodes[i]);

    cout<<ans<<endl;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int main() {
  off;
  int t;
  //cin>>t;
  t=1;
  while(t--){  
    int n;
    cin>>n;
    int a[n],l[n+1],r[n+1];
    l[0]=0;
    r[n]=0;
    //cout<<__gcd(0,2)<<" ";
    for(int i=0;i<n;i++)
        {
          cin>>a[i];
          l[i+1]=__gcd(a[i],l[i]);
        }
     for(int i=n-1;i>=0;i--)
        {
           r[i]=__gcd(a[i],r[i+1]);
        }
        int max1=0;
      for(int i=0;i<n;i++)
          max1=max(max1,__gcd(l[i],r[i+1]));
      cout<<max1<<"\n";  
  }
    return 0;
}

Measured memory_bytes: 1408
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    R = INT()

    if R < 1200: print("ABC")
    elif R < 2800: print("ARC")
    else: print("AGC")


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

typedef struct {
    int sx, sy;
    int ex, ey;
} RECT;

int area;
int length;

RECT calc[10000];
RECT before[10000];
RECT grid[10000];
int bsize;

bool comp(const RECT& rLeft, const RECT& rRight){
    return (rLeft.sx < rRight.sx);
}

void mergeArea(int n, int *sq)
{
    int i, j;
    int num;
    int start, end;
    
    if (n == 0){
        return;
    }
    
    sort(grid, grid + n, comp);
    
    num = 0;
    start = grid[0].sx;
    end = grid[0].ex;
    for (i = 1; i < n; i++){
        if (grid[i].sx <= end){
            end = max(end, grid[i].ex);
        }
        else {
            calc[num].sx = start;
            calc[num++].ex = end;
            start = grid[i].sx;
            end = grid[i].ex;
        }
    }
    calc[num].sx = start;
    calc[num++].ex = end;
    for (i = 0; i < num; i++){
        area += calc[i].ex - calc[i].sx;
    }
    
    *sq = num;
}

void mergeLength(int n)
{
    vector<int> total;
    int i;
    int res;
    
    for (i = 0; i < n; i++){
        total.push_back(calc[i].sx);
        total.push_back(calc[i].ex);
    }
    for (i = 0; i < bsize; i++){
        total.push_back(before[i].sx);
        total.push_back(before[i].ex);
    }
    
    sort(total.begin(), total.end());
    res = 0;
    for (i = 0; i < total.size(); i += 2){
        res += total[i + 1] - total[i];
    }
    length += res + 2 * n;
}

int main(void)
{
    int n, query;
    static RECT p[10000];
    int num;
    int i, j;
    int sq;
    int miny, maxy;
    
    while (1){
        scanf("%d%d", &n, &query);
        
        if (n + query == 0){
            break;
        }
        area = length = 0;
        miny = 1000000;
        maxy = -100000;
        for (i = 0; i < n; i++){
            scanf("%d%d%d%d", &p[i].sx, &p[i].sy, &p[i].ex, &p[i].ey);
            miny = min(miny, p[i].sy);
            maxy = max(maxy, p[i].ey);
        }
        if (query == 1){
            continue;
        }
        bsize = 0;
        memset(before, 0, sizeof(before));
        area = length = 0;
        for (i = miny; i <= maxy; i++){
            memset(grid, 0, sizeof(grid));
            num = sq = 0;
            for (j = 0; j < n; j++){
                if (p[j].sy <= i && i < p[j].ey){
                    grid[num++] = p[j];
                }
            }
            mergeArea(num, &sq);
            if (query == 2 && (bsize != 0 || num != 0)){
                mergeLength(sq);
            }
            memcpy(before, calc, sizeof(calc));
            bsize = sq;
        }
        printf("%d\n", area);
        printf("%d\n%d\n", area, length);
    }
    
    return (0);
}

Measured memory_bytes: 1444
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	
	string str1, str2, str3;
	ll a, b;
	cin >> str1 >> str2;
	cin >> a >> b;
	cin >> str3;
	if(str1 == str3){
		cout << a-1 << " " << b << endl;
	} else {
		cout << a << " " << b-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
  cin>>n;
  int s[100001];
  for(int i=0; i<n; i++) cin>>s[i];
  s[n]=1e9+7;
  int q; cin>>q;
  int ans=0;
  for(int i=0; i<q; i++){
    int t; cin>>t;
    int l=0, r=n;
    while(l!=r){
      int m=(l+r)/2;
      if(s[m]>=t){
        r=m;
      }else{
        l=m+1;
      }
    }
    if(s[l]==t) ans++;
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3468