akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <utility>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, as[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // solve greedy
  set<pair<int, int>> ps;
  ps.insert(make_pair(as[0], 0));
  for (int i = 1; i < N; i++) {
    // for (pair<int, int> p : ps) {
    //   printf("(%d, %d) ", p.first, p.second);
    // }
    // printf("\n");
    // printf("%d\n", (--ps.end())->first);
    // get maximum less than a
    const int a = as[i];
    auto it = ps.lower_bound(make_pair(a, 0));
    if (it != ps.begin()) {
      --it;
      if (it->first < a) {
        // use same color
        ps.erase(it);
      }
    }
    ps.insert(make_pair(a, i));
  }
  // for (pair<int, int> p : ps) {
  //   printf("(%d, %d) ", p.first, p.second);
  // }
  // printf("\n");
  // printf("%d\n", (--ps.end())->first);
  printf("%d\n", (int)ps.size());

  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int N,A;
	cin>>N>>A;
	
	vector<int> x(N);
	for(int i=0;i<N;i++){
		cin>>x[i];
	}
	
	vector<vector<vector<long long>>> dp(N+1,vector<vector<long long>>(N+1,vector<long long>(A*N+1,0)));//dp[i][j][k] i枚目まででj枚使ってちょうどk
	
	dp[0][0][0] = 1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=A*N;k++){
				dp[i+1][j][k] += dp[i][j][k];
				if(j==N)continue;
				int a = k+x[i];
				if(a>A*N)continue;
				dp[i+1][j+1][a] += dp[i][j][k];
			}
		}
	}
	
	long long ans = 0;
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<=A*N;j++){
			if(j==0)continue;
			if(i*A==j)ans += dp[N][i][j];
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 52224
#!/usr/bin/env python3
def main():
    N = int(input())
    H = [int(x) for x in input().split()]

    INF = 10 ** 5 * 10 ** 4
    dp = [INF] * N
    dp[0] = 0
    dp[1] = abs(H[0] - H[1])
    for i in range(2, N):
        dp[i] = min(dp[i],
                    dp[i - 1] + abs(H[i] - H[i - 1]),
                    dp[i - 2] + abs(H[i] - H[i - 2]))
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 20504
#include<bits/stdc++.h>
using namespace std;
const int N=2000005;
struct qwq{
	int a,b;
	inline qwq(){}
	inline qwq(int a,int b):a(a),b(b){}
}s[N],t[N];
int a[N];
char c[N>>1];
int main(){
	int ss=0,ts=0,n,y,z,m,k,i,j,p;
	scanf("%d%d%d%s",&n,&m,&k,c+1);--k;
	for(i=1,j=n;j;++i,--j)if(c[j]=='1')a[i] =1;
	scanf("%s",c+1);
	for(i=1,j=m;j;++i,--j)if(c[j]=='1')a[i]|=2;
//	printf("n=%d k=%d\n",n,k);
//	for(i=1;i<=max(n,m);++i)printf("%d ",a[i]);printf("A\n");
	s[0].b=1000000000;
	for(i=n=max(n,m);i;--i)if(a[i]){
		if(a[i]==3){
//			printf("SOLVE i=%d\n",i);
			m=i;y=3;z=k;
			while(1){
//				printf("y=%d z=%d m=%d ss=%d cur=(%d,%d)\n",y,z,m+1,ss,s[ss].a,s[ss].b);
				if((++m)!=s[ss].b){
					if(y==3){
//						printf("zeros z=%d p=%d\n",z,s[ss].b-m);
						if(z>=(p=s[ss].b-m)){z-=p;m=s[ss].b;}
						else{s[++ss]=qwq(3,m+z);break;}
					}else{
						s[++ss]=qwq(y,m);
						break;
					}
				}
//				printf("nonzero z=%d\n",z);
				if(y==3){
					t[++ts]=qwq((y=s[ss--].a)^3,m);
				}else if(y==s[ss].a){
					--ss;
				}else{
					if(z--){--ss;y=3;}
					else{s[ss].a=3;break;}
				}
			}
			while(ts)s[++ss]=t[ts--];
		}else s[++ss]=qwq(a[i],i);
//		printf("DBG i=%d\n",i);
//		for(j=ss;j;--j)printf("(%d,%d)\n",s[j].a,s[j].b);
	}
	n+=k+1;
	memset(a,0,sizeof(a));
	for(;ss;--ss)a[s[ss].b]=s[ss].a;
//	for(i=1;i<=n;++i)printf("%d ",a[i]);printf("ANS\n");
	for(i=n;i;--i)if(a[i]&1)break;for(;i;--i)putchar((a[i]   &1)|48);puts("");
	for(i=n;i;--i)if(a[i]&2)break;for(;i;--i)putchar((a[i]>>1&1)|48);puts("");
	return 0;
}

Measured memory_bytes: 22528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,p,n) for(int i=p;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

const int MOD = 1000000007;

int main() {

int N; cin >> N ;

N%=10;

if(N==2||N==4||N==5||N==7||N==9) cout << "hon" << endl;

else if(N==0||N==1||N==6||N==8) cout << "pon" << endl;

else cout << "bon" << endl;

  return 0;
}

Measured memory_bytes: 3624
A, B, K = gets.split.map(&:to_i)

a = A
b = B

K.times do |i|
  if i.even?
    a -= 1 if a.odd?
    t = a / 2
    a -= t
    b += t
  else
    b -= 1 if b.odd?
    t = b / 2
    b -= t
    a += t
  end
end

puts [a, b].join(' ')


Measured memory_bytes: 1788
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(a);
    cins(s);
    if(!(a<3200))
        cout<<s<<endl;
    else
        cout<<"red"<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int descending_order(int *x, int *order, int size){
  int i,j;
  for(i=0;i<size;i++){
    order[i] = 0;
  }

  int rank;
  for(i=0;i<size;i++){
    for(j=0;j<size;j++){
      if(i==j)continue;
      if(x[i] > x[j]){
        order[i]+=1;
      }else if(x[i] == x[j] && i > j){
        order[i]+=1;
      }
    }
  }
  return 0;
}

int sort(int *x, int size){
  int i,j,tmp;
  for(i=0;i<size;i++){
    for(j=i;j<size;j++){
      if(x[i]>x[j]){
        tmp = x[i];
        x[i] = x[j];
        x[j] = tmp;
      }
    }
  }
}

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
  if (x < y)
    if (y < z) return y; else if (z < x) return x; else return z; else
    if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right)
