akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp       make_pair
#define mt       make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int T;
int N;
vector<int> wake;
vector<int> ap;
int dp[110][33];
int d;
int memo(int day, int cycle){
	if (day == d + 1)return dp[day][cycle] = 0;
	if (dp[day][cycle] >= 0)return dp[day][cycle];
	int res = INF;
	if (wake[cycle] > ap[day]){
		return dp[day][cycle] = INF;
	}
	res = min(res, memo(day + 1, 0) + 1);
	res = min(res, memo(day + 1, (cycle + 1) % T));

	// cout << day << " " << cycle << " " << res << endl;
	return dp[day][cycle] = res;
}
int main(){
	while (cin >> T, T){
		memset(dp, -1, sizeof(dp));
		wake.clear();
		wake.resize(T);
		for (int i = 0; i < T; i++) {
			cin >> wake[i];
		}
		cin >> N;
		ap.clear();
		ap.resize(110, INF);
		d = 0;
		for (int i = 0; i < N; i++) {
			int D,M;
			cin >> D >> M;
			D--;
			d = max(d, D);
			ap[D] = min(ap[D], M);
		}
		cout << memo(0, 0) << endl;
	}
	return 0;
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  
  int count = 0;
  int ans;
  
  for(int i = A; i >= 1; i--){
    if( A % i == 0 && B % i == 0 ) {
      ans = i;
      count++;
    }
     if( K == count )break;
   }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INTMAX = 10**30

def solve(N: int, K: int, A: "List[int]"):
    K = bin(K)[2:]
    A = [bin(a)[2:] for a in A]
    ndig = max([len(a) for a in A+[K]])
    
    A = [(ndig-len(s))*"0"+s for s in A]
    K = (ndig-len(K))*"0"+K
    
    dp = [0, -INTMAX] # exact, smaller
    base = 2**(ndig-1)
    for k, digs in zip(K, zip(*A)):
        n1 = digs.count("1")
        n0 = len(A)-n1
        dp[1] = max([dp[0]+base*n1 if k=="1" else -INTMAX, dp[1]+base*max(n1,n0)])
        dp[0] = dp[0] + base*(n1 if k=="0" else n0)
        base //= 2
    print(max(dp))

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
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


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

int main() {
    int h, w;
    
    while(1) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;

        for(int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i == 0 || j == 0 || i == h-1 || j == w-1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
        	cout << endl;
        }
        cout << endl;
    }
}


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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

