akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int k,n;
  cin>>k>>n;
  int a;
  int tmp;
  int max=0;
  int a_f;
  REP(i,n){
    cin>>a;
    if(i!=0){
      if(max<=a-tmp){
        max=a-tmp;
      }
    }else{
      a_f=a;
    }
    tmp=a;
  }
  if(max<=k-tmp+a_f){
    k-=k-tmp+a_f;
  }else{
    k-=max;
  }
  cout<<k<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int N= sc.nextInt();
		int game=N*(N-1)/2;
		int point[] =new int[N];
		for(int i=0;i<game;i++){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int c=sc.nextInt();
			int d=sc.nextInt();
			if(c<d){
				point[b-1]=point[b-1]+3;
			}else if(c>d){
				point[a-1]=point[a-1]+3;
			}else if(c==d){
				point[a-1]=point[a-1]+1;
				point[b-1]=point[b-1]+1;
			}
		}//ここまで得点計算
		int rnk[]=new int[N];
		for(int i=0;i<N;i++){
		rnk[i]=1;
		for(int j=0;j<N;j++){
		if(point[i]<point[j]){
		rnk[i]=rnk[i]+1;
		}
	}
}
		for(int i=0; i<N;i++){
		System.out.println(rnk[i]);
		}
	}
}

Measured memory_bytes: 42120
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

char board[110][110];
const char WHITE = '.', BLACK = '#';
const int H = 100, W = 100;

signed main() {
    int A, B; cin >> A >> B;
    for(int i=0; i<H/2; i++) {
        for(int j=0; j<W; j++) {
            board[i][j] = WHITE;
            if(i%2 == 0 && j%2 == 0) {
                if(B > 1) {
                    board[i][j] = BLACK;
                    B--;
                }
            }
        }
    }
    for(int i=H-1; i>=H/2; i--) {
        for(int j=0; j<W; j++) {
            board[i][j] = BLACK;
            if(i%2 == 0 && j%2 == 0) {
                if(A > 1) {
                    board[i][j] = WHITE;
                    A--;
                }
            }
        }
    }

    printf("%lld %lld\n", H, W);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            printf("%c", board[i][j]);
        }
        printf("\n");
    }
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int N, T;
    std::cin >> N >> T;

    int mn = 1100;
    
    for(int i=0;i<N;++i){
        int c, t;
        std::cin >> c >> t;

        if(t <= T){
            mn = std::min(mn, c);
        }
    }

    if(mn < 1100){
        std::cout << mn << std::endl;
    }else{
        std::cout << "TLE" << std::endl;
    }
}


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

int main() {
    int n;
    int m;
 
   cin >> n >> m;
  
   int sum = 1;
  
for(int i = 0;i<n;i++){
  
  if(sum<m){
  sum = sum*2;
  
  }else{
    sum = sum+m;
  }
     

}

   
   
  
   cout << sum << endl;
  
  
  return 0;
}

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

struct Posi {
    ll x;
    ll y;
};

