akhauriyash/Code-Regression huggingface dataset:
def take2(i):
    while True:
        yield next(i),next(i)
def main(f):
    _ = int(f.readline())
    xyuv = [[x+y*1j for x,y in take2(map(int, line.split()))] for line in f]

    print(solve(xyuv))
def is_all_same_attime(xyuv):
    xy0, uv0 = xyuv[0]
    for i in range(len(xyuv)):
        if xyuv[0] == xyuv[i]:
            continue
        xyi,uvi = xyuv[i]

        t = get_cross_time(xy0 - xyi, uv0 - uvi)

        if t is None or t < 0:
            return False

        p0 = xy0 + uv0 * t
        for j in range(i + 1,len(xyuv)):
            xyj, uvj = xyuv[j]
            pj = xyj + uvj * t
            if is_zero(pj - p0):
                continue
            return False
        break
    return True
def get_cross_time(xy,uv):
     denominator = uv.real - uv.imag
     return (xy.imag - xy.real) / denominator if denominator else None

def is_all_same(xyuv):
    for xyuvi in xyuv:
        if xyuvi != xyuv[0]:
            return False
    return True

def is_zero(a):
    return abs(a) < 0.00001

def get_t(xy1,uv1,xy2,uv2):
    a = uv1.real * uv2.imag - uv1.imag * uv2.real
    b = xy1.real * uv2.imag - xy1.imag * uv2.real + uv1.real * xy2.imag - uv1.imag * xy2.real
    c = xy1.real * xy2.imag - xy1.imag * xy2.real
    if a:
        d = b * b - 4 * a * c
        if d < 0:
            return []
        elif d == 0:
            return [-b / (2 * a)]
        else:
            d = d ** 0.5 / (2 * a)
            b /= 2 * a
            return [-b + d, -b - d]
    if b:
        return [-c / b]
    if not c:
        global always_lined_point
        always_lined_point += 1
    return []

from itertools import combinations
from itertools import groupby
from collections import Counter
#@profile
def solve(xyuv):
    global always_lined_point
    if len(xyuv) <= 2 or is_all_same(xyuv) or is_all_same_attime(xyuv):
        return len(xyuv)
    max_ij = 0
    for i, j in combinations(range(len(xyuv)), 2):
        if xyuv[i] == xyuv[j]:
            continue
        xyi,uvi = xyuv[i]
        xyj,uvj = xyuv[j]
            
        always_lined_point = 0
        t = []
        for indeces in (range(i),range(i + 1,j),range(j + 1,len(xyuv))):
            for k in indeces:
                xyk,uvk = xyuv[k]
                t.extend(get_t(xyi - xyk, uvi - uvk, xyj - xyk, uvj - uvk))

        t = [ti for ti in t if 0 <= ti] #t<0?????????
        t = [round(ti, 10) for ti in t] #?????????
        t = Counter(t)

        xyi -= xyj
        uvi -= uvj

        group_lengths = [0]
        for k, c in t.most_common(2):
            group_length = 1 if is_zero(xyi + uvi * k) else c
            group_lengths.append(group_length)
             
        max_ij = max(max_ij, max(group_lengths) + always_lined_point + 2)
    return max_ij

import sys
f = sys.stdin

main(f)

Measured memory_bytes: 7012
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String S  = s.next();
		String ans;
		if(S.charAt(1) =='B') {ans ="ARC";}
		else {ans ="ABC";}
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 35632
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    vector<int> retu(N);
    vector<bool> already(N,false);
    
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    sort(retu.begin(),retu.end());
    vector<bool> ng(1000005);
    for(int i = 0;i<N;i++){
        if(i == 0) continue;
        if(retu.at(i) == retu.at(i-1)) ng.at(retu.at(i)) = true;
    }
    vector<bool> okornot(retu.back()*2,false);
    bool ok = true;
    int ans = 0;
    int maxiindex = N;
    int prv = retu.at(0);
    for(int i = 0;i<N;i++){
        if(ng.at(retu.at(i))) {
            already.at(i) = true;
        }
        prv = retu.at(i);
        if(okornot.at(retu.at(i))){
            already.at(i) = true;
        }
        int A = retu.at(i);
        int B = retu.at(i);
        while(A <= retu.back()*2-1){
            okornot.at(A) = true;
            A += B;
        }
    }
    for(int i = 0;i<N;i++)if(!already.at(i)) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 4360
s = input()
a_pos = 0
z_pos = 0
for i in range(len(s)):
    if s[i] == "A":
        a_pos = i
        break
for i in range(len(s)):
    if s[len(s)-i-1] == "Z":
        z_pos = len(s)-i-1
        break
print(z_pos-a_pos+1)