/* クイックソート
 * a     : ソートする配列
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 */
{
  if (left < right) {
    int i = left, j = right;
    value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
    while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
      while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
      while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
      if (i >= j) break;
      tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
      i++; j--;
    }
    quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
    quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
  }
}

int print_array(int *a, int size){
  int i;
  for(i=0;i<size;i++){
    printf("%d ", a[i]);
  }
  puts("");
  return 0;
}

int main(int argc, char *argv[])
{
  int n, m;
  scanf("%d %d", &n, &m);
  int *x, i,j;
  x = (int*)malloc(sizeof(int) * m);
  for(i=0;i<m;i++){
    scanf("%d", x+i);
  }

  if(n >= m){
    printf("0\n");
    return 0;
  }

  /* print_array(x, m); */
  quicksort(x, 0, m-1);
  /* print_array(x, m); */

  int *sub;
  sub = (int*)malloc(sizeof(int)*(m-1));
  for(i=0;i<m-1;i++){
    sub[i] = x[i+1]-x[i];
  }
  /* print_array(sub, m-1); */
  quicksort(sub, 0, m-2);
  /* print_array(sub, m-1); */

  int s=0;
  for(i=0;i<m-n;i++){
    s+=sub[i];
  }
  printf("%d\n", s);
  free(x);
  free(sub);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)


