akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    
    
    vector<int> A(n*n, 0);
    vector<int> x(n);
    vector<int> y(n);
    vector<int> xb(m);
    vector<int> yb(m);
    vector<int> xe(m);
    vector<int> ye(m);
    vector<int> xs;
    vector<int> ys;
    
    for(int j = 0; j < n; j++)
        cin >> x[j] >> y[j];
    
    for(int i = 0; i < m; i++)
        cin >> xb[i] >> yb[i] >> xe[i] >> ye[i];
    
    xs = x;
    ys = y;
    sort( xs.begin(), xs.end() );
    sort( ys.begin(), ys.end() );
    xs.erase( unique( xs.begin(), xs.end() ), xs.end() );
    ys.erase( unique( ys.begin(), ys.end() ), ys.end() );
    
    for(int j = 0; j < n; j++){
        x[j] = find( xs.begin(), xs.end(), x[j] ) - xs.begin();
        y[j] = find( ys.begin(), ys.end(), y[j] ) - ys.begin();
    }
    
    for(int i = 0; i < m; i++){
        xb[i] = lower_bound( xs.begin(), xs.end(), xb[i] ) - xs.begin();
        yb[i] = lower_bound( ys.begin(), ys.end(), yb[i] ) - ys.begin();
        xe[i] = upper_bound( xs.begin(), xs.end(), xe[i] ) - xs.begin() - 1;
        ye[i] = upper_bound( ys.begin(), ys.end(), ye[i] ) - ys.begin() - 1;
    }
    
    
    
    for(int j = 0; j < n; j++){
        A[ n*y[j] + x[j] ] += 1;
    }
    
    for(int j = 0; j < n; j++){
        for(int k = 1; k < n; k++){
            A[n*j+k] += A[n*j+k-1];
        }
    }
    for(int k = 0; k < n; k++){
        for(int j = 1; j < n; j++){
            A[n*j+k] += A[n*(j-1)+k];
        }
    }
    
    for(int i = 0; i < m; i++){
        if(xe[i] < 0 || ye[i] < 0 || xb[i] == (int)xs.size() || yb[i] == (int)ys.size()){
            cout << 0 <<endl;
            continue;
        }
        int a, b, c;
        if(xb[i] > 0 && yb[i] > 0)
            c = A[ n*(yb[i]-1) + (xb[i]-1) ];
        else
            c = 0;
        if(xb[i] > 0)
            a = A[ n*ye[i] + (xb[i]-1) ];
        else
            a = 0;
        if(yb[i] > 0)
            b = A[ n*(yb[i]-1) + xe[i] ];
        else
            b = 0;
        cout << A[ n*ye[i] + xe[i] ] - a - b + c <<endl;
    }
    
}

Measured memory_bytes: 108428
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, b, z = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());
        if (s == t) z++;
    }
    cout << z;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, k;
    cin >> n >> k;

    int ca = 0;
    vector<int> cnt(n+1, 0);
    REP(i, n) {
        int a; cin >> a;
        if (cnt[a] == 0) ca++;
        cnt[a]++;
    }

    if (ca <= k) print(0);
    else {
        int ans = 0;
        sort(ALL(cnt));
        int num = ca - k;
        for(auto &e: cnt) {
            if (num == 0) break;
            if (e == 0) continue;
            num--;
            ans += e;
        }

        print(ans);
    }
}

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