Measured memory_bytes: 3512
n = gets.to_i
s = gets.chomp
max = n - 1
count = []
1.upto(max) do |i|
  c = 0
  before = s[0..(i - 1)]
  after = s[i..max].chars.uniq

  before.chars.uniq.each do |v|
    c += 1 if after.index(v)
  end
  count.push(c)
end
puts count.max


Measured memory_bytes: 1916
'use strict'

function main(input) {
  input = input.split(' ').map(v => ~~v)
  const n = input[0]
  const m = input[1]

  const limit = 1e9 + 7 //(Math.pow(10, 9) + 7)

  //交互に並べられない
  if (Math.abs(n - m) >= 2) {
    console.log(0)
    return
  }

  let nn = 1
  for (let i = 2; i <= n; i++) {
    nn *= i
    if (nn >= limit) {
      nn = nn % limit
    }
  }
  // let mm = 1
  for (let i = 2; i <= m; i++) {
    nn *= i
    if (nn >= limit) {
      nn = nn % limit
    }
  }
  // console.log(nn,mm)

  let tmp = nn % limit
  // console.log(tmp)
  if (n == m) {
    tmp = 2 * tmp
  }
  const ans = tmp % limit

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 9932
import java.util.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        
        int[] T  = new int[N];
        for(int i=0;i<N;i++){
            T[i] = Integer.parseInt(sc.next());
        }
        
        int M = Integer.parseInt(sc.next());
        int[] P = new int[M];
        int[] X = new int[M];
        
        for(int i=0;i<M;i++){
            P[i] = Integer.parseInt(sc.next());
            X[i] = Integer.parseInt(sc.next());
        }
    
        for(int i=0;i<M;i++){
            int s=0;
            for(int k=0;k<N;k++){
                
            if(P[i]-1==k) s += X[i]; 
            else s += T[k];
                
            }
            System.out.println(s);
        }
        


        System.out.println();
    }

}

Measured memory_bytes: 9936
#include <stdio.h>
#include <math.h>
int main(void){
	double x,h,hh,S;
	while(1){
	scanf("%lf %lf",&x,&h);
	if(x==0 && h==0)break;
	S=x*x;
	h=sqrt(h*h+x*x/4);
	S+=2*x*h;
	printf("%.9lf\n",S);
	}
	return 0;
}

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

