akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
#define ss second
signed main()
{
    flash
  char str[99];
  cin>>str;
  int n=strlen(str),flag=0,glag=0;  
  //cout<<n;
    for(int i=0;i<n;i++)
        {
            if(str[i]!=str[n-i-1])
            {
                flag= 1;break;
            }
        }    
        if(flag) {cout<<"No"; return 0;}
        else glag++;
        int k=(n-3)/2+1;
        for(int i=0;i<k;i++)
        {
            if(str[i]!=str[k-i-1])
            {
                flag=1; break;
            }
        }
        if(flag) {cout<<"No"; return 0;}
        else glag++;
        int j=(n+1)/2;
        for(int i=j;i<n;i++)
        {
            if(str[i]!=str[n-i-1])
            {
                flag=1;break;
            }
        }
        //cout<<f;
        if(flag) {cout<<"No"; return 0;}
        else glag++;
        if(glag==3) cout<<"Yes";
} 


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define decn int n = 0; cin >> n
#define sort(v) sort(v.begin(), v.end())
#define in(type, n) type n = 0; cin >> n

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	int n = 0;
	cin >> n;
	std::vector<int> v;

	rep(i, n) {
		int x;
		cin >> x;
		v.push_back(x);
	}

	ll min = 999999999999;
	rep(i, 100) {
		ll tmp = 0;
		rep(j, n) {
			tmp += (v[j] - (i + 1)) * (v[j] - (i + 1));
		}
		if (min > tmp) {
			min = tmp;
		}
	}

	cout << min;

	return 0;
}


Measured memory_bytes: 888
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break

        ii = LI()
        m = inf
        r = '-1'
        for s in range(16):
            for a in range(16):
                for c in range(16):
                    t = s
                    f = [0] * 256
                    for i in ii:
                        t = (a * t + c) % 256
                        f[(t + i) % 256] += 1
                    h = 0
                    for i in range(256):
                        if f[i] == 0:
                            continue
                        h -= f[i] / n * math.log(f[i] / n)
                    if m > h + eps:
                        m = h
                        r = '{} {} {}'.format(s, a, c)

        rr.append(r)


    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9056
#include <cstdio>
#include <algorithm>

int dp[2][401][401];

struct med
{
  int a;
  int b;
  int c;
};

int main()
{
  int n, ma, mb;
  scanf("%d%d%d", &n, &ma, &mb);
  med m[40];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d%d", &m[i].a, &m[i].b, &m[i].c);
  }
  std::fill((int*)dp, (int*)dp + 401 * 401 * 2, 1e9);
  dp[0][0][0] = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j <= 400; ++j)
    {
      for (int k = 0; k <= 400; ++k)
      {
        if (j - m[i].a >= 0 && k - m[i].b >= 0)
        {
          dp[(i + 1) & 1][j][k] = std::min(dp[i & 1][j][k], dp[i & 1][j - m[i].a][k - m[i].b] + m[i].c);
        }
        else
        {
          dp[(i + 1) & 1][j][k] = dp[i & 1][j][k];
        }
      }
    }
  }
  int ans = 1e9;
  for (int i = ma, j = mb; i <= 400 && j <= 400; i += ma, j += mb)
  {
    ans = std::min(ans, dp[n & 1][i][j]);
  }
  printf("%d\n", ans == 1e9 ? -1 : ans);
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
	int area1,area2;
		cin>>a>>b>>c>>d;
	area1=a*b;
	area2=c*d;
	//cin>>a>>b>>c>>d;
	if(area1>area2)
	{
		cout<<a*b ;
	}
	else
			cout<<c*d ;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int d = 0;

		for (int i = 0; i < b; i++) {
			int c = input.nextInt();
			d = a - c;
			a = d;
		}

		if (d < 0) {
			d = -1;
		}
		System.out.println(d);
	}
}

Measured memory_bytes: 46428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) {}
#endif