int main(){

    ll N,M,K;
    cin>>N>>M>>K;
    vector<ll> A(N);
    vector<ll> B(M);


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

    for(ll i=0;i<M;i++){
        cin>>B[i];
    }

    vector<ll> arui(N+1);
    vector<ll> brui(M+1);

    for(ll i=0;i<N;i++){
        arui[i+1]=arui[i]+A[i];
    }

    for(ll i=0;i<M;i++){
        brui[i+1]=brui[i]+B[i];
    }

    ll ans=0;
    ll am=0;
    ll bm=0;
    for(ll i=N;i>=0;i--){
        if(arui[i]<=K){
            am = i;
            break;
        }
    }

    for(ll i=M;i>=0;i--){
        if(brui[i]<=K){
            bm = i;
            break;
        }
    }

    ans = max(am,bm);
    ll now=0;
    for(ll i=am;i>=0;i--){
        for(ll j=now;j<=bm;j++){
            if(arui[i]+brui[j]<=K){
                now = j;
                if(ans<i+j){
                    ans=j+i;
                }
            }
            else{
                break;
            }
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 9604
N, M = map(int, input().split())
answer = 0
if N == 1 and M == 1:
    answer = 1
elif N == 1 and M != 1:
    answer = max(0, M-2)
elif N != 1 and M == 1:
    answer = max(0, N-2)
elif M >= 2 and N >= 2:
    answer = (M-2) * (N-2)

print(answer)
    

Measured memory_bytes: 2940
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll h, w;
char a[8][8];
bool seen[8][8];

bool dfs(int i, int j) {
    seen[i][j] = true;
    if (i - 1 >= 0 && a[i - 1][j] == '#' && !seen[i - 1][j]) return false;
    if (j - 1 >= 0 && a[i][j - 1] == '#' && !seen[i][j - 1]) return false;
    if (i == h - 1 && j == w - 1) return true;

    if (i + 1 <= h - 1 && a[i + 1][j] == '#' && j + 1 <= w - 1 && a[i][j + 1] == '#')
        return false;
    if (i + 1 <= h - 1 && a[i + 1][j] == '#') if (dfs(i + 1, j)) return true;
    if (j + 1 <= w - 1 && a[i][j + 1] == '#') if (dfs(i, j + 1)) return true;
    return false;
}

void solve() {
    fill(seen[0], seen[8], false);
    if (a[0][0] == '#' && dfs(0, 0)) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

int main() {
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> a[i][j];
    solve();
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

input=stdin.readline

def isPrime(x):
  for div in range(2, x // 2 + 1):
    if x % div == 0:
      return False

  return True

X = int(input())

if isPrime(X):
   print(X)
   exit()

while (X < 10 ** 5):
  X+=1
  if isPrime(X):
    print(X)
    exit()

#100000より大きい素数のうち最小のもの
print(100003)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>


using namespace std;

int main(void) {

	int n, m, X, Y;

	cin >> n >> m >> X >> Y;

	vector<int> x(n);
	vector<int> y(m);

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		x[i] = tmp;
	}
	for (int i = 0; i < m; i++) {
		int tmp;
		cin >> tmp;
		y[i] = tmp;
	}

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	
	int Z = max(x.back(), X)+1;
	
	if (X >= y.front() || Y <= x.back()) {
		cout << "War";
	}
	else if (y.back() < Z) {
		cout << "War";
	}
	else if (x.back() >= y.front()) {
		cout << "War";
	}
	else {
		cout << "No War";
	}

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int cnt = 0;
  int mx = -1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a >= mx) ++cnt;
    mx = max(mx, a);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
s = str(input())
n = len(s)
res = 0
for i in range(2**(n-1)):
    bit = bin(i)[2:].zfill(n-1)
    index = []
    for j in range(n-1):
        if bit[j]=='1':
            index.append(j+1)
    if len(index)>0:
        div = []
        for k in range(len(index)):
            if k==0:
                div.append(int(s[:index[k]]))
            else:
                div.append(int(s[index[k-1]:index[k]]))
        div.append(int(s[index[-1]:]))
        res += sum(div)
    else:
        res += int(s)
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,b;
int main()
{
	cin>>n;
	for(i=1;i<=10;i++) 
	if(pow(2,i)>n) {
	cout<<pow(2,i-1)<<"\n";return 0;}
	 else if(pow(2,i)==n) {
	 cout<<pow(2,i)<<"\n";return 0; } 
	 return 0; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define mp make_pair
#define pb push_back
#define f first
//#define s second
#define mod 1000000007
const ll N=2e5+5;
unordered_map<ll,vector<ll>> adj;
vector<ll> vis(300005,0);
vector<ll> p(100005,0);
ll c[100005];
ll cnt;
ll n;
void dfs(ll node)
{
  if(vis[node])
    return;
  vis[node]=1;
  cnt++;
  for(auto i:adj[node])
    {
      dfs(i);
    }
}
struct range{
  ll l;
  ll r;
  ll index;
};
bool cmp(range& p1,range& p2)
{
     return p1.l<p2.l;
}


int main()
{
   ll n;
   cin>>n;
   ll i,j;
   ll temp;
   ll cnt=0;
   for(i=1;i<=sqrt(n-1);i++)
   {
      for(j=i;j*i<n;j++)
        cnt++;
   }
    cnt*=2;
    cnt-=int(sqrt(n-1));
   cout<<cnt;
}

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

import sys

dic = {'A':True, 'B':False, 'C':False}
for line in sys.stdin:
    c1, c2 = map(str, line.split(','))
    c2 = c2[0]
    dic[c1], dic[c2] = dic[c2], dic[c1]
for hoge in dic:
    if dic[hoge]:
        print hoge
        break

Measured memory_bytes: 6436
a, b, c, x, y = gets.split(" ").map(&:to_i)
price = 0

if (a+b)/2 >= c
	if x >= y
		price += y*c*2 
		if a >= c*2
			price += (x-y)*c*2
		else
			price += (x-y)*a
		end
	else
		price += x*c*2
		if b >= c*2
			price += (y-x)*c*2
		else
			price += (y-x)*b
		end
	end
else
	price = x*a + y*b
end

puts price


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;


int arr[100];
int main() {
	int N;
	scanf("%d", &N);
	double sum=0.0;
		
	for (int i = 0; i<N; ++i) {
		scanf("%d", &arr[i]);
		sum += (double)arr[i];
	}
	double ave = sum / (double) N;


	double diff = 12345.0;
	int idx = 0;
	for (int i = 0; i < N; ++i) {
		double temp= abs(ave - arr[i]);
		if (temp < diff) {
			idx = i;
			diff = temp;
		}
		if (diff == 0.0) {
			break;
		}
	}

	printf("%d\n", idx);


	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	// Code for B - Minesweeper
	var H, W int
	fmt.Scanf("%d %d", &H, &W)

	S := make([]string, H+2)
	var temp string
	S[0] = strings.Repeat(string('.'), W+2)
	for i := 1; i <= H; i++ {
		fmt.Scanf("%s", &temp)
		S[i] = string('.') + temp + string('.')
	}
	S[H+1] = strings.Repeat(string('.'), W+2)

	var count int
	for i := 1; i <= H; i++ {
		for j := 1; j <= W; j++ {
			if S[i][j] == '.' {
				count = 0
				for l := -1; l <= 1; l++ {
					for m := -1; m <= 1; m++ {
						if S[i+l][j+m] == '#' {
							count++
						}
					}
				}
				fmt.Printf("%d", count)
			} else {
				fmt.Printf("#")
			}
		}
		fmt.Printf("\n")
	}
}


Measured memory_bytes: 1900
# coding: utf-8

x = int(input())

item_number = x // 100
target = x % 100

for i0 in range(item_number + 1):
    for i1 in range(item_number + 1 - i0):
        for i2 in range(item_number + 1 - i0 - i1):
            for i3 in range(item_number + 1 - i0 - i1 - i2):
                for i4 in range(item_number + 1 - i0 - i1 - i2 - i3):
                    for i5 in range(item_number + 1 - i0 - i1 - i2 - i3 - i4):
                        if i1 + (i2 * 2) + (i3 * 3) + (i4 * 4) + (i5 * 5) == target:
                            print(1)
                            exit()
print(0)


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

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using usize = std::size_t;
using namespace std;

#define rep(i, max) for(i32 i = 0; i < (i32)max; ++i)
#define loop while(true)
#define allOf(collection) collection.begin(), collection.end()

unique_ptr<string> readLine() { unique_ptr<string> line(new string()); getline(cin, *line); return line; }
template<typename T1, typename T2> pair<T1, T2> readPair() { T1 res1; cin >> res1; T2 res2; cin >> res2; readLine(); return make_pair(res1, res2);}
template<typename T> unique_ptr<vector<T>> readVector(usize num, bool isForIndex = false) { unique_ptr<vector<T>> list(new vector<T>(num)); rep(i, num) { cin >> (*list)[i]; if(isForIndex) --(*list)[i]; } readLine(); return list; }
void readValues() { readLine(); }
template<typename H, typename... T> void readValues(H& head, T&&... tails){ H a; cin >> a; head = a; readValues(forward<T>(tails)...); }
void writeLine() { cout << endl; }
template<typename T> void write(const T& arg) { cout << arg; }
template<typename T> void writeLine(const vector<T>& arg){ if(arg.empty()) { writeLine(); return; } write(arg[0]); for(int i = 1; i < arg.size(); ++i){ write(" "); write(arg[i]); } writeLine(); }
template<typename T> void writeLine(const T& arg) { cout << arg << endl; }
void recursiveCombination(vector<i32>& indexes, i32 s, i32 rest, function<void(vector<i32>&)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursiveCombination(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursiveCombination(indexes, s - 1, rest - 1, f); } }
void foreachWithCombination(i32 n, i32 k, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(k); recursiveCombination(indexes, n - 1, k, f); }
void foreachWithPermutaton(i32 n, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(); indexes.reserve(n); rep(i, (usize)n) indexes.push_back(i); do f(indexes); while (next_permutation(allOf(indexes))); }
void foreachWithPermutaton(i32 n, i32 k, function<void(vector<i32>&)> f){ foreachWithCombination(n, k, [=](vector<i32>& combIndexes){ foreachWithPermutaton(k, [=](vector<i32>& permIndexes){ auto indexes = vector<i32>(); indexes.reserve(k); rep(i, (usize)k){ indexes.push_back(combIndexes[permIndexes[i]]); } f(indexes); }); }); }
void program();
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    program();
}

constexpr i64 mod = 1'000'000'007;

void program() {
    i32 n;
    readValues(n);

    if(n == 1) {
        writeLine(0);
        return;
    }

    i64 res1 = 1;
    i64 res2 = 1;
    i64 res3 = 1;

    rep(i, n) {
        res1 *= 10;
        res1 %= mod;
        res2 *= 9;
        res2 %= mod;
        res3 *= 8;
        res3 %= mod;
    }

    i64 res = res1 - 2 * res2 + res3;
    while(res < 0) res += mod;
    writeLine(res % mod);
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define swap(type,x,y) do{type t=x;x=y;y=t;}while(0)

using namespace std;

int main() {
	int n, m, i, j, k, s;
	int *x;

	cin >> n >> m;

	x = new int[n];

	for (i = 0; i < n; i++)
		x[i] = 0;

	for (i = 0; i < m; i++) {
		cin >> j >> k;
		if (j == 1)
			x[k - 1]++;
		else if (k == n)
			x[j - 1]++;
	}
	for (i = 0; i < n; i++) {
		if (x[i] == 2) {
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll n;
	cin>>n;
	vector<pair<ll,ll>>ch;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ch.push_back(make_pair(y,x));
	}
	sort(ch.begin(),ch.end());
	ll cnt=0;
	bool ans=true;
	for(ll i=0;i<n;i++){
		cnt+=ch[i].second;
		if(cnt>ch[i].first){
			ans=false;
		}
	}
	cout << (ans?"Yes":"No");
	// your code goes here
	return 0;
}

Measured memory_bytes: 6384
#include<iostream>
#include<string.h>
using namespace std;

void function(char *s,char *t)
{
    strcat(t,s);
    cout<<t<<endl;
}

int main()
{
    char s[500];
    char t[500];
    cin>>s;
    cin>>t;
    function(s,t);
    return 0;
}


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

int main() {
  
  int n,x,t;
  cin >> n >> x >> t;
  
  int time = 0;
  int tako = 0;
  
  while (tako < n) {
    tako += x;
    time += t;
  }
  
  cout << time << endl;

return 0;
}

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  
  vector<vector<int>> rect(H, vector<int>(W, 1));
  for (int i = 0; i < N; i++) {
    if (a.at(i) == 1) {
      for (int j = 0; j < H; j++) {
        for (int k = 0; k < x.at(i); k++) {
          rect.at(j).at(k) = 0;
        }
      }
    } else if (a.at(i) == 2) {
      for (int j = 0; j < H; j++) {
        for (int k = x.at(i); k < W; k++) {
          rect.at(j).at(k) = 0;
        }
      }
    } else if (a.at(i) == 3) {
      for (int j = 0; j < y.at(i); j++) {
        for (int k = 0; k < W; k++) {
          rect.at(j).at(k) = 0;
        }
      }
    } else if (a.at(i) == 4) {
      for (int j = y.at(i); j < H; j++) {
        for (int k = 0; k < W; k++) {
          rect.at(j).at(k) = 0;
        }
      }
    }
  }
  int area = 0;
  for (int j = 0; j < H; j++) {
    for (int k = 0; k < W; k++) {
      area += rect.at(j).at(k);
    }
  }
    
  cout << area << endl;
}


Measured memory_bytes: 3676
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

int n,k;
string a[11];
char t[5];
set<string> ss;
string s;

int main()
{
	while(scanf(" %d%d",&n,&k),n|k){
		ss.clear();
		for(int i = 0; i < n; ++i){
			scanf(" %s ",t);
			a[i] = t;
		}
		sort(a,a+n);
		do{
			s.clear();
			for (int i = 0; i < k; ++i){
				s += a[i];
			}
			ss.insert(s);
		}while(next_permutation(a,a+n));
		printf("%d\n",(int)ss.size());
	}
}

Measured memory_bytes: 1332
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    m = 10**9+7
    if n == 1:
        print(0)
    elif n == 2:
        print(2)
    else:
        print((10**n - 2*9**n + 8**n)%m)


if __name__=="__main__":
    main()


Measured memory_bytes: 11216
#include<iostream>
using namespace std;
int main()
{
    int n,i,j,num[200000],number=1,minnum;
    cin>>n>>minnum;
    for(i=1;i<n;i++)
    {
        cin>>num[i];
        if(minnum>=num[i])
        {
            number++;
            minnum=num[i];
        }
    }
    cout<<number;
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
int a,b,c;
char op;
while(1){
scanf("%d %c %d",&a,&op,&b);
if(op=='?')break;
if(op=='+')c=a+b;
else if(op=='-')c=a-b;
else if(op=='*')c=a*b;
else if(op=='/')c=a/b;


printf("%d\n",c);
}
return 0;
}


Measured memory_bytes: 1972
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

#define MOD 1000000007

using namespace std;

typedef long long int64;





int main(void){
    int64 N,K;
    cin>>N>>K;
    int64 ans=0;

    for (int64 i = K; i <= N+1; i++)
    {
        ans+=(N+N-i+1)*i/2-(i-1)*i/2+1;
        ans%=MOD;
    }
    
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);

    for(int i = 0; i < N+1; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }

    ll tmp;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        tmp = B[i];
        ans += min(A[i], tmp);
        tmp -= min(A[i], tmp);
        tmp = min(A[i+1], tmp);
        ans += min(A[i+1], tmp);
        A[i+1] -= tmp;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

int n,m;
string s,p,g;

struct edge{
	int to;
	int cost;
};

class Situation{
public:
    int cost;
	int idx;

	Situation(int cost_,int idx_){
		cost=cost_;
		idx=idx_;
	}
	Situation();

	bool operator<(const Situation &s)const{
		return s.cost < this->cost;
	}
};

//typedef pair<int,int> P;
int V;

const int MAX_V = 5000;

vector<edge> G[MAX_V];
int d[MAX_V];
const int INF = 100000000;

map<string,int> msi;
string ism[10000];

int prevv[MAX_V];
void dijkstra(int s){
	priority_queue<Situation> que;
	fill(d,d+MAX_V,INF);
	fill(prevv,prevv+MAX_V,-1);
	d[s] = 0;
	que.push(Situation(0,s));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
		int v = p.idx;
		if(d[v] < p.cost)
			continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(Situation(d[e.to],e.to));
				// ツつサツづ個ノツーツドツづ鳴づ個催短ツ仰猟猟」ツ経ツ路ツづーツ記ツ録ツつオツづつィツつュ
				prevv[e.to] = v;
			}
		}
	}
}
void solve(){
    while(cin>>n>>m&&!(n==0&&m==0)){
        int idx=0;
        msi.clear();
        for(int i = 0; i < MAX_V; i++){
            G[i].clear();
        }
        cin>>s>>p>>g;
        for(int i = 0; i < m; i++){
            int d,t;
            string a,b;
            cin>>a>>b>>d>>t;
            if(msi.find(a)==msi.end()){
                msi[a]=idx++;
            }
            if(msi.find(b)==msi.end()){
                msi[b]=idx++;
            }
            edge e;
            e.to=msi[b];e.cost=d/40+t;
            G[msi[a]].push_back(e);
            e.to=msi[a];
            G[msi[b]].push_back(e);
        }
        dijkstra(msi[s]);
        ll sum=d[msi[p]];
        dijkstra(msi[p]);
        sum+=d[msi[g]];
        cout<<sum<<endl;
    }
}

int main(){

    solve();

    return 0;
}

Measured memory_bytes: 1292
import java.util.*
 
fun main(args: Array<String>){
  
  val(x,y) = readLine()!!.split(" ").map{it.toInt()}
 
  val max = 4*x
  val min = 2*x
  
  if(y < min || max < y){
    print("No")
  }else if(y % 2 != 0){
 	print("No")
  }else{
    print("Yes")
  }
  
}

Measured memory_bytes: 36328
n,m=map(int,input().split())
ac,wa=0,0
aced=0
p,s=0,0
l=[0 for _ in range(m)]
for i in range(m):
  p,s=input().split()
  p=int(p)
  l[i]=[p,s,i+1]
l.sort(key=lambda x: (x[0],x[2]))
#print(l)
cw=0
p=0
for i in range(m):
  s=l[i][1]
  r=p
  p=l[i][0]
  if aced!=p:
    if s=='AC':
      ac+=1
      aced=p
      if r==p:
        wa+=cw
        cw=0
      else:
        cw=0
    else:
      if r==p:
        cw+=1
      else:
        cw=1

  #print(ac,wa,aced)

  
  

print(ac,wa)

Measured memory_bytes: 33088
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N;
    cin >> N;
    for(int i=30;i>=0;i--){
        if(N >= (1LL << i) - 1){
            cout << i << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3100
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592653589793238

int main() {
	int N;
	cin >> N;
	cout << (int64_t)(N - 1) * N / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
x = 0

sf = s[:2]
sl = s[2:]

if (int(sf[0]) == 0 and int(sf[1]) != 0):
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 0:
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 1:
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 2:
    x += 1


if (int(sl[0]) == 0 and int(sl[1]) != 0):
    x += 2

if int(sl[0]) == 1 and int(sl[1]) == 0:
    x += 2
if int(sl[0]) == 1 and int(sl[1]) == 1:
    x += 2
if int(sl[0]) == 1 and int(sl[1]) == 2:
    x += 2

b = x

if b == 0:
  print('NA')
elif b == 3:
  print('AMBIGUOUS')
elif b == 1:
  print('MMYY')
elif b == 2:
  print('YYMM')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    string a = s.substr(0, 2);
    string b = s.substr(2, 2);
    if ("01" <= a && a <= "12" && "01" <= b && b <= "12") {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if ("00" <= a && a <= "99" && "01" <= b && b <= "12") {
        cout << "YYMM" << endl;
        return 0;
    }
    if ("01" <= a && a <= "12" && "00" <= b && b <= "99") {
        cout << "MMYY" << endl;
        return 0;
    }

    cout << "NA" << endl;
    return 0;
}


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

int N = 0;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin >> N;
    vector<vector<int>> candies(2, vector<int>(N, 0));
    vector<vector<int>> sum(2, vector<int>(N, 0));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> candies[i][j];
        }
    }
    sum[0][0] = candies[0][0];
    for (int i = 1; i < N; i++) {
        sum[0][i] = sum[0][i - 1] + candies[0][i];
    }
    sum[1][0] = sum[0][0] + candies[1][0];
    for (int i = 1; i < N; i++) {
        sum[1][i] = max(sum[0][i], sum[1][i - 1]) + candies[1][i];
    }
    cout << sum[1][N - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 1; i < (n); i++)
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  ll sum = 0;
  rep(i, n + 1) {
    if (i % 3 == 0 && i % 5 == 0) {
      continue;
    } else if (i % 3 == 0 || i % 5 == 0) {
      continue;
    } else {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3640
// finish date: 2019/07/20

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int r;
    cin >> r;
    cout << 3 * (r*r) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

vector<vector<int>> g(8);
int sum=0;
int n;

void solve(int d,vector<bool>& c,int k){
  k++;
  if(k==n) sum++;
  c[d]=1;
  rep(i,g[d].size()){
    int to=g[d][i];
    if(c[to]) continue;
    vector<bool> C(n);
    rep(i,n){
      if(c[i]) C[i]=1;
      else C[i]=0;
    }
    solve(to,C,k);
  }
}

int main(){
  int m; cin>>n>>m;
  rep(i,m){
    int a,b; cin>>a>>b;
    a--;b--;
    g[a].pb(b);g[b].pb(a);
  }

  vector<bool> c(n,0);
  solve(0,c,0);
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    cout << 24 + (24 - n);
    return 0;
}

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

using namespace std;

int main() {
    vector<int> abc(3);
    int x;
    for (int i=0; i<3; i++) cin >> abc[i];
    cin >> x;
    sort(abc.begin(), abc.end());

    cout << abc[0] + abc[1] + abc[2] * (1<<x) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int w = in.nextInt();

        long[] dp = new long[100001];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            long weight = in.nextLong();
            int val = in.nextInt();
            for (int j = dp.length - 1; j >= val; j--) {
                dp[j] = Math.min(dp[j], dp[j - val] + weight);
            }
        }

        for (int i = dp.length - 1; i >= 0; i--) {
            if (dp[i] <= w) {
                out.println(i);
                break;
            }
        }
        out.close();

    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public String nextLine() throws IOException {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
                return nextLine();
            }

            String ret = "";
            while (st.hasMoreTokens()) {
                ret += st.nextToken();
            }
            return ret;
        }
        public int[] nextIntArr(int size) throws IOException {
            int[] arr = new int[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        public long[] nextLongArr(int size) throws IOException {
            long[] arr = new long[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        public double[] nextDoubleArr(int size) throws IOException {
            double[] arr = new double[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 34460
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> s){
  ll ans = 0;
  for(ll d = 1; d < N-1; d++){
    ll l,r;
    l = 0;
    r = N-1;
    ll wa = 0;
    if((N-1)%d==0){
      while(true){
        if(r-d<=0) break;
        wa += s[l];
        wa += s[r];
        chmax(ans,wa);
        dump(l,r,wa);
        dump(r,r-d);
        l += d;
        r -= d;
        if(l>=r) break;
      }
    }else{
      while(true){
        if(r-d<=0) break;
        wa += s[l];
        wa += s[r];
        chmax(ans,wa);
        dump(l,r,wa);
        dump(r,r-d);
        l += d;
        r -= d;
        if(l>N-1 || r<0) break;
      }
    }
  }
  cout << ans << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> s(N-1-0+1);
  for(int i = 0 ; i < N-1-0+1 ; i++){
    scanf("%lld",&s[i]);
  }
  solve(N, std::move(s));
  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    string s; cin >> s;
    int n = s.size();
    int g = 0;
    rep(i, n){
        if(s[i] == 'g') g++;
    }
    out(g - (n+1)/2);
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
    
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] A = in.nextInt(new int[n]);
        HashSet<Integer> okNumber = new HashSet<>();
        calc(A,0,0,okNumber);
        for(int m : in.nextInt(new int[in.nextInt()])) {
        	out.println(okNumber.contains(m)?"yes":"no");
        }
        out.flush();
    }
    
    private void calc(int[] A, int base, int offset, HashSet<Integer> okNumber) {
    	if(offset==A.length-1){
    		okNumber.add(base);
    		okNumber.add(base + A[offset]);
    	}else{
    		calc(A,base,offset+1,okNumber);
    		calc(A,base+A[offset],offset+1,okNumber);
    	}
    }
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 44284
function Main(input) {
    'use strict';

    const n = parseInt(input.split("\n").shift());
    const charList = ["A", "T", "G", "C"];
    const div = 1000000007;
    let obj = [];
    const tmpObj = [];
    (function addChar(init){
        const queue = [init];
        while(queue.length !== 0){
            const str = queue.shift();
            if(str.length !== 3){
                charList.forEach(char => queue.push(str + char));
            }else{
                if(!str.match(/ACG|AGC|GAC/)){
                    obj[str] = 1;
                    tmpObj[str] = 0;
                } 
            }
        }
    })("");

    if(n === 3) console.log(Object.keys(obj).length);
    else{
        for(let i = 0; i < n - 3; i++){
            const newObj = Object.assign([],tmpObj);
            Object.keys(obj).forEach(key => {
                const val = obj[key];
                charList.forEach(char => {
                    const newStr = key + char;
                    if(!newStr.match(/ACG|AGC|GAC|AG.C|A.GC/)) newObj[newStr.slice(-3)] += val % div;
                })
            })
            obj = newObj;
        }
        //RE
        //console.log(Object.values(obj).reduce((acc, curr) => acc + curr) % div);
        console.log(Object.keys(obj).reduce((acc, curr) => acc + obj[curr], 0) % div);
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));




Measured memory_bytes: 10528
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    
    if(a>=0 && a<=5){
        printf("0\n");
    }
    
    else if(a>5 && a<=12){
        printf("%d\n",b/2);
    }
    
    else if(a>12){
        printf("%d\n",b);
        
    }
    
    
    return 0;
}

Measured memory_bytes: 128