int main() {
  ll N;
  cin >> N;
  rep(h,1,3501){
    rep(n,h,3501){
      ll w = N*h*n,p = 4*h*n-N*(h+n);
      if(p == 0) continue;
      if(w%p == 0 && p > 0){
        w /= p;
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
queue<int>q;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
map<int,int>p;
/*struct knd{
	int x,y,z;
}s[200000];*/ 
int  a,b;
int main()
{
	int m,n,i,j,t,k=0,s=0;
	cin>>n;
	 for(i=1;i<=n;i++)
	 {
	 	cin>>a>>b;
	 	if(a==b) {
	 		s++;
	 		k=max(s,k);
		 }
	 	else s=0;
	 }
	 if(k>=3) cout<<"Yes";
	 else cout<<"No";
 } 

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a%2==0 || b%2==0)
        printf("Even");
    else
        printf("Odd");
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
mod = int(1e9) + 7 # <-- input modulo
maxf = 500010           # <-- input factional limitation

def make_fact(n, k):
    tmp = n
    perm = [i for i in range(k)]
    L = [0 for _ in range(k)]
    for i in range(k):
        L[i] = tmp % (i + 1)
        tmp //= i + 1
    LL = [0 for _ in range(k)]
    for i in range(k):
        LL[i] = perm[L[-i-1]]
        for j in range(L[-i-1]+1, k):
            perm[j-1] = perm[j]
    return LL

def doubling(n, m, modulo=mod):
    y = 1
    base = n
    tmp = m
    while tmp != 0:
        if tmp % 2 == 1:
            y *= base
            if modulo > 0:
                y %= modulo
        base *= base
        if modulo > 0:
            base %= modulo
        tmp //= 2
    return y

def inved(a, modulo=mod):
    x, y, u, v, k, l = 1, 0, 0, 1, a, modulo
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return x % modulo

fact = [1 for _ in range(maxf+1)]
invf = [1 for _ in range(maxf+1)]

for i in range(maxf):
    fact[i+1] = (fact[i] * (i+1)) % mod
invf[-1] = inved(fact[-1])
for i in range(maxf, 0, -1):
    invf[i-1] = (invf[i] * i) % mod

S = 0
sign = 1
for i in range(N+1):
    S += (sign*fact[M-i]*invf[i]*invf[N-i])%mod
    S %= mod
    sign *= -1
    sign %= mod
print(S*fact[N]*fact[M]*invf[M-N]*invf[M-N]%mod)

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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using si = set<int>;
using sll = set<ll>;


ll a[405];
ll prefix[405];
ll sum[405][405];

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	
	
	for (int i = 0; i < n; i++){
		if (i == 0) prefix[i] = a[i];
		else prefix[i] = prefix[i - 1] + a[i];
	}
	
	for (int i = 0; i < 405; i++){
		for (int j = 0; j < 405; j++){
			sum[i][j] = 1e18;
		}
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j + i < n; j++){
			int l = j, r = j + i;
			if (r == l){
				sum[l][r] = 0;
			}
			else if (r - l == 1){
				sum[l][r] = a[l] + a[r];
			}
			else{
				for (int k = 0; l + k < r; k++){
					ll l_sum = prefix[l + k];
					if (l > 0) l_sum -= prefix[l - 1];
					ll r_sum = prefix[r];
					if (r > 0) r_sum -= prefix[l + k];
					sum[l][r] = min(sum[l][r], l_sum + sum[l][l + k] + r_sum + sum[l + k + 1][r]);
				}
			}
			//cout << l << " - " << r << ": " << sum[l][r] << endl;
		}
	}

	cout << sum[0][n - 1] << endl;
	return 0;
}


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

int main() {
	// your code goes here
	int n,w;
	cin>>n>>w;
	vector<long> val(n);
	vector<long> wgt(n);
	for(int i=0;i<n;i++)
	{
	    cin>>wgt[i];
	    cin>>val[i];
	   
	}
	vector<vector<long>> dp(n+1,vector<long>(w+1,0));
	
	for(int i=0;i<=n;i++)
	{
	    for(int j=0;j<=w;j++)
	    {
	        if(i==0 || j==0)
	            dp[i][j]=0;
	            
	       else if(wgt[i-1]<=j)
	       {
	            dp[i][j] = max(dp[i-1][j], val[i-1]+dp[i-1][j-wgt[i-1]]);
	       }
	       else
	            dp[i][j]  = dp[i-1][j];
	    
	    }
	}
	
// 	for(int i=0;i<=n;i++)
// 	{
// 	    for(int j=0;j<=w;j++)
// 	    {
// 	           cout<<dp[i][j]<<" ";
// 	    }
// 	    cout<<endl;
// 	}
	
	cout<<dp[n][w];
	
	return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;

    int a[100], b[100], c[100];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n - 1; i++) cin >> c[i];

    int ret = 0;
    int prev = -2;
    for (int i = 0; i < n; i++) {
        ret += b[a[i]];
        if (prev + 1 == a[i]) ret += c[prev];
        prev = a[i];
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    if (a+b>=10){
      System.out.println("error");
    } else {
      System.out.println(a+b);
    }
  }
}

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

using namespace std;