int main(){
    string S; cin>>S;
    int count=0;
    for(ll i=0;i<S.size();i++){
        if(S[i]=='1') count+=1;
        else if(S[i]=='2') count+=2;
        else if(S[i]=='3') count+=3;
        else if(S[i]=='4') count+=4;
        else if(S[i]=='5') count+=5;
        else if(S[i]=='6') count+=6;
        else if(S[i]=='7') count+=7;
        else if(S[i]=='8') count+=8;
        else if(S[i]=='9') count+=9;
    }
    //cout<<count<<endl;
    if(count%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3752
#include<iostream>

using namespace std;
typedef long long ll;

int main()
{
    ll H, W;
    cin >> H >> W;
    if(H != 1 && W != 1)
    {
        cout << (H * W + 1) / 2 << endl;
    }else
    {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;


int main(){
	int a,b,count,s;

	while(scanf("%d %d",&a,&b)!=EOF){
		count=0;
		s=a+b;
		while(s!=0){
			s/=10;
			count++;
		}
		printf("%d\n",count);
	}

    return 0;
}

Measured memory_bytes: 2704
#include<stdio.h>

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

int main(void){
int a,b;
int c;
int sum=0;
int n,i;
scanf("%d%d%d",&n,&a,&b);
for(i=1; i<n+1; i++){
 c=total(i);
 if(a<=c&&c<=b){
 sum= sum+i;}
}
printf("%d\n",sum);
return 0;
}


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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int d, t, s; cin >> d >> t >> s;
    int dist = t*s;
    if(dist < d){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, L;
    scan(N, L);
    auto ss = new string[](N);
    foreach (i; 0 .. N)
        scan(ss[i]);
    ss.sort();
    writeln(ss.reduce!"a~b");
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  string ans="YES";
  map<int, int> hoge;
  
  rep(i,N) {
    cin >> A[i];
    if(hoge[A[i]] == 1) ans="NO";
    else hoge[A[i]] = 1;
  }
  
  cout << ans << endl;
   
  return 0;
}

Measured memory_bytes: 13552
import itertools as it

N, M = map(int, input().split())
graph = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a].append(b)
    graph[b].append(a)
ans = 0
for path in it.permutations(range(N)):
    if path[0] != 0:
        continue
    is_connected = True
    for ith_edge in range(len(path) - 1):
        if path[ith_edge + 1] not in graph[path[ith_edge]]:
            is_connected = False
            break
    if is_connected:
        ans += 1
print(ans)


Measured memory_bytes: 3064
from collections import deque
n = int(input())
li_h = list(map(int, input().split()))
li_ans = [0]*n
for i in range(n):
  if i == 0:
    continue
  if li_h[(-1)*i] <= li_h[(-1)*(i+1)]:
    li_ans[(-1)*(i+1)] = li_ans[(-1)*i] + 1
  else:
    li_ans[(-1)*(i+1)] = 0
print(max(li_ans))


Measured memory_bytes: 14636
#include <bits/stdc++.h>
using namespace std;
int X;
int num[1010]={};
int pow1(int a,int b){
  int ans=1;
  if(b==0){
    return 1;
  }
  else{
    for(int i=0;i<b;i++){
      ans = a*ans;
      //ans%=1000000007;//これでいい
    }
    return ans;
  }
}
int main(){
  int x=2,y=2;
  num[1]++;
  while(pow1(x,y)<=1000){
    while(pow1(x,y)<=1000){//整数のべき乗　pow関数を使うと浮動小数点による誤差が生じるため、自前のpow関数を用いたほうが良い
      num[pow1(x,y)]++;
      //cout << round(pow(x,y),1) << endl;
      y++;
    }
    //if(pow(x,y)==961) cout << x << " " << y << endl;
    y=2;
    x++;
  }
  //cout << num[960];
  cin >> X;
  while(X>0){
    if(num[X]!=0){
      cout << X << endl;
      return 0;
    }
    X--;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n;
string x;
string s[55];
int a[55];
signed main() {
	cin >> n;
	rep(i, n)cin >> s[i] >> a[i];
	cin >> x;
	int su;
	rep(i, n) {
		if (s[i] == x)su = i;
	}
	int ans = 0;
	for (int i = su + 1; i < n; i++)ans += a[i];
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 505;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, k;
int main() {
	read(k), n = (k + 1) / 2;
	if (k == 1) {
		puts("1");
		puts("1");
		return 0;
	}
	if (n & 1) n += 1;
	cout << n << endl;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++)
			if (i & 1) printf("%d ", (i + j) % n + 1);
			else if ((i + j) % n + 1 + n > k) printf("%d ", (i + j) % n + 1);
			else printf("%d ", (i + j) % n + 1 + n);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
 
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
 
ll func(ll num){
    return (ll)(num * (num - 1)) / 2;
}
 
int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    map<ll, ll> mp;
    rep(i, N) mp[A[i]]++;
    ll sum = 0;
    for(auto p = mp.begin(); p != mp.end(); p++){
        sum += func(p->second);
    }
    for(ll i = 0; i < N; i++){
        ll res = sum;
        ll value = mp[A[i]];
        res -= (value-1);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,p1=0,p2=0;
    string str1,str2;
    
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> str1 >> str2;
        if(str1 > str2)p1 += 3;
        if(str2 > str1)p2 += 3;
        if(str2 == str1){p1 += 1; p2 += 1;}
    }
    cout << p1 << " " << p2 << endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  string S;
  cin>>S;
  int N = S.size();
  int ANS = INF;
  for (int i = 0; i < 26; i++)
  {
    int reqMAX = 0;
    for (int j = 0; j < N; j++)
    {
      int waf = N - j;
      for (int k = j; k < N; k++)
      {
        if(S[k] == i + 'a')
        {
          waf =min(waf,k-j);
        }
      }
      chmax(reqMAX,waf);  
    }
    ANS = min(ANS,reqMAX);

    
  }
  cout<<ANS<<endl;
  
  return;
}




int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [int(input())-1 for _ in range(N)]

ans,i = 0,0
check = [0]*N

while i != 1:
  check[i] += 1
  if check[i] > 1:
    ans = -1
    break
  ans += 1
  i = a[i]

print(ans)

Measured memory_bytes: 7852
import sys
sys.setrecursionlimit(10**9)

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
MOD = 10 ** 9 + 7
count = [0]
dp = [[-1] * W for _ in range(H)]

def dfs(x, y):
  ret = 0
  for nx, ny in ((1,0), (0,1)):
    nx += x
    ny += y
    if nx == W-1 and ny == H-1:
      ret += 1
      continue
    elif nx >= W or ny >= H:
      continue
    elif dp[ny][nx] > -1:
      ret += dp[ny][nx]
      continue
    elif field[ny][nx] == "#":
      continue
    else:
      ret += dfs(nx, ny)
  dp[y][x] = ret % MOD
  return ret

dfs(0,0)
print(dp[0][0])


Measured memory_bytes: 169992
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ans1 = 0;
		for(int i = 0; i < S.length(); i++) {
			if(i % 2 == 0) {
				if(S.substring(i, i + 1).equals("1")) ans1++;
			} else {
				if(S.substring(i, i + 1).equals("0")) ans1++;
			}
		}
		int ans2 = 0;
		for(int i = 0; i < S.length(); i++) {
			if(i % 2 == 0) {
				if(S.substring(i, i + 1).equals("0")) ans2++;
			} else {
				if(S.substring(i, i + 1).equals("1")) ans2++;
			}
		}
		System.out.println(Math.min(ans1, ans2));
	}
}


Measured memory_bytes: 34828
import unittest


def solve(n, a):
    # 貪欲
    cnt = 0
    total = a[0]
    if a[0] < 1:
        cnt = abs(a[0]) + 1
        total = 1
    for i in range(1, n):
        if i % 2 == 0:  # +
            if total + a[i] > 0:
                total += a[i]
            else:
                diff = abs(total + a[i]) + 1
                cnt += abs(diff)
                total = 1
        else:  # -
            if total + a[i] < 0:
                total += a[i]
            else:
                diff = abs(total + a[i]) + 1
                cnt += abs(diff)
                total = -1
    t = cnt
    cnt = 0
    total = a[0]
    if a[0] > -1:
        cnt = abs(a[0]) + 1
        total = -1
    for i in range(1, n):
        if i % 2 == 0:  # -
            if total + a[i] < 0:
                total += a[i]
            else:
                diff = abs(total + a[i]) + 1
                cnt += abs(diff)
                total = -1
        else:  # +
            if total + a[i] > 0:
                total += a[i]
            else:
                diff = abs(total + a[i]) + 1
                cnt += abs(diff)
                total = 1

    return min(t, cnt)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    result = solve(n, a)
    print(result)


if __name__ == "__main__":
    main()


class Test(unittest.TestCase):
    def test_solve_1(self):
        n = 4
        a = [1, -3, 1, 0]
        actual = solve(n, a)
        expected = 4
        self.assertEqual(actual, expected)

    def test_solve_2(self):
        n = 5
        a = [3, -6, 4, -5, 7]
        actual = solve(n, a)
        expected = 0
        self.assertEqual(actual, expected)

    def test_solve_3(self):
        n = 6
        a = [-1, 4, 3, 2, - 5, 4]
        actual = solve(n, a)
        expected = 8
        self.assertEqual(actual, expected)

    def test_solve_4(self):
        n = 6
        a = [-1, 2, -2, 2, -2, 1000]
        actual = solve(n, a)
        expected = 0
        self.assertEqual(actual, expected)


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

int main(){
  char we[10];
  scanf("%s",we);
  char s1[]="Sunny";
  char s2[]="Cloudy";
  char s3[]="Rainy";
    if(strcmp(we,s1)==0)
      printf("%s",s2);
    else if(strcmp(we,s2)==0)
      printf("%s",s3);
    else
      printf("%s",s1);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

vector<bool> prime_table(int n) { // table:= false: not prime, true: prime
    vector<bool> prime(n + 1, true);
    if (n >= 0)
        prime[0] = false;
    if (n >= 1)
        prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i])
            continue;
        for (int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

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

    int N;
    cin >> N;
    vector<bool> table = prime_table(200000);
    FOR(i, N, 200000) {
        if (table[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  long N;
  scanf("%ld",&N);
  int i;
  long a[N];
  for(i = 0; i < N; i++){
    scanf("%ld",&a[i]);
  }
  
  long maxf = 0;
  for(i = 0; i < N; i++){
    maxf += a[i] - 1;
  }
  
  printf("%ld",maxf);
  
  return 0;
  
}
  

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__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((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

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;

int check(char op, int x, int y) {
    switch (op) {
    case '*':
        return min(x, y);
    case '+':
        return max(x, y);
    }
    assert(0);
}

int formula(string& form, int& idx) {
    switch (form[idx]) {
    case '0':
    case '1':
    case '2':
        ++idx;
        return form[idx-1] - '0';
    case '-':
        ++idx;
        return 2 - formula(form, idx);
    case '(':
        ++idx;
        int x = formula(form, idx);
        char op = form[idx];
        ++idx;
        int y = formula(form, idx);
        ++idx;
        return check(op, x, y);
    }
    assert(0);
}

int main() {
    while (1) {
        string line;
        getline(cin, line);
        if (line == ".") {
            break;
        }

        int n = 0;
        REP(p, 3) REP(q, 3) REP(r, 3) {
            string tmp = line;
            REP(i, tmp.length()) {
                switch (tmp[i]) {
                case 'P':
                    tmp[i] = p + '0';
                    break;
                case 'Q':
                    tmp[i] = q + '0';
                    break;
                case 'R':
                    tmp[i] = r + '0';
                    break;
                }
            }
            int idx = 0;
            if (formula(tmp, idx) == 2) {
                n++;
            }
        }
        cout << n << endl;
    }
}

Measured memory_bytes: 1192
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<iostream>
#define ll long long
using namespace std;

const int maxn = 210000;

int n,A,B;
int a[maxn];

bool judge(const ll x)
{
	ll re=0;
	for(int i=1;i<=n;i++)
	{
		ll tmp=(ll)a[i]-x*B;
		if(tmp>0) re+=(ll)(tmp+(ll)A-1ll)/(ll)A;
	}
	return re<=x;
}

int main()
{
	scanf("%d%d%d",&n,&A,&B); A-=B;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	ll l=1,r=1000000000ll;
	while(l<=r)
	{
		ll mid=(l+r)/2ll;
		if(judge(mid)) r=mid-1ll;
		else l=mid+1ll;
	}
	printf("%lld\n",r+1ll);
	
	return 0;
}


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

int main()
{
    int n;
    cin >> n ;
    ll power = 1 ;
    for(int i = 1 ; i <= n ; i++)
    {
        power *= i;
        power %= 1000000007;
    }
    cout << power << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
int main()
{
    lint a,b,c,d;
    cin >> a>> b>> c>> d;
    lint l = b - a + 1;
    lint s = c*d/__gcd(c,d);
    lint q = (a-1)/c + (a-1)/d - (a-1)/(s);
    lint w = b/c + b/d - b/(s);
    //cout << l << " " << q << " " << w << endl;
    cout << l - (w - q) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		Set<String> strSet = new HashSet<>();

		IntStream.range(0, n).forEach(i -> strSet.add(stdIn.next()));

		stdIn.close();

		System.out.println(strSet.size());
	}
}


Measured memory_bytes: 76896
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

vector<string> v;

void gen(ll lasts) {
    if(v.size() > 100000) return;
    int end = v.size();
    ll cnt = 0;
    for(ll i = v.size()-lasts; i < end; i++) {
        if(v.size() > 100000) return;
        if(v[i].back() != '0') {
            v.PB(v[i] + (char)(v[i].back()-1));
            cnt++;
        }
        v.PB(v[i] + v[i].back());
        cnt++;
        if(v[i].back() != '9') {
            v.PB(v[i] + (char)(v[i].back()+1));
            cnt++;
        }
    }
    gen(cnt);
}

int main() {
    ios_base::sync_with_stdio(false);
    for(int i = 1; i <= 9; i++) {
        string s = "";
        s += '0' + i;
        v.PB(s);
    }
    gen(9);
    int k;
    cin >> k;
    cout << v[k-1] << endl;
}


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

int main () {
    string s;
    int i, joi, ioi;
while(cin >> s, !cin.eof()) {
    joi = 0;
    ioi = 0;
    for(i=0;i<s.size()-2;i++) {
        if(s[i]=='J') {
            if(s[i+1]=='O') {
                if(s[i+2]=='I') {
                    joi++;
                    i += 1;
                }
            }
        }
           if(s[i]=='I') {
            if(s[i+1]=='O') {
                if(s[i+2]=='I') {
                    ioi++;
                    i += 1;
                }
            }
        }
    }      
cout << joi << endl;
cout <<ioi << endl;
}
}

Measured memory_bytes: 1192
// file creato da gio il 2020-06-24 19:30:16.615349

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define MOD 1000000007
#define S second
#define F first
#define PB push_back
using namespace std;
#define MAXN 100001

int arr[100001];

int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	int n;
    long sum=0;
	cin >> n;
    for(int i=0;i<n;i++){
        int tmp;
        cin >>tmp;
        arr[tmp]++;
        sum+=tmp;
    }
    int q;
    cin >> q;
    for(int i=0;i<q;++i){
        int a,b;
        cin >>a>>b;
        sum-=(long)arr[a]*a;
        sum+=(long)arr[a]*b;
        arr[b]+=arr[a];
        arr[a]=0;
        cout <<sum<<endl;
    }

}


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

int main()
{
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  sort(a.rbegin(),a.rend());
  cout << a.at(0) - a.at(N-1) << endl; 
}

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

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define digits(x) floor(log10(x) + 1)
#define countbits(x) ((int)log2(x)+1)
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define deb(x) cout << #x << "=" << x << endl;
#define test unsigned int tet;cin >> tet;while(tet--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

signed main(void)
{
    	fastio
    	int x,y;
        cin >> x >> y;

        for(int a=0; a<=x; a++){
            if(4*x-2*a == y){
                cout << "Yes\n";
                return 0;
            }
        }
        cout << "No\n";

    	return 0;
}



Measured memory_bytes: 3644
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int X = int.Parse(input[1]);
            int[] L = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            // 1回目の跳ねを考慮して初期化
            int D, count;
            D = 0;
            count = 1;
            for (int i = 0; i < N; i++)
            {
                D += L[i];
                if (D > X) break;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

int main(){	
	ll A, B, M;
	cin >> A >> B >> M;
	vector<ll> a(A), b(B), x(M), y(M), c(M);
	rep(i, A) cin >> a[i];
	rep(i, B) cin >> b[i];
	rep(i, M) cin >> x[i] >> y[i] >> c[i];
	ll res = INF;
	rep(i, M) {
		res = min(res, a[x[i]-1]+b[y[i]-1]-c[i]);
	}
	ll am = INF, bm = INF;
	rep(i, A) {
		am = min(am, a[i]);
	}
	rep(i, B) {
		bm = min(bm, b[i]);
	}
	res = min(res, am+bm);
	cout << res << endl;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
vector<long long> vertexs[3000];
int dfs(int now, int back, int fukasa) {
	int ans = 0;
	fukasa--;
	if (fukasa < 0) ans++;
	for (int i = 0;i < vertexs[now].size();++i) {
		if (vertexs[now][i] != back) {
			ans += dfs(vertexs[now][i], now, fukasa);
		}
	}
	return ans;
}
int main() {
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> wow;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		wow.push_back(make_pair(a - 1, b - 1));
		vertexs[a - 1].push_back(b - 1);
		vertexs[b - 1].push_back(a - 1);
	}
	int geko = 3000;
	for (int q = 0;q < n;++q) {
		geko = min(geko, dfs(q, -1, (k + 2) / 2));
	}
	for (int q = 0;q < wow.size();++q) {
		geko = min(geko, dfs(wow[q].first, wow[q].second, (k+1) / 2) + dfs(wow[q].second, wow[q].first, (k+1) / 2));
	}
	cout << geko << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] nmArr = sc.nextLine().split(" ");
		String[] priceStrArr = sc.nextLine().split(" ");
		sc.close();
		
		int n = Integer.parseInt(nmArr[0]);
		int m = Integer.parseInt(nmArr[1]);
		
		
		PriorityQueue<Integer> prioqueue = new PriorityQueue<>(Comparator.reverseOrder());
		for(int i = 0; i < n; i++) {
			prioqueue.add(new Integer(priceStrArr[i]));
		}
		
		for(int i = 0; i < m; i++) {
			Integer maxPrice = prioqueue.poll();
			prioqueue.add(maxPrice/2);
		}
		
		long sumprice = 0;
		
		for(int i = 0; i < n; i++) {
			sumprice = sumprice + prioqueue.poll();
		}
		System.out.println(sumprice);
		
	}
	
	public static int getMaxIndex(int[] intArr,int start, int end) {
		int maxPriceIndex = start;
		for(int i = start; i <= end; i++) {
			if(intArr[maxPriceIndex] < intArr[i]) {
				maxPriceIndex = i;
			}
		}
		return maxPriceIndex;
	}

}


Measured memory_bytes: 54940
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N;
VL A, B;

int main(void) {
    scanf("%d", &N);
    A.resize(N);
    B.resize(N);
    REP(i, N) scanf("%lld%lld", &A[i], &B[i]);
    LL ans = 0;
    RREP(i, N) {
        if ((A[i] + ans) % B[i] == 0) continue;
        LL buf = (A[i] + ans) % B[i];
        ans += B[i] - buf;
        //DEBUG(ans)
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
const int limit = 100010;
using edge = struct {
    int to;
    ll cost;
};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
    depth[v] = d;
    for (auto &e : tree[v]) {
        if (e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

int main(void) {
    int N;
    cin >> N;
    for (int i = 0; i < N - 1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int Q, K;
    cin >> Q >> K;
    K--;

    dfs(K, -1, 0);
    for (int i = 0; i < Q; ++i) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << depth[x] + depth[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 14336
// Harshad Number

#include <iostream>

using namespace std;

int sumDigits(int n){
	if (n / 10 == 0)
		return n;
	return sumDigits(n/10) + n%10;
}

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

	int sd = sumDigits(N);

	if (N % sd)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

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

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <set>
#include <utility>

namespace null_null {

void main_() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<std::pair<i64, i64>> v(N);
  for (usize i = 0; i < static_cast<usize>(N); i++) std::cin >> v[i].second >> v[i].first;
  std::sort(v.begin(), v.end());
  std::reverse(v.begin(), v.end());

  std::set<i64> s;
  for (i64 i = -M + 1; i <= 0; i++) s.insert(i);
  s.insert(1e9);
  i64 ans = 0;

  for (auto x : v) {
    i64 day = *(s.lower_bound(x.second - M));
    if (day == 1e9) {
      continue;
    } else {
      s.erase(day);
      ans += x.first;
    }
  }

  std::cout << ans << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<pair<int, int> > v;
    for(int i=0;i<n;++i){
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    long int sum=0;
    int j=0,x=0;
    for(int i=1;i<=m;++i){
        sum += v[j].first;
        if(i==v[j].second+x){
            x += v[j].second;
            ++j;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
vector<int> d;
vector<vector<int>> A;
    
int main () {
  int N;
  cin >> N ;
  string s ;
  s = to_string(N);
  reverse(s.begin(), s.end());
  if (s.at(0) == '2' || s.at(0) == '4' || s.at(0) == '5' || s.at(0) == '7' 
      || s.at(0) == '9'){
    cout << "hon" << endl;}
  else if (s.at(0) == '3') {
    cout << "bon" << endl;}
  else {
    cout << "pon" << endl;}
  
return 0;
}

Measured memory_bytes: 3656
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int h = in.nextInt();
		int w = in.nextInt();
		String[] map = new String[h];
		
		for (int i = 0; i < h; i++) {
			map[i] = in.next();
		}
		
		for (int i = 0; i < h; i++) {
			System.out.println(map[i]);
			System.out.println(map[i]);
		}
	}
}

Measured memory_bytes: 22996
#include <stdio.h>
void aaa(int, int, int, int);
int a0[10][3]={{0}} ,a1[10][3]={{0}}, a2[10][3]={{0}}, a3[10][3]={{0}};

void aaa(int b, int f, int r, int v)
{
	if (b==1)
	{
		a0[r-1][f-1]=a0[r-1][f-1]+v;
		
	}
	else if (b==2)
	{
		a1[r-1][f-1]=a1[r-1][f-1]+v;
	}
	else if (b==3)
	{
		a2[r-1][f-1]=a2[r-1][f-1]+v;
	}
	else if (b==4)
	{
		a3[r-1][f-1]=a3[r-1][f-1]+v;
	}
	return ;
}

int main(void)
{
	int i, y, n, b, f, r, v;

	scanf("%d", &n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d%d", &b, &f, &r, &v);
		aaa(b, f, r, v);
	}

	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a0[y][i]);
		}
		printf("\n");
	}
	printf("####################\n");
	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a1[y][i]);
		}
		printf("\n");
	}
	printf("####################\n");
	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a2[y][i]);
		}
		printf("\n");
	}
	printf("####################\n");
	for (i=0;i<3;i++)
	{
		for (y=0;y<10;y++)
		{
			printf(" %d", a3[y][i]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2752
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
    long long int q,l;
    cin>>q;
    if(q<1200){
        cout<<"ABC"<<endl;
    }
    else{
        cout<<"ARC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3580
import numpy as np
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(gcd(x))

Measured memory_bytes: 24992
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

int main() {
  vi a(3);
  rep(i,3){
    cin >> a.at(i);
  }
  sort(ALL(a));
  int b,ans=0;
  cin >> b;
  rep(i,b){
    a.at(2)*=2;
  }
  cout << a.at(0)+a.at(1)+a.at(2);
}

Measured memory_bytes: 3600
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int no1 = -1;
		int index = 0;
		int no2 = -1;
		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if(x >= no1) {
				no2 = no1;
				no1 = x;
				index = i;
			}
			else if(x > no2) {
				no2 = x;
			}
		}
		for(int i = 0; i < n; i++) {
			System.out.println((i != index)?no1:no2);
		}
	}
}

Measured memory_bytes: 82104
//============================================================================
// Name        : dpl_1c.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
	int n, W, v[100], w[100], dp[10001];
	cin >> n >> W;
	for(int i = 0;i < n;i++){
		cin >> v[i] >> w[i];
	}
	fill(dp,dp + 10001,-1);
	dp[0] = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= W;j++){
			if(j - w[i] >= 0 && dp[j - w[i]] != -1 && (dp[j] == -1 || dp[j] < dp[j - w[i]] + v[i])){
				dp[j] = dp[j - w[i]] + v[i];
			}
		}
	}
	int ans = 0;
	for(int i = 0;i <= W;i++){
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
char s[15];
int main(){
  scanf("%s",s + 1);
  int n = strlen(s + 1);
  s[n + 1] = '#';
  int lst = 0,ans = 0;
  for(int i = 1;i <= n + 1;i++){
    if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' &&s[i] != 'T'){
      ans = max(ans,i - lst - 1);
      lst = i;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<climits>
#include<algorithm>
using namespace std;
typedef int Cost;
typedef int Node;

void dijkstra(int start,   vector<vector< pair<Node,Cost> > > m){
  vector<Cost> costs(m.size());
  bool visited[m.size()];

  fill(costs.begin(),costs.end(),INT_MAX);
  fill(visited,visited+m.size(),false);
  
  priority_queue<pair<Cost,Node> ,vector<pair<Cost,Node> >, greater<pair<Cost,Node> > > q;
  q.push(make_pair(0,start));
  while(!q.empty()){
    Cost c = q.top().first;
    Node n = q.top().second;
    q.pop();
    if(!visited[n]){
      costs[n] = c;
      for(auto &x:m[n]){
        int node = x.first;
        int cost = x.second;
        q.push(make_pair(cost+c,node));
      }
      visited[n] = true;
    }
  }
  for(int i = 0;i < costs.size();i++){
    cout << i << ' ' << costs[i] << endl;
  }
}

int main(){
  int n;
  cin >> n;
  vector<vector< pair<Node,Cost> > > m(n);
  
  for(int i = 0;i < n;i++){
    int u,k;
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      int v,c;
      cin >> v >> c;
      m[u].push_back(make_pair(v,c));
    }
  }
  dijkstra(0,m);
}

Measured memory_bytes: 15160
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i);
  }

  double ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      double a = (x.at(i) - x.at(j)) * (x.at(i) - x.at(j));
      double b = (y.at(i) - y.at(j)) * (y.at(i) - y.at(j));
      double c = sqrt(a + b);
      ans += c;
    }
  }
  cout << fixed << setprecision(10) << ans / n << endl;

} 

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
  if ( n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 /180.0;

  s.x = (2.0 * a.x +1.0 * b.x)/ 3.0;
  s.y = (2.0 * a.y +1.0 * b.y)/ 3.0;
  t.x = (1.0 * a.x +2.0 * b.x)/ 3.0;
  t.y = (1.0 * a.y +2.0 * b.y)/ 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;  
  
  koch( n-1 ,a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch( n-1 ,s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch( n-1 ,u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch( n-1 ,t, b);
  }
  

int main(){
  Point a,b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch( n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;

}

Measured memory_bytes: 2736
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt();
		int a[]=new int[n];
		int z=0,y=0,x=1,i=n/2-1;
		if(n%2==1)
			i++;
		while(z<n){
			if(z%2==0){
				a[i-y]=stdIn.nextInt();
				y++;
			}
			else{
				a[i+x]=stdIn.nextInt();
				x++;
			}
			z++;
		}z--;
		if(n%2==1){
			z=0;
			while(z<n){
				System.out.print(a[z]+" ");
				z++;
			}
		}
		else
			while(z>=0){
				System.out.print(a[z]+" ");
				z--;
			}
	}
}

Measured memory_bytes: 92620