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 REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr << #x << ": " << x << endl;

#define fi first
#define se second

#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int    inf = 100100100;
const int    MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int    dx[4] = {0, 1, 0, -1};
const int    dy[4] = {1, 0, -1, 0};


int w, h;
int sx, sy, gx, gy;
int G[25][25] = {};


int dfs(int x, int y, int depth) {
    if (depth > 10) return 11;
    int mi = 11;
    rep(i, 4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (G[ny][nx] == 1) continue;
        if (nx == gx && ny == gy) return depth + 1;
        if (ny + dy[i] < 0 || h <= ny + dy[i] || nx + dx[i] < 0 || w <= nx + dx[i]) continue;
        while (G[ny + dy[i]][nx + dx[i]] != 1) {
            nx += dx[i];
            ny += dy[i];
            if (nx == gx && ny == gy) return depth + 1;
            if (ny + dy[i] < 0 || h <= ny + dy[i] || nx + dx[i] < 0 || w <= nx + dx[i]) break;
        }
        if (ny + dy[i] < 0 || h <= ny + dy[i] || nx + dx[i] < 0 || w <= nx + dx[i]) continue;
        G[ny + dy[i]][nx + dx[i]] = 0;
        mi = min(mi, dfs(nx, ny, depth + 1));
        G[ny + dy[i]][nx + dx[i]] = 1;
    }
    return mi;
}

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

//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());

    while (cin >> w >> h, w) {
        memset(G, 0, sizeof(G));

        rep(y, h) rep(x, w) {
                cin >> G[y][x];
                if (G[y][x] == 2) sx = x, sy = y;
                if (G[y][x] == 3) gx = x, gy = y;
            }
        int ans = dfs(sx, sy, 0);
        if (ans > 10) ans = -1;
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s,t;
  cin>>s>>t;
  if(s.size()>t.size())
    cout<<"GREATER"<<endl;
  else if(s.size()<t.size())
    cout<<"LESS"<<endl;
  else{
    if(s==t) cout<<"EQUAL"<<endl;
    else if(s>t) cout<<"GREATER"<<endl;
    else cout<<"LESS"<<endl;
  }
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------
bool used[limit] = {};
vector<int> E[limit];

bool check(int s, int t) {
    for (auto e : E[s]) if (!used[e]) return false;
    for (auto e : E[t]) if (!used[e]) return false;
    return true;
}

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

    int s, t;

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (i == 0) s = a, t = b;
        E[a].push_back(b);
        E[b].push_back(a);
    }

    deque<int> que;
    que.push_back(s);
    que.push_back(t);
    used[s] = used[t] = true;

    while (1) {
        if (check(s, t)) break;
        for (auto e : E[s]) {
            if (used[e]) continue;
            used[e] = true;
            que.push_front(e);
            s = e;
            break;
        }
        for (auto e : E[t]) {
            if (used[e]) continue;
            used[e] = true;
            que.push_back(e);
            t = e;
            break;
        }
    }
    cout << que.size() << endl;
    rep(i, que.size()) cout << que[i] << (i == que.size() - 1 ? "\n" : " ");
    return 0;
}



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

int main(void)
{
    int N, R;
    cin >> N >> R;

    if (N >= 10) {
        cout << R << endl;
    }
    else {
        cout << R + (100 * (10 - N)) << endl;
    }

    return 0;
}

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

using namespace std;

#define ll long long

const int MAXN = 1001;
const int mod = 1000000007;

int n;
int m;
int a[MAXN + 1];
int b[MAXN + 1];
int Max[MAXN + 1][MAXN + 1];
int s[MAXN * MAXN + 1];
int A[MAXN * MAXN + 1];
int B[MAXN * MAXN + 1];
int S[MAXN * MAXN + 1];

