akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll mod = 1e9+7;
const int MAX = 3e5;
using P = pair<ll,ll>;

ll gcd(ll a, ll b){
  return b ? gcd(b, a % b) : a;
}

P process(ll a, ll b) {
  P p;
  ll g = gcd(abs(a),abs(b));
  a /= g, b /= g;
  if(a*b > 0) p = P(abs(a),abs(b));
  else if(a*b < 0) p = P(-abs(a),abs(b));
  else p = (a == 0 ? P(0,1) : P(1,0)); 
  return p;
}

int main(){
  ll n, zero = 0, ans, x, y, res = 1;
  cin >> n;
  map<P,ll> m;
  vector<ll> pw(MAX,1);
  vector<P> v;
  for(int i = 1; i < MAX; i++) pw[i] = pw[i-1] * 2 % mod;
  rep(i,n) {
    cin >> x >> y;
    if(x == 0 && y == 0) zero++;
    else {
      P p = process(x,y);
      if(m[p] == 0) v.push_back(p);
      m[p]++;
    }
  }
  ans = zero;
  for(auto x : v) {
    P y;
    if(x.first > 0) y = P(-x.second,x.first);
    else y = P(x.second,-x.first); 
    ll c = (pw[m[x]] + pw[m[y]] - 1) % mod;
    (res *= c) %= mod;
    m[x] = m[y] = 0;
  }
  res += mod - 1;
  (ans += res) %= mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 33484
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string s;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> s;
	s[3]='8';
	
	cout << s << '\n';
	
}

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


Measured memory_bytes: 128
#include "bits/stdc++.h"
//#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
int n, m;
vi v, w;
vvi va;

int solve(int i, int j){
	if(va[i][j] != -1)
		return va[i][j];
	if(i == n)
		return va[i][j] = 0;
	if(j < w[i])
		return va[i][j] = solve(i + 1, j); 
	return va[i][j] = max(solve(i + 1, j), solve(i + 1, j - w[i]) + v[i]);
}

signed main(){
	cin >> n >> m;
	v = vi(n);
	w = vi(n);
	va = vvi(n + 1, vi(m + 1));
	rep(i, n + 1)rep(j, m + 1)va[i][j] = -1;
	rep(i, n)cin >> v[i] >> w[i];
	cout << solve(0, m) << endl;
}

Measured memory_bytes: 6740
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
using ll = long long;

#define f first
#define s second
#define pb push_back

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

const char *inputFile = "input.txt";
ifstream ifs(inputFile);
const char *outputFile = "output.txt";
ofstream ofs(outputFile);

ll solve(vector<pair<ll, ll>> A){
  if(A.size() == 1) return A[0].s;
  ll res;
  if(A[0].s == -1){
    res = 0;
    ll Rank = A[0].f;
    for(int i = 1; i < A.size(); i++){
      if(A[i].s >= 0 && A[i].f == Rank + 1) res += A[i].s;
      else{
        vector<pair<ll,ll>> P;
        while(true){
          P.pb(A[i]);
          if(i+1 == A.size()) break;
          if(A[i+1].f <= Rank + 1) break;
          i++;
        }
        res += solve(P);
      }
    }
  }else{
    res = 1;
    ll Rank = A[0].f;
    for(int i = 1; i < A.size(); i++){
      if(A[i].s >= 0 && A[i].f == Rank + 1) res *= A[i].s;
      else{
        vector<pair<ll, ll>> P;
        while(true){
          P.pb(A[i]);
          if(i+1 == A.size()) break;
          if(A[i+1].f <= Rank + 1) break;
          i++;
        }
        res *= solve(P);
      }
    }
  }
  return res;
}

int main(){
  while(true){
    ll N; cin >> N;
    if(N == 0) return 0;
    vector<pair<ll, ll>> A(N);
    rep(i, N){
      string S; cin >> S;
      ll cnt = 0;
      rep(j, S.size()){
        if(S[j] != '.'){
          if(S[j] == '+') A[i].s = -1;
          else if(S[j] == '*') A[i].s = -2;
          else A[i].s = S[j] - '0';
        }
        else{
          cnt++;
        }
      }
      A[i].f = cnt;
    }
    cout << solve(A) << endl;
  }
}



Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<int> C(N),D(N);
  rep(i,N) cin>>C[i]>>D[i];

  for(int i=0;i+2<N;i++){
    if(D[i]!=C[i]) continue;
    if(D[i+1]!=C[i+1]) continue;
    if(D[i+2]!=C[i+2]) continue;

    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 30;
int n;
int a[130];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	bool flg = 1;
	for(int i = 1; i <= n; i++) {
		if(a[i] & 1) continue;
		else {
			if((a[i] % 3) && (a[i] % 5)) {
				flg = 0;
				break;
			}
		}
	}
	if(flg) puts("APPROVED");
	else puts("DENIED");
	return 0;
}

