akhauriyash/Code-Regression huggingface dataset:
/* Author: Jason L.(int3xccATgmailDOTcom), Fri May  4 23:45:24 CST 2018 */
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pll = pair<ll, ll>; using dd = long double;
//=========================================================================
namespace {
static bool constexpr dbg =
#ifdef INT3XCC_DEBUG
        1;
#else
        0;
#endif
#define Dprintf(fmt, ...) do{if(dbg) printf(fmt, ##__VA_ARGS__);}while(0)
#define Ddump(expr) do{if(dbg) cout<<#expr<<" = "<<expr<<'\n';}while(0)
#define REP0(i, n) for (ll i = 0, ii_ = (n); i <  ii_; ++i)
#define REP1(i, n) for (ll i = 1, ii_ = (n); i <= ii_; ++i)
//=========================================================================
ll constexpr N = 2.1e5;
ll n, d[N+9];
//=========================================================================
void init() {
    cin>>n; REP1(i, n) cin>>d[i];
}
void solve() {
    ll res = 0, sum = 0;
    map<ll, ll> mp; mp[0] = 1;
    REP1(i, n) {
        if (mp.count(sum+d[i])) res += mp[sum+d[i]];
        sum += d[i];
        ++mp[sum];
    }
    cout<<res;
}}
//=========================================================================
int main() {
    if (!dbg) { std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
    cout<<fixed<<setprecision(20); init(); solve(); return 0;
}


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

const int H_MAX = 1e5, MOD = 1e9 + 7;

int h, w, a, b;

int ans, lin, col;
int fact[2 * H_MAX + 2];

void factorial();
int exp(int a, int b);
int comb(int n, int k);

int main()
{
    factorial();

    cin >> h >> w >> a >> b;

    int row, col = b + 1, cur, i, j;
    for(row = 1; row < h - a; row++)
    {
        cur = comb(row + col - 2, col - 1);

        i = h - row + 1, j = w - col;
        cur = (1LL * cur * comb(i + j - 2, j - 1)) % MOD;

        ans = (1LL * ans + cur) % MOD;
    }

    row = h - a;
    cur = comb(row + col - 2, col - 1);

    i = h - row + 1, j = w - col + 1;
    cur = (1LL * cur * comb(i + j - 2, j - 1)) % MOD;

    ans = (1LL * ans + cur) % MOD;

    cout << ans << '\n';

    return 0;
}

void factorial()
{
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= 2 * H_MAX; i++)
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
}

int exp(int a, int b)
{
    int ans;
    for(ans = 1; b; b >>= 1)
    {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        a = (1LL * a * a) % MOD;
    }

    return ans;
}

int comb(int n, int k)
{
    return (1LL * fact[n] * exp(fact[k], MOD - 2) % MOD * exp(fact[n - k], MOD - 2) % MOD) % MOD;
}


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

using namespace std;

#define int long long

const int MAXN = 1e5 + 7;
const int INF = 1e18 + 7;