int main(){
	ll n, m, k;
	cin >> n >> m >> k;
	
	vector<ll> asum(n+1);
	vector<ll> bsum(m+1);
	
	ll sum = 0;
	rep(i,n){
		asum[i] = sum;
		ll a;
		cin >> a;
		sum += a;
	}
	asum[n] = sum;
	
	sum = 0;
	rep(i,m){
		bsum[i] = sum;
		ll b;
		cin >> b;
		sum += b;
	}
	bsum[m] = sum;
	
	ll aread = 0;
	ll bread = m;
	
	while ( asum[aread] + bsum[bread] <= k && aread <= n )
		aread++;
	if ( aread )
		aread--;
	
	ll readmax = 0;
	for ( ; aread <= n; aread++ ){
		while ( asum[aread] + bsum[bread] > k && bread >= 0 )
			bread--;
		if ( bread < 0 )
			break;
		chmax( readmax, aread+bread );
	}
	
	cout << readmax << endl;
	
	
	return 0;
}




Measured memory_bytes: 6428
#include <iostream>
using namespace std;
int main(){
	int sec, h, m, s;
	
	cin >> sec;
	
	h = sec / 3600;
	m = sec % 3600 / 60;
	s = sec % 3600 % 60;
	cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;


int gcd(int x,int y){
    return (y==0)? x:gcd(y,x%y);
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    
    int N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    vint a(N),b(N),c(N);
    repeat(i, N){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[2][420][420];
    int gcddp[420][420];
    repeat(aa, 420){
        repeat(bb, 420){
            dp[0][aa][bb] = INF;
            dp[1][aa][bb] = INF;
            gcddp[aa][bb] = INF;
        }
    }
    dp[0][0][0] = 0;
    int bit=0;
    repeat(i, N){
        bit = !bit;
        //cout << bit << endl;
        repeat(aa, 400){
            repeat(bb, 400){
                if(dp[!bit][aa][bb] == INF)
                    continue;
                dp[bit][aa][bb] = min(dp[bit][aa][bb],dp[!bit][aa][bb]);
                if(aa != 0 && bb != 0){
                    int g = gcd(aa,bb);
                    gcddp[aa/g][bb/g] = min(gcddp[aa/g][bb/g],dp[bit][aa][bb]);
                }
                int na = aa+a[i];
                int nb = bb+b[i];
                dp[bit][na][nb] = min(dp[bit][na][nb],dp[!bit][aa][bb]+c[i]);
                int ng = gcd(na,nb);
                gcddp[na/ng][nb/ng] = min(gcddp[na/ng][nb/ng],dp[bit][na][nb]);
            }
        }
    }
    int ans = gcddp[Ma][Mb];
    if(ans == INF)
        ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;
    ll K;cin>>N>>K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    vector<ll> B(N,0),C(N,0);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(A[i]>A[j]){
                if(i>j) B[i]++;
                C[i]++;
            }
        }
    }
    
    ll ans=0;
    
    for(int i=0;i<N;i++){
        ans+=((1+K)*K/2)%mod*C[i]-(K*B[i])%mod+mod;
        ans=ans%mod;
        //cout<<B[i]<<" "<<C[i]<<endl;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
    cin >> a;
    // スペース区切りの整数の入力
    //int b,c;
    //cin >> b >> c;
    // 文字列の入力
    string s, t;
    //cin >> s;
    // 出力
    s = "ABC";
    t = "ARC";
    if(a>=1200)
        cout << t << endl;
    else
        cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
fun main() {
    val s = readLine()!!.toString()
    val t = readLine()!!.toString()

    val lenDiff = s.length - t.length
    (0..lenDiff).map { i ->
        val sub = s.substring(i, i + t.length)
        sub.zip(t) { sc, tc -> sc == tc}.count { it }
    }.max()!!.let { println(t.length - it) }
}

Measured memory_bytes: 40104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	vector<int>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	vector<int>v(3);
	rep(i, 3) {
		v[i] = V[i];
	}
	sort(V);
	if (V[1] == v[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using Graph = vector<vector<int>>;

void dfs(int v,const Graph &G,vector<int> &seen,vector<int> &dis) {
  seen[v] = 1;
  for(int nv:G[v]) {
    if(seen[nv]) continue;
    dis[nv] = dis[v] + 1;
    dfs(nv,G,seen,dis);
  }
}

int main() {

  int N,u,v;
  cin >> N >> u >> v;

  u--; v--;
  vector<vector<int>> e(N,vector<int>(0));
  for(int i = 0;i < N-1;i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  vector<int> seen(N,0),T(N,0),A(N,0);
  dfs(u,e,seen,T);
  seen.assign(N,0);
  dfs(v,e,seen,A);

  int ans = 0;
  for(int i = 0;i < N;i++) {
    if(T.at(i) < A.at(i)) ans = max(ans,A.at(i));
  }

  cout << ans-1 << endl;



  
}


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

long long dp[3000][3000][4];
int arr[3000][3000];

long long rec(int i, int j, int p)
{
  if(dp[i][j][p]!=-1) return dp[i][j][p];
  if(i==0 && j == 0 && p!=0) return dp[i][j][p] = arr[i][j];
  else if(i==0 && j==0) return dp[i][j][p]=0;

  long long m1 = 0, m2 = 0, m3 = 0;
  if(j> 0){
    if(p>0)
      if(arr[i][j]!=0)
        m1 = rec(i, j-1, p-1)+arr[i][j];
      m2 = rec(i, j-1, p);
  }
  if(i>0){
    m3 = rec(i-1,j,3);
    if(p!=0)
      m3 += arr[i][j];

  }

  return dp[i][j][p] = max(m1, max(m2, m3));
}

int main()
{
    int i, j, r, c, k;
    cin >> r>> c>> k;
    for(i=0;i<3000; i++)
      for(j=0;j<3000; j++)
        for(int c1=0;c1<4;c1++)
          dp[i][j][c1]=-1;
    for(i=0;i<k;i++)
    {
      int a,b,c;
      cin >>a>>b>>c;
      arr[a-1][b-1] =c;
    }
    long long ans = rec(r-1, c-1, 3);

    cout<<dp[r-1][c-1][3]<<endl;
}


Measured memory_bytes: 320476
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    half = int(len(d) / 2)
    d = sorted(d)
    bef = list(d[:half])
    aft = list(d[half:])
    ans = aft[0] - bef[len(bef) - 1]
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)


if __name__ == "__main__":
    main()


Measured memory_bytes: 15988
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = inp()
a = inpl()
ans = 0
for i in range(0, n, 2):
    if a[i] % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 68360
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  VV<int> v(3,V<int>(3));
  rep(i,0,3)rep(j,0,3)cin>>v[i][j];

  int n;cin>>n;
  rep(i,0,n){
    int x;cin>>x;
    rep(j,0,3)rep(k,0,3)if(v[j][k]==x)v[j][k]=-1;
  }

  bool ans=false;
  rep(i,0,3){
    if(v[i][0]==v[i][1] && v[i][1]==v[i][2])ans=true;
    if(v[0][i]==v[1][i] && v[2][i]==v[1][i])ans=true;
  }
  if(v[0][0]==v[1][1] && v[1][1]==v[2][2])ans=true;
  if(v[2][0]==v[1][1] && v[1][1]==v[0][2])ans=true;

  if(ans)cout<<"Yes"<<ENDL;
  else cout<<"No"<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll parent[200005];
ll rating[200005];
ll fre[200005];
ll find_parent(ll x){
    while(parent[x]!=x)
        x = parent[x];
    return x;
}
void make_union(ll x,ll y){
    ll par1 = find_parent(x);
    ll par2 = find_parent(y);
    if(rating[par1]>=rating[par2]){
        parent[par2] = par1;
        rating[par1]++;
    }
    else{
        parent[par1] = par2;
        rating[par2]++;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin >> n >> m;
    for (i = 1; i <= n;i++)
        parent[i] = i;
    for (i = 1; i <= m; i++)
    {
        cin >> k >> l;
        make_union(k, l);
    }
    ll maxi = 0;
    for (i = 1; i <= n;i++){
        parent[i] = find_parent(i);
        fre[parent[i]]++;
        maxi = max(maxi, fre[parent[i]]);
    }
    cout << maxi << "\n";
    return 0;
}

Measured memory_bytes: 7860
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String s = sc.next();
			String t=sc.next();
			int sl = s.length(),tl=t.length();
			short[][] dp = new short[sl+1][tl+1];
			int max=0;
			for(int i=1;i<sl+1;i++){
				for(int j=1;j<tl+1;j++){
					if(s.charAt(i-1)==t.charAt(j-1)){
						dp[i][j] = (short) (dp[i-1][j-1]+1);
						max = Math.max(max, dp[i][j]);
					}else{
						dp[i][j]=0;
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 120632
def input_data_set
  data_count = gets.strip.to_i
  return data_sets if data_count.nil? || data_count.to_i == 0
  data_count.times.map{ gets }
end

data_set = input_data_set
=begin
data_set = [
  "Hoshino",
  "Hashino",
  "Masayuki Hoshino was the grandson of Ieyasu Tokugawa.",
]
=end

data_set.each{ |s| print s.gsub(/Hoshino/, "Hoshina") }

Measured memory_bytes: 6116
n = int(input())
w = []
status = True

for i in range(n):
    w.append(input())

x = list(set(w))

if len(w) != len(x):
    status = False
else:
    for i in range(n-1):
        a = ""
        b = ""
        a = w[i]
        b = w[i+1]
        if a[-1] == b[0]:
            pass
        else:
            status = False
            break

if status:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<pii> T;
    for(int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        T.pb({l+x, x});
    }
    sort(all(T));
    int last = -INF, cnt = 0;
    for(int i = 0; i < n; i++){
        int l = T[i].fi - T[i].se;
        int x = T[i].se;
        if(last > x - l) continue;
        last = l+x;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1400
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
pos = [10**10]+[a[i]-b[i] for i in range(n) if a[i] > b[i]]
neg = [b[i]-a[i] for i in range(n) if a[i] < b[i]]
pos.sort(reverse=True)
pos[0] = 0
for i in range(len(pos)-1): pos[i+1] += pos[i]
need = sum(neg)
ans = len(neg)
for i in range(len(pos)):
    if pos[i] >= need:
        ans += i
        break
else:
    ans = -1
print(ans)

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

bool comp(const pair<int, int>& a, const pair<int, int>& b) {
  return a.first > b.first;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<pair<int, int>> B(N);
  rep(i, N) {
    cin >> A[i];
    B[i] = make_pair(A[i], i);
  }

  sort(B.begin(), B.end(), comp);

  rep(i, N) {
    int ans;
    rep(j, N) {
      if (B[j].second == i)
        continue;
      ans = B[j].first;
      break;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3968
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
bit = [0 for i in range(32)]
for i in range(32):
    for i2 in A:
        if (i2 >> i) & 1:
            bit[i] += 1
ans = [0 for i in range(len(A))]
for i in range(32):
    for i2 in range(len(A)):
        if bit[i] % 2 == 0:
            if (A[i2] >> i) & 1:
                ans[i2] += 2 ** i
        else:
            if not (A[i2] >> i) & 1:
                ans[i2] += 2 ** i
print(" ".join(map(str,ans)))

Measured memory_bytes: 114444
N, K = map(int,input().split(' '))
S = input()
S2=[]
key=S[0]
tmpcnt=1
if key=='0':
    S2.append(0)
S2.append(0)
S2.append(0)
for i in range(1,len(S)):
    if key!=S[i]:
        if key == '0':
            S2.append(-1*tmpcnt)
        else:
            S2.append(tmpcnt)
        key=S[i]
        tmpcnt=1
    else:
        tmpcnt+=1
if key == '0':
    S2.append(-1*tmpcnt)
    S2.append(0)
    S2.append(0)
else:
    S2.append(tmpcnt)
    S2.append(0)
    S2.append(0)
#print(S2)
max=0
tmp=S2[0]
maxj=len(S2)-1
for j in range(1,K*2+1):
    tmp+=abs(S2[min(0+j,maxj)])
    #print(S2[i],S2[min(i+j,maxj)])
if tmp >= max:
    max=tmp
    #print(tmp)

for i in range(2,len(S2),2):
    tmp-=abs(S2[i-1])
    tmp-=abs(S2[i-2])
    tmp+=abs(S2[min(i+j-1,maxj)])
    tmp+=abs(S2[min(i+j,maxj)])
    #print(i-1,i-2,i+j-1,i+j)
    #print(tmp)
    if tmp>= max:
        max=tmp
print(max)


Measured memory_bytes: 4212
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  int X;
  cin >> X;

  int res = 0;
  while (X) {
    int i = 2;
    for (i = 2; i < X; i++) {
      if (X % i == 0) {
        break;
      }
    }
    if (i == X)
      break;
    X++;
  }

  cout << X << endl;


  return 0;
}

Measured memory_bytes: 3636
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn list_std(n: usize, cur: &mut String, used_kind: u8) -> Vec<String> {
    if cur.len() == n {
        return vec![cur.clone()];
    }

    // Do not use new character
    let mut res: Vec<String> = vec![];
    for k in 0..used_kind {
        cur.push(('a' as u8 + k) as char);
        let mut tmp = list_std(n, cur, used_kind);
        res.append(&mut tmp);
        cur.pop();
    }

    // Use new character
    if cur.len() > 0 {
        cur.push(('a' as u8 + used_kind) as char);
        let mut tmp = list_std(n, cur, used_kind + 1);
        res.append(&mut tmp);
        cur.pop();
    }
    res
}

fn main() {
    let n: usize = read_as_vec()[0];
    let mut ans = list_std(n, &mut String::from(""), 1);
    ans.sort();

    for s in ans {
        println!("{}", s);
    }
}


Measured memory_bytes: 12272
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
 
a.append(x)
a = sorted(a)
 
index = a.index(x)
if index < len(a) - (index + 1):
    print(index)
else:
    print(len(a) - (index + 1))


Measured memory_bytes: 2940
#include <iostream>
#include <time.h>

using namespace std;
int main()
{
	int N, M, a = 2, count = 0, aaa = 1, check = 0;
	cin >> N;

	for (int i = 103; i <= N; i+=2) {
		M = i;
		aaa = 1;
		a = 2;
		count = 0;

		while (M >= a) {
			if (M % a == 0) {
	

				count++;
				M /= a;
			}
			else {
				if (count != 0) {
					aaa = aaa * (count + 1);
				}
				count = 0;
				a++;
			}
		}
		if (count != 0) {
			aaa = aaa * (count + 1);
		}

		if (aaa == 8) {
			check++;
		}
	}
	cout << check;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int n;
    cin >> n;
    int sum = 0;
    for(int i = 0;i < to_string(n).size();i++)
    {
        sum += to_string(n)[i] - '0';
    }
    if(n % sum == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main() {
    int E;int Y;cin>>E>>Y;
    Y--;
    if(E==1)cout<<1868+Y<<endl;
    if(E==2)cout<<1912+Y<<endl;
    if(E==3)cout<<1926+Y<<endl;
    if(E==4)cout<<1989+Y<<endl;
    if(E==0){
        Y++;
        if(Y>=1989)cout<<'H'<<Y-1989+1<<endl;
        else if(Y>=1926)cout<<'S'<<Y-1926+1<<endl;
        else if(Y>=1912)cout<<'T'<<Y-1912+1<<endl;
        else cout<<'M'<<Y-1868+1<<endl;
    }
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(x,y) memset(x,y,sizeof(x))

ll num[2000005],cont[200005];

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

    ll i,j,k,s,d,r,m,n;
    cin>>n;
    for(i=1; i<=n; i++) cin>>r, num[r]=i;

    m=1; d=1;
    for(i=2; i<=n; i++)
    {
        if(num[i]>num[i-1]) d++, m = max(m, d);
        else d=1;
    }
    cout<<n-m<<endl;
}




Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, h, w;
    cin >> n >> h >> w;
    ll ans = 0;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        if(a>=h&&b>=w)ans++;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

ll n;
ll a[5];
ll mi = INF*INF;
int mem;
int main() {
    cin >> n;

    for (ll i=0;i<5;i++) {
        cin >> a[i];
        if (mi > a[i]) {
            mi = a[i];
            mem = i;
        }
    }
    ll ans;
    if(n%mi != 0)  ans = n/mi + 5;
    else ans = n/mi + 4;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int dx[8]={0,0,-1,1,-1,-1,1,1};
int dy[8]={1,-1,0,0,-1,1,-1,1};
int h,w;

int maze[51][51];
bool seen[51][51];
void dfs(int x,int y){
     seen[x][y]=true;
     rep(i,8){
          int nx,ny;
          nx=x+dx[i];ny=y+dy[i];
          if (nx >= 0 && nx < h && ny >= 0 && ny < w && maze[nx][ny] == 1){ 
               if (seen[nx][ny]) continue;
               dfs(nx,ny);
          }   
     }
     
}

int main(){
     bool can = true;
     while(can){
          cin >> w >> h;
          if (h == 0 && w==0) {
               can = false;
               break;
          }
          int ans=0;
          rep(i,h) rep(j,w) seen[i][j]=false;

          rep(i,h) rep(j,w) cin >> maze[i][j];
          rep(i,h) rep(j,w){
               if (!seen[i][j] && maze[i][j] == 1) {
                    ans++;
                    //printf("(i,j) = (%d,%d)\n",i,j);
                    dfs(i,j);
               }
          }
          cout << ans << endl;
     }
    
     
     return 0;
}




Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	string S; cin >> S;
	if (N % 2) {
		cout << "No" << endl;
	}
	else {
		rep(i, 0, N / 2) {
			if (S[i] != S[i + N / 2]) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    rep(i, N-1){
        if(A[i] == A[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 1024
implicit none
character(200000) :: s
integer :: n,a,z,i
read *,s
n = len_trim(s)
do i = 1, n
   if (s(i:i) == 'A') then
      a = i
      exit
   endif
enddo
do i = n, 1, -1
   if (s(i:i) == 'Z') then
      z = i
      exit
   endif
enddo
print '(i0)',z-a+1
end

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

#define ll long long

using namespace std;

int n, w;

ll dp[(int)1e7 + 7];

main() {
	scanf("%d %d", &n, &w);
	memset(dp, -1, sizeof dp);
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		for (int j = w; j >= a; j--) {
			if (dp[j - a] != -1)
				dp[j] = max(dp[j], dp[j - a] + b);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= w; i++) {
		ans = max(ans, dp[i]);
	} 
	cout << ans;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


ll a, b, x;

int main(){
	cin >> a >> b >> x;
	
	cout << b/x - a/x + !(a%x) << endl;
	
	return 0;
}

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

using namespace std;

vector<pair<int,int> >vec;

int main(){

	int N,M;

	scanf("%d %d",&N,&M);

	int i;

	for(i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		vec.push_back(make_pair(b,a));
	}

	sort(vec.begin(),vec.end());

	int ans=0;
	int endtime=0;

	for(i=0;i<M;i++){
		if(endtime<=vec[i].second){
			endtime=vec[i].first;
			ans++;
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using ll = long long;
using namespace std;

int main()
{
  string S;
  cin >> S;

  int out = 0;
  for( int i=0;i<3;i++ )
    {
      if( S[i] == '1')
	out += 9;
      else if(S[i] == '9')
	  out += 1;
      else
	out += int(S[i]-'0');
      if( i!= 2)
	out *= 10;
    }
  cout << out << endl;
}


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

int main(void){
	string str;
	cin>>str;
	map<char,int> m;
	for(int i=0;i<4;i++){
		m[str[i]]+=1;
	}
	if(m[str[0]]==2&&m[str[1]]==2&&m[str[2]]==2&&m[str[3]]==2){cout<<"Yes";}else{cout<<"No";}
}


Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            while ((line = br.readLine()) != null) {
            	String[] list = line.split(" ", 0);
            	int a = Integer.parseInt(list[0]);
            	int b = Integer.parseInt(list[1]);
            	
            	if(a < b){
            		System.out.println("a < b");
            	}else if(a > b){
            		System.out.println("a > b");
            	}else if(a == b){
            		System.out.println("a == b");
            	}
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

int main()
{
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) cin >> s[i];

    int ans = 0;
    int both, b, a;
    both = b = a = 0;
    for (auto str : s)
    {
        for (int i = 0; i < str.size() - 1; i++)
        {
            // cout << 'a'<<endl;
            if (str[i] == 'A' and str[i+1] == 'B')
                ++ans;
        }
        if (str[0] == 'B' and str[str.size()-1] == 'A')
            ++both;
        else if (str[0] == 'B')
            ++b;
        else if (str[str.size() - 1] == 'A')
            ++a;
        // cout << str << ' ' << both << ' ' << a << ' ' << b << endl;
    }
    // cout << ans << ' ' << both << ' ' << a << ' ' << b << endl;

    if (both > 0)
    {
        ans += both - 1;
        both = 1;
    }
    // cout << ans << ' ' << both << ' ' << a << ' ' << b << endl;

    ans += min(a, b);
    if (max(a, b) > 0)
        ans += both;
    // cout << ans << ' ' << both << ' ' << a << ' ' << b << endl;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;
int a[200010];
int imos[200010];
signed main(){
  int n,k;cin>>n>>k;
  rep(i,n)cin>>a[i];
  rep(ima,k){
    rep(i,n){
      if(i-a[i]>=0)imos[i-a[i]]++;
      else imos[0]++;
      if(i+a[i]<=n-1)imos[i+a[i]+1]--;
      else imos[n]--;
    }
    int cnt=0;
    rep(i,n){
      if(i==0)a[0]=imos[0];
      else a[i]=a[i-1]+imos[i];
      if(a[i]==n)cnt++;
      imos[i]=0;
    }
    if(cnt==n){break;}
  }
  rep(i,n)cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 6720
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void){
    int n, m, a[50], b[50], c[50], d[50];
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; i++) scanf("%d%d", &a[i], &b[i]);
    for(int i=0; i<m; i++) scanf("%d%d", &c[i], &d[i]);

    for(int i=0; i<n; i++){
        int check=0;
        float ans = INFINITY;
        for(int j=0; j<m; j++){
            int judge = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(ans>judge){
                ans = judge;
                check = j+1;
            }
        }
        printf("%d\n", check);
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    vector<string> s(h);
    vector<bool> f(h),g(w);
    rep(i,h) cin>>s[i];
    rep(i,h){
        rep(j,w)if(s[i][j]=='#'){
            f[i] = true;
            break;
        }
    }
    rep(j,w){
        rep(i,h)if(s[i][j]=='#'){
            g[j] = true;
            break;
        }
    }
    rep(i,h){
        if (!f[i]) continue;
        rep(j,w)if(g[j]){
            cout<<s[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main()
{
	ll n, m, c;
	ll a[25], b[25];
	ll state;
	ll ans = 0;

	scanf("%lld %lld %lld", &n, &m, &c);
	for (ll i = 0; i < m; i++) {
		scanf("%lld", &b[i]);
	}

	for (ll i = 0; i < n; i++) {

		state = 0;
		for (ll i = 0; i < m; i++) {
			scanf("%lld", &a[i]);
			state = state + (a[i] * b[i]);
		}
		state = state + c;

		if (state > 0) {
			ans++;
		}
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n];
  int flag = 0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    if(arr[i]%2==0)
      if(arr[i]%3!=0&&arr[i]%5!=0)
        flag++;
  }
    if(flag==0)
      cout<<"APPROVED";
    else
      cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
l = [0] * (m+1)
ans = 0
for i in range(n):
    s = list(map(int, input().split()))
    for t in s[1:]:
        l[t] += 1
for j in l:
    if j==n:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll a,b;
cin>>a>>b;
ll gcd=__gcd(a,b);
ll ans=(a*b)/gcd;
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

 

int main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
ll n;
cin>>n;
ll a[n],b[n];
rep(i,0,n)
cin>>a[i],
cin>>b[i];
ll ans=0;
ll cnt=0;
rep(i,n,0)
{
	a[i]=a[i]+cnt;
	if(a[i]%b[i]==0)
	continue;
	ll x=a[i]/b[i];
//	cout<<a[i]<<" "<<b[i]<<" ";
	ll y=(x+1)*b[i];
//	cout<<y<<" ";
	y-=a[i];
///	cout<<y<<endl;
	cnt+=y;
}
cout<<cnt;


}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   int x, y;
   cin >> x >> y;

   cout<<x*y;

   
   

   return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);

typedef std::pair<int, int> pii;

template<typename T>
void print_array(T *A_, s32 size) {
  //printf("%d\n", size);
  if( size != 0 ) {
    for(int i = 0; i < size - 1; ++i) {
      printf("%d ", A_[i]);
    }
    printf("%d\n", A_[size - 1]);
  }
}


auto main() -> int {

  for(;;) {
    int n, m;
    std::cin >> n >> m;
    if( n == 0 and m == 0 ) break;

    std::vector< pii > vpii;
    for(int i = 0; i < n; ++i) {
      int d, p;
      std::cin >> d >> p;
      vpii.push_back( pii(p, d) );
    }
    std::sort(vpii.begin(), vpii.end());
    std::reverse(vpii.begin(), vpii.end());

    int res = 0;
    for(int i = 0; i < n; ++i) {
      if( vpii[i].second <= m ) {
        m -= vpii[i].second;
      }
      else {
        res += (vpii[i].second - m) * vpii[i].first;
        for(int j = i + 1; j < n; ++j) {
          res += vpii[j].first * vpii[j].second;
        }
        break;
      }
    }
      
    std::cout << res << std::endl;
    
  }
  
  return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


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

    int ans = 0;
    int prev_a = 101;
    REP(i, n) {
        int a;
        cin >> a;
        if(prev_a == a)  {
            ans++;
            prev_a = 101;
        } else {
            prev_a = a;
        }
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for(char c : s.toCharArray()) {
			if(c=='1') count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
using namespace std;

typedef long long int lli;

lli N, ans;
map<lli, int> primes;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    lli t = N;
    for(lli n = 2; n * n <= N && t > 1; ++n){
        if(t % n) continue;
        primes[n] = 1;
        t /= n;
        while(t % n == 0){
            t /= n;
            primes[n]++;
        }
    }
    if(t > 1){
        primes[t] = 1;
    }
    for(auto itr = primes.begin(); itr != primes.end(); ++itr){
        int c = itr->second;
        int n = (-1 + sqrt((double)1 + 8 * c)) / 2;
        ans += n;
    }
    cout << ans;
    return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		sc.nextLine();
		String s;
		int length = 0;
		int leftB = 0;
		int rightA = 0;
		int numAB = 0;
		int lr = 0;
		for(int i = 1; i <= N; i++){
			s = sc.nextLine();
			length = s.length();
			if(s.substring(0,1).contentEquals("B")) {
				leftB ++;
				if(s.substring(s.length()-1,s.length()).contentEquals("A")) {
					rightA ++;
					lr ++;
				}
			}
			else if(s.substring(s.length()-1,s.length()).contentEquals("A")) {
				rightA ++;
			}
			
			s = s.replace("AB", "X");
			numAB += length - s.length();
		}
		//System.out.println(numAB);
		//System.out.println(leftB);
		//System.out.println(rightA);
		//System.out.println(lr);
		
		if(leftB == rightA) {
			if(lr != leftB || leftB == 0) {
				System.out.println(numAB + leftB);
			}else {
				System.out.println(numAB + leftB-1);
				}	
		}else {
			System.out.println(numAB + Math.min(leftB,  rightA));
		}
	}
}

Measured memory_bytes: 45968
#!/usr/bin/env python3
import sys

def main():
    N = int(input())
    a = list(map(int,input().split()))
    b = sorted(a, reverse=True) # aを大きい順に並べる
    
    Alice = 0
    Bob = 0


    for i in range(N):
        if i % 2 == 0:
            Alice += b[i]
        else:
            Bob += b[i]
    
    print(Alice - Bob)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int k=gi();
	    int[] n= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	    
	    System.out.print(n[k-1]);
//	    if (a==b && b==c) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35300