int main()
{
    ll N, M; cin >> N >> M;
    struct Posi P[N];
    vector<ll> Px(N, 0);
    vector<ll> Py(N, 0);
    struct Posi C[M];
    vector<ll> Cx(M, 0);
    vector<ll> Cy(M, 0);

    rep(i, N) {
        ll a, b; cin >> a >> b;
        Px[i] = a; Py[i] = b;
        P[i].x = a;
        P[i].y = b;
    }
    rep(i, M) {
        ll c, d; cin >> c >> d;
        Cx[i] = c; Cy[i] = d;
        C[i].x = c;
        C[i].y = d;
    }
    vector<ll> ans;
    rep(i, N) {
        ll min = -1;
        ll num = 0;
        rep(j, M) {
            ll tmp = abs(Px[i] - Cx[j]) + abs(Py[i] - Cy[j]);
            if (min == -1) {
                min = tmp; num = j; 
            }
            else if (min > tmp) {
                min = tmp; num = j;
            }
        }
        ans.push_back(num+1);
    }

    rep(i,N) {
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 3612
#include<stdio.h>

int main(void)
{
  int Ai, Am, As, Ae;
  int Bi, Bm, Bs, Be;
  int Asum, Bsum;

  scanf("%d %d %d %d", &Ai, &Am, &As, &Ae);
  scanf("%d %d %d %d", &Bi, &Bm, &Bs, &Be);

  Asum = Ai + Am + As + Ae;
  Bsum = Bi + Bm + Bs + Be;

  if (Asum > Bsum){
    printf("%d\n", Asum);
  }
  else if (Asum < Bsum){
    printf("%d\n", Bsum);
  }
  else if (Asum == Bsum){
    printf("%d\n", Asum);
  }

  return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N, 0);
    vector<int> B(N, 0);
    rep(i, N) { cin >> A[i] >> B[i]; }

    vector<int> dp(H + 1, INF);
    dp[0] = 0;
    for (int h = 0; h <= H; h++) {
        for (int i = 0; i < N; i++) {
            int nh = min(h + A[i], H);
            dp[nh] = min(dp[nh], dp[h] + B[i]);
        }
    }
    // dump(dp);
    cout << dp[H] << endl;
    return 0;
}

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

int main() {
  string w; cin >> w;
  string ans = "Yes";
  for (char c = 'a'; c <= 'z'; ++c) {
    int cnt = 0;
    for (int i = 0; i < w.size(); ++i) {
      if (w[i] == c) ++cnt;
    }
    if (cnt % 2 != 0) ans = "No";
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, cnt;
    string ans;
    cin >> N;
    cnt = 0;
    rep(i, N){
        int a;
        cin >> a;
        if(i+1 != a){
            cnt++;
        }
    }
    ans = "NO";
    if(cnt<=2){
        ans = "YES";
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
def line():return sys.stdin.readline().strip()

I = {}
while True:
    try:
        a,b = line().split()
        b = int(b)
        if a in I:
            I[a].append(b)
        else:
            I[a] = [b]
    except:
        break
for k in sorted(I):
    print(k)
    print(" ".join(map(str,sorted(I[k]))))

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

int main() {
  string S; cin >>S;
  int ans=0;
  rep(i,0,4) {
    if (S[i]=='+') ans++;
    else ans--;
  }
  cout <<ans <<endl;
  return 0;
}


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

int main(){
  constexpr int Nalp= 26;
  constexpr int INF= INT_MAX;

  string S,T;
  cin >> S >> T;
  if(S.size() > T.size()){
    swap(S, T);
  }

  vector<vector<int>> posT(Nalp);
  for(size_t t=0; t<T.size(); t++){
    int id_c= T.at(t)- 'a';
    posT.at(id_c).emplace_back(t);
  }

  vector<int> dpLIS(S.size()+1, INF);
  vector<string> CSs(S.size()+1);
  dpLIS.at(0)= -1;
  int len= 0;
  for(auto c:S){
    int id_c= c- 'a';

    int len_prev= len;
    for(int l=len_prev; l>= 0; l--){
      auto itr= upper_bound(posT.at(id_c).begin(), posT.at(id_c).end(), dpLIS.at(l));
      if(itr != posT.at(id_c).end() && dpLIS.at(l+1) > *itr){
        dpLIS.at(l+1)= *itr;
        CSs.at(l+1)= CSs.at(l)+ c;
      }
    }
    if(dpLIS.at(len+1) < INF){ len++; }
  }

  string ans= CSs.at(len);

  cout << ans << endl;
}

Measured memory_bytes: 12712
from bisect import bisect_left, bisect_right

def main():
    N, K =  [int(i) for i in input().split()]
    A =  sorted(list(map(int, input().split())))

    nega_end = bisect_left(A, 0)
    posi_start = bisect_right(A, 0)

    posi_cnt = N - posi_start
    nega_cnt = nega_end
    zero_cnt = N - (posi_cnt + nega_cnt)

    nega_pairs_cnt = posi_cnt * nega_cnt
    zero_pairs_cnt = zero_cnt * (posi_cnt + nega_cnt) + (zero_cnt * (zero_cnt-1) // 2)

    if K <= nega_pairs_cnt:
        ok, ng = 0, -10 ** 18

        while abs(ok - ng) > 1:

            X = (ok + ng) // 2
            or_higher_cnt, r = 0, posi_start

            for l in range(nega_end):
                while (r < N) and (A[l] * A[r] > X):
                    r += 1
                or_higher_cnt += posi_cnt - (r - posi_start)

            if or_higher_cnt >= K:
                ok = X
            else:
                ng = X
            #print(ok, ng)
        print(ok)

    elif nega_pairs_cnt < K <= nega_pairs_cnt + zero_pairs_cnt:
        print(0)
        return
    else:
        K -= (nega_pairs_cnt + zero_pairs_cnt)
        ok, ng = 10 ** 18, 0
        while abs(ok - ng) > 1:
            X = (ok + ng) // 2
            or_higher_cnt = 0
            r = N - 1
            for l in range(posi_start, N):
                while (r < N) and (A[l] * A[r] > X) and (l < r):
                    r -= 1
                or_higher_cnt += max(0, r - l)

            l = 0
            for r in range(nega_end - 1, -1, -1):
                while (l < N) and (A[l] * A[r] > X) and (l < r):
                    l += 1

                or_higher_cnt += max(0, r - l)

            if or_higher_cnt >= K:
                ok = X
            else:
                ng = X
        print(ok)
if __name__ == "__main__":
    main()

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

int main()
{
    int matrix[100][100];
    int b[100];
    long c[100];

    int n, m;

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

    // compute
    for(int i = 0; i < n; i++)
    {
        c[i] = 0;
        for(int j = 0; j < m; j++)
        {
            c[i] += matrix[i][j] * b[j];
        }
    }

    // output
    for(int i = 0; i < n; i++)
    {
        cout << c[i] << endl;
    }

    return 0;
}

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

int const N = 5000, md = 1e9 + 7;
int dp[N + 1][N + 1], x[N + 1], n, n1[N + 1], fc[N + 1], vis[N + 1], fr[N + 1];
vector<int> v;
bool bad[N + 1];

void ad(int &x, int y) { if ((x += y) >= md)x -= md; }

int go(int v){
	if (vis[v])return vis[v];
	if (bad[v])return v;
	vis[v] = v;
	return vis[v] = go(x[v]);
}

int main(){
	scanf("%d", &n);
	n1[0] = 1;
	f(i, 1, n + 1)n1[i] = (ll)n1[i - 1] * (n - 1) % md;
	fc[0] = 1;
	f(i, 1, n + 1)fc[i] = (ll)fc[i - 1] * i % md;
	
	f(i, 1, n + 1)scanf("%d", x + i);
	f(i, 1, n + 1)if (x[i] == -1)v.push_back(i), bad[i] = true;
	f(i, 1, n + 1){
		int t = go(i);
		if (bad[t])++fr[t];
	}
	
	int an = 0;
	f(i, 1, n + 1)if (vis[i] == i)ad(an, n1[v.size()]);
	dp[0][0] = 1;
	f(i, 0, v.size())f(j, 0, i + 1){
		ad(dp[i + 1][j + 1], (ll)dp[i][j] * fr[v[i]] % md);
		ad(dp[i + 1][j], dp[i][j]);
	}
	f(i, 2, v.size() + 1)ad(an, (ll)dp[v.size()][i] * fc[i - 1] % md * n1[v.size() - i] % md);
	f(i, 0, v.size())ad(an, (ll)(fr[v[i]] - 1) * n1[v.size() - 1] % md);
	
	an = (ll)n * n1[v.size()] % md - an;
	if (an < 0)an += md;
	printf("%d\n", an);
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
char S[1000010];
int Q;
ll sum[1000010];

int main(){
  scanf("%d",&N);
  scanf("%s",S);
  scanf("%d",&Q);
  rep(q,Q){
    int K;
    scanf("%d",&K);
    ll crtmsum=0;
    rep(i,N){
      if(S[i]=='M')crtmsum++;
      if(S[i]=='C')sum[i]=crtmsum;
    }
    ll res=0;
    crtmsum=0;
    ll totmcsum=0;
    ll cntc=0;
    rep(i,K){
      if(S[i]=='C'){
        cntc++; totmcsum+=sum[i];
      }
    }
    rep(i,N){
      if(S[i]=='D'){
        res+=totmcsum;
      }
      if(S[i]=='M'){
        crtmsum++; totmcsum-=cntc;
      }
      if(S[i]=='C'){
        cntc--;
      }
      if(i+K<N&&S[i+K]=='C'){
        cntc++; totmcsum+=sum[i+K]-crtmsum;
      }
    }
    printf("%lld\n", res);
  }

  return 0;
}


Measured memory_bytes: 9088
import java.util.*;

public class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		int i=1;
		if(k%2==0){
			System.out.println(-1);
			return;
		}
		int num=7;
		for(;i<=k;i++){
			if(num%k==0){
				System.out.println(i);
				return;
			}
			num=(num*10+7)%k;
		}
		System.out.println(-1);
		sc.close();
		return;
	}
}

Measured memory_bytes: 35768
def GCD(s, t):
    if s < t:
        s, t = t, s
    if t == 0:
        return s
    else:
        return GCD(t,s%t)

A, B, C, D = map(int, input().split())
E = C*D // GCD(C,D)
x = B // C - (A-1) // C
y = B // D - (A-1) // D
z = B // E - (A-1) // E
print(B-A-x-y+z+1)

Measured memory_bytes: 3064
import numpy as np
S = input()
l = len(S)
oddArr = np.arange(1,l+1,2)
evenArr = np.arange(2,l+1,2)
playable = True
for i in oddArr:
    if S[i-1]=='R' or S[i-1]=='U' or S[i-1]=='D':
        continue
    else:
        playable = False
        break
if playable:
    for i in evenArr:
        if S[i-1] == 'L' or S[i-1] == 'U' or S[i-1] == 'D':
            continue
        else:
            playable = False
            break
if playable:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12504
#include <stdio.h>
int main (){
int a,b,c,x,i,k=0,j,l;
  scanf ("%d%d%d%d",&a,&b,&c,&x);
for (i=0;i<a+1;i++){
if (x-(i*500)>-1){
for (j=0;j<b+1;j++){
if (x-(i*500)-(j*100)>-1){
for (l=0;l<c+1;l++){
if (x-(i*500)-(j*100)-(l*50)==0){
k++;
}
}
}
  else{
  break;
  }
}
}
else{
break;
}
}
printf ("%d",k);
return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int i;
  int pri,am;
  int bi1,bi5,bi10;

  for(;;){
    scanf("%d%d",&pri,&am);
    if(pri==0 && am==0)
      break;

    am-=pri;

    bi10=am/1000;
    am%=1000;
    bi5=am/500;
    am%=500;
    bi1=am/100;

    printf("%d %d %d\n",bi1,bi5,bi10);
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

typedef long long int ll;

const ll mod=998244353;

ll fact[200005];
ll fact_inv[200005];

class Comb{
public:
    Comb(ll N){
        fact[0]=1;
        fact_inv[0]=1;
        for(int i=1;i<=N;++i){
            fact[i]=fact[i-1]*i%mod;
            fact_inv[i]=modPow(fact[i],mod-2);
        }
    }

    ll modPow(ll a, ll n) {
        if(n==1)return a%mod;
        if (n%2==1)return(a*modPow(a,n-1))%mod;
        ll t=modPow(a,n/2);
        return (t*t)%mod;
    }

    ll comb(ll n,ll r){
        return (((fact[n]*fact_inv[r])%mod)*fact_inv[n-r])%mod;
    }
};

ll N,M,K;

int main(){
    cin>>N>>M>>K;
    ll ans=0;
    Comb C(N+1);
    ll P=M;
    for(int x=N-1;x>=0;--x){
        if(x<=K)ans+=C.comb(N-1,x)*P;
        P*=(M-1);
        P%=mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6716
#include <atcoder/convolution>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<long long> a(n), b(m);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &(a[i]));
    }
    for (int i = 0; i < m; i++) {
        scanf("%lld", &(b[i]));
    }

    vector<long long> c = convolution(a, b);
    // or: vector<long long> c = convolution<998244353>(a, b);

    for (int i = 0; i < n + m - 1; i++) {
        printf("%lld ", c[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 27280
#include<stdio.h>

int n, A[20];

int solve(int i, int m){
  if( m == 0 ) return 1;
  if( i >= n ) return 0;
  int res = solve(i+1, m) || solve(i+1, m-A[i]);
  return res;
}

int main(){
  int q, M, i;

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

  scanf("%d", &q);
  for( i = 0 ; i < q ; i++ ){
    scanf("%d", &M);
    if( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2044
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

#define ceil(a,b) (a%b?a/b+1:a/b)

signed main() {
	int n,d;
	std::cin >> n >> d;
	print(ceil(n,(2*d+1)));
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = 2.times.map{gets.chomp.split.map(&:to_i)}

dp = Array.new(2){Array.new(n,0)}
dp[0][0] = as[0][0]
dp[1][0] = dp[0][0] + as[1][0]
(0..n-2).each do |i|
	dp[0][i+1] = dp[0][i] + as[0][i+1]
	dp[1][i+1] = [dp[1][i] + as[1][i+1], dp[0][i+1] + as[1][i+1]].max
end

puts dp[1][n-1]

Measured memory_bytes: 3836
n, a, b = map(int, input().split())
mod = 10**9+7


def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0], r[1]-q*w[1], r[2]-q*w[2]]
        r = r2
        w = w2
    # [x,y]
    return [w[0], w[1]]


def mod_inv(a, m):
    x = extgcd(a, m)[0]
    return (m+x % m) % m


def comb(n, r, mod):
    u = 1
    d = 1
    for i in range(r):
        u *= n-i
        d *= i+1
        if u >= mod:
            u %= mod
        if d >= mod:
            d %= mod
    return u*mod_inv(d, mod)


def binary(n):
    return bin(n)[2:]


def pow_by_binary_exponentiation(a, x, n):  # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y


ac = comb(n, a, mod)
bc = comb(n, b, mod)
ans = pow_by_binary_exponentiation(2, n, mod)
print(((ans - ac - bc - 1) % mod)//1)


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string s;
    cin >> N >> s;
    char a[26] = {'A','B','C','D','E','F','G','H','I',
                'J','K','L','M','N','O','P','Q','R','S','T',
                'U','V','W','X','Y','Z'};
    for(int i = 0; i < s.length(); i++){
        int k;
        for(int j = 0; j < 26; j++){
            if(s[i] == a[j]){
                k = j;
            }
        }
        k += N;
        k %= 26;
        cout << a[k];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
//GCD(最大公約数)
ll gcd(ll a, ll b) {
   if(a < b) return gcd(b, a);
   if(b == 0) return a;
   return gcd(b, a % b);
}
//LCM(最小公倍数)
ll lcm(ll a, ll b) {
   return a / gcd(a, b) * b;  //オーバーフローする場合など 必要に応じて
}

int main() {
    ll a, b;
    cin >> a >> b;

    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x+r<=W){
        if(x-r>=0){
            if(y+r<=H){
                if(y-r>=0){
                    cout<<"Yes"<<endl;
                }else{
                    cout<<"No"<<endl;
                }
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3092
[n,m] = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(n):
    s = 0
    for j in range(m):
        s += a[i][j]
        print(str(a[i][j]) + " ",end='')
    print(s)

t = []
for j in range(m):
    u = 0
    for i in range(n):
        u += a[i][j]
    t.append(u)

for j in range(m):
    print(str(t[j]) + " ",end='')
print(sum(t))

Measured memory_bytes: 8304
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 4005;
int n, m, k;
int dp[maxN][maxN];
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
int ndp[maxN][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m >> k;
    swap(n, m);
    dp[0][0] = 1;
    for (int i = 1; i <= n + m; i++) {
        int cur = 0;
        for (int c = 0; c <= n; c++) {
            cur = sum(cur, dp[i - 1][c]);
            if (c - k >= 0) cur = sub(cur, dp[i - 1][c - k]);
            dp[i][c] = cur;
        }
    }
    for (int i = 1; i <= n + m; i++) {
        int cur = 0;
        for (int c = 0; c <= n; c++) {
            if (c) cur = sum(cur, dp[i - 1][c - 1]);
            if (c - k >= 0) cur = sub(cur, dp[i - 1][c - k]);
            ndp[i][c] = cur;
        }
    }
    for (int i = 0; i <= n + m; i++) {
        for (int c = 0; c <= n; c++) {
            if (c % (k - 1) != n % (k - 1)) ndp[i][c] = 0;
            if (c) ndp[i][c] = sum(ndp[i][c], ndp[i][c - 1]);
        }
    }
    int ans = 0;
    for (int digs = 1; digs <= n + m; digs++) {
        int r = n;
        int l = (k - 1) * (digs - 1) + k - m;
        l = max(l, 0);
        if (l > r) continue;
        int pp = ndp[digs][r];
        if (l) pp = sub(pp, ndp[digs][l - 1]);
//        cout << digs << " " << last << " " << l << " " << r << " " << pp << endl;
        ans = sum(ans, pp);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 124928
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n,x,t;
    cin>>n>>x>>t;

    ll q = n/x;
    ll ans=q*t;
    if(n%x!=0){
        ans+=t;
    }
    cout<<ans;

    return 0;
}

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

int main() {
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<long> V(N);
    for(auto& i : V)cin >> i;
    vector<vector<long>> left(N + 1), right(N + 1);
    for(unsigned long i = 0; i <= N; ++i){
        copy(V.begin(), V.begin() + i, back_inserter(left[i]));
        copy(V.rbegin(), V.rbegin() + i, back_inserter(right[i]));
        sort(left[i].rbegin(), left[i].rend());
        sort(right[i].rbegin(), right[i].rend());
        partial_sum(left[i].begin(), left[i].end(), left[i].begin());
        partial_sum(right[i].begin(), right[i].end(), right[i].begin());
    }
    long ans{0};
    for(unsigned long i = 1; i <= K; ++i)for(unsigned long j = 1; j + i <= K; ++j)for(unsigned long x = (i + 2) / 2, y = ~i & 1; x <= N && y < x; ++x, y += 2)for(unsigned long z = (j + 2) / 2, w = ~j & 1; z + x <= N && w < z; ++z, w += 2)ans = max(ans, left[x][y] + right[z][w]);
    for(unsigned long i = 1; i <= K; ++i)for(unsigned long x = (i + 2) / 2, y = ~i & 1; x <= N && y < x; ++x, y += 2)ans = max({ans, left[x][y], right[x][y]});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll x;
   cin >> x;
   ll store = 100;
   ll cnt = 0;
   while(1) {
       if(store>=x) {
           cout << cnt << endl;
           return 0;
       }
       store*=1.01;
       cnt++;
   }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
struct edge{
	int to,nxt;
}g[1100101];
int tot,dep[1010101],head[1010101],a[1010101],fa[1010101];
inline void made(int from,int to){
	g[++tot].to=to;g[tot].nxt=head[from];head[from]=tot;
}
void dfs(int u){
	dep[u]=dep[fa[u]]+1;
	for (int i=head[u];i;i=g[i].nxt){
		int v=g[i].to;
		if (v==fa[u]) continue;
		dfs(v);
	}
}
struct dataa{
	long double x;
	int sz,f,X;
}F[1010101];
int find(int u){
	if (F[u].f!=u) return F[u].f=find(F[u].f);
	return F[u].f;
}
inline bool operator < (dataa a,dataa b){
	return (fabs(a.x-b.x)<1e-23?(dep[a.f]==dep[b.f]?a.f<b.f:dep[a.f]>dep[b.f]):a.x<b.x);
}
set<dataa> S;
ll ans;
int main(){
	int n=read();
	for (int i=2;i<=n;i++){
		fa[i]=read();
		made(fa[i],i);made(i,fa[i]);
	}
	dfs(1);
	for (int i=1;i<=n;i++){
		a[i]=read();F[i].f=i,F[i].sz=1;
		F[i].x=a[i];F[i].X=a[i];
		if (i!=1) S.insert(F[i]);
	}
	dataa now;
	bool flag=1;
	while (S.size()){
		now=(*S.begin());
		S.erase(now);
		int FA=find(fa[now.f]);
		ans+=1ll*F[FA].X*(F[now.f].sz-F[now.f].X);
		if (S.find(F[FA])!=S.end()) S.erase(F[FA]);
		F[FA].sz+=F[now.f].sz;
		F[FA].X+=F[now.f].X;
		F[FA].x=(long double)F[FA].X/(long double)F[FA].sz;
		F[now.f].f=FA;
		if (FA!=1) S.insert(F[FA]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 41168
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{ return firstElof.second < secondElof.second; }
//**Snippetリスト**//
//rep, vin, all//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; 
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = INF;
vl flag, color; vll path; vl D;
//***********//
int main() {
	ll R;
	cin >> R;
	if (R >= 2800) cout << "AGC";
	else if (R < 1200) cout << "ABC";
	else cout << "ARC";
}
	


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
public class Test
{
    public static void Main(string[] vs)
    {
        char[] s = new char[] { 'A', 'C', 'G', 'T' };
        int i = 0;
        Console.WriteLine(
        Console.ReadLine().ToCharArray().Select(c => s.Contains(c))
            .Select((b) =>
            {
                if (b)
                    i++;
                else
                    i = 0;
                return i;
            }).Max());
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define pq priority_queue
#define st first
#define nd second

using namespace std;
typedef long long ll;
ll const inf = 1e9;
ll const mod = 998244353;

int a[9];
int n;
int ans = 0;
void gen(int s, int f, int t, int i, bool ok){

    if(i == n){
        ans += (min(s, min(t, f)) > 0);
        return;
    }
    else{
        if(ok){
            gen(s + 1, f, t, i + 1, ok);
            gen(s, f + 1, t, i + 1, ok);
            gen(s, f, t + 1, i + 1, ok);
        }
        else{
            if(a[i] >= 7) gen(s + 1, f, t, i + 1, !(a[i] == 7));
            if(a[i] >= 5) gen(s, f + 1, t, i + 1, !(a[i] == 5));
            if(a[i] >= 3) gen(s, f, t + 1, i + 1, !(a[i] == 3));

        }
    }
}
void gen2(int s, int f, int t, int i){
    ans += (min(s, min(t, f)) > 0);
    if(i == n - 1){
        return;
    }
    else{
        gen2(s + 1, f, t, i + 1);
        gen2(s, f + 1, t, i + 1);
        gen2(s, f, t + 1, i + 1);

    }


}
int main()
{
    string s;
    cin >> s;
    n = (int)s.size();
    fr(i, 0, n){
        a[i] = (int)(s[i] - '0');
    }
    gen(0, 0, 0, 0, 0);
    gen2(0, 0, 0, 0);
    cout << ans << endl;
    return 0;

}


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

int N, Q;
char s[200002], t[200000], d[200000];

int judge(int x){
	if(x == 0) return -1;
	if(x == N+1) return 1;
	for(int i=0; i<Q; i++){
		if(s[x] == t[i]){
			if(d[i] == 'L') x--;
			else x++;
			if(x <= 0) return -1;
			if(x > N) return 1;
		}
	}
	return 0;
}

int search_left(void){
	int i = 0, j = N+1;
	while(j-i > 1){
		int m = (i+j)/2;
		if(judge(m) >= 0) j = m;
		else i = m;
	}
	return j;
}

int search_right(void){
	int i = 0, j = N+1;
	while(j-i > 1){
		int m = (i+j)/2;
		if(judge(m) == 1) j = m;
		else i = m;
	}
	return j;
}

int main(){
	cin >> N >> Q;
	for(int i=1; i<=N; i++) cin >> s[i];
	for(int i=0; i<Q; i++) cin >> t[i] >> d[i];
	cout << search_right() - search_left() << endl;
	return 0;
}


Measured memory_bytes: 768
N, M = gets.split.map(&:to_i)

ans = 0
1.upto(Float::INFINITY) do |i|
  last_pb = 0.5**M
  rest_pb = 1 - last_pb
  pb = (rest_pb ** (i-1)) * last_pb
  break if pb == 0
  time = ((N-M)*100 + M*1900) * i
  #p i: i, pb: pb, time: time
  ans += pb * time
end
p ans.round


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=5005,Mod=1e9+7;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,a,b,Sum[MAXN],f[MAXN][MAXN],tmp[MAXN][MAXN];
inline void Add(int&x,int y){x+=y,x>=Mod?x-=Mod:0;}
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),a=read(),b=read();if(a>b)swap(a,b);
	f[0][0]=1;
	Rep(i,0,n){
		if(i)Add(Sum[i],Sum[i-1]);Add(f[i][1],Sum[i]);
		Rep(j,1,b)Add(f[i][j],tmp[i][j]),Add(tmp[i+1][min(j+1,b)],tmp[i][j]);
		if(i==n)break;
		Rep(j,0,b-1){
			Add(f[i+1][j+1],f[i][j]),Add(Sum[i+2],f[i][j]);
			if(i+a+1<=n)Add(Sum[i+a+1],Mod-f[i][j]),Add(tmp[i+a+1][min(j+a+1,b)],f[i][j]);
			if(n-i>=a)Add(f[n][min(n-i+j,b)],f[i][j]);
		}
	}int ans=0;
	Rep(i,1,n)ans=(ans+1ll*Fp(2,n-i)*f[i][b])%Mod;
	cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 199148
N = int(input())
P = list( map( int, input().split() ) )

P_ = sorted( P )

cnt = 0
for i in range( len( P )):
  if P[i] != P_[i]:
    cnt += 1
if cnt in [ 0, 2 ]:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main(void){
  int day, xxoo, ooxx, judge_xxoo=0, judge_ooxx=0;
  cin >> day;
  xxoo = day / 100;
  ooxx = day % 100;

  if(xxoo > 12 || xxoo ==0) judge_xxoo = 1;
  if(ooxx > 12 || ooxx ==0) judge_ooxx = 1;

  // cout << judge_ooxx << ":" << judge_xxoo << endl;

  if(judge_ooxx){
    if(judge_xxoo) cout << "NA" << endl;
    else if(judge_xxoo==0) cout << "MMYY" << endl;
  }else if(judge_ooxx==0){
    if(judge_xxoo==0) cout << "AMBIGUOUS" << endl;
    else if(judge_xxoo) cout << "YYMM" << endl;
  }

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

Measured memory_bytes: 764
import queue

q=queue.Queue()
for i in range(1,10):
    q.put(i)
    
k=int(input())

a=0

for i in range(k):
    a=q.get()
    if a%10!=0:
        q.put(10*a+a%10-1)
    q.put(10*a+a%10)
    if a%10!=9:
        q.put(10*a+a%10+1)

print(a)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

int n, m;
bool broken[MAX_N];

ll dp[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i <= n; ++i) {
    broken[i] = false;
  }

  for (int i = 0; i < m; ++i) {
    int tmp;
    scanf("%d", &tmp);

    broken[tmp] = true;
  }

  dp[0] = 1LL;

  for (int i = 0; i < n; ++i) {
    if (broken[i]) continue;

    dp[i + 1] += dp[i];
    dp[i + 1] %= MOD;

    dp[i + 2] += dp[i];
    dp[i + 2] %= MOD;
  }

  printf("%lld\n", dp[n]);

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	int n,x[200000],y[200000], t[200000];\
	cin>>n;
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i=1;i<=n;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	bool f=1;
	for(int i=1;i<=n;i++){
		int k=x[i]-x[i-1];
		int s=y[i]-y[i-1];
		k=abs(k);
		s=abs(s);
		if((k+s)%2!=(t[i]-t[i-1])%2){
			f=0;
		}
		if(k+s>t[i]-t[i-1]){
			f=0;
		}
	}
	if(f==1){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 2432
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

struct edge {
    int from, to;
};

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 50;
const int MAX_M = 50;

int N, M;

edge E[MAX_M];

int par[MAX_N]; //親
int t_rank[MAX_N]; //木の深さ

// n要素で初期化
void init(int n)
{
    for (int i = 0; i < n; i++) {
        par[i] = i;
        t_rank[i] = 0;
    }
}

// 木の根を求める
int find(int x)
{
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (t_rank[x] < t_rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (t_rank[x] == t_rank[y])
            t_rank[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y)
{
    return find(x) == find(y);
}

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

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        edge e = { s, t };
        E[i] = e;
    }

    int ans = 0;

    for (int i = 0; i < M; i++) {
        init(N);
        for (int j = 0; j < M; j++) {
            if (i != j) {
                edge e = E[j];
                if (!same(e.from, e.to)) {
                    unite(e.from, e.to);
                }
            }
        }
        int g = find(0);

        for (int k = 1; k < N; k++) {
            if (g != find(k)) {
                ans++;
                break;
            }
        }
    }



    cout << ans << "\n";

    return 0;
}

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

ll MAX=200005;
ll n;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = n;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * (n+1-i) % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[k] * (finv[k] % MOD) % MOD;
}

ll power(ll n){
    if(n==1)return 2;
    if(n%2==1){return 2*power((n-1)/2)*power((n-1)/2)%MOD;}
    else{return power(n/2)*power(n/2)%MOD;}
}

int main() {
  ll a,b;
  cin>>n>>a>>b;
  COMinit();
  ll ans=power(n);

  ans+=MOD-COM(n,a);
  ans%=MOD;
  ans+=MOD-COM(n,b);
  ans%=MOD;
  cout<<ans-1<<endl;
}

Measured memory_bytes: 4992
#include<string>
#include<iostream>

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

using namespace std;

int main() {
    Radix r;
  int n,k;
  cin >> n >> k;
  
  string s;
  
  s = r.to(n,k);
    
    cout << s.size() << endl;
    return 0;
}


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

int main() {
  int x,n,a;
  cin >> x >> n;
  vector<int> p(n);
  vector<int> arr(101, 1);
  for(int i=0; i<n; i++){
    cin >> a;
    arr.at(a) = 0;
  }
  int j=1, check = 1;
  if(arr.at(x)==1){
    cout << x << endl;
    return 0;
  }
  while(check==1){
    if(x+j > 100){
      int ans = x+j;
      if(arr.at(x-j)==1){
        ans = x-j;
      }
      cout << ans << endl;
      return 0;
    }
    if(x-j < 1){
      int ans = x-j;
      if(arr.at(x+j)==1){
        ans = min(x-j,x+j);
      }
      cout << ans << endl;
      return 0;
    }
    if(x-j < 1){
      int ans = min(abs(x+j), abs(x-j));
      cout << ans << endl;
      return 0;
    }
    if(arr.at(x-j)==1){
      cout << x-j << endl;
      return 0;
    }
    else if(arr.at(x+j)==1){
      cout << x+j << endl;
      return 0;
    }
    j++;
  }
}

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

const int N = 3005;

int a[N];
int dp[N];
bool mark[N];
vector <int> adj[N];

void dfs(int v) {
	mark[v] = true;
	dp[v] = false;
	for (auto u : adj[v]) {
		if (!mark[u]) {
			dfs(u);
			if (!dp[u] && a[v] > a[u]) {
				dp[v] = true;
			}
		}
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		fill(mark, mark + n + 1, false);
		fill(dp, dp + n + 1, false);
		dfs(i);
		if (dp[i]) {
			cout << i << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n,m;
int ans;

int main()
{
    //~ freopen("file.in", "r", stdin);
    scanf("%d%d",&n,&m);
	ans=n*m-n-m+1;

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


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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define vl vector<ll>

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vl a(n); rep(i, n) cin >> a[i];
  vl s(n+1); rep(i, n) s[i+1] = s[i] + a[i];

  ll ans = INF;
  rep(i, n){
    chmin(ans, abs(s[i+1] - (s[n] - s[i+1]) ) );
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 3328
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;
 
//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());
  int res = 0;
  rep(i,k) res += p[i];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{
	string s;
	int i;
	int n;
	string a;
	cin >> s;
	n = s.size() / 2 + s.size() % 2;
	
	for (i = 0; i < n; i++) {
		a.push_back(s[2 * i]);
	}

	cout << a << endl;

	return (0);
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int n, a, i, s=0;

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



Measured memory_bytes: 128