int a[MAXN];

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

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a[i];

    int ans = INF;
    for (int i = 0; i + k - 1 < n; ++i) {
        int l = i;
        int r = i + k - 1;
        ans = min(ans, abs(a[l]) + (a[r] - a[l]));
        ans = min(ans, abs(a[r]) + (a[r] - a[l]));    
    }   

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=998244353;
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
ll extgcd(ll a, ll b, ll& x, ll&y){
    ll d=a;
    if(b!=0){
        d=extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else {
        x=1; y=0;
    }
    return d;
}
ll mod_inverse(ll a, ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
//n!modp
ll fact[300020]; //0<=n<pについてn! modpのテーブルO(p)
//n!=a p＾eとした時のa modpを求める。O(log_p n)
ll mod_fact(ll n, ll p, ll& e){
    e=0;
    if(n==0) return 1;
    
    //pの倍数の部分を計算
    ll res=mod_fact(n/p,p,e);
    e+=n/p;
    
    //(p-1)!≡-1なので(p-1)!^(n/p)はn/pの偶奇だけで計算できる
    if(n/p%2!=0) return res*(p-fact[n%p])%p;
    return res*fact[n%p]%p;
}

//nCk modpを求める。O(log_p n)
ll mod_comb(ll n, ll k, ll p){
    if(n<0||k<0||n<k) return 0;
    ll e1, e2, e3;
    ll a1=mod_fact(n,p,e1), a2=mod_fact(k,p,e2), a3=mod_fact(n-k,p,e3);
    if(e1>e2+e3) return 0;
    return a1*mod_inverse(a2*a3%p,p)%p;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,A,B,K;
    cin>>N>>A>>B>>K;
    ll x,y;
    ll g=extgcd(A, B, x, y);
    if(K%g){
        cout <<0<<"\n";
        return 0;
    }
    x*=K/g;
    y*=K/g;
    ll m=max(-g*x/B,(y-N)*g/A), M=min(g*y/A,(N-x)*g/B);
    fact[1]=1;
    rep(i,2,300020){
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
    }
    ll ans=0;
    rep(i,m,M+1){
        ans+=mod_comb(N, x+B/g*i, MOD)*mod_comb(N, y-A/g*i, MOD);
        ans%=MOD;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <stack>
#include <stdlib.h>

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

struct range{
	bool a[256];
	range(){
		for(int i = 0; i < 256; i++) a[i] = false;
	}
	range(int v){
		for(int i = 0; i < 256; i++) a[i] = (v == i);
	}
	range(int u, int v){
		for(int i = 0; i < 256; i++) a[i] = (i >= u && i <= v);
	}
	range operator+(const range& ope){
		range ret;
		for(int i = 0; i < 256; i++){
			for(int j = 0; j < 256; j++){
				if(this->a[i] && ope.a[j]) ret.a[(i+j)%256] = true;
			}
		}
		return ret;
	}
	range operator-(const range& ope){
		range ret;
		for(int i = 0; i < 256; i++){
			for(int j = 0; j < 256; j++){
				if(this->a[i] && ope.a[j]) ret.a[(i+256-j)%256] = true;
			}
		}
		return ret;
	}
	range operator*(const range& ope){
		range ret;
		for(int i = 0; i < 256; i++){
			for(int j = 0; j < 256; j++){
				if(this->a[i] && ope.a[j]) ret.a[(i*j)%256] = true;
			}
		}
		return ret;
	}
	range operator/(const range& ope){
		range ret;
		for(int i = 0; i < 256; i++){
			for(int j = 0; j < 256; j++){
				if(this->a[i] && ope.a[j]) ret.a[(i/j)%256] = true;
			}
		}
		return ret;
	}
	
};

int m, n;
map<string, range> mp;
stack<range> stk;

int main(void)
{
	cin >> m;
	
	range tmp;
	string name; int lb, ub;
	
	for(int i = 0; i < m; i++){
		cin >> name >> lb >> ub;
		for(int j = 0; j < 256; j++){
			mp[name] = range(lb, ub);
		}
	}
	
	string s;
	range ope1, ope2;
	bool ans = true;
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s;
		
		int v = atoi(s.c_str());
		if(v != 0) stk.push(range(v));
		else if(v == 0 && s == "0") stk.push(range(0));
		else{
			
			if(s == "+"){
				ope2 = stk.top(); stk.pop();
				ope1 = stk.top(); stk.pop();
				stk.push(ope1 + ope2);
			}else if(s == "-"){
				ope2 = stk.top(); stk.pop();
				ope1 = stk.top(); stk.pop();
				stk.push(ope1 - ope2);
			}else if(s == "*"){
				ope2 = stk.top(); stk.pop();
				ope1 = stk.top(); stk.pop();
				stk.push(ope1 * ope2);
			}else if(s == "/"){
				ope2 = stk.top();
				if(ope2.a[0]){
					ans = false;
					goto end;
				}
				stk.pop();
				ope1 = stk.top(); stk.pop();
				stk.push(ope1 / ope2);
			}else{
				stk.push( mp[s] );
			}
		}
		
	}
	
	end:;
	if(ans) cout << "correct" << endl;
	else cout << "error" << endl;
	
	return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#define INF (1 << 30)
using namespace std;

int main() {
    int N, min_count = INF, count, six, nine;
    cin >> N;
    for (int i = 0; i <= N; i++) {
        count = 0;
        six = i;
        while (six > 0) {
            count += six % 6;
            six /= 6;
        }
        nine = N - i;
        while (nine > 0) {
            count += nine % 9;
            nine /= 9;
        }
        min_count = min(min_count, count);
    }
    cout << min_count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

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

    stack<s64> s;

    char str[2000];
    scanf("%2000[^\n]", str);
    char *ptr = strtok(str, " ");
    while (ptr != NULL)
    {
        if (ptr[0] == '+')
        {
            s64 y = s.top();
            s.pop();
            s64 x = s.top();
            s.pop();
            s.push(x + y);
        }
        else if (ptr[0] == '-')
        {
            s64 y = s.top();
            s.pop();
            s64 x = s.top();
            s.pop();
            s.push(x - y);
        }
        else if (ptr[0] == '*')
        {
            s64 y = s.top();
            s.pop();
            s64 x = s.top();
            s.pop();
            s.push(x * y);
        }
        else
        {
            s.push(atoll(ptr));
        }

        ptr = strtok(NULL, " ");
    }

    cout << s.top() << "\n";

    return 0;
}



Measured memory_bytes: 3260
os = input()
import  collections
c = collections.Counter(os)
res = 99999
for k in c:
    s = os
    cnt = 0
    while True:
        # 一文字になったなら
        if len(collections.Counter(s)) == 1:
            break
        ss = ""
        for i in range(len(s) - 1):
            if s[i] == k or s[i+1] == k:
                ss += k
            else:
                ss += s[i]
        cnt += 1
        s = ss
    res = min(res, cnt)
print(res)


Measured memory_bytes: 43240
#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>;
using namespace std;

int main()
{
   vector<string> v = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

   string s;
   cin >> s;

   auto f = find(v.begin(), v.end(), s);

   auto d = distance(v.begin(), f);

   cout << 7 - d << endl;

    return 0;
}


Measured memory_bytes: 256
N,L=map(int,input().split())
A=list(map(int,input().split()))
sum_A=sum(A)

junban=[]
flg=False

for i in range(N-1):
    if A[i]+A[i+1]>=L:
        tmp=i
        flg=True


if flg:
    print("Possible")
    for i in range(N-1):
        if tmp>i:
            print(i+1)
        else:
            print(N+tmp-i-1)
else:
    print("Impossible")

Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010,mod=1000000007;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,k,a[1111],f[22][1111],fac[maxn],inv[maxn],invfac[maxn];
inline int C(int n,int m){
	if(n<0 || m<0 || n<m) return 0;
	return 1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod;
}
int main(){
	n=read();k=read();
	FOR(i,1,k) a[i]=read();
	fac[0]=fac[1]=inv[1]=invfac[0]=invfac[1]=1;
	FOR(i,2,n){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=mod-1ll*(mod/i)*inv[mod%i]%mod;
		invfac[i]=1ll*invfac[i-1]*inv[i]%mod;
	}
	f[0][0]=1;
	FOR(i,1,k) FOR(j,0,n) FOR(k,0,j) f[i][j]=(f[i][j]+1ll*f[i-1][j-k]*C(n-k,a[i]-k)%mod*invfac[k])%mod;
	printf("%d\n",int(1ll*f[k][n]*fac[n]%mod));
}
// why hard?

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

using namespace std;

int main(){
  long long n, m, a[100009], cumsum=0;
  map<long long, long long> mp;
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> a[i];
  mp[0]++;
  long long ans=0;
  for(int i=0;i<n;i++){
    cumsum=(cumsum+a[i])%m;
    ans+=mp[cumsum];
    mp[cumsum]++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 8276
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, y;
	cin >> n >> y;
	vector<int> result(3, -1);
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int c = n - i - j;
			int sum = i * 10000 + j * 5000 + c * 1000;
			if (sum == y && c >= 0 && c <= n) {
				result.at(0) = i;
				result.at(1) = j;
				result.at(2) = c;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		cout << result.at(i);
		if (i != 2) {
			cout << ' ';
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

bool cheak(string x[],string y[]){
  bool ans=true;
  for(int i=0;i<x[0].size();i++){
    if(x[i]!=y[i]){
      ans=false;
    }
  }
  return ans;
}

int main() {
  int N,M,ans=0;
  cin>>N>>M;
  string n[N];
  string m[M];
  for(int i=0;i<N;i++){
    cin>>n[i];
  }
  for(int i=0;i<M;i++){
    cin>>m[i];
  }
  for(int i=0;i<(N-M+1);i++){
    for(int j=0;j<(N-M+1);j++){
      string a[M];
      for(int k=0;k<M;k++){
        a[k]=n[k+j].substr(i,M);
      }
      if(cheak(a,m)){
        ans=1;
      }
    }
  }
  if(ans){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
      
}

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

int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  
  if(a == 0)cout << 1 << endl;
  else if(b == 0)cout << 2 << endl;
  else if(c == 0)cout << 3 << endl;
  else if(d == 0)cout << 4 << endl;
  else if(e == 0)cout << 5 << endl;
}

Measured memory_bytes: 3616
import math

# input
N = int(input())

# エラトステネスの篩で素数を列挙（table[q] = 0: qは素数, table[i] = j: iはjを素因数に持つ）
def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = dict()

    while prime_factor_table[n] != 0:
        if prime_factor_table[n] in prime_count.keys():
            prime_count[prime_factor_table[n]] += 1
        else:
            prime_count[prime_factor_table[n]] = 1
        n = int(n/prime_factor_table[n])
    if n in prime_count.keys():
        prime_count[n] += 1
    else:
        prime_count[n] = 1
    return prime_count

Ps = dict()
P_1000 = prime_factor_table(1000)
ans = 1

for i in range(2, N + 1):
    P_i = prime_factor(i, P_1000)
    for k in P_i.keys():
        if k in Ps.keys():
            Ps[k] += P_i[k]
        else:
            Ps[k] = P_i[k]

for k in Ps.keys():
    ans = (ans * (Ps[k] + 1)) % (10 ** 9 + 7)

print(ans)




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


using namespace std;

int main() {
  
  int n;
  int m;
  
  scanf ( "%i" , &n );
  
  map<int,int> One;
  map<int,int> Two;
  
  
  for ( int i = 0 ; i < n ; i++ ) {
    int tmp;
    scanf ( "%i" , &tmp );
    One[tmp]++;
  }
  
  scanf ( "%i" , &m );
  for ( int i= 0 ; i < m ; i++ ) {
    int tmp;
    scanf ( "%i" , &tmp );
    Two[tmp]++;
  }
  
  
  bool fail = false;
  
  for ( auto x : Two ) {
    
    if ( x.second > One[x.first] ) {
      fail = true;
    }
    
  }
  
  if ( fail ) printf ( "NO\n" );
  else printf ("YES\n" );
}


Measured memory_bytes: 18944
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
using namespace std;
int p(int h){
	int j=0;
	while(h){
		h/=10;
		j++;
	}
	return j;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF){
		cout<<p(a+b)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main()
{
    int n; cin >> n;
    set<int> s;
    rep(i, n){
        int a; cin >> a;
        s.insert(a);
    }
    puts(s.size()==n?"YES":"NO");

}

/*
g++ c.cpp
./a.out

oj d URL
oj t
*/

Measured memory_bytes: 9600
import java.util.*;class Main{public static void main(String[]v){Scanner s=new Scanner(System.in);for(int n,i,j,t,r=Integer.MAX_VALUE;(n=s.nextInt())>0;){int m=s.nextInt(),l=s.nextInt(),k=s.nextInt(),a=s.nextInt(),h=s.nextInt();long[][]p=new long[n][n];long e;for(i=n;i-->0;)Arrays.fill(p[i],r);int[]b=new int[n];for(b[a]=b[h]=1;l-->0;)b[s.nextInt()]=1;for(;k-->0;){i=s.nextInt();j=s.nextInt();t=s.nextInt();p[i][j]=p[j][i]=t;}f(n,p);for(i=n;i-->0;)for(j=n;j-->0;)if(p[i][j]>m||b[i]+b[j]<2)p[i][j]=r;f(n,p);System.out.println((e=p[a][h])<r?e+(e-m<0?0:e-m):"Help!");}}static void f(int n,long[][]p){int t=n,i,j;for(;t-->0;)for(i=n;i-->0;)for(j=n;j-->0;){long e=p[i][t]+p[t][j];if(p[i][j]>e)p[i][j]=e;}}}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;++i)cin >> A[i];
    multiset<int> s;
    for (int i=0;i<N;++i){
        auto itr=s.lower_bound(A[i]);
        if (itr==s.begin()) s.insert(A[i]);
        else s.erase(--itr),s.insert(A[i]);
    }
    cout << s.size() << endl;
}

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

int main() {
	ll N, H;
	cin >> N >> H;
	vector<ll> a(N);
	vector<ll> b(N);
	rep(i, N){
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	ll cnt = 0;
	while (H > 0){
		ll tmp_a, tmp_b;
		if (b.size() > 0){
			tmp_a = a.back();
			a.pop_back();
			tmp_b = b.back();
			b.pop_back();
			if (tmp_a >= tmp_b){
				while (H > 0){
					cnt++;
					H -= tmp_a;
				}
				break;
			}
			else {
				H -= tmp_b;
				a.push_back(tmp_a);
				cnt += 1;
			}
		}
		else {
			tmp_a = a.back();
			while (H > 0){
				cnt++;
				H -= tmp_a;
			}
			break;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4768
s=input()
t=input()
ma=0
a=[0,0]
dp=[[0 for i in range(len(t)+1)] for j in range(len(s)+1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        dp[i][j]=max(dp[i-1][j],dp[i][j-1])
        if s[i-1]==t[j-1]:
            dp[i][j]=max(dp[i][j],1+dp[i-1][j-1])
i=len(s)
j=len(t)

ss=""
while i and j:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ss+=s[i-1]
        i-=1
        j-=1
ss=ss[-1::-1]
print(ss)
    


Measured memory_bytes: 120540
#include<stdio.h>
#define MAX 10000
#define NOT_FOUND -1

int linear(int *A, int key, int n){
  int i = 0;
  A[n] = key;

  while(A[i] != key){
    //printf("A[i](%d) and key(%d) is different!\n", A[i], key);
    i++;
    if(i == n) return NOT_FOUND;
  }
  return A[i];
}

int main(){
  int i, n_S, n_T, cnt=0, find;
  int S[MAX], T[MAX];

  scanf("%d", &n_S);
  for(i=0; i<n_S; i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &n_T);
  for(i=0; i<n_T; i++){
    scanf("%d", &T[i]);
  }
  for(i=0; i<n_T; i++){
    if(linear(S, T[i], n_S-1) != NOT_FOUND){
      //printf("find!____%d\n", linear(S, T[i], n_S));
      cnt++;
    }
  }

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



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

template<ll mod, ll lim = static_cast<ll>(3e3)>
class Comb{
private:
    vector<vector<ll>> c;
public:
    Comb(): c{lim+1, vector<ll>(lim+1, 0LL)} {
        c[0][0] = c[1][0] = c[1][1] = 1;
        FOR(i, 1, lim)FOR(j, 0, i+1){
        (c[i+1][j+1] += c[i][j]) %= mod;
        (c[i+1][j] += c[i][j]) %= mod;
        }
    }

    ll query(int n, int r){
        if(n < r) return 0LL;
        return c[n][r];
    }
};

int main() {
    constexpr int mod = 1e9 + 7;
    int n, k; cin >> n >> k;

    Comb<mod> comb;

    FOR(i, 1, k + 1) {
        ll cut = comb.query(k - 1, i - 1);
        ll insert = comb.query((n-k) + 1, i);
        cout << cut * insert % mod << endl;
    }

    return 0;
}


Measured memory_bytes: 70784
import java.util.Scanner;

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

       while(true){

           String str = scan.next();

              if(str.equals("-")){

                 break;

              }

           int m = scan.nextInt();

              for(int i =0;i<m;i++){

                  int h = scan.nextInt();

                  str =str.substring(h,str.length())+str.substring(0,h);

              }

          System.out.println(str);

       }

       }
   }


Measured memory_bytes: 26720
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    int n,m;
    while(cin>>n>>m,n){
        int a[1000],ans=0;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        sort(a+1,a+n+1);
        reverse(a+1,a+n+1);
        for(int i=1;i<=n;i++){
            if(i%m!=0)ans+=a[i];
        }

        cout<<ans<<endl;
    }

    return 0;
}

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

int main()
{
    int i,N,even,odd;

    cin>>N;

    if(N%2==0)
    {
        even = N/2;
        cout<<even;
    }
    else{

        odd = N/2 + 1;
        cout<<odd;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int f(int a, int b) {
    if (a <= b) {
        return a;
    }
    return a - 1;
}

int main() {

    int a, b;
    cin >> a >> b;

    int result = f(a, b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		public static void Compute(TextReader reader, TextWriter writer)
		{
//			string line = null;
//			while (null != (line = reader.ReadLine()))

			var line = reader.ReadLine();
			var n = int.Parse(line);
			
/*
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

*/			
			int i = 1;
			do
			{
				int x = i;
				
				if ( x % 3 == 0 )
				{
					writer.Write(' ');
					writer.Write(i);
					continue;
				}
				
				do
				{
					if ( x % 10 == 3 )
					{
						writer.Write(' ');
						writer.Write(i);
						break;
					}
					x /= 10;
				
				} while ( 0 != x );
				
			} while ( ++i <= n );
			Console.WriteLine();
		}
	}
}

Measured memory_bytes: 5724
n=int(input())

t = list(map(int,input().split()))

res = 100000000000000000000000000000000

t.sort()
#print(t)
for i in range(t[0], t[-1]+1):
    memo = 0
    for j in t:
        memo += (j-i)**2
    res = min(memo, res)

print(res)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<pii> v(n);
    REP(i,n) cin >> v[i].second >> v[i].first;
    sort(ALL(v));
    
    bool ans = true;
    ll day = 0;
    REP(i,n) {
        day += v[i].second;
        if (day > v[i].first) {
            ans = false;
            break;
        }
    }

    ATYN(ans)

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 0; i < n; i++) {
        int d;
        cin >> d;
        mp[d]++;
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++) {
        int t;
        cin >> t;
        if(mp[t]==0){
            cout << "NO" << "\n";
            return 0;
        }
        mp[t]--;
    }
    cout << "YES" << "\n";

    return 0;
}

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

char x[5] = {'M', 'A', 'R', 'C', 'H'};

int main()
{
    int n;
    cin >> n;
    map<char, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, 5) {
            if(s[0] == x[j]) mp[x[j]]++;
        }
    }
    ll ans = 0;
    ans += (ll) mp[x[0]] * mp[x[1]] * mp[x[2]] + (ll) mp[x[0]] * mp[x[1]] * mp[x[3]] + (ll) mp[x[0]] * mp[x[1]] * mp[x[4]] + (ll) mp[x[0]] * mp[x[2]] * mp[x[3]] + (ll) mp[x[0]] * mp[x[2]] * mp[x[4]] + (ll) mp[x[0]] * mp[x[3]] * mp[x[4]] + (ll) mp[x[1]] * mp[x[2]] * mp[x[3]] + (ll) mp[x[1]] * mp[x[2]] * mp[x[4]] + (ll) mp[x[1]] * mp[x[3]] * mp[x[4]] + (ll) mp[x[2]] * mp[x[3]] * mp[x[4]];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
n, m = list(map(int, input().split(' ')))
h = list(map(int, input().split(' ')))
a = [0 for i in range(m)]
b = [0 for i in range(m)]

for i in range(m):
    a[i],b[i] = list(map(int, input().split(' ')))
    a[i] -= 1; b[i] -= 1
root = [[] for i in range(n)]

for i in range(m):
    root[a[i]] += [b[i]]
    root[b[i]] += [a[i]]

ret = [0 for i in range(n)]
for i,v in enumerate(root):
    flg = True
    for x in v:
        if h[i] > h[x]:
            flg = True
        else:
            flg = False
            break
    if flg:
        ret[i] += 1
print(len([1 for i in ret if i>0]))


Measured memory_bytes: 31988
#include <stdio.h>

int main(void) {
	int a[32] = {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};
	int k;
	scanf("%d",&k);
	printf("%d",a[k-1]);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,ans=1,t[105];
ll gcd(ll a,ll b)
{
	ll c;
	if(a<b) swap(a,b);
	while(a%b!=0)
		c=a%b,a=b,b=c;
	return b;
}
ll mcm(ll a,ll b){return (a/gcd(a,b))*b;}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>t[i];
	for(int i=1;i<=n;i++) ans=mcm(ans,t[i]);
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int main(){
    int N, x, y;
    vector<pair<int, int> > red, blue;
    cin >> N;
    Rep(i, 0, N){
        cin >> x >> y;
        red.push_back(make_pair(x, y));
    }
    Rep(i, 0, N){
        cin >> x >> y;
        blue.push_back(make_pair(x, y));
    }
    sort(red.begin(), red.end(), [](pair<int, int> x, pair<int, int> y) -> bool{return (x.first < y.first);});
    sort(blue.begin(), blue.end(), [](pair<int, int> x, pair<int, int> y) -> bool{return (x.first < y.first);});
    int cnt = 0, index = -1;
    bool paired[100];
    Rep(i, 0, N) paired[i] = false;
    Rep(i, 0, N){
        index = -1;
        y = -1;
        Rep(j, 0, N){
            if(!paired[j] && red[j].first < blue[i].first && red[j].second < blue[i].second && y < red[j].second){
                y = red[j].second;
                index = j;
            }   
        }
        if(index != -1){
            paired[index] = true;
            cnt++;
        }
    }
    Print(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
    int N;cin>>N;
    vector<string> S(N);
    for (auto& s : S) cin >> s;
    
    int na=0,nb=0,nab=0;
    int ans = 0;
    for (auto s : S) {
        auto c = s[0];
        for (size_t i = 1; i < s.size(); i++) {
            if (c == 'A' and s[i] == 'B')
                ans++;
            c = s[i];
        }
        if (s[0] == 'B' and s.back() == 'A')
            nab++;
        else if (s[0] == 'B')
            na++;
        else if (s.back() == 'A')
            nb++;
    }
    if (nab) {
        ans += nab-1;
        if (na > 0)
            ans++, na--;
        if (nb > 0)
            ans++, nb--;
    }
    ans += min(na, nb);
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1144
#include <vector>
#include <algorithm>
#include <iostream>
#include <chrono>
#include<bitset>
#include<deque>
#include <map>
#define vint vector<int>
#define vint2 vector<vint>
#define vchar vector<char>
#define vchar2 vector<vchar> 
#define vchar3 vector<vchar2> 
#define pr pair<int,int>
#define vpr vector<pr>

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

using namespace std;


int main(){
	int a[] = { 1, 3, 5, 7, 8, 10, 12 };
	int b[] = { 4, 6, 9, 11 };
	int c[] = { 2 };

	int x, y;
	cin >> x >> y;
	int xx = -1, yy = -1;

	REP(i, 7){
		if (x == a[i])xx = 0;
		if (y == a[i])yy = 0;
	}
	REP(i, 4){
		if (x == b[i])xx = 1;
		if (y == b[i])yy = 1;
	}
	
		if (x == 2)xx = 2;
		if (y == 2)yy = 2;
		cout << ((xx == yy) ? "Yes" : "No") << endl;
	

	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, t) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val tn = readLine()?.split(" ")?.map(String::toInt) ?: return
    var total = t.toLong()
    var c = tn.first()
    1.until(n).forEach { i ->
        val tt = tn[i]
        val diff = tt - c
        if (t <= diff) {
            total += t
        } else {
            total += diff
        }
        c = tt
    }
    println(total.toString())
}



Measured memory_bytes: 81564
#include<stdio.h>
int main ()
{
  int a;
  scanf("%d", &a);
  if (a >= 3 && a <= 7 && a % 2 == 1 )
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define int long long
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=2005;
int n,k;
signed main(){
	cin>>n>>k;
	n-=k; k--;
	cout<<(n+k-1)/k+1<<endl; 
}



Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()
left = A[0]
right = A[N - 1]
ans = right - left
for i in range((N - 2) // 2):
    if i % 2 == 0:
        ans += right - A[1 + i]
        ans += A[N - 2 - i] - left
        right = A[1 + i]
        left = A[N - 2 - i]
    else:
        ans += left - A[1 + i]
        ans += A[N - 2 - i] - right
        left = A[1 + i]
        right = A[N - 2 - i]

if N % 2 == 1:
    ans += max(abs(right - A[N // 2]), abs(left - A[N // 2]))

print(ans)

Measured memory_bytes: 7488
#include<stdio.h>
int main()
{
    int sec, h, m, s;
    scanf("%d", &sec);
    h=sec/3600;
    m=(sec/60)%60; 
    s=sec%60; 
    printf("%d:%d:%d\n", h, m, s); 
    return 0; 
}


Measured memory_bytes: 2752
n, m = gets.chomp.split.map(&:to_i)
ll, rr = 1, n
m.times do
  l, r = gets.chomp.split.map(&:to_i)
  ll = l if l > ll
  rr = r if r < rr
end
if rr < ll
  puts 0
else
  puts rr - ll + 1
end


Measured memory_bytes: 1916
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#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;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n,a,b;
    cin>>n>>a>>b;

    ll ans = (n/(a+b))*a + min(a,n-(a+b)*(n/(a+b)));
    cout<<ans;









    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll n, X; cin >> n >> X;
  Vll b(n), l(n), u(n);
  rep(i, n) cin >> b[i] >> l[i] >> u[i];

  Vll d1(n);
  rep(i, n) d1[i] = u[i]*(X-b[i]) - l[i]*(0-b[i]);
  Vll d1s = d1;
  sort(all(d1s));
  reverse(all(d1s));


  auto f = [&] (ll K) {
    if (K < 0) return false;
    ll m = K / X;
    ll x = K % X;
    if (m >= n) return true;

    Vll d2(n);
    rep(i, n) d2[i] = ((x < b[i]) ? l[i] : u[i]) * (x-b[i]) - l[i]*(0-b[i]);

    ll g = 0;
    rep(i, n) g += l[i]*(0-b[i]);
    rep(i, m) g += d1s[i];

    ll cmax = -INFll;
    rep(i, n) {
      ll h = d2[i];
      if (d1[i] > d1s[m]) h += d1s[m] - d1[i];
      chmax(cmax, h);
    }
    return (g + cmax >= 0);
  };


  ll ok = ll(1e10) + 5;
  ll ng = -1;
  while (llabs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (f(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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 const INF = 1001001001;


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

int A,B,C,D; cin >> A >> B >> C >> D;
int t = (A+D-1)/D;
int a = (C+B-1)/B;

if(t >= a) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3656
mozi = input()
N = len(mozi)
mozilist1 = list()
mozilist2 = list()
kai1 = (N - 1)//2
kai2 = (N + 3)//2

for i in range(kai1):
    mozilist1.append(mozi[i])
    

for j in range(kai2-1,N):
    mozilist2.append(mozi[j])
    
if mozilist1 == mozilist2:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,h[200005],k,s;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>h[i];
	sort(h,h+n);
	for(int i=0;i<n-k;i++)s+=h[i];
	cout<<s<<endl;
	return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n, q;cin >> n >> q;
	vector<pair<P, ll>> v;

	REP(i, n){
		ll s, t, x;cin >> s >> t >> x;
		v.EB(MP(s - x, t - x), x);
	}

	sort(ALL(v));
	//REP(i, n)cout << "(" << v[i].FI.FI << " " << v[i].FI.SE << " " << v[i].SE << ")" << endl;

	ll pla = 0;
	priority_queue<pair<ll, P>, vector<pair<ll, P>>, greater<>> pq;
	REP(i, q){
		ll now;cin >> now;
		while(pla < n && v[pla].FI.FI <= now){
			pq.push(MP(v[pla].SE, v[pla].FI));
			pla++;
		}
		while(!pq.empty() && pq.top().SE.SE <= now){
			pq.pop();
		}
		//cout << i << " " << now << " " << pla << endl;
		if(pq.empty())cout << -1 << endl;
		else cout << pq.top().FI << endl;
	}

	return 0;
}


Measured memory_bytes: 15212
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N, M;
    cin >> N >> M;

    print(N * (N - 1) / 2 + M * (M - 1) / 2);

    return 0;
}

Measured memory_bytes: 256
x,n = (int(num) for num in input().split())
p = [int(num) for num in input().split()]

sa = 10000
ans = 101
for i in range(0,102):
    if not (i in p) and abs(i - x) < sa:
        sa = abs(i-x)
        ans = i
        
print(ans)

Measured memory_bytes: 61728
//waz
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
 
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}
 
const int MaxN = 1e5 + 10;
 
int N, E, T, x[MaxN];
 
long long f[MaxN];
 
int find(int i)
{
	int j = i;
	for (int k = 18; ~k; --k)
		if ((j - (1 << k)) >= 0 && 2 * (x[i] - x[j - (1 << k) + 1]) <= T)
			j -= 1 << k;
	return j;
}

struct zkw
{
	long long s[MaxN << 2];

	int cnt;

	void build()
	{
		cnt = 1;
		for (; cnt < N + 3; cnt <<= 1); --cnt;
		for (int i = 1; i <= N + 1; ++i) s[cnt + i] = 1e18;
		for (int i = cnt; i; --i) s[i] = 1e18;
	}

	void modify(int pos, long long x)
	{
		++pos;
		pos += cnt;
		s[pos] = min(s[pos], x);
		for (pos >>= 1; pos; pos >>= 1) s[pos] = min(s[pos << 1], s[pos << 1 | 1]);
	}

	long long query(int l, int r)
	{
		long long ans = 1e18;
		++l, ++r;
		for (l += cnt - 1, r += cnt + 1; l ^ r ^ 1; l >>= 1, r >>= 1)
		{
			if (~l & 1) ans = min(ans, s[l ^ 1]);
			if (r & 1) ans = min(ans, s[r ^ 1]);
		}
		return ans;
	}
} s1, s2;


 
int main()
{
	giii(N, E, T);
	for (int i = 1; i <= N; ++i) gi(x[i]), f[i] = 1e18;
	s1.build(), s2.build();
	s1.modify(0, -2 * x[1]);
	s2.modify(0, 0);
	for (int i = 1; i <= N; ++i)
	{
		int k = find(i);
		f[i] = min(f[i], s1.query(0, k - 1) + 3LL * x[i]);
		/*for (int j = 0; j < k; ++j)
			f[i] = min(f[i], 3LL * x[i] + f[j] - x[j] - 2 * x[j + 1]));*/
		f[i] = min(f[i], s2.query(k, i - 1) + x[i] + T);
		s1.modify(i, f[i] - x[i] - 2 * x[i + 1]);
		s2.modify(i, f[i] - x[i]);
		/*for (int j = k; j < i; ++j)
			f[i] = min(f[i], f[j] + x[i] - x[j] + T);*/
	}
	//cerr << f[2] << endl;
	f[N] += E - x[N];
	printf("%lld\n", f[N]);
	return 0;
}

Measured memory_bytes: 7296
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
		int a = sc.nextInt();
		
		a=a-1;
		x=x-1;
		System.out.print(a*x);
    }
}

Measured memory_bytes: 21844
c = [list(map(int,input().split())) for _ in range(3)]
d = []
for j in range(2):
    d.append(c[0][j]-c[0][j+1])
for i in range(1,3):
    for j in range(2):
        if c[i][j]-c[i][j+1]!=d[j]:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 38428
b;main(r,g,c,s,t){for(;;printf("%d\n",100-t*3+s*3+c*2+g*7+r*15+b*15+r*3*16+b*5*16)){scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t);if(!t)exit(0);}}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef int T_CC;
const int CC_MAX = 100010;

class CC{
	T_CC unzip[CC_MAX];
	map<T_CC , int> zip;
	int size;
	
public:
	
	void dft(){
		size = 0;
		zip.clear();
	}
	
	int insert(T_CC a){
		if(size == CC_MAX) return -1;
		zip[a] = size;
		unzip[size] = a;
		return ++size;
	}
	
	int arrange(){
		int a = 0;
		for(map<T_CC , int>::iterator it = zip.begin() ; it != zip.end() ; ++it){
			(*it).second = a;
			unzip[a] = (*it).first;
			++a;
		}
		size = a;
		return size;
	}
	
	int get_size(){
		return size;
	}
	
	int code(T_CC a){
		map<T_CC , int>::iterator it = zip.find(a);
		return it != zip.end() ? (*it).second : -1;
	}
	
	T_CC decode(int a){
		if(a >= size) return -1;
		return unzip[a];
	}
};

const int UF_MAX = 100010;

class UF{
	int x[UF_MAX];
	int co;
	
public:
	
	UF(){
		fill(x,x+UF_MAX,-1);
		co = 0;
	}
	
	int boss(int a){
		int s = a;
		while(x[s] > -1) s = x[s];
		if(s != a) x[a] = s;
		return s;
	}
	
	void uni(int a , int b){
		int s = boss(a);
		int t = boss(b);
		if(s != t){
			++co;
			if(x[s] < x[t]){
				x[s] += x[t];
				x[t] = s;
			} else {
				x[t] += x[s];
				x[s] = t;
			}
		}
	}
	
	bool find(int a , int b){
		return boss(a) == boss(b);
	}
	
	int count(){
		return co;
	}
	
	int member(int a){
		return -x[boss(a)];
	}
} uf;

const int MC = 100010;
int N;
int a[MC],b[MC];
int c[MC],d[MC];
CC solve;

int main(){
	scanf("%d" , &N);
	int x = 0;
	repp(i,0,N){
		scanf("%d" , a + i);
		c[i] = a[i];
		x ^= a[i];
	}
	repp(i,0,N){
		scanf("%d" , b + i);
		d[i] = b[i];
	}
	c[N] = x;
	sort(c,c+N+1);
	sort(d,d+N);
	int w = 0;
	repp(i,0,N){
		if(c[i+w] == d[i]) continue;
		++w;
		--i;
		if(w > 1) return []{printf("-1\n");return 0;}();
	}
	solve.insert(x);
	int z = 0;
	repp(i,0,N){
		if(a[i] == b[i]) continue;
		solve.insert(a[i]);
		++z;
	}
	int s = solve.arrange();
	repp(i,0,N){
		if(a[i] == b[i]) continue;
		uf.uni(solve.code(a[i]),solve.code(b[i]));
	}
	printf("%d\n" , z + s - uf.count() - 1);
	return 0;
}


Measured memory_bytes: 7296
plan = [{t: 0, x: 0, y: 0}]
gets.to_i.times do
  input = gets.split(' ').map(&:to_i)
  plan.push({ t: input[0], x: input[1], y: input[2] })
end

ans = nil

(plan.size - 1).times do |i|
  time = plan[i + 1][:t] - plan[i][:t]
  x_distance = (plan[i + 1][:x] - plan[i][:x]).abs
  y_distance = (plan[i + 1][:y] - plan[i][:y]).abs
  if (x_distance + y_distance <= time) && ((x_distance + y_distance) % 2 == time % 2)
    ans = 'Yes'
  else
    ans = 'No'
    break
  end
end
puts ans


Measured memory_bytes: 31356
n,m = map(int,input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cnt = 0
a = sorted(a, key=lambda x:x[0])
for i in range(n):
    if cnt + a[i][1] <m:
        ans += a[i][0]*a[i][1]
        cnt +=a[i][1]
    else:
        ans += a[i][0]*(m-cnt)
        break
print(ans)

Measured memory_bytes: 29356
#include <bits/stdc++.h>
#define P pair<int,ll>
using namespace std;
typedef long long ll;
const int maxx=1e5+10;
int a[maxx],c[maxx];
int pos[maxx];
int main(){
    int n; cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        pos[a[i]]=i;
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        int x; scanf("%d",&x); sum+=x;
    }
    for(int i=2;i<=n;i++){
        cin>>c[i];
    }
    for(int i=2;i<=n;i++){
        if(a[i]-a[i-1]==1){
            sum+=c[a[i]];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256