struct DSU {
    int n;
    vector<int> ps;
    vector<int> rank;
    int num_components;
    DSU(int n): n(n), ps(n), num_components(n), rank(n) {
        for (int i = 0 ; i < n; ++i) {
            ps[i] = i;
            rank[i] = 0;
        }
    }
    int parent(int i) {
        if (ps[i] == i) {
            return i;
        }
        return ps[i] = parent(ps[i]);
    }
    int merge(int i, int j) {
        i = parent(i);
        j = parent(j);
        if (i != j) {
            if (rank[i] <= rank[j]) {
                swap(i, j);
            }
            if (rank[i] == rank[j]) {
                ++rank[i];
            }
            ps[j] = i;
            --num_components;
            return true;
        }
        return false;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> ps(n);
    for (int i = 0; i < n; ++i) {
        ps[i] = i;
    }
    DSU dsu(n);
    for (int i = 0; i < m; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        --x;
        --y;
        dsu.merge(x, y);
    }
    cout << dsu.num_components << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

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

    int i = a;
    int count=0;
    for(; i <= b; i++){
        if( c % i == 0){
            count++;
        }
    }


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


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

ll A,B,Q;
vector<ll> SH(100010,0);
vector<ll> TE(100010,0);
ll Sp,Sps,Tp,Tps;

void Sq(ll q){
  ll a=0; ll b=A-1; ll nib;
  if(q<=SH[0]){
    Sp=Sps=SH[0];
    return;
  }
  if(q>=SH[A-1]){
    Sp=Sps=SH[A-1];
    return;
  }
  while(1){
    nib=(a+b)/2;
    if(SH[nib]<=q){
      if(q<=SH[nib+1]){
        break;
      }
      a=nib;
    }else{
      b=nib;
    }
  }
  Sp=SH[nib]; Sps=SH[nib+1];
  return;
}

void Tq(ll q){
  ll a=0; ll b=B-1; ll nib;
  if(q<=TE[0]){
    Tp=Tps=TE[0];
    return;
  }
  if(q>=TE[B-1]){
    Tp=Tps=TE[B-1];
    return;
  }
  while(1){
    nib=(a+b)/2;
    if(TE[nib]<=q){
      if(q<=TE[nib+1]){
        break;
      }
      a=nib;
    }else{
      b=nib;
    }
  }
  Tp=TE[nib]; Tps=TE[nib+1];
  return;
}

int main(){
  cin >> A >> B >> Q;
  SH.resize(A);
  TE.resize(B);
  for(int i=0;i<A;i++){
    cin >> SH.at(i);
  }
  for(int i=0;i<B;i++){
    cin >> TE.at(i);
  }
  sort(SH.begin(),SH.end());
  sort(TE.begin(),TE.end());
  
  ll X;
  vector<ll> ans(8,0);
  for(int i=0;i<Q;i++){
    cin>>X;
    vector<ll> ans(8,0);
    //神社先パターン
    Sq(X); ans[0]=abs(Sp-X); ans[2]=abs(Sps-X);
    Tq(Sp); ans[1]=ans[0]+abs(Tp-Sp); ans[0]+=abs(Tps-Sp);
    Tq(Sps); ans[3]=ans[2]+abs(Tp-Sps); ans[2]+=abs(Tps-Sps);
    //寺先パターン
    Tq(X); ans[4]=abs(Tp-X); ans[6]=abs(Tps-X);
    Sq(Tp); ans[5]=ans[4]+abs(Sp-Tp); ans[4]+=abs(Sps-Tp);
    Sq(Tps); ans[7]=ans[6]+abs(Sp-Tps); ans[6]+=abs(Sps-Tps);

    sort(ans.begin(),ans.end());
    cout << ans[0] << endl;
  }
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

    
vector< vector< pair<int, long long> > > path;
long long dist[100000];

void func( int c, long long cost ) {
    
    dist[c] = cost;
    
    for ( int i = 0; i < path[c].size(); i++ ) {
        pair<int,long long> p = path[c][i];
        
        int next = p.first;
        long long c = p.second;
        
        if ( dist[next] != LLONG_MAX ) { continue; }
        
        func( next, cost+c );
    }
}



int main() {
    vector< pair<int,int> > Query;
    int N;
    cin >> N;
    
    fill( dist, dist+100000, LLONG_MAX );
    
    path.resize(N);
    for ( int i = 0; i < N-1; i++ ) {
        long long a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        
        path[a].push_back( make_pair(b,c) );
        path[b].push_back( make_pair(a,c) );
    }
    
    int Q,K;
    cin >> Q >> K;
    for( int i = 0; i < Q; i++ ) {
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        Query.push_back( make_pair( x, y ) );
    }
    
    func( K-1, 0 );
    
    for( int i = 0; i < Q; i++ ) {
        cout << dist[Query[i].first] + dist[Query[i].second] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 15220
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

int main(){
	string s,t;
	cin >> s;
	int n = s.size();
	if( s[n-1]=='s' ){
		t = "es";
	}else{
		t = "s";
	}
	cout << s+t;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
using namespace std;
int a[100007];
int main(){
	int n,m;
	int i,j,k;
	string sa;
	cin>>n;
	cin>>sa;
	for(i=0;i<4;i++){
		a[0]=i/2;
		a[1]=i%2;
		for(j=1;j<n;j++){
			if((sa[j]=='o' && a[j]==0)||(sa[j]=='x' && a[j]==1))a[j+1]=a[j-1];
			else a[j+1]=1-a[j-1];
		}
		m=0;
		if(a[n]==a[0])m++;
		if((sa[0]=='o' && a[0]==0)||(sa[0]=='x' && a[0]==1)){
			if(a[1]==a[n-1])m++;
		}else{
			if(a[1]!=a[n-1])m++;
		}
		if(m==2)break;
	}
	if(m==2){
		for(i=0;i<n;i++){
			if(a[i]==0)cout<<"S";
			else cout<<"W";
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}


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

using namespace std;
   
        
      


    void solve(){
         int n, w ;
         cin>>n>>w;
         vector<int>values(n);
         vector<int>weights(n);
         for(int i = 0; i < n;++i) cin>>weights[i]>>values[i];
        int sum = 0;
         for(int x : values) sum += x;
         vector<long long > dp (sum+1,(long long)1e18);
         dp[0] = 0;
         for(int i = 0;i<n;++i){
             for(int temp = sum - values[i];temp>=0;--temp){
                    
                        dp[temp + values[i] ] = min(dp[temp + values[i] ], dp[temp] + weights[i]);
                    
             }
         }    
         int an = 0;
            for(int i = 0;i<=sum;++i){
                if(dp[i]<=w) an = i;
            }

        
        cout<<an<<'\n';
    }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    //cin>>tc;
    while (tc--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3992
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<int> vint;


struct state{
	int pos, bit, dist;
	bool operator< (const state &s) const{
		return dist > s.dist;
	}
};


void solve(int n, int m, int L, int k){
	int s, g, a, b, c;
	vector<vpii> G(n + 1);
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d", &a, &b, &c);
		G[a].push_back(pii(b, c));
		G[b].push_back(pii(a, c));
	}
	scanf("%d%d", &s, &g);
	vint ball(n + 1, -1);
	for(int i = 0; i < L; ++i){
		scanf("%d", &b);
		ball[b] = i;
	}

	vector<vector<vint> > d(n + 1, vector<vint>(1 << L));
	vector<vint> nxtn(n + 1, vint(1 << L));
	
	b = (1 << L) - 1;
	if(ball[s] != -1){
		b &= ~(1 << ball[s]);
	}
	d[s][b].push_back(0);
	priority_queue<state> pq;
	pq.push((state){s, b, 0});
	while(!pq.empty()){
		state st = pq.top();
		pq.pop();
		int p = st.pos;
		b = st.bit;
		if(d[p][b].size() <= nxtn[p][b] || d[p][b][nxtn[p][b]] != st.dist){
			continue;
		}

		++nxtn[p][b];
		if(p == g && b == 0 && nxtn[p][b] == k){
			printf("%d\n", st.dist);
			return;
		}

		for(int i = 0; i < G[p].size(); ++i){
			int to = G[p][i].first;
			int nd = st.dist + G[p][i].second;
			int nb = b;
			if(ball[to] != -1){ nb &= ~(1 << ball[to]); }
			
			vint &v = d[to][nb];
			int t = upper_bound(v.begin(), v.end(), nd) - v.begin();
			v.insert(v.begin() + t, nd);
			if(v.size() > k){ v.resize(k); }

			if(t < v.size()){
				pq.push((state){to, nb, nd});
			}
		}
	}
	puts("NA");
}

int main(){
	int n, m, L, k;
	while(scanf("%d%d%d%d", &n, &m, &L, &k), n){
		solve(n, m, L, k);
	}
}

Measured memory_bytes: 4192
//#pragma GCC optimize (2)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ii =  pair<int,int>;
const int  dir[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
const int mod = 1000000007;
const int INF = 0x3f3f3f;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
//    cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
void solve() {
    int x;
    cin>>x;
    cout<<(x>=30?"Yes":"No")<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int n;
int a[110],b[110];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 1; i < n; i++) {
    a[i] += a[i-1];
  }
  for (int i = n - 2; i >= 0; i--) {
    b[i] += b[i+1];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, a[i] + b[i]);
  }
  cout << ans << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

void solve(int a,int b,int c,int d) {
  int k = (max(a,b) + min(a,b)) / (min(a,b) + 1);
  int l = 0, r = a, ans = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    int na = mid;
    int nb = (na - 1) / k;
    if (b - nb <= 1ll * (a - na + 1) * k) ans = mid, l = mid + 1;
    else r = mid - 1;
  }
  int na = ans;
  int nb = (na - 1) / k;
  int p1 = na + nb;
  int p2 = p1 + ((b - nb) - (a - na) * k);
  rep (i, c, d) {
    if (i <= p1) {
      if (i % (k+1) == 0) putchar('B');
      else putchar('A');
    } else if (i <= p2) {
      putchar('B');
    } else {
      if ((i - p2) % (k+1) == 1) putchar('A');
      else putchar('B');
    }
  }
  puts("");
}
int main() {
  int q,a,b,c,d;
  read(q);
  while (q --) {
    read(a), read(b), read(c), read(d);
    solve(a, b, c, d);
  }
  return 0;
}


Measured memory_bytes: 384
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
 var x = chunk.split(" ")
 var a = Number(x[0])
 var b = Number(x[1])

 if (a == b) {
   console.log("a == b")
 } else if (a < b) {
     console.log("a < b")
   } else
     console.log("a > b")
});

Measured memory_bytes: 15596
catch = input()
catch = catch.split(" ")

f = 0
n = 0

for i in range(3):
    if catch[i] == "7":
        n +=1
    elif catch[i] == "5":
        f +=1

if f == 2 and n == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m): #高速素因数分解 m[n]=nを割ることの出来る最小の素数
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n): #b[n]=nを割ることの出来る最小の素数　の配列を生成　エラトステネスの篩
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


def main():
    #l,r,d=map(int,input().split())
    s=int(input())
    ans=0
    if s>=6:
        amari=s%3
        maxdiv=s//3
        ans=1
        for i in range(2,maxdiv+1): #i=3で分けた項数
            nokori=s-3*i
            ans+=cmb(nokori+i-1,i-1)
            ans%=MOD
    elif s>=3:
        ans=1




    print(ans%MOD)






if __name__ == "__main__":

    main()


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

using namespace std;

const int N = 110;

int a[N];

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

	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

	sort(a, a+n);
	int ans = 0;
	for (int i = 0; i < n-1; ++i) {
		if(a[i] <= x) {
			x -= a[i];
			ans = max(ans, i+1);
		} else {
			break;
		}
	}
	if(a[n-1] == x) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    sc.close();
    
    int dig;
    int mod;
    for (int i = 1; i <= 9; i++ ) {
      dig = N / i;
      mod = N % i;
      if (1 <= dig && dig <= 9 && mod == 0) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 22612
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    ans = "Yes"
    for i in range(len(S)):
        if (i+1) % 2 == 1:
            if S[i] is "L":
                ans = "No"
        else:
            if S[i] is "R":
                ans = "No"
        if ans == "No":
            print(ans)
            exit()
    print(ans)


if __name__ == '__main__':
    main()


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

#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {


	int a[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	int n;
	cin>>n;
	int b[n];
	for(int i=0;i<n;i++){
		cin>>b[i];
	}

	for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				for(int k=0;k<n;k++){
					if(b[k]==a[i][j]){
						a[i][j]=0;
					}

				}



			}

	}

	int cnt=0;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(a[i][j]==0){
				cnt+=1;
			}
		}
		if(cnt==3){
			cout<<"Yes"<<endl;
			return 0;
		}else{
			cnt=0;
		}
	}