//return x^y mod p
ll power(ll x,ll y, ll p)
{
    ll res = 1;     
    x = x % p; 
 
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n; cin>>n;
    vll arr(n);
    FOR(i, 0, n) cin>>arr[i];
    sort(all(arr));
    ll res = 0;
    FOR(i, 0, n) {
        ll contrib = power(4, i, MOD);
        contrib *= power(2, n - i, MOD); contrib %= MOD;
        contrib *= arr[i]; contrib %= MOD;
        
        if(i < n - 1) {
            ll sm = (power(2, n - i - 1, MOD))%MOD;
            sm += ((n - i - 1) * power(2, n - i - 2, MOD))%MOD; sm %= MOD;
            contrib *= sm; contrib %= MOD;
        }
        
        res += contrib; res %= MOD;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
ll n;
cin>>n;
 vector<pair<ll,ll> > v;
ll x,l,a[n+1]={0},b[n+1]={0};
for(ll i=0;i<n;i++){
cin>>x>>l;
v.push_back({x+l,x-l});
}
ll now=-(1e18);
ll ans=0;
sort(v.begin(),v.end());
for(ll i=0;i<n;i++)
{
	if(now<=v[i].second)
    {
      ans++;
      now=v[i].first;
    }
}
  cout<<ans;
}

Measured memory_bytes: 3956
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll N;
ll a,b;
int main(){
    cin>>N;
    ll ans=0;
    for(int i=1;i<=N;i+=2){
        ll cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt==8){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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 = 1001001001;

int main()
{   
    int n;
    cin >> n;
    int h[n][3];
    rep(i, n) rep(j, 3) cin >> h[i][j];

    vvi dp(n+1, vi(3, -114514));
    rep(i, 3) dp[0][i] = 0;
    rep(i, n) rep(j, 3) rep(k, 3) {
        if(j == k) continue;
        chmax(dp[i+1][k], dp[i][j] + h[i][k]);
    }
    int ans = 0;
    rep(i, 3) chmax(ans, dp[n][i]);

    cout << ans << endl;

    return 0;
}


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

int A,B,C,D,E,F;
bool canW[3010],canS[3010];
vector<int> S,W;

int main()
{
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);

    for(int i = 0; i * A * 100 <= F; i++)
    {
        for(int j = 0; i * A * 100 + j * B * 100 <= F; j++)
        {
            canW[i * A * 100 + j * B * 100] = true;
        }
    }
    for(int i = 0; i * C <= F; i++)
    {
        for(int j = 0; i * C + j * D <= F; j++)
        {
            canS[i * C + j * D] = true;
        }
    }
    for(int i = 0; i <= F; i++)
    {
        if(canW[i])W.push_back(i);
        if(canS[i])S.push_back(i);
    }

    double ans = -1.0;
    int s,w;
    for(int i = 0; i < W.size(); i++)
    {
        for(int j = 0; j < S.size(); j++)
        {
            if(W[i] + S[j] == 0)continue;
            if(W[i] + S[j] <= F && (double)W[i] / 100.0 * (double)E >= (double)S[j] && ans < (double)(100 * S[j]) / (double)(W[i] + S[j]))
            {
                ans = (double)(100 * S[j]) / (double)(W[i] + S[j]);
                w = W[i] + S[j];
                s = S[j];
            }
        }
    }

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


Measured memory_bytes: 256
string = gets.chomp

# erase, eraser が含まれていたらスペースに変換する
string.gsub!(/eraser/, " ")
string.gsub!(/erase/, " ")

# dream, dreamerが含まれていたらスペースに変換する
string.gsub!(/dreamer/, " ")
string.gsub!(/dream/, " ")

# スペースを消す
string.gsub!(/ /, "")

# 結果の出力
puts string.empty? ? "YES" : "NO"


Measured memory_bytes: 4220
#include <cstdio>
#include <vector>
using namespace std;
int main(){
    int N,K,R=0,k=0;
    scanf("%d%d",&N,&K);
    vector<int>v(N),b(K+1);
    for(int i=0;i<N;i++)scanf("%d",&v[i]);
    int start=0,stop=0;
    for(;;){
        for(;stop<N&&k<K;stop++){
            if(v[stop]<=K&&++b[v[stop]]==1)k++;
        }
        if(k<K)break;
        for(;start<N&&k>=K;start++){
            if(!R||R>stop-start)R=stop-start;
            if(v[start]<=K&&!--b[v[start]])k--;
        }
    }
    printf("%d\n",R);
}


Measured memory_bytes: 3156
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = '-' + sr()
N = len(S) - 1
def solve(S):
    if S[1] == '0':
        print(-1); exit()
    if S[N] == '1':
        print(-1); exit()
    prev = 1
    graph = []
    for n in range(1,N//2 + 1):
        if S[n] != S[N-n]:
            print(-1); exit()
        if S[n] == '0':
            continue
        for i in range(prev,n):
            graph.append('{} {}'.format(i,n))
        prev = n
    for i in range(prev,N):
        graph.append('{} {}'.format(i,N))
    return graph

graph = solve(S)

if graph is None:
    print(-1)
else:
    print('\n'.join(graph))


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

int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;

  vector<string> sub;
  for (int i = 1; i <= min((int)s.size(), K); i++)
    for (int j = 0; j <= s.size() - i; j++) sub.push_back(s.substr(j, i));

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

  string prev;
  int ans;
  for (int i = 0; i < sub.size(); i++) {
    if (sub[i] != prev) {
      prev = sub[i];
      K--;
    }

    if (K == 0) {
      ans = i;
      break;
    }
  }

  cout << sub[ans] << endl;

  return 0;
}

Measured memory_bytes: 1660
#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;cin >> n;
	cout << n * n << endl;

	return 0;
}


Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const MOD = 1000000007

const [n, m] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const a = stdin
  .split('\n')
  .map(Number)
  .slice(1)

const A = new Set(a)

const ans = () => {
  const steps = A.has(1) ? [1, 0] : [1, 1]

  for (let i = 2; i <= n; i++) {
    if (A.has(i)) {
      steps[i] = 0
    } else if (steps[i - 1] === 0 && steps[i - 2] === 0) {
      return 0
    } else {
      steps[i] = (steps[i - 1] + steps[i - 2]) % MOD
    }
  }

  const last = steps[n]

  return last
}

console.log(ans())


Measured memory_bytes: 34136
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var hw = Input.ar;
        var gred = Enumerable.Repeat(0, hw[0]).Select(v =>Input.ar).ToArray();
        var dp = new int[hw[0] + 1, hw[1] + 1];
        for (var i = 1; i <= hw[0]; i++)
            for (var j = 1; j <= hw[1]; j++)
                if (gred[i-1][j-1] == 0)
                    dp[i,j] = Min(Min(dp[i - 1, j - 1], dp[i - 1, j]), dp[i, j - 1]) + 1;
        var max = 0;
        for (var i = 1; i <= hw[0]; i++)
            for (var j = 1; j <= hw[1]; j++)
                max = Max(max, dp[i, j]);
        WriteLine(max * max);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}



Measured memory_bytes: 53448
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    int sum = 0;
    int n = N;

    while (n > 0){
        sum += n % 10;
        n = n / 10;
    }

    if (N % sum == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#define ll long long
using namespace std;

ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 

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

ll lcm(ll a, ll b){
	return a*b/gcd(a,b);
}

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

	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << b - a + 1 - countDivisibles(a,b,c) - countDivisibles(a,b,d) + countDivisibles(a,b,lcm(c,d));
	return 0;
}

Measured memory_bytes: 3564
///created: 28/May/2019 20:20:19

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 1;
typedef long long ll;
int n, cnt[41][2] = {0};
ll k;

int main() {
	scanf("%d%lld", &n, &k);
	for (int i = 1; i <= n; ++i) {
		ll a;
		scanf("%lld", &a);
		for (int j = 0; j <= 40; ++j)
			cnt[j][(a >> j) & 1]++;
	}
	ll ans = 0, x = 0;
	for (int i = 40; i >= 0; --i) {
		if (cnt[i][0] > cnt[i][1]) {
			if (x + (1ULL << i) <= k) {
				x += (1ULL << i);
				ans += (1ULL << i) * cnt[i][0];
			}
			else ans += (1ULL << i) * cnt[i][1];
		}
		else ans += (1ULL << i) * cnt[i][1];
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = onem()

a = l()

R = [1 for i in range(n)]
L = [1 for i in range(n)]

for i in range(n):
    ii = -(i+1) 
    if i == 0:
        R[ii] = a[ii]
        L[i] = a[i]
    else:
        R[ii] = gcd(R[ii+1],a[ii])
        L[i] = gcd(L[i-1],a[i])
ma = 1

for i in range(n):
    if i == 0:
        ma = max(ma,R[1])
    elif i == n-1:
        ma = max(ma,L[-2])
    else:
        ma = max(ma,gcd(L[i-1],R[i+1]))
print(ma)





Measured memory_bytes: 103468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

int main(){
	cin >> n;
	vector<ll> a(n),b(n);
	vector<bool> f(n,false);
	vector<ll> MIN(n,INF);
	rep(i,n)cin >> a[i];
	rep(i,n)cin >> b[i];
	f[0] = 1;
	f[n-1] = 1;
	bool ok = true;
	if(n == 1){
		if(a[0] != b[0])ok = false;
	}
	rep(i,n-1){
		if(a[i]<a[i+1]){
			f[i+1] = 1;
			if(b[i+1]<a[i+1])ok = false;
		}
		MIN[i+1] = min(MIN[i+1],a[i+1]);
	}
	for(int i = n-1;i>=1;i--){
		if(b[i-1]>b[i]){
			f[i-1] = 1;
			if(b[i-1]>a[i-1])ok = false;
		}
		MIN[i-1] = min(MIN[i-1],b[i-1]);
	}
	ll ans = 1;
	rep(i,n){
		if(!f[i]){
			// cout << i << " " << MIN[i] << endl;
			ans *= MIN[i];
			ans %= MOD;
		}
	}
	if(ok)cout << ans << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y)
{
	return y==0?x:gcd(y,x%y);
}
int a[100010],n,ma,k,b;
#define ye exit(0*puts("POSSIBLE"))
#define no exit(0*puts("IMPOSSIBLE"))
int main()
{
	scanf("%d%d",&n,&k);
	if(n==1)
	{
		scanf("%d",&ma);
		ma==k?ye:no;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b=max(b,a[i]);
	}
	if(b<k)
		no;
	ma=gcd(max(a[1],a[2]),min(a[1],a[2]));
	for(int i=3;i<=n;i++)
		ma=gcd(max(ma,a[i]),min(a[i],ma));
	(b-k)%ma?no:ye;
}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string s;
  int diffX = tx - sx;
  int diffY = ty - sy;
  s.append(diffX, 'R');
  s.append(diffY, 'U');
  s.append(diffX, 'L');
  s.append(diffY + 1, 'D');
  s.append(diffX + 1, 'R');
  s.append(diffY + 1, 'U');
  s.append(1, 'L');
  s.append(1, 'U');
  s.append(diffX + 1, 'L');
  s.append(diffY + 1, 'D');
  s.append(1, 'R');
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
ll ctoi(char c) {
    if (c == '0')return 0;
    else if (c == '1')return 1;
    else if (c == '2')return 2;
    else if (c == '3')return 3;
    else if (c == '4')return 4;
    else if (c == '5')return 5;
    else if (c == '6')return 6;
    else if (c == '7')return 7;
    else if (c == '8')return 8;
    else if (c == '9')return 9;
    else return -1;
}
int main() {
    ll N,M;
    cin >> N >> M;
    map<ll,bool> broken;
    ll n;
    rep(i, M) {
        cin >> n;
        broken[n] = true;
    }
    ll memo[100005];
    memo[0] = 1;
    if (broken[1])
        memo[1] = 0;
    else memo[1] = 1;
    for (int i = 2; i <= N; i++) {
        if (broken[i])memo[i] = 0;
        else {
            memo[i] = (memo[i - 1] + memo[i - 2]) % mod;
        }
    }
    cout << memo[N] << endl;
}

Measured memory_bytes: 7296
def main(): 
    n = int(input())
    A = list(map(int,input().split()))

    ans = n
    A.sort()
    table = [True]*(A[-1]+1)
    for k,a in enumerate(A):
        if table[a]:
            if k+1<n and A[k+1]==a:
                ans-=1
            for i in range(a,A[-1]+1,a):
                table[i] = False
        else:
            ans-=1
    
    print(ans)
main()

Measured memory_bytes: 101372
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int n, a[100001]={0};
  cin>>n;
  for (int i(0);i<n;i++){
    int b;
    cin>>b;
    a[b]++;
  }
  int ma(0);
  for (int i(1);i<100000;i++){
    ma=max(ma,a[i-1]+a[i]+a[i+1]);
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 640
s=[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]

k=int(input())
print(s[k-1])

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

using namespace std;
#define int long long


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

#define arr (int)(4e3)

int f[arr];
int rf[arr];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<arr;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[arr-1]=powmod(f[arr-1],MOD-2, MOD);
    for (int i=arr-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

signed main(void)
{
	IOS;
	int n;
	cin>>n;
	vi c(n);
	for(int i = 0; i < n; i++)
		cin>>c[i];
	sort(all(c));
	int ans=0;
	for(int i = 0; i < n-1; i++) {
		ans += /*(powmod(2,n+i,MOD)*c[i])%MOD*/ ((c[i]*powmod(2,n+i,MOD))%MOD*(powmod(2,n-i-1,MOD)+((n-i-1)*powmod(2,n-i-2,MOD))%MOD))%MOD;
		ans %= MOD;
	}
	ans += (powmod(2,n+n-1,MOD)*c[n-1])%MOD;
	ans %= MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#define mod 998244353
using namespace std;
int n, i, nr, x, sol;
int ok[5];
char s[300005];
int main(){
    cin>> n;
    cin>> s + 1;
    for(i = 1; i <= 3 * n; i++){
        if(s[i] == 'R'){
            s[i] = 1;
        }
        else{
            if(s[i] == 'G'){
                s[i] = 2;
            }
            else{
                s[i] = 3;
            }
        }
    }
    sol = 1;
    for(i = 3 * n; i >= 1; i--){
        if(ok[ s[i] ] > 0){
            sol = sol * 1LL * ok[ s[i] ] % mod;
            ok[ s[i] ]--;
        }
        else{
            if(nr > 0 && x != s[i]){
                ok[6 - s[i] - x]++;
                sol = sol * 1LL * nr % mod;
                nr--;
            }
            else{
                nr++;
                x = s[i];
            }
        }
    }
    for(i = 1; i <= n; i++){
        sol = sol * 1LL * i % mod;
    }
    cout<< sol;
}


Measured memory_bytes: 512
def gcd(a,b):
    if(b == 0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)
n = int(input())
mod = int(1e9 + 7)
a = [int(i) for i in input().split()]
ans = int(1)
for i in a:
    ans = lcm(ans,i)

print(sum(ans//i for i in a)%mod)


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

using namespace std;
int n, k;
long long ans[100001];
vector < long long > m, p;
int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(a >= 0){
            p.push_back(a);
        }
        else{
            m.push_back(a);
        }
    }
    for(int i = 0; i < p.size(); i++){
        if(i + 1 + m.size() >= k && i + 1 < k){
            ans[i] = m[m.size() - (k - i - 1)] * 1ll * 2 * (-1) + p[i];
        }
        else if(i + 1 >= k){
            ans[i] = p[i];
        }
        else{
            ans[i] = 1e18;
        }
    }
    long long mn = 1e18;
    for(int i = 0; i < p.size(); i++){
        mn = min(mn, ans[i]);
    }
    reverse(m.begin(), m.end());
    reverse(p.begin(), p.end());
    for(int i = 0; i < m.size(); i++){
        if(i + 1 + p.size() >= k && i + 1 < k){
            ans[i] = p[p.size() - (k - i - 1)] * 1ll * 2 + m[i] * (-1);
        }
        else if(i + 1 >= k){
            ans[i] = m[i] * (-1);
        }
        else{
            ans[i] = 1e18;
        }
    }
    for(int i = 0; i < m.size(); i++){
        mn = min(mn, ans[i]);
    }
    cout << mn;
}


Measured memory_bytes: 2036
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll n;  cin >> n;
    ll *a = new ll[n], *b = new ll[n], *c = new ll[n];

    for (ll i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];

    ll **dp = new ll*[n];
    for (int i = 0; i < n; i++) {
        dp[i] = new ll[3];
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 0; i < n-1; i++) {
        dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i+1];
        dp[i+1][1] = max(dp[i][0], dp[i][2]) + b[i+1];
        dp[i+1][2] = max(dp[i][0], dp[i][1]) + c[i+1];
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
}

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

ans=1;
m=10**9+7
if n==1:
  print(0)
else:
  ans1=1;
  ans2=1;
  ans3=1;
  for i in range(n):
    ans1 = (ans1*10)%m
    ans2 = (ans2*9)%m
    ans3 = (ans3*8)%m
   

  ans = (ans1-(2*ans2)+ans3)%m;
  print(ans)
    

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL c(n-1),s(n-1),f(n-1);
	for (int i = 0; i < n-1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	VL ans(n,0);
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n-1; j++) {
			ans[i] += (s[j] <= ans[i] ? ((f[j] - ans[i] % f[j]) % f[j]) : s[j] - ans[i]) + c[j];
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define up(i,a,b) for(register int i=a;i<=b;i++)
#define Auto(i,x) for(register int i=h[x];i;i=e[i].nxt)
#define cntsize(a) (sizeof(a) / 1024.0 / 1024.0)
#define re register
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
struct ios{
	template <typename ty> inline ios& operator >> (ty &x){
		x = 0;register char c=getchar();int f=1;
		for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
		for(;isdigit(c);c=getchar()) x = (x<<1) + (x<<3) + (c^48);
		x *= f;return *this;
	}
	template <typename ty> inline ios& operator << (ty x){
		if(x < 0) putchar('-') , x=-x;
		if(x > 9) *this << x/10;
		putchar(x%10+48);return *this;
	} 
	inline ios& operator << (char x){putchar(x);return *this;}
}io;
const int N = 2e7;
const ll mod = 998244353;
ll fac[N],inv[N];
inline ll ksm(ll a, ll b)
{
	ll ret = 1;
	for(;b;b>>=1, a=a*a%mod) if(b&1) ret = (ret * a) % mod;
	return ret;
}
inline ll C(ll n, ll m)
{
//	return fac[n] * inv[m] % mod * inv[n-m] % mod;
	return fac[n] * ksm(fac[m],mod-2) % mod * ksm(fac[n-m],mod-2) % mod;
}
ll n,a,b,k;
int main()
{
	io >> n >> a >> b >> k;
	fac[0] = 1;for(ll i=1;i<=N-5;i++) fac[i] = (fac[i-1] * i) % mod;
	inv[N-5] = ksm(fac[N-5],mod-2);
	for(ll i=N-6;i>=1;i--) inv[i] = (inv[i+1] * (i+1)) % mod;
	ll ans = 0;
	for(ll R=0;R*a<=k && R<=n;R++)
	{
		if((k - R * a) % b == 0)
		{
			ll B = (k - R * a) / b;
			if(B > n) continue;
			ans = (ans + C(n,R) * C(n,B) % mod) % mod;
		}
	}
	io << ans;
	return 0;
}

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

int main() {
  int N, L,R,sum,syoki;
  cin >> N;
  int i;
  syoki=N;
  L = 0;
  for(i = 8;i>-1;i--){
    	//10の8乗、7乗、６とつくっていく
    	sum =1;
    	for(int j=0;j<i;j++){
    		sum *= 10;	
    	}
    	//
     R = N/sum;
     if(R!=0){
     	L += R;
     	N = N-(R*sum);
     }

   }
  int AA = syoki%L;
  if(AA == 0){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=998244353;
const int maxn=(1e6)+10;
int n,k;
ll jc[maxn],iv[maxn],ivjc[maxn],ans;
ll C(ll x,ll y) {
	if (y<0||x<y) return 0;
	return jc[x]*ivjc[y]%mod*ivjc[x-y]%mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	jc[0]=iv[0]=ivjc[0]=1;
	jc[1]=iv[1]=ivjc[1]=1;
	for (int i=2;i<maxn;i++) {
		jc[i]=jc[i-1]*i%mod;
		iv[i]=(mod-mod/i)*iv[mod%i]%mod;
		ivjc[i]=ivjc[i-1]*iv[i]%mod;
	}
	read(n); read(k);
	int T,B;
	for (int R=n;R<=k;R++) {
		B=k-R;
		if (R<B) continue;
		T=R-n+1;
		if (R==B) B--;
		ans+=C(R+B,R)-C(R+B,B-T)+mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
bool f(string s) {
    if (s.length() % 2) return 0;
    int k = s.length() / 2;
    for (int i = 0; i < k; i++) {
        if (s[i] != s[i+k]) return 0;
    }
    return 1;
}
int main () {
    string s;
    cin >> s;
    while (1) {
        s.erase(s.end() - 2, s.end());
        if (f(s)) {
            cout << s.length() << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;

int main() {
	ll a,b,c,d;
	ll n;
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &d, &n);
	if(2*a < b) {
		b = 2*a;
	}
	if(2*b < c) {
		c = 2*b;
	}
	if(2*c < d) {
		d = 2*c;
	}
	printf("%lld\n", (n/2)*d+(n%2)*c);
	return 0;
}


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

using namespace std;

int main(){

  long long n,m;
  long long sum = 0;

  cin >> n >> m;

  vector<long> a(n);

  for(long long i = 0;i < n;++i)
	cin >> a[i];

  long long b;

  int sum_b = 0;
  
  for(long long i = 0;i < m;++i){
	cin >> b;
	sum_b += b;
  }

  for(long long i = 0;i < n;++i)
	sum += sum_b*a[i];
	
  cout << sum << endl;
  
}



Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll inp; cin >> inp;
    ll ans = 0;
    
    ans += (inp/500) * 1000;
    inp %= 500;
    
    ans += (inp/5) * 5;
    
    cout << ans << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product
N=int(input())
XYs = []
for i in range(N):
    A = int(input())
    XYs.append([tuple(map(int, input().split())) for _ in range(A)])

n=0
for ts in product([1,0], repeat=N):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in XYs[i]):
                break
    else:
        n=max(n,sum(ts))
print(n)

Measured memory_bytes: 3064
n = int(input())
for i in range(n):
    y,m,d = map(int, input().split())
    dif = 999 - y
    leap = int(dif / 3) + 1
    common = dif - leap + 1
    days = leap * 200 + common * 195 # days from y 1 1
    days -= (m - 1) * 20
    if y % 3 != 0:
        days += int((m - 1) / 2)
    days -= (d - 1)
    print(days)

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

using namespace std;

int main(int argc, char const *argv[]) {
	int a,b,c,d;
	std::cin >> a >> b >> c >> d;
	if (a + b == c + d) {
		std::cout << "Balanced" << '\n';
	}
	else if (a + b < c + d) {
		std::cout << "Right" << '\n';
	}
	else {
		std::cout << "Left" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
ans = 0
M,D = map(int,input().split())
for d in range(D+1):
    d1 = d%10
    d10 = int(d/10)
    if (d10>1 and d1>1):
        if (d10*d1<=M):
            #print (d10,d1)
            ans+=1
print (ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	vector<pair<string, int> > v(n);
	rep(i,0,n) {
		cin >> v[i].F >> v[i].S;
	}
	string x;
	cin >> x;
	int ret = 0;
	bool flag = false;
	rep(i,0,n) {
		if(flag) ret += v[i].S;
		if(v[i].F == x) flag = true;
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N,M;
    cin >> N >> M;
    int A[N];
    long long S = N;
    for(int i = 0; i < M;i++){
        
        cin >> A[i];
        
        S -= A[i];
        
    }
    
    if(S<0)S= -1;
    
    cout << S << endl;
    
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string x, y;
    cin >> x;
    cin >> y;
    if (x[0] == y[2] && x[1] == y[1] && x[2] == y[0])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
string s, t = "keyence";
int main() {
	cin >> s;
	if (s == t) {
		cout << "YES" << endl;
		return 0;
	}
	for (int i = 0;i < s.size();i++) {
		for (int j = i;j < s.size();j++) {
			string S = "";
			for (int k = 0;k < s.size();k++) {
				if (i <= k && k <= j) continue;
				else S.push_back(s[k]);
			}
			if (S == t) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ITP1_2_A{
    class Sample{
        static void Main(string[] args){
            List<int> A = new List<int>();
            int N = int.Parse(Console.ReadLine());
            for(int i=0; i<N; i++){
                int[] Inst = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
                if(Inst[0] == 0) A.Add(Inst[1]);
                else if(Inst[0] == 1) Console.WriteLine(A[Inst[1]]);
                else if(Inst[0] == 2) A.RemoveAt(A.Count-1);
            }
        }
    }
}


Measured memory_bytes: 23788
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=1e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int n,m[4],k,T;
ll ans,yu;

int main() 
{
    int i,j;
	double r;
	double pi=3.1415926;
	scanf("%lf",&r);
	printf("%f",2*r*pi);
    return 0;
}


Measured memory_bytes: 3824
n = input()

s1 = []
s2 = []

for i in range(len(n)):
    if n[i] == '\\':
        s1.append(i)
    elif n[i] == '/' and len(s1) > 0:
        a = s1.pop(-1)
        s2.append([a, i - a])

i = 0
while len(s2) > 1:
    if i == len(s2) - 1:
        break
    elif s2[i][0] > s2[i + 1][0]:
        s2[i + 1][1] += s2.pop(i)[1]
        i = 0
    else:
        i += 1

s = []
total = 0
for i in s2:
    s.append(str(int(i[1])))
    total += int(i[1])
print(total)
if len(s2) == 0:
    print('0')
else:
    print('{} {}'.format(len(s2), ' '.join(s)))


Measured memory_bytes: 6752
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

const int M=1e5+9;

int m;
int a[M],b[M],top;

int main()
{
	if(fopen("b.in","r"))
	{
		freopen("b.in","r",stdin);
		freopen("b.out","w",stdout);
	}

	int n=read(),m=read();
	int odd1=-1,odd2=-1;
	for(int i=1;i<=m;i++)
	{
		a[i]=read();
		if(a[i]&1)
		{
			if(odd1==-1)
				odd1=i;
			else if(odd2==-1)
				odd2=i;
			else
			{
				puts("Impossible");
				return 0;
			}
		}
	}

	if(m==1)
	{
		if(a[1]==1)
			printf("1\n1\n1\n");
		else
			printf("%d\n2\n1 %d\n",a[1],a[1]-1);
		return 0;
	}

	if(odd1!=-1)
		swap(a[1],a[odd1]);
	if(odd2!=-1)
		swap(a[m],a[odd2]);

	for(int i=1;i<=m;i++)
		printf("%d%c",a[i]," \n"[i==m]);

	if(a[m]==1)
	{
		printf("%d\n",m-1);
		printf("%d ",a[1]+1);
		for(int i=2;i<m;++i)
			printf("%d ",a[i]);
		puts("");
		return 0;
	}

	b[1]=a[1]+1;
	for(int i=2;i<m;i++)
		b[i]=a[i];
	b[m]=a[m]-1;
	
	printf("%d\n",m);
	for(int i=1;i<=m;i++)
		printf("%d%c",b[i]," \n"[i==m]);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

class RollingHash {
    const ll base = 9973;
    const vector <ll> mod = {999999937LL, 1000000007LL};
    string S;
    vector <ll> hash[2], pow[2];

public:
    RollingHash(const string &s) {
        S = s;
        int n = S.size();
        for (int i = 0; i < 2; i++) {
            hash[i].assign(n + 1, 0);
            pow[i].assign(n + 1, 1);
            for (int j = 0; j < n; j++) {
                hash[i][j + 1] = (hash[i][j] * base + S[j]) % mod[i];
                pow[i][j + 1] = pow[i][j] * base % mod[i];
            }
        }
    }

    // get hash of [l:r)
    ll get(int l, int r, int id = 0) {
        ll res = hash[id][r] - hash[id][l] * pow[id][r - l] % mod[id];
        if (res < 0) res += mod[id];
        return res;
    }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B&lang=jp
void AOJ_ALDS1_14_B() {
    string T, P;
    cin >> T >> P;
    RollingHash rh1(T), rh2(P);
    for (int i = 0; i + P.size() <= T.size(); i++) {
        if (rh1.get(i, i + P.size()) == rh2.get(0, P.size())) {
            cout << i << "\n";
        }
    }
}

int main() {
    AOJ_ALDS1_14_B();
    return 0;
}


Measured memory_bytes: 36416
def main():
    x,n=map(int,input().split())
    pp=set(map(int,input().split()))
    if x not in pp:
        print(x)
        return
    i=1
    while True:
        if x-i not in pp:
            print(x-i)
            return
        elif x+i not in pp:
            print(x+i)
            return
        i+=1

main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  cout << min(b/a, c) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main() {
 
  int i, j, len, count = 0, m, n;
  char s[201], h[101], t[201];
 
  while(1) {
    scanf("%s",s);
    len = strlen(s);
    if(s[0] == '-') break;
    scanf("%d", &m);
    for(i = 0; i < m; i++) {
      scanf("%d", &n);
      //printf("%s -> ", s);
      for(j = 0; j < len - n; j++) {
    t[j] = s[n+j];
    //printf("(%d, %d) ", j, n+j);
      }
      //printf("\n");
      for(j = 0; j < n; j++) {
    t[len - n + j] = s[j];
    //printf("(%d, %d) ", len-n+j, j);
      }
      //printf("\n");
      for(j = 0; j < len; j++) {
    s[j] = t[j];
      }
    }
 
    for(i = 0; i < len; i++) {
      printf("%c",t[i]);
    }
    printf("\n");
  }      
 
  return 0;
}

Measured memory_bytes: 568