Measured memory_bytes: 256
#include <set>  
#include <map>  
#include <math.h>  
#include <vector>  
#include <stdio.h>  
#include <string.h>  
#include <iostream>  
#include <algorithm>  
using namespace std;  
#define  LL long long  
const double pi = acos(-1);  
const double g = -9.8;  
const int maxn = 1e5+555;  
   
int main()  
{  
    char s[maxn];  
    scanf("%s",s);  
    int ll=strlen(s);  
    int ans=ll/2;  
    int l,r;  
    while(1){  
        l=ll-ans;  
        r=ans+1;  
        int flag=1;  
        int now=s[l-1];  
        for(int i=l;i<r;i++){  
            if(s[i]!=now){  
                flag=0;  
                break;  
            }  
        }  
        if(!flag){  
            break;  
        }  
        ans++;  
    }  
    printf("%d\n",ans);  
}  

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)

N,Q = map(int,input().split())
tree = [[] for _ in range(N)]

# tree[i]: i番目の頂点とつながっている頂点（リスト）を入れる
for _ in range(N-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

# x_list[i]: iの配下に足す数を入れる
x_list = [0]*N
for _ in range(Q):
    p,x = map(int,input().split())
    x_list[p-1] += x

ans = [0]*N

def dfs(child, parent):
    ans[child] = ans[parent] + x_list[child]
    for v in tree[child]:
        if v != parent:
            dfs(v, child)

dfs(0,0)
print(' '.join([str(i) for i in ans]))

Measured memory_bytes: 228984
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    total = sum(A)
    for i in range(N):
        r = min(A[i], B[i])
        A[i] -= r
        B[i] -= r

        r = min(A[i + 1], B[i])
        A[i + 1] -= r
        B[i] -= r

    print(total - sum(A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 19260
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int i; cin >> i;
    if(i==1){
        cout << "Hello World" << endl;
        return 0;
    } 
    int a, b;
    cin >> a;
    cin >> b;
    cout << a + b << endl;
    return 0;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

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

	ll N;

	cin >> N;

	vector<ll> A(N+2, 0);
	ll tmp;
	rep(i, N) {
		cin >> A[i+1];
	}

	vector<ll> L(N+2, 0), R(N+2, 0);

	L[1] = 0;
	R[N+1] = 0;
	rep2(i, 1, N+1) {
		L[i + 1] = gcd(L[i], A[i]);
		R[N - i + 1] = gcd(R[N - i + 2], A[N - i + 1]);
	}

	ll max = -1;
	rep2(i, 1, N+1) {
		if (max < gcd(L[i], R[i + 1])) {
			max = gcd(L[i], R[i + 1]);
		}
	}

	cout << max << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	int ans=0;
	for(int i=0;i<a.size()/2;i++){
		bool wa=true;
		if(a[i]==a[a.size()-i-1]&&a[i]>100&&a[i]<120)wa=false;
		if(a[i]+a[a.size()-i-1]==81)wa=false;
		if(wa)ans++;
	}
	if(a.size()%2==1&&a[a.size()/2]<100)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1184
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import random
#####################################
k=int(input())
if k%2==0:
    print("{:.10f}".format(1/2))
else:
    print("{:.10f}".format((k//2+1)/k))


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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n&1)puts("No");
  else {
    string t = s.substr(0,n/2);
    string g = s.substr(n/2,n/2);
    if(g==t)puts("Yes");
    else puts("No");
  
  }
  return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner
import scala.math._

object Main extends App {

  val sc = new Scanner(System.in)

  val N = sc.nextInt()

  var list = List.fill(N)(sc.nextInt())
  var cnt=0

  while(list.forall(_%2==0)){
    cnt+=1
    list = list.map(_ / 2)
  }
  println(cnt)

}



Measured memory_bytes: 27568
#include<iostream>
#include<string>
#define Num 3
using namespace std;
int main(void){
  string s[Num];
  for(int i(0);i<Num;i++){
    cin>>s[i];
  }
  int f(0);
  char p='a';
  int aCnt(0),bCnt(0),cCnt(0);
  size_t sizeA=s[0].length();
  size_t sizeB=s[1].length();
  size_t sizeC=s[2].length();
  while(f==0){
    if(p=='a'){
      if(aCnt==sizeA){
        cout<<"A"<<endl;
        f=1;
      }
      p=s[0][aCnt];
      aCnt++;
    }else if(p=='b'){
      if(bCnt==sizeB){
        cout<<"B"<<endl;
        f=1;
      }
      p=s[1][bCnt];
      bCnt++;
    }else{
      if(cCnt==sizeC){
        cout<<"C"<<endl;
        f=1;
      }
      p=s[2][cCnt];
      cCnt++;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
	int n;
	string s,t;
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n-i; j++) {
			if (s[i + j] != t[j])break;
			if (j == n - i - 1) {
				cout << n + i << endl;
				return 0;
			}
		}
	}
	cout << n*2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<limits.h>
using namespace std;

typedef long long LL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5+10;
int a[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans=1,tmp;
    cin>>n>>a[0];
    tmp=a[0];
    for(int i=1;i<n;++i) {
        cin >> a[i];
        if(tmp>=a[i]) {
            tmp = a[i];
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
//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 <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL fact[202020];

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


	fact[0] = 1;

	for (int i = 1; i <= 200000; i++)fact[i] = fact[i - 1] * i%MOD;
	LL ans = 0;

	if (n == m) {
		cout << 2 * fact[n] * fact[m] % MOD << endl;
	}
	else if (abs(n - m) == 1) {
		cout << fact[n] * fact[m] % MOD << endl;
	}
	else {
		cout << 0 << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1792
#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;

const double pi = 3.141592653589793;

#define xx          first
#define yy          second
#define mp          make_pair
#define intl        long long
#define filein      freopen("input.txt", "r", stdin)
#define fileout     freopen("output.txt", "w", stdout)
#define debug       cout << "YES" << endl
#define what_is(x)  cout << #x << " is " << x << endl
#define pb          push_back
#define pii         pair<int, int>

//find_by_order(int) and order_of_key(int)
//typedef tree < intl , null_type ,less<intl>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
const int M = 345678;
int k, dist[123456];

int dijkstra()
{
    priority_queue<pii>q; //sum, rem
    memset( dist, 125, sizeof dist );
    for( int i = 1; i <= 9; i++ )
    {
        q.push( mp(-i,i) );
        dist[i] = i;
    }

    while( !q.empty() )
    {
        pii a = q.top();
        q.pop();
        int r = a.yy, s = dist[a.yy];
        if( r == 0 ) return s;
        for( int i = 0; i < 10; i++ )
        {
            int tr = (r*10 + i)%k;
            if( dist[tr] > s + i )
            {
                dist[tr] = s+i;
                q.push( mp( -dist[tr], tr ) );
            }
        }
    }
    //return dist[0];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //filein;
    cin >> k;
    cout << dijkstra() << endl;
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define SZ(x) (int((x).size()))
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 2e6 + 20;
const int MOD = 1e9 + 7;
const int MUL = 32323;
string s, t, T;
vector<int> edge[MAXN >> 2];
int dp[MAXN >> 2], OK[MAXN >> 2], que[MAXN >> 2], deg[MAXN >> 2];
lint Hash[2][MAXN], mul[MAXN];
inline void DoHash(lint HHH[], string & SSS) {
	#define s SSS
	#define Hash HHH
	Hash[0] = s[0] - 'a' + 1;
	rep (i, 1, SZ(s) - 1) {
		if (i) Hash[i] = (Hash[i - 1] * MUL + s[i] - 'a' + 1) % MOD;
	}
	#undef s
	#undef Hash
}
inline ulint getHash(lint HHH[], int l, int r) {
	if (!l) return HHH[r];
	return (HHH[r] - HHH[l - 1] * mul[r - l + 1] % MOD + MOD) % MOD;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> T >> s;
	while (SZ(t) < SZ(s)) t += T; t += t;
	mul[0] = 1;
	rep (i, 1, MAXN - 1) {
		mul[i] = mul[i - 1] * MUL % MOD;
	}
	DoHash(Hash[0], t);
	DoHash(Hash[1], s);
	rep (i, 0, SZ(t) - SZ(s)) {
		OK[i % SZ(T)] |= (getHash(Hash[0], i, i + SZ(s) - 1) == getHash(Hash[1], 0, SZ(s) - 1));
	}
	rep (i, 0, SZ(T) - 1) {
		if (OK[i] && OK[(i + SZ(s)) % SZ(T)]) {
			edge[i].pb((i + SZ(s)) % SZ(T)), ++deg[(i + SZ(s)) % SZ(T)];
		}
	}
	int l = 1, r = 0;
	rep (i, 0, SZ(T) - 1) {
		if (OK[i] && deg[i] == 0) {
			que[++r] = i;
		}
	}
	while (l <= r) {
		int u = que[l++];
		for (auto v : edge[u]) {
			if ((--deg[v]) == 0) {
				que[++r] = v;
			}
		}
	}
	rep (i, 0, SZ(T) - 1) if (deg[i]) {
		cout << -1 << endl; return 0;
	}
	int ans = 0;
	per (i, r, 1) {
		int now = que[i];
		if (edge[now].size() == 0) dp[now] = 1;
		else dp[now] = dp[(now + SZ(s)) % SZ(T)] + 1;
		ans = max(ans, dp[now]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 77000
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int64_t seg_a[100000] = {};
int64_t seg_b[100000] = {};

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

	int n; cin >> n;

	vector<int> ss(n);
	for (auto& s : ss) {
		cin >> s;
	}

	int64_t ans = 0;
	FOR_LT(c, 1, n) {
		int b = (n - 1) % c;
		if (b == 0) b = c;

		int64_t a_sum = 0;
		int64_t c_sum = 0;

		int l = 0;
		for (int i = 0; ; i++) {
			if (n <= (i + 1) * c + b) break;
			a_sum += ss[(i + 1) * c + b];
			c_sum += ss[i * c];
			l++;
		}

		int apos = b + c;
		int cpos = c * (l - 1);
		while (true) {
			bool skip = false;
			if (b == c) {
				if (apos <= cpos) {
					skip = true;
				}
			}

			if (!skip) {
				int64_t val = a_sum + c_sum;
				ans = max(ans, val);
			}

			if (cpos <= 0 || n <= apos) break;

			a_sum -= ss[apos];
			c_sum -= ss[cpos];
			apos += c;
			cpos -= c;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI")
		Yes();
	else
		No();

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1161&lang=jp
typedef long long ll;
using namespace std;
#define INF 1<<30
#define LINF 1LL<<62
vector<string> S;
vector<int> zero;
vector<ll> keisuu;
vector<char> alpha;

ll solve(int x, int bit, ll sum) {
	if (x == alpha.size()) {
		return sum == 0;
	}
	ll ret = 0;

	for (int j = 0; j <= 9; j++) {
		if (j == 0 && zero[alpha[x] - 'A'] == 1) continue;
		if (bit & (1 << j))continue;
		//if (x == 0) cout << j << endl;
		int new_bit = bit | (1 << j);
		ret += solve(x + 1, new_bit, sum + keisuu[alpha[x] - 'A'] * j);
	}
	return ret;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N;
	while (cin >> N, N) {
		alpha.clear();
		S.clear(); S.resize(N);
		zero.clear(); zero.resize(26, 0);
		keisuu.clear(); keisuu.resize(26, 0);
		for (int i = 0; i < N;i++) {
			cin >> S[i];
			if(S[i].length() >= 2)zero[S[i][0] - 'A'] = 1;
			int ten = 1;
			for (int j = S[i].length() - 1; j >= 0; j--) {
				alpha.push_back(S[i][j]);
				if(i != N-1)keisuu[S[i][j] - 'A'] += ten;
				else keisuu[S[i][j] - 'A'] -= ten;
				ten *= 10;
			}
		}

		sort(alpha.begin(), alpha.end());
		alpha.erase(unique(alpha.begin(), alpha.end()), alpha.end());

		/*for (int i = 0; i < 26;i++) {
			cout << char('A' + i) << " : " << keisuu[i] << " : " << zero[i] << endl;
		}*/

		cout << solve(0,0,0) << endl;
	}
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll power(ll a, ll n){
	ll result = 1;
	ll i = 1;
	while( i <= n ) {
		if( n & i ) result *= a;
		i <<= 1ll;
		a = a * a;
	}
	return result;
}

int main(){
	ll n;
	ll x;
	cin >> n >> x;
	--x;
	ll ans = 0;
	while(n){
		if( n == 1 ){
			if( x >= 1 ) ans += 1;
			if( x >= 2 ) ans += 1;
			if( x >= 3 ) ans += 1;
			break;
		}
		ll mid = (1ll<<(n+1))-2;
		if( x == mid ) ++ans;
		if( x > mid ){
			ans += (1ll<<n);
			x -= mid;
		}
		--x;
		--n;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string.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 x,ans=0;
  rep(i,5){
    cin >> x;
    if(x==0){
      ans=i+1;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3672
fun main(args: Array<String>){
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    var max = (n - 1) * (n - 2) / 2
    if (max < k){
        println(-1)
        return
    }

    val list = mutableListOf<Pair<Int, Int>>()
    for (i in 2..n){
        list.add(Pair(1, i))
    }
    loop@ for (i in 2..n-1){
        for(j in i+1..n){
            if(max != k) {
                list.add(Pair(i, j))
                max--
            }else{
                break@loop
            }
        }
    }
    println(list.size)
    list.forEach {
        println("${it.first} ${it.second}")
    }
}

Measured memory_bytes: 38592
import scala.annotation.tailrec

object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  for (_ ← 0 until readLine.trim.toInt) {
    val Array(n, x, y) = readLine.trim.split(' ').map(_.toInt)
    val enter = readLine.trim.split(' ').map(_.toInt).let { it ⇒
      val Array(a, b) = it
      Coordinate(a, b)
    }
    val clue = Array.tabulate(n) { _ ⇒
      val Array(a, b) = readLine.trim.split(' ').map(_.toInt)
      Coordinate(a, b)
    }
    val echos = Array.tabulate(n) { _ ⇒ Nil: List[Int] }
    for {i ← 0 until n
         j ← 0 until n if i != j} {
      if (clue(i).distance(clue(j)) <= 50) {
        echos(i) ::= j
        echos(j) ::= i
      }
    }

    def move(state: Array[Int]): Boolean = {
      /*
    state(i) は前回発声し終わったタイミングからの経過時間
    state(i) >= Y　の時、店員iは前回発声してからY以上たっているか発声したことがない
    state(i) == 0　の時、このタイミングで店員iは発声する

    店員iが発声する店員から50以内にいて、かつstate(i) > Yの時次に発生することとなり、state(i) == 0になる
    発声する店員iはstate(i) == Xになる
    発声しなかったし、発生する予定もない店員iはstate(i) += Xになる

     */
      val calling = state.zipWithIndex.filter(_._1 == 0).map(_._2)
      for {call ← calling
           echo ← echos(call)} {
        if (state(echo) == y + 1) {
          state(echo) = 0
        }
      }
      for (i ← state.indices){
        if (state(i) != 0) state(i) = if (state(i) + x > y + 1) y + 1 else state(i) + x
      }
      for (call ← calling) {
        state(call) = if (x > y + 1) y + 1 else x
      }
      calling.nonEmpty
    }

    val state1 = Array.tabulate(n) { _ ⇒ y + 1}
    val state2 = Array.tabulate(n) { _ ⇒ y + 1}
    val firstCall = clue.indices.filter{it ⇒ clue(it).distance(enter) <= 10}
    for (call ← firstCall){
      state1(call) = 0
      state2(call) = 0
    }
    move(state2)
    var time = 0
    while (state1.zip(state2).exists(it ⇒ it._1 != it._2)) {
      //println("calling" + state1.indices.filter(it ⇒ state1(it) == 0).mkString(","))
      //println("state => " + state1.mkString(","))
      if (move(state1)) time += x
      move(state2)
      move(state2)
    }
    //println("state1" + state1.mkString(","))
    //println("state2" + state2.mkString(","))
    println(
      if (state1.contains(0)) "You're always welcome!" else if (firstCall.isEmpty) 0 else time
    )
  }
  case class Coordinate(x: Int, y: Int) {
    def -(that: Coordinate): Coordinate = Coordinate(x - that.x, y - that.y)
    def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)
    def distance(that: Coordinate): Double = (this - that).let{it ⇒ math.sqrt(it.x * it.x + it.y * it.y)}
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 449016
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N  = parseInt(arg[0].split(" ")[0]);
    const Q  = arg[0].split(" ")[1];
    const S  = arg[1];
    const Qs = arg.slice(2, Q + 2);
    let dp = new Array(N).fill(0);
    let cnt = 0;
    
    for(let i in dp) {
        if(S.charAt(i) === "A" && S.charAt(parseInt(i)+1) === "C") {
            cnt++;
        }
        
        dp[parseInt(i)+1] = cnt;
    }

    for(let i=0; i<Q; i++) {
        let lr = Qs[i].split(" ");
        let l = lr[0];
        let r = lr[1];
        
        console.log(dp[r-1]-dp[l-1]);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 41424
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	string S;
	cin >> S;
	vector<int> s(10);
	int N = S.size();
	for (int i = 0; i < N; i++)
	{
		s[i] = atoi(S.substr(i, 1).c_str());
	}
	
	int answer = INT_MAX;
	for (int i = 0; i < N - 2; i++)
	{
		int value = 100 * s[i] + 10 * s[i + 1] + 1 * s[i + 2];
		if (value >= 753)
		{
			value = value - 753;
		}
		else {
			value = 753 - value;
		}
		
		answer = min(value, answer);
	}
	
	cout << answer << endl;
	
	return 0;
}

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

int main(void) {
	int n;
	cin >> n;
	int v[n];
	int c[n];
	
	for(int i = 0;i < n; i++)
	{
		cin >> v[i];
	}
	
	for(int i = 0;i < n; i++)
	{
		cin >> c[i];
	}
	
	int tmp = 0, sum = 0;
	
	for(int i = 0; i < n;i++)
	{
		tmp = v[i] - c[i];

		if(tmp > 0){
			sum += tmp;	
		}	
	}

	cout << sum;
}


Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

x,a,b = gi
if b-a <= 0
  puts "delicious"
elsif x >= b - a
  puts "safe"
else
  puts "dangerous"
end

Measured memory_bytes: 2300
#include <stdio.h>

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if(c < b){
        int temp = b;
        b = c;
        c = temp;
    }
    if(b < a){
        int temp = a;
        a = b;
        b = temp;
    }
    if(c < b){
        int temp = b;
        b = c;
        c = temp;
    }

    printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 2068
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
if(ch=='A')return 1;
else if(ch=='C')return 2;
else if(ch=='G')return 3;
else if(ch=='T')return 4;
else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
if(com[0]=='i'){
  insert(str);
}else{
  if(find(str)){
    printf("yes\n");
  }
else {
  printf("no\n");
}
}
  }
return 0;
}


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

using namespace std;
#define INF 100001

int searchMinCoins(const vector<int> &Coins, vector<int> &minCoins,int n){
    for(int i = 0;i < Coins.size();i++){
        for(int j = Coins[i];j <= n;j++){
            minCoins[j] = min(minCoins[j],minCoins[j-Coins[i]]+1);
        }    
    }
    return minCoins[n];
}


int main()
{
    int n,m;
    int temp;

    scanf("%d %d",&n,&m);
    vector<int> Coins(m,0);
    vector<int> minCoins(n+1,INF);
    
    for(int i = 0;i < m;i++){
        scanf("%d",&temp);
        Coins[i] = temp;
    }
    
    minCoins[0] = 0;
    int minCoin = searchMinCoins(Coins,minCoins,n);
    printf("%d\n",minCoin);

    return 0;
}



Measured memory_bytes: 3224
#include <stdio.h>

int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){
      break;
    }
    for(i=0; i<H; i++){
      for(j=0; j<W; j++){
        if(i==0||j==0||j==W-1||i==H-1)
        printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

ll n,a[100010],b[100010],ans=0;

void init(){
	cin>>n;
	rep(i,n+1)cin>>a[i];
	rep(i,n)cin>>b[i];
}

int main(void){
	init();
	irep(i,n){
		if(a[i+1]<b[i]){
			ans+=a[i+1];
			b[i]-=a[i+1];
			a[i+1]=0;
		}else{
			ans+=b[i];
			a[i+1]-=b[i];
			b[i]=0;
		}
		if(a[i]<b[i]){
			ans+=a[i];
			b[i]-=a[i];
			a[i]=0;
		}else{
			ans+=b[i];
			a[i]-=b[i];
			b[i]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	string s, t;
	cin >> s >> t;
	
	if (t.size() > s.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	
	string ans(s.size(),'z');
	bool exist = false;
	
	rep(i,s.size()-t.size()+1) {
		bool ok = true;
		rep(j,t.size()){
			if(s[i+j] != '?' && s[i+j] != t[j]) {
				ok = false;
			}
		}
		if (ok) {
			exist = true;
			string u = "";
			u += s.substr(0, i);
			u += t;
			u += s.substr(i+t.size(), s.size());
			
			rep(i,s.size()){
				if(u[i] == '?'){
					u[i] = 'a';
				}
			}
			ans = min(ans,u);
		}
	}
	
	if(exist){
		cout << ans << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	}
	
}
	


Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict


def solution():
    pass


def main():
    n, m = r_array()
    heights = r_array()
    heights.insert(0, 0)
    di = defaultdict(int)
    for _ in range(m):
        a, b = r_array()
        di[a] = max(di[a], heights[b])
        di[b] = max(di[b], heights[a])

    res = sum(heights[i] > di[i] for i in range(1, n + 1))
    write(res)


# fast-io region
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end='\n'):
    for x in args[:-1]:
        sys.stdout.write(str(x) + ' ')
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()


Measured memory_bytes: 93608
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef  long long int ll;
using namespace std;
const int M=1e9+7;
const int N=3e3+5;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
ll dp[N][N];
int main()
{
    ios ;
    ll t=1;
  //  cin>>t;
    while(t--)
    {
       ll n;cin>>n;
       ll a[n];
       for(ll i=0;i<n;++i)
       cin>>a[i];
       for(ll i=n-1;i>=0;--i)
       {
           for(ll j=i;j<n;++j)
           {
               if(i==j)
               dp[i][j]=a[i];
               else
               {
                   dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
               }
           }
       }
       cout<<dp[0][n-1];
    }
}

Measured memory_bytes: 49708
input()
flowers = list(map(int,input().split()))
def mizuyari(*f):
  num = 0
  if f == ():
    return 0
  f_min = min(f)
  f_min_index = f.index(f_min)
  num += f_min
  f = [i-f_min for i in f]
  num += mizuyari(*f[:f_min_index])
  num += mizuyari(*f[f_min_index+1:])
  return num

ans = mizuyari(0, *flowers)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef online_judge
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x;
    cin >> x;
    if(x >= 400 && x <= 599)
        cout << 8;
    if (x >= 600 && x <= 799)
        cout << 7;
    if(x >= 800 && x <= 999)
        cout << 6;
    if(x >= 1000 && x <= 1199)
        cout << 5;
    if(x >= 1200 && x <= 1399)
        cout << 4;
    if (x >= 1400 && x <= 1599)
        cout << 3;
    if(x >= 1600 && x <= 1799)
        cout << 2;
    if(x >= 1800 && x <= 1999)
        cout << 1;
    return 0;
}


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

bool is_integer(double x) {
    return floor(x) == x;
}

int main() {
    int n, d;
    int ans = 0;
    cin >> n >> d;
    vector<vector<int>> x;
    x.resize(n, vector<int>());
    rep(i, n) x[i].resize(d);
    rep(i, n) rep(j, d) cin >> x[i][j];
    rep(i,n) {
        vector<int> x2 = x[i];
        for (int j = i + 1; j < n; j++){
            double res = 0;
            rep(k, d) {
                int ful = x2[k] - x[j][k];
                res += ful * ful;
            }
            res = sqrt(res);

            if (is_integer(res)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
    {
      int s, n, i, h, maxheight;
      s = 0;
      maxheight = 0;
      cin >> n;
      for(i =0; i<n; i++)
      {
        cin >> h;
        if(h >= maxheight)
        {
          s++;
          maxheight = h;
        }
      }
      cout << s << endl;
      return 0;
    }

Measured memory_bytes: 256
while n=gets
  words=n.chomp.split(" ")
end
count_max=0
count_word=0
max=0
word=0
m=words.length
m.times{|i|
  if words[i].length>max
    max=words[i].length 
    word=words[i]
  end
}
count = Hash.new(0)
words.each do |elem|
  count[elem] += 1
  if count[elem]>count_max
    count_max=count[elem]
  end
end


puts print(count.key(count_max),"\s",word)


Measured memory_bytes: 6844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;

class Sobaya
{
    static void Main(){
      new Sobaya().calc();
      return;
    }
      
    Scanner cin;
    
    void calc(){
        cin = new Scanner();
        int a = cin.nextInt();
        int b = cin.nextInt();
        if((a+b)%2 ==1) Console.WriteLine("IMPOSSIBLE");
        else Console.WriteLine((a+b)/2);

    }
}




class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let rec f s ac =
        let ss = 
                if s mod 2 = 0 then
                        s / 2
                else
                        3 * s + 1
        in
        let exists = List.exists (fun elmnt -> elmnt = ss) ac in
                if exists then
                        1 + List.length ac
                else
                        f ss ([ss] @ ac)

let () =
        Scanf.sscanf (read_line ()) "%d" (
                fun s -> 
                        f s [s]
        ) |> Printf.printf "%d\n"


Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-7
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(n) ((n) * (n))
#define INF 300000005
#define MAXN 1000000

int main()
{
	string str;
	cin >> str;
	str = "ABC" + str;
	cout << str;
	return 0;
}


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

using namespace std;

const int kMod = 1e9 + 7;

vector<vector<int>> graph;
pair<int, int> DFS(int node, int par) {
    pair<int, int> ret = {1, 1};
    for (auto vec : graph[node]) {
        if (vec == par) continue;
        pair<int, int> sub = DFS(vec, node);
        ret.first = 1LL * ret.first * (sub.first + sub.second) % kMod;
        ret.second = 1LL * ret.second * sub.first % kMod;
    }
    return ret;
}

int main() {
    
    int n; cin >> n;
    graph.resize(n);
    for (int i = 1; i < n; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int b, w; tie(b, w) = DFS(0, -1);
    cout << (b + w) % kMod << endl;

    return 0;
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void print_vec(vector<long long>& a, int n=-1){
    n=(n==-1?a.size():n);
    for(int i=0;i<n;i++)
        cout<<a[i]<<(i<n-1?" ":"\n");
}

void solve(){
    int k,ctr=0;
    cin>>k;
    vector<vector<vector<long long>>> dp(10,vector<vector<long long>>(20));
    for(int i=0;i<10;i++){
        dp[i][1].pb(i);
        if(i>0)
            ctr++;
    }

    int dig=2;
    long long mul=10;
    while(ctr<k){
        for(int i=0;i<10;i++){
            for(int j=0;j<dp[i][dig-1].size();j++){
                dp[i][dig].pb(i*mul+dp[i][dig-1][j]);
            }
            if(i>0){
                for(int j=0;j<dp[i-1][dig-1].size();j++){
                    dp[i][dig].pb(i*mul+dp[i-1][dig-1][j]);
                }
            }
            if(i<9){
                for(int j=0;j<dp[i+1][dig-1].size();j++){
                    dp[i][dig].pb(i*mul+dp[i+1][dig-1][j]);
                }
            }
        }
        for(int i=1;i<10;i++){
            ctr+=dp[i][dig].size();
        }
        mul*=10ll;
        dig++;
    }
    vector<long long> ans;
    for(int i=1;i<10;i++){
        for(int j=1;j<dp[i].size();j++){
            for(int k=0;k<dp[i][j].size();k++){
                ans.pb(dp[i][j][k]);
            }
        }
    }
    sort(full(ans));
    // print_vec(ans,min(int(ans.size()),100));
    cout<<ans[k-1]<<"\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 4340
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

a = listA[0][0]
b = listA[1][0]
c = listA[1][1]

if b % a == 0:
  print ('OK')

d = b // a

if b % a !=0:
  if a * (d+1) <= c:
    print ('OK')
  else:
    print ('NG')

Measured memory_bytes: 9076