	cnt=0;

	for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(a[j][i]==0){
					cnt+=1;
				}
			}
			if(cnt==3){
				cout<<"Yes"<<endl;
				return 0;
			}else{
				cnt=0;
			}
		}
	cnt=0;

	for(int i=0;i<3;i++){
		if(a[i][i]==0){
			cnt+=1;
		}
	}
	if(cnt==3){
		cout<<"Yes"<<endl;
		return 0;
	}else{
		cnt=0;
	}

for(int i=0;i<3;i++){
	if(a[2-i][i]==0){
		cnt+=1;
	}
}

if(cnt==3){
	cout<<"Yes"<<endl;
}else{
	cout<<"No"<<endl;
}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
// typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	ll ans = 0;
	sort(arr.begin(),arr.end());
	for (int z=0;z<n;z++){
		for (int x=z+1;x<n;x++){
			ll k = arr[z]+arr[x];
			auto it = lower_bound(arr.begin()+x,arr.end(),k);
			ans += (it-arr.begin())-x-1;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
bool cmp(char a,char b){
	return a<b;
}
string a[1000];
int main(){
	
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],b[N];
struct node
{
    int x,pos;
    node(int x=0,int pos=0):x(x),pos(pos){}
    bool operator<(const node&o)const
    {
        return x<o.x;
    }
};
priority_queue<node>q;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]),q.push(node(b[i],i));
    long long ans=0;
    while(!q.empty())
    {
        int u=q.top().pos;q.pop();
        if(b[u]==a[u]) continue;
        int l=u-1,r=u+1;
        if(l==0) l=n;
        if(r==n+1) r=1;
        int now=max(a[u],max(b[l],b[r]));
        if((b[u]-now)/(b[l]+b[r])>0)
        {
            ans+=(b[u]-now)/(b[l]+b[r]);
            b[u]-=(b[u]-now)/(b[l]+b[r])*(b[l]+b[r]);
        }
        else
        {
            b[u]-=b[l]+b[r];
            ans++;
        }
        if(b[u]<a[u])
        {
            printf("-1\n");return 0;
        }
        if(b[u]!=a[u])
            q.push(node(b[u],u));
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3700
#include <stdio.h>

int main(void)
{
	int s, i, a;
	a = 0;
	
	for(s = 1; s <= 10; s++){
		scanf("%d", &i);
		a = a + i;
	}
	
	printf("%d\n", a);
		
	return 0;
}


Measured memory_bytes: 2064
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int N = int.Parse(Console.ReadLine());
		
      	// スペース区切りの整数の入力
		//string[] input = Console.ReadLine().Split(' ');
      	//int[] H = new int[N];
      	//for (int i = 0;i<N;i++){
          //H[i] = int.Parse(input[i]); 
        //}
		//int A = int.Parse(input[0]);
		//int B = int.Parse(input[1]);
		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
      	
		Console.WriteLine((long)N * (N-1) / 2);
	}
}