int main() {
	memset(Max, 127, sizeof(Max));
	ll res = 1;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if(A[a[i]]) {
			puts("0");
			return 0;
		}
		A[a[i]] = i;
		for(int j = 1; j <= m; j++)
			Max[i][j] = min(Max[i][j], a[i]);
	}
	for(int j = 1; j <= m; j++) {
		scanf("%d", &b[j]);
		if(B[b[j]]) {
			puts("0");
			return 0;
		}
		B[b[j]] = j;
		for(int i = 1; i <= n; i++)
			Max[i][j] = min(Max[i][j], b[j]);
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {
			s[Max[i][j]]++;
			S[a[i]] += Max[i][j] == a[i];
			S[b[j]] += Max[i][j] == b[j];
		}
	for(int i = n * m; i >= 1; i--) if(A[i] && B[i]) S[i] = 1;
	for(int i = n * m; i >= 1; i--) {
		s[i] += s[i + 1];
		if(A[i] || B[i])
			res = res * S[i] % mod;
		else
			res = res * s[i] % mod;
		s[i]--;
	}
	printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 13824
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	string s,ans="None";
	cin >> s;
	vector<bool> b(26, false);
	for (int i = 0;i < s.size();i++) {
		b[s[i] - 'a'] = true;
	}
	for (int i = 0;i < 26;i++) {
		if (b[i] == false) {
			ans = i + 'a';
			break;
		}
	}
	cout << ans << endl;
}

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i=0;i<N;i++)cin >> L.at(i);
  int count = 1;
  int D = 0;
  for(int i=0;i<N;i++){
    D += L.at(i);
    count++;
    if(X<D){
      count--;
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
using namespace std;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef pair<ll,ll> P;
int main(){
    string s; cin >> s;
    int ans = 0;
    rep(i,4){
        if(s[i]=='+') ans++;
        else ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && b != c) || (a == c && b != c) || (b == c && b != a)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    string year = S.substr(0, 4);
    string month = S.substr(5, 5);

    if(year <= "2019"){
        if(month <= "04/30"){
            cout << "Heisei" << endl;
        }
        else{
            cout << "TBD" << endl;
        }
    }
    else{
        cout << "TBD" << endl;
    }  
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 51;

int n, cnt[26][MAXN];
string s;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    REP (u, n) {
        cin >> s;
        int cur[26] = {};
        for (auto c : s) {
            cur[c - 'a']++;
        }
        REP (i, 26) {
            REP (j, cur[i]+1) {
                cnt[i][j]++;
            }
        }
    }

    REP (i, 26) {
        RREP (j, MAXN-1) {
            if (cnt[i][j] == n) {
                REP (k, j) {
                    cout << char(i+'a');
                }
                break;
            }
        }
    }
    cout << endl;
    return 0;
}


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

int main()
{
    int x,y;
    cin >> x >> y;
    if(x == 1 || x == 3 ||x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
        if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
            cout << "Yes";
            return 0;
        }
    }
    if(x == 4 || x == 6 || x == 9 || x == 11){
        if(y == 4 || y == 6 || y == 9 || y == 11){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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 long long INF = 1LL << 60;

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

    int cnt=0;
    REP(n, 999+1){
        char c[3]={n/100, (n/10)%10, n%10};
        int f=0;
        REP(i, N){
            if(S[i]==c[f]+'0') f++;
            if(f==3) break;
        }
        if(f==3) cnt++;
    }

    cout << cnt << endl;   

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll aa = max(a*c, a*d);
    ll bb = max(b*c, b*d);
    cout << max(aa, bb) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
    int x[3000],y[3000],i,j;

    for (i = 0; i < 3000; i++) {
      scanf("%d %d",&x[i],&y[i]);
        if(x[i] == 0 && y[i] == 0)
          break;
        j++;
      }

    for (i = 0; i < j; i++) {
       if (x[i] <= y[i]) {
        printf("%d %d\n",x[i],y[i]);
     } else {
        printf("%d %d\n",y[i],x[i]);
     }
    }

    return 0;
}

Measured memory_bytes: 624
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll T;
  T = 1;
  while(T--) {
    char x;
    cin >> x;
    if(x >= 'a' and x <= 'z') cout << 'a';
    else cout << "A";
  }
  return 0;
} //good night.


Measured memory_bytes: 3648
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_D

def postorder(binary_tree, target_index, result):
    
    left = binary_tree[target_index]["left"]
    right = binary_tree[target_index]["right"]
    
    if not left == -1:
        postorder(binary_tree, left, result)
    if not right == -1:
        postorder(binary_tree, right, result)

    result.append(target_index)

def solve(preorder_list, inorder_list, result):
    #print(preorder_list, inorder_list)
    if len(inorder_list) == 1:
        return inorder_list[0]
    
    parent = preorder_list[0]
    left_trees = inorder_list[:inorder_list.index(parent)]
    right_tree_index = 1
    if left_trees:
        result[parent]["left"] = solve(preorder_list[1:], left_trees, result)
        right_tree_index = len(left_trees) + 1
        
    right_trees = inorder_list[inorder_list.index(parent) + 1:]
    if right_trees:
        result[parent]["right"] = solve(preorder_list[right_tree_index:], right_trees, result)

    return parent

def reconstruction(preorder_list, inorder_list, node_num):
    result = [{"left":-1,"right":-1} for i in range(node_num + 1)]
    solve(preorder_list, inorder_list, result)
    return result

def main():
    node_num = int(input())
    preorder_list = [int(a) for a in input().split()]
    inorder_list = [int(a) for a in input().split()]
    binary_tree = reconstruction(preorder_list, inorder_list, node_num)
    postorder_list = []
    postorder(binary_tree, preorder_list[0], postorder_list)
    print(*postorder_list)
if __name__ == "__main__":
    main()

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

int main() {
    int X, x, n, max, n_num;
    max = 0;
    n_num = 0;
    cin >> X;
    x = floor(sqrt(X));
    //cout << x << endl;

    if(X==1) {
        //cout << 1;
        max = 1;
    }
    else {
        for(int i=2; i<=x; i++) {
            n = 2;
            n_num = 0;
            while(n_num<X) {
                n_num = int(pow(double(i), double(n)));
                //cout << n_num << endl;
                if(max<=n_num && n_num<=X) {
                    max = n_num;
                }
                n++;
            }
        }
    }
    
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0181


"""
import sys
from sys import stdin
input = stdin.readline


def Cond(m, n, mid, books):
    rem = mid
    i = 0
    while True:
        while rem >= books[i]:
            rem -= books[i]
            i += 1
            if i == n:
                break
        rem = mid
        m -= 1
        if i == n:
            break

    if m < 0:
        return False
    else:
        return True


def solve(m, n, books):
    ub = 1500000
    lb = max(books)

    min_width = float('inf')
    for i in range(30):
        mid = (ub + lb) // 2
        if Cond(m, n, mid, books):
            min_width = min(min_width, mid)
            ub = mid
        else:
            lb = mid
    return min_width


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        books = [int(input()) for _ in range(n)]
        result = solve(m, n, books)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

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

int main() {
  int x,y;
  cin>>x>>y;
  if((2*x<=y && y<=4*x) && y%2==0){
    cout<<"Yes"<<endl;
  }
  
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	char s[202]={0,},p[101]={0,};
    int i,j,n,count=0,ssize=0,psize=0;
	
	scanf("%s", &s);
	scanf("%s", &p);
    while(1){
		if(s[ssize++]=='\0') break;
	}
	while(1){
		if(p[psize++]=='\0') break;
	}
	for(i=0;i<ssize;i++){
		s[ssize+i-1]=s[i];
	}
	n=(ssize-1)*2;
	for(i=0;i<n;i++){
		if(s[i]==p[count]){
			while(1){
				if(s[i+count]==p[count]) count++;
				else break;
			}
			if(count==(psize-1)) break;
			else count=0;
		}
	}

	if(count==(psize-1)) printf("Yes\n");
	else printf("No\n");

	return 0;   
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <functional>

using namespace std;

#define tp template
#define tn typename
#define cl class
#define us using

us str=string;
us ll=long long;
us ul=unsigned long long;
us sz=size_t;
tp<cl T,sz N>us ary=array<T,N>;
tp<sz N>using ari=array<ll,N>;

#define rep(i, n) for(ll i = 0,i##_len=(n); i < i##_len; i++)
#define loop(i, n, m) for(ll i = (n),i##_len<=(m); i < i##_len; i++)
#define all(x) (x).begin(),(x).end()

tp<tn a,tn f>void setary(a b,a e,f l){ll c=0;for(a i=b;i!=e;i++){*i=l(c);c++;}}

int main(){
	int h,w,cv[52][52];
	cin >> h >> w;
	rep(i,h+2)
	rep(j,w+2)
		cv[i][j] = 0;
	rep(i,h){
		str buf;
		cin >> buf;
		rep(j,w){
			cv[i+1][j+1] = buf[j]=='.'?0:1;
		}
	}
	string ans = "Yes";
	rep(i,h)
	rep(j,w)
		if(
			cv[i][j+1]+cv[i+1][j]+cv[i+1][j+2]+cv[i+2][j+1] == 0 && cv[i+1][j+1] == 1
		){
			ans = "No";
		}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << a[k - 1] << endl;
  return;
}

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


Measured memory_bytes: 256
N, A, B = map(int, input().split())

# 別解：10で割った余りを足していく
ans = 0
for n in range(1, N+1):
  s = 0
  m = n
  while m > 0:
    s += m % 10
    m = m // 10
  if A <= s and s <= B: ans += n
    
print(ans)

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

#define MAX 100000

int n, k;
long long baggage[MAX];

int check(long long P)
{
  int i = 0;
  for (int j = 0; j < k; j++)
  {
    long long sum = 0;
    while (sum + baggage[i] <= P)
    {
      sum += baggage[i];
      i++;
      if (i == n)
        return n;
    }
  }
  return i;
}

int solve()
{
  long long left = 0;
  long long right = 100000 * 10000;
  long long mid;
  while (right - left > 1)
  {
    mid = (left + right) / 2;
    int v = check(mid);
    if (v >= n)
    {
      right = mid;
    }
    else
    {
      left = mid;
    }
  }

  return right;
}

int main()
{
  cin >> n >> k;

  for (int i = 0; i < n; i++)
  {
    cin >> baggage[i];
  }

  long long answer = solve();

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3892
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    if (n in 400..599) {
        println(8)
    } else if (n in 600..799) {
        println(7)
    } else if (n in 800..999) {
        println(6)
    } else if (n in 1000..1199) {
        println(5)
    } else if (n in 1200..1399) {
        println(4)
    } else if (n in 1400..1599) {
        println(3)
    } else if (n in 1600..1799) {
        println(2)
    } else {
        println(1)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34400
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;
#define MAX 100000

int n,k;
ll T[MAX];

int check(ll P){
	int i = 0;
	REP(j,k){
		ll s = 0;
		while(s + T[i] <= P){
			s += T[i];
			i++;
			if(i == n) return n;
		}
	}
	return i;
}

int solve(){
	ll left = 0;
	ll right = MAX * 10000;
	ll mid;
	while(right - left > 1){
		mid = (left + right) / 2;
		int v = check(mid);
		if(v >= n) right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	cin >> n >> k;
	REP(i,n) cin >> T[i];
	cout << solve() << endl;
}


Measured memory_bytes: 3892
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(3*n);
  long long ans = 0;
  for(int i=0;i<3*n;i++)cin>>a[i];
  sort(a.rbegin(),a.rend());
  for(int i=0;i<2*n;i++){
    if(i&1) ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
    char s;
    char boin[5] = {'a', 'i', 'u', 'e', 'o'};
    scanf("%c", &s);
    for(int i=0; i<5; i++){
        if(s==boin[i]){
            puts("vowel");
            return 0;
        }
    }
    puts("consonant");
    return 0;
}

Measured memory_bytes: 1600
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll n;
vector<ll> g;
int main()
{
    fastio();
    cin>>n;
    ll now = 0,t = 1;
    for(int i=1;;i++){
        g.pb(t);
        t = t*26;
        now += t;
        if(now>=n){
            n -= now-t+1;
            reverse(g.begin(),g.end());
            int sz = g.size();
            rep(j,0,sz-1){
                char ans = 'a' + n/g[j];
                cout<<ans;
                n%=g[j];
            }
            break;
        }
    }
    return 0;
}


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

int h, w;
char board[101][101];
int d[101][101];
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};

void dfs(int x, int y) {
    d[x][y] = 1;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx >= 0 && nx < h && ny >= 0 && ny < w && d[nx][ny] == 0 &&
            board[nx][ny] == board[x][y]) {
            dfs(nx, ny);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    while (cin >> h >> w && !(h == 0 && w == 0)) {
        memset(d, 0, sizeof(d));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) cin >> board[i][j];
        }
        int r = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (d[i][j] == 0) {
                    r++;
                    dfs(i, j);
                }
            }
        }
        cout << r << "\n";
    }
}


Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] x=new int[n];
        int min=Integer.MAX_VALUE;
        int max=Integer.MIN_VALUE;
        for(int i=0;i<n;i++)
        {
            x[i]=sc.nextInt();
            min=Math.min(min,x[i]);
            max=Math.max(max,x[i]);
        }
       int left=min,right=max+1;
       int res=Integer.MAX_VALUE;
       for(int i=left;i<right;i++)
       {
           res=Math.min(res,dis(x,i));
       }
       System.out.println(res);

    }
    public static int dis(int[] x, int p)
    {
        int res=0;
        for(int num: x)
        {
            res+=(num-p)*(num-p);
        }
        return res;
    }
}

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

using namespace std;
int n;
bool open[105][15];
long long p[105][15];

long long cal(int x)
{
	long long ret=0;
	for(int i=1;i<=n;i++)
	{
		int sum=0;
		for(int j=0;j<=9;j++)
			if(open[i][j] && (x&(1<<j))) sum++;
		ret+=p[i][sum];
	}
	return ret;
}

int main()
{	
	cin >> n;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=9;j++)
			cin >> open[i][j];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=10;j++)
			cin >> p[i][j];
	
	long long res=-(1<<30);
	for(int i=1;i<=1023;i++)
	{
		long long temp=cal(i);
		res=max(res,temp);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    ll res=0;
    for(int i=1;i<=n;i++)res+=((n-1)/i);
    cout<<res<<endl;
}

Measured memory_bytes: 3592
N, X = [int(_) for _ in input().split()]


def count(n, x):
    if [n, x] == [0, 1]:
        return 1
    elif x == 1:
        return 0
    elif x < 2 * 2 ** n - 1:
        return count(n - 1, x - 1)
    elif x == 2 * 2 ** n - 1:
        return count(n - 1, 2 * 2 ** n - 3) + 1
    elif x < 4 * 2 ** n - 3:
        return count(n - 1, 2 * 2 ** n - 3) + 1 + \
            count(n - 1, x - 2 * 2 ** n + 1)
    else:
        return 2 * count(n - 1, 2 * 2 ** n - 3) + 1


print(count(N, X))


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    string ans = "No";

    if (abs(c - a) <= d) {
        ans = "Yes";
    }

    if ((abs(b - a) <= d) && (abs(c - b) <= d)) {
        ans = "Yes";
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,pos;
int a[40],b[40];

void solve(int k,int r){
  if(k>r){
      return;
  }
  if(k==r){
    if(b[k]==a[0])printf("%d",b[k]);
    else printf("%d ",b[k]);
    pos++;
    return;
  }

  int x=a[pos],i;
  pos++;
  for(i=k;i<=r;i++){
    if(b[i]==x)break;
  }
  solve(k,i-1);
  solve(i+1,r);
  
  if(x==a[0])printf("%d",x);
  else printf("%d ",x);
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
      scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
      scanf("%d",&b[i]);
  }
  pos=0;
  solve(0,n-1);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

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

		int hp = sc.nextInt();
		int attack = sc.nextInt();

		int count = 0;

		count = hp / attack;

		if(hp % attack >= 1) {
			count++;
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 23764
from fractions import gcd
n=int(input())
a=[int(i) for i in input().split()]
l=[0]*n
r=[0]*n
for i in range(n-1):
    l[i+1]=gcd(l[i],a[i])
    r[i+1]=gcd(r[i],a[n-i-1])
r=r[::-1]
g=[]
for i in range(n):
    g.append(gcd(l[i],r[i]))
print(max(g))

Measured memory_bytes: 16156
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<iterator>
#include<cstdio>


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;


int main()
{
    SAM;
    int n,q;
    ll sum=0;
    cin>>n;
    vector<int> v(mxn);

    FOR(i,0,n)
    {
    	int x;
    	cin>>x;
    	sum+=x;
    	v[x]++;
    }

    cin>>q;
    FOR(i,0,q)
    {
    	int b,c;
    	cin>>b>>c;
    	sum+=v[b]*(c-b);
    	v[c]+=v[b];
    	v[b]=0;

    	cout<<sum<<"\n";

    }
}




Measured memory_bytes: 3972
import sys
input=sys.stdin.readline

a,b,q=map(int,input().split())
A=[]
for i in range(a):
    A.append(int(input()))
B=[]
for i in range(b):
    B.append(int(input()))
Q={}
for i in range(q):
    Q[int(input())]=i
X=sorted(Q)

C=[]
now=0
for i in range(a):
    while now<b and A[i]>=B[now]:
        now+=1
    if now==0:
        C.append(abs(A[i]-B[0]))
    elif now==b:
        C.append(abs(A[i]-B[b-1]))
    else:
        C.append(min(abs(A[i]-B[now-1]),abs(A[i]-B[now])))
D=[]
now=0
for i in range(b):
    while now<a and B[i]>=A[now]:
        now+=1
    if now==0:
        D.append(abs(B[i]-A[0]))
    elif now==a:
        D.append(abs(B[i]-A[a-1]))
    else:
        D.append(min(abs(B[i]-A[now-1]),abs(B[i]-A[now])))

Y=[]
now=0
for i in range(q):
    while now<b and X[i]>=B[now]:
        now+=1
    if now==0:
        Y.append(abs(X[i]-B[0])+D[0])
    elif now==b:
        Y.append(abs(X[i]-B[b-1])+D[b-1])
    else:
        Y.append(min(abs(X[i]-B[now-1])+D[now-1],
                     abs(X[i]-B[now])+D[now]))
Z=[]
now=0
for i in range(q):
    while now<a and X[i]>=A[now]:
        now+=1
    if now==0:
        Z.append(abs(X[i]-A[0])+C[0])
    elif now==a:
        Z.append(abs(X[i]-A[a-1])+C[a-1])
    else:
        Z.append(min(abs(X[i]-A[now-1])+C[now-1],
                     abs(X[i]-A[now])+C[now]))
        
Ans=[0]*q
for i in range(q):
    x=Q[X[i]] #番号
    Ans[x]=min(Y[i],Z[i])
for ans in Ans:
    print(ans)

Measured memory_bytes: 83676
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,m,j,b,ai,l;
    unsigned long long int  a[101][101], gh[101][101],ans[101][101];
    
    scanf("%d %d %d",&n,&m,&l);
    for(j=0;j<101;j++){
        for(b=0;b<101;b++){
            ans[j][b]=0;
            a[j][b]=0;
            gh[j][b]=0;
        }
    }
    for(j=0;j<n;j++){
        for(b=0;b<m;b++){
            scanf("%d",&a[j][b]);
        }
    }
    for(j=0;j<m;j++){
        for(b=0;b<l;b++){
            scanf("%d",&gh[j][b]);
        }
    }
    for(j=0;j<n;j++){
        for(b=0;b<l;b++){
            for(ai=0;ai<m;ai++){
                ans[j][b]+=a[j][ai]*gh[ai][b];
            }
        }
    }
    for(j=0;j<n;j++){
        for(b=0;b<l;b++){
            if(b==0){printf("%llu",ans[j][b]);
            }
            else{
                printf(" %llu",ans[j][b]);
            }
        }printf("\n");
    }
    scanf("%d",&n);
    return 0;
}



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

int main()
{
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int count = 0;
  int p = 1;
  while (count <= N) {
    count++ ;
    
    if (vec.at(p-1) == 2){
      cout << count << endl;
      return 0;
    }
    p = vec.at(p-1);
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Back and Forth
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

void putchars(int n, int c) { while (n--) putchar(c); }

/* main */

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx - sx, dy = ty - sy;

  putchars(dy, 'U');
  putchars(dx, 'R');
  putchars(dy, 'D');
  putchars(dx, 'L');
  putchar('L');
  putchars(dy + 1, 'U');
  putchars(dx + 1, 'R');
  putchar('D');
  putchar('R');
  putchars(dy + 1, 'D');
  putchars(dx + 1, 'L');
  putchar('U');
  putchar('\n');
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;
const int SZE = 1e6+1;

int a[100009];

int main(){
	DRII(n,x);
	REP(i,n){
		RI(a[i]);
	}
	LL ans=0;
	REPP(i,1,n){
		if(a[i]+a[i-1]>x){
			int na=max(0,a[i]-(a[i]+a[i-1]-x));
			ans+=a[i]-na;
			a[i]=na;
		}
		if(a[i]+a[i-1]>x){
			int na=max(0,a[i-1]-(a[i]+a[i-1]-x));
			ans+=a[i-1]-na;
			a[i-1]=na;
		}
	}
	printf("%lld",ans);
}


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

int N, l, ans = 0;

int main() {
  scanf("%d", &N);
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &l);
    v.at(i) = l;
  }
  sort(v.begin(), v.end());

  for (int b = 0; b < N; b++) {
    for (int a = 0; a < b; a++) {
      ans += lower_bound(v.begin(), v.end(), v.at(a) + v.at(b)) - v.begin() - b - 1;
    }
  }

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

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

 
int main() 
{
    //forItachi
    int n,m;
    cin>>n>>m;
    int arr[100003] = {0};
    
    int pen[100003] = {0};
    int i,correct =0,penalties = 0;
    for( i =0 ; i <m;i++){
        int x;
        string s;
        cin>>x>>s;
        if(arr[x] == 0){
            if(s[0] == 'W'){
                pen[x] = pen[x] + 1;
            }
            if(s[0] == 'A'){
                correct++;
                penalties = penalties + pen[x];
                arr[x] = 1;
            }
        }
        
    }
    cout<<correct<<" "<<penalties<<endl;
	
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}

vi arr;

void dfs(vi *vert, int curr, multiset<int> &s, vi &ans, int p = -1){
    // cout << curr << endl;
    s.insert(arr[curr]);
    auto it = s.lower_bound(arr[curr]);
    it++;
    int last = -1;
    if(it != s.end()){
        last = *it;
        s.erase(it);
    }
    ans[curr] = sz(s);
    tr(vert[curr], x){
        if(x != p)
            dfs(vert, x, s, ans, curr);
    }
    
    s.erase(arr[curr]);
    if(last != -1)
        s.insert(last);

}

int main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    int N;
    cin >> N;

    arr.resize(N);
    rep(i, N){
        cin >> arr[i];
    }

    vi vert[N];

    int x, y;
    rep(i, N - 1){
        cin >> x >> y;
        vert[x-1].push_back(y-1);
        vert[y-1].push_back(x-1);
    }

    vi ans(N);
    multiset<int> s;
   
    dfs(vert, 0, s, ans);
    tr(ans, a){
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 32888
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;




int main(){
    ll N, K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<ll> cum(N+1,0);
    rep(i,N){
        cum[i+1] = cum[i] + A[i];
    }

    for(int i = K; i < N; i++){
        ll current = cum[i+1] - cum[i+1-K];
        ll prev = cum[i] - cum[i-K];
        if (current > prev){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 6420
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

/*

bcd
3
2 1 a
2 2 e
1

*/

fn main() {
    let mut S = rl().chars().collect::<VecDeque<_>>();
    let Q = read!(usize);

    let mut is_reversed = false;

    for _ in 0..Q {
        let line = rl();
        let mut words = line.split_whitespace();
        let t = words.next().unwrap().parse::<i32>().unwrap();

        if t == 1 {
            is_reversed = !is_reversed;
            continue;
        }

        let f = words.next().unwrap().parse::<i32>().unwrap();
        let c = words.next().unwrap().chars().next().unwrap();

        let f = if is_reversed { 3 - f } else { f };
        if f == 1 {
            S.push_front(c);
        } else {
            S.push_back(c);
        }
    }

    let S = if is_reversed {
        S.into_iter().rev().collect::<String>()
    } else {
        S.into_iter().collect::<String>()
    };

    println!("{}", S)
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int n, arr[MAXN+10];

int pa, pb;
int a, b, c;

vector<pii> ans2;

int main()
{
    int i, j;

    scanf("%d", &n);
    for(i=1; i<=n; i++) scanf("%d", &arr[i]);
    sort(arr+1, arr+n+1);

    for(i=1; i<=n; i++)
    {
        if(arr[i]<0) a++;
        else if(arr[i]==0) b++;
        else c++;
    }

    if(n==2)
    {
        printf("%d\n%d %d", arr[2]-arr[1], arr[2], arr[1]);
        return 0;
    }

    if(b==n)
    {
        printf("0\n");
        for(i=1; i<n; i++) printf("0 0\n");
        return 0;
    }
    else if(a==0) pa=1, pb=2;
    else if(c==0) pa=n-1, pb=n;
    else pa=a, pb=a+1;

    int now;


    if(pb!=n)
    {
        now=arr[pa]-arr[pb];
        ans2.push_back({arr[pa], arr[pb]});
    }
    else
    {
        now=arr[pb]-arr[pa];
        ans2.push_back({arr[pb], arr[pa]});
    }
    while(pb<n)
    {
        if(pb+1<n)
        {
            pb++;
            ans2.push_back({now, arr[pb]});
            now=now-arr[pb];
        }
        else
        {
            pb++;
            ans2.push_back({arr[pb], now});
            now=arr[pb]-now;
        }
    }
    while(pa>1)
    {
        pa--;
        ans2.push_back({now, arr[pa]});
        now=now-arr[pa];
    }
    printf("%d\n", now);
    for(i=0; i<ans2.size(); i++) printf("%d %d\n", ans2[i].first, ans2[i].second);
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
int ans[32769][5];
int main(){
    vector<int>data;
    for(int i=1;i*i<=32768;i++)data.push_back(i*i);
    ans[0][0]=1;
    REP(i,data.size()){
        REP(j,32769){
            if(j+data[i]>32768)break;
            REP(k,4)ans[j+data[i]][k+1]+=ans[j][k];
        }
    }
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        int sum=0;
        REP(i,4)sum+=ans[n][i+1];
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 3756
import heapq

H, W = map(int, input().split())
cs = [list(map(int, input().split())) for i in range(10)]
As = [list(map(int, input().split())) for i in range(H)]

N = 10
adj = [[] for i in range(N)]
for i in range(N):
    for j in range(N):
        adj[j].append((i, cs[i][j]))


cost = [float('inf') for i in range(N)]
cost[1] = 0

pq = []
heapq.heappush(pq, (0, 1))

while pq:
    c, vNow = heapq.heappop(pq)
    if c > cost[vNow]: continue

    for v2, w in adj[vNow]:
        if cost[vNow] + w < cost[v2]:
            cost[v2] = cost[vNow] + w
            heapq.heappush(pq, (cost[v2], v2))


ans = 0
for i in range(H):
    for j in range(W):
        if As[i][j] == -1:
            continue
        ans += cost[As[i][j]]

print(ans)


Measured memory_bytes: 3572
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#include <numeric>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int H, W, M; cin >> H >> W >> M;
	vector<int>BH(H + 1, 0), BW(W + 1, 0);
	map<P, int>b;
	rep(i, M) {
		int h, w; cin >> h >> w;
		BH[h]++; BW[w]++;
		P a = make_pair(h, w);
		b[a]++;
	}
	int maxh = max_element(BH.begin(), BH.end()) - BH.begin();
	int maxw = max_element(BW.begin(), BW.end()) - BW.begin();
	vector<int> bh, bw;
	REP(i, H) {
		if (BH[maxh] == BH[i]) {
			bh.push_back(i);
		}
	}
	REP(i, W) {
		if (BW[maxw] == BW[i]) {
			bw.push_back(i);
		}
	}
	for (int& e : bh) {
		for (int& el : bw) {
			if (b[make_pair(e, el)] == 0) {
				cout << BH[maxh] + BW[maxw] << endl;
				return 0;
			}
		}
	}


	cout << BH[maxh] + BW[maxw] - b[make_pair(maxh, maxw)] << endl;
}



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

int main() {
  int c=0;
  int i,j,k,n;
  
  cin >> n;
  for(k=0;k<n;k++){
    cin >> i >> j;
    c = c+j-i+1;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#import<bits/stdc++.h>
#define sorted(vector) sort(vector.begin(),vector.end())
using namespace std;


int a,b,c,x;
string s,t,r;

int main(void){
    cin>>x>>a>>b;
    if (x<(b-a)){
        puts("dangerous");
    }else{
        if (a<b) {
            puts("safe");
        }else{
            puts("delicious");
        }
    }
}

Measured memory_bytes: 256