Measured memory_bytes: 11092
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def concentrate(water, sugar):
    if water+sugar == 0:
        return 0
    else:
        return sugar/(water+sugar)


A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water_list = []
sugar_list = []

max_cont = E/(E+100)

max_water = F//B+1
for i in range(max_water):
    remain = F - B*i
    if remain < 0:
        break
    else:
        j = remain//A
        for k in range(j+1):
            water_list.append(A*k+B*i)

max_sugar = F//D+1
for i in range(max_sugar):
    tmp = D*i
    remain = F - tmp
    if remain < 0:
        break
    else:
        j = remain//C
        for k in range(j+1):
            sugar_list.append(D*i+C*k)

water_list = sorted(set(water_list))
sugar_list = sorted(set(sugar_list))

max_tmp = 0
ans = [0, 0]
for water in water_list:
    for sugar in sugar_list:
        if water+sugar > F:
            break
        else:
            conc = concentrate(water, sugar)
            if conc > max_cont:
                break
            else:
                if max_tmp <= conc:
                    max_tmp = conc
                    ans = [water, sugar]
print(sum(ans), ans[1])


Measured memory_bytes: 12440
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
const int MAXN = 1e5 + 10;
int n , a , b , cnt;
bool col[MAXN];
vector<int> adj[MAXN];
void dfs(int u , int p)
{
	for(auto v : adj[u])
		if(v != p)
		{
			dfs(v , u);
			if(!col[v])
				col[u] = true;
		}
	return;
}
int32_t main()
{
	cin >> n;
	/*if(n & 1)
		return cout << "First" << endl , 0;*/
	for(int i = 1 ; i < n ; i ++)
		cin >> a >> b , a -- , b -- , adj[a].pb(b) , adj[b].pb(a);
	if(n & 1)
		return cout << "First" << endl , 0;
	dfs(0 , -1);
	for(int i = 0 ; i < n ; i ++)
		if(col[i])
			cnt ++;
	return cout << (cnt == n / 2 ? "Second" : "First") << endl , 0;
}




Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		// 標準入力
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();

		// 入力を入れる配列
		String[] inputAry = new String[3];
		inputAry = input.split(" ");

		// 答え
		int max = 0;
		int min = 0;

		// 総数
		int n = Integer.parseInt(inputAry[0]);
		// A 購読
		int aNum = Integer.parseInt(inputAry[1]);
		// B 購読
		int bNum = Integer.parseInt(inputAry[2]);

		if (aNum == bNum && aNum == n && bNum == n) {
			// 全てが同数
			min = n;
			max = n;
		}

		if ((aNum + bNum) > n) {
			max = aNum<bNum?aNum:bNum;
			min = (aNum + bNum) - n;
		}

		if ((aNum + bNum) < n) {
			max = aNum<bNum?aNum:bNum;
			min = 0;
		}

		if ((aNum + bNum) == n) {
			max = aNum<bNum?aNum:bNum;
			min = 0;
		}

		System.out.println(max + " " + min);

	}
}


Measured memory_bytes: 23764
a,b,c,d=map(int, input().split())

aoki = int(c/b)
if c % b != 0:
    aoki += 1

taka = int(a/d)
if a % d != 0:
    taka += 1

if aoki <= taka:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long Int;

Int n;
Int a[108000];
Int nim;
int main(){
  cin >> n;
  for(int i = 0;i < n;i++)cin >> a[i],a[i] *= -1;
  sort(a, a + n);
  a[n] = 0;
  for(int i = 0;i < n;i++){
    if((a[i+1] - a[i]) % 2)nim ^= i+1;
  }
  if(nim)cout << "first" << endl;
  else cout << "second" << endl;
  return 0;
}

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

using namespace std;

int main()
{
  int n,  cnt = 1;
  char s[100005];
  
  scanf("%d", &n);
  
  scanf("%s", s);
  char prev = s[0];
  for(int i = 1; i < n; i++)
  {
    if(s[i] == prev)
      continue;
    else
    {
      prev = s[i];
      cnt++;
    }
  }
  
  cout<<cnt<<endl;
  
  return 0;
}  

Measured memory_bytes: 384
#include<stdio.h>
int devcon(int i,int x);

int n,a[21];

int main(){
  int i,m,x,result;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&a[i]);}
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&x);
    result=devcon(0,x);
    if(result)printf("yes\n");
    else printf("no\n");
  }
}

int devcon(int i,int x){
  int result;
  if(x==0)return 1;
  if(i>=n)return 0;
  result = devcon(i+1,x)||devcon(i+1,x-a[i]);
  return result;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int cnt[N];

int solve(){
    int n; cin>>n;
    int ans=0;
    for (int i = 0; i < n; ++i)
    {
        int t; cin>>t;
        cnt[t]++;
        ans+=t;
    }
    int q; cin>>q;
    while(q--){
        int b,c; cin>>b>>c;
        int x=cnt[b];
        cnt[b]=0; cnt[c]+=x;
        int tt=(c-b)*x;
        ans+=tt;
        cout<<ans<<"\n";
    }
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<'\n';
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int hyouzir;
    int naibur;
    cin >> n;
    cin >> hyouzir;

    if (n >10){
        naibur = hyouzir;
    }
    else{
        naibur = hyouzir + 100*(10-n);
    }
    
    cout << naibur << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		System.out.print(a.charAt(0));
		System.out.print(b.charAt(1));
		System.out.println(c.charAt(2));
	}
}

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

int main() {
	int n, k;
	char s[20];
	cin >> n;
	cin >> s;
	cin >> k;

	for (int i = 0; i < n; i++) {
		if (s[i] != s[k - 1]) s[i] = '*';
	}

	cout << s;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <string>
#include <cstring>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int K;
    cin>>K;
    ll sum=0;
    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            for (int l = 1; l <= K; ++l) {
                sum+=__gcd(i,__gcd(j,l));
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    vector<int> v(9);

    REP(i, N) {
        int b = a[i] / 400;
        if (8 < b)
            b = 8;
        v[b]++;
    }
    int mx, mn = 0;
    REP(i, 9) {
        if (0 < v[i] && i < 8)
            mn++;
        if (i == 8) {
            mx = mn + v[8];
        }
    }
    if (mn == 0)
        mn = 1;
    if (mx == 0)
        mx = 1;

    cout << mn << " " << mx << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

ll dp[1010][1010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    dp[0][0] = 1LL;
    rep(i, h) rep(j, w) {
        if(i+1 < h && s[i+1][j] != '#') (dp[i+1][j] += dp[i][j]) %= MOD;
        if(j+1 < w && s[i][j+1] != '#') (dp[i][j+1] += dp[i][j]) %= MOD;
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    int count = 0;
    for (int i = 0; i < N; i++) {
      count += sc.nextInt() % 2;
    }
    System.out.println(count % 2 == 0 ? "YES" : "NO");
  }

}


Measured memory_bytes: 32264
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
int a[55],b[55];
int main()
{
    int n,su=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
            su++;
    }
    if(su==2||su==0)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}



Measured memory_bytes: 256
def solve():
    S = list(raw_input())
    prevSi = S[0]
    cnt = 1
    cur = 1
    while cur < len(S):
        if S[cur] != prevSi:
            prevSi = S[cur]
            cnt += 1
            cur += 1
        elif cur < len(S) - 1:
            prevSi = S[cur] + S[cur + 1]
            cnt += 1
            cur += 2
        else:
            prevSi += S[cur]
            cur += 1
    print cnt

if __name__ == '__main__':
    solve()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ULL unsigned long long
#define LL long long

using namespace std;

int main(){
	ULL N,A;
	ULL BUKA[200000]={0};
	
	cin >> N;
	for(ULL i=1;i<N;i++){
		cin >> A;
		BUKA[A-1]++;
	}for(ULL i=0;i<N;i++){
		printf("%llu\n",BUKA[i]);
	}
	return 0;
}

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

int main() {
	int N;
	std::vector<int> p;

	std::cin >> N;
	p.reserve(N);

	for (int i = 0; i < N; ++i) {
		std::cin >> p[i];
	}

	int count = 0;
	for (int i = 0; i < N; ++i) {
		if (p[i] == i + 1) {
			std::swap(p[i], p[i + 1]);
			++count;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int en(vint &v){
    int ret=0;
    rep(i,v.size()){
        ret=ret*3+v[i];
    }
    return ret;
}


int M,N;

int memo[81*81*27];
int dfs(vint lis,vint v){
    int c=en(v);
    if(memo[c]!=-1)return memo[c];

    if(lis.size()==1)return 0;
    int &ret=memo[c];
    ret=1001001001;
    rep(i,M){
        bool ok=false;
        rep(j,lis.size())if((lis[j]>>i&1)!=(lis[0]>>i&1))ok=true;
        if(!ok)continue;
        vint x,y;
        rep(j,lis.size()){
            if((lis[j]>>i&1))x.pb(lis[j]);
            else y.pb(lis[j]);
        }

        vint a,b;
        a=v;b=v;
        a[i]=1;b[i]=2;
        chmin(ret,max(dfs(x,a),dfs(y,b))+1);
    }
    return ret;
}

signed main(){
    while(cin>>M>>N,M||N){
        vector<int>lis;
        rep(i,N){
            string s;
            int b;
            cin>>s;
            rep(j,s.size()){
                b=b*2+s[j]-'0';
            }
            lis.pb(b);
        }
        vector<int>v(M);
        memset(memo,-1,sizeof(memo));
        cout<<dfs(lis,v)<<endl;
    }
    return 0;
}

Measured memory_bytes: 2628
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
string s;
int main() {
	cin >> s;
	string ret;
	for (int i = 0; i < s.size(); i += 2) ret += s[i];
	cout << ret << endl;
}

Measured memory_bytes: 512