akhauriyash/Code-Regression huggingface dataset:
def get_lmb(N):
    while (N >= 10):
        N = int(N/10)
    return N

def get_rmb(N):
    return N%10

def find_all():
    from collections import defaultdict
    dic = defaultdict(int)
    N = int(input())
    for i in range(1, N+1):
        lmb, rmb = get_lmb(i), get_rmb(i)
        dic[(lmb, rmb)] += 1
    # print(dic)
    count = 0
    for i in range(1, 10):
        for j in range(1, 10):
            count += dic[(i, j)] * dic[(j, i)]
    # for i in range(1, 10):
    #     count += dic[(i, i)] * dic[(i, i)]
    return count

print(find_all())

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

bool cmp(const tuple<ll, ll, ll, ll> &p, const tuple<ll, ll, ll, ll> &q)
{
	if (get<1>(p) == get<1>(q))
			return get<2>(p) < get<2>(q);
	else
		return get<1>(p) < get<1>(q);
}

bool cmp_input(const tuple<ll, ll, ll, ll> &p, const tuple<ll, ll, ll, ll> &q)
{
	return get<0>(p) < get<0>(q);
}

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

	int n, m;
	cin >> n >> m;

	vector<tuple<ll, ll, ll, ll>> id(m); // input_num, prefecture, year, id
	rep (i, 0, m) {
		ll p, y;
		cin >> p >> y;
		id[i] = make_tuple(i, p, y, 0);
	}

	sort(id.begin(), id.end(), cmp);

	int id_num = 1;
	int pre_num = 0;
	rep (i, 0, m) {
		if (pre_num == get<1>(id[i])) {
			get<3>(id[i]) = ++id_num;
		} else {
			id_num = 1;
			pre_num = get<1>(id[i]);
			get<3>(id[i]) = id_num;
		}
	}

	sort(id.begin(), id.end(), cmp_input);

	rep (i, 0, m) {
		cout << setw(6) << setfill('0') << get<1>(id[i]);
		cout << setw(6) << setfill('0') << get<3>(id[i]) << endl;
	}
	return 0;

}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	string a,b;
	cin>>a>>b;
	cout<<((a=="H")?((b=="H")?"H":"D"):((b=="H")?"D":"H"))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 2001
#define INF 1000000007
typedef long long ll;
int N, K;
ll C1[maxn][maxn];
ll C2[maxn][maxn];
int main(void)
{
    cin >> N >> K;
    C1[0][0] = 1;
    for (int i = 1; i <= N - K + 1; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            C1[i][j] = C1[i - 1][j] + C1[i - 1][j - 1];
            C1[i][j] %= INF;
        }
    }
    C2[0][0] = 1;
    for (int i = 1; i <= K - 1; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            C2[i][j] = C2[i - 1][j] + C2[i - 1][j - 1];
            C2[i][j] %= INF;
        }
    }
    for (int i = 1; i <= K; i++)
    {
        cout << C1[N - K + 1][i] * C2[K - 1][i - 1] % INF << endl;
    }
}


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

#define ll long long
#define pb push_back

int ans[2003][2003];
deque < int > v;
int sti1, sti2, fii1, fii2;

main() {
    int n = 37 * 38 + 1;
    int k = 38;
    printf ("%d %d\n", n, k);
    int cnt = 2;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            if (j == 1) {
                ans[i][j] = 1;
            } else {
                ans[i][j] = cnt++;
            }
        }
    }
    int add = k - 1;
    sti1 = 2, fii1 = k;
    for (int i = 2; i <= k; i++) {
        for (int j = 2; j <= k; j++) {
            v.pb(ans[j][i]);
        }
    }
    for (int i = k + 1; i <= k + add; i++) {
        ans[i][1] = 2;
        for (int j = 2; j <= k; j++) {
            ans[i][j] = v.front();
            v.pop_front();
        }
    }
    sti1 = k + 1, fii1 = sti1 + add - 1;
    sti2 = sti1 + add, fii2 = sti2 + add - 1;
    cnt = 3;
    int xi = sti1;
    int res = 0;
    int cn = 0;
//    cout << sti1 << ' ' << fii1 << endl;
//    cout << sti2 << ' ' << fii2 << endl;
    for (int i = sti2; i <= n; i++) {
        ans[i][1] = cnt;
        res++;
        v.clear();
        int ri = sti1 + cn;
        int rj = 2;
        for (int j = 2; j <= k; j++) {
            v.pb(ans[ri][j]);
            ri++;
            if (ri > fii1) {
                ri = sti1;
            }
        }
        for (int j = 2; j <= k; j++) {
            ans[i][j] = v[j - 2];
        }
        cn++;
        if (res >= add) {
            sti1 = sti2;
            fii1 = fii2;
            sti2 = fii1 + 1;
            fii2 = sti2 + add - 1;
            res = 0;
            cnt++;
            cn = 0;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            printf ("%d ", ans[i][j]);
        }
        puts("");
    }
}


Measured memory_bytes: 11776
import sys
one=list(map(int,input().split()))
two=list(map(int,input().split()))
two.sort()
three=list(map(int,input().split()))
three.sort()
for i in range(one[2]+1,one[3]+1):
    if two[-1]<i and three[0]>= i:
        print("No War")
        sys.exit()
print("War")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const double INF = 10000000.0;

int n, m;
double dp[100][100];
double table[100][100];

main(){
   while(cin >> n >> m && (n || m)){
      fill(dp[0], dp[100], 0);
      for(int i=0;i<n;i++){
         for(int j=0;j<n;j++){
            cin >> table[i][j];
         }
      }
      for(int i=0;i<n;i++){
         dp[0][i] = 1.0;
      }
      for(int i=0;i<m;i++){
         for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
               dp[i+1][k] = max(dp[i+1][k], dp[i][j] * table[j][k]);
            }
         }
      }
      double ans = 0.0;
      for(int i=0;i<n;i++){
         ans = max(ans, dp[m-1][i]);
      }
      printf("%.2f\n", ans);
   }
   return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
int a[3][10][4] = {0};
int i, j, k;
int n, p;
int b, f, r, v; 

scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d%d%d%d", &b, &f, &r, &v);

a[f-1][r-1][b-1] += v;
}

for(k=0; k<4; k++){
for(i=0; i<3; i++){
for(j=0; j<10; j++){
if(a[i][j][k] == 0){
printf(" 0");
}else{
printf(" %d", a[i][j][k]);
}
}
printf("\n");
}
if(k != 3){
printf("####################\n");
}
}

return 0;
}


Measured memory_bytes: 2112
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    ans = set()
    for i in range(N):
        s = input()
        ans.add(s)
    print(len(ans))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 31820
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;
//快读
ll read() {
	char c = getchar();
	ll x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
ll n, t, ans[45], now;
int main() {
	n = read();
	while (n)
	{
		t = (n - 1) % 26;
		ans[now] = t;
		n = (n - 1) / 26;
		now++;
	}
	for (int i = now - 1; i >= 0; --i)
		printf("%c", ans[i] + 'a');
	return 0;
}

Measured memory_bytes: 3764
import numpy as np
N,M=map(int,input().split())
A=[]
for i in range(M):
  A.append(tuple(map(str,input().split())))
check=np.zeros((N,2))
for i in range(M):
  if check[int(A[i][0])-1,0]==0:
    if A[i][1]=='WA':
      check[int(A[i][0])-1,1]+=1
    elif A[i][1]=='AC':
      check[int(A[i][0])-1,0]+=1
for i in range(N):
  if check[i,0]==0:
    check[i,1]=0
sum=check.sum(axis=0)
print(int(sum[0]),int(sum[1]))

Measured memory_bytes: 32004
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff(i,n) for(i=0;i<n;i++)
#define pb push_back
ll bg =  998244353;
ll fac[300000];
ll power(ll x,ll y)
{
    if(y==0)
	    return 1;
	ll d = power(x,y/2)%bg;
	ll f = (d*d)%bg;
	if(y%2==0)
	  return f;
	else
	  return (f*x)%bg;	 	
}
ll modinv(ll m)
{
	return power(m,bg-2);	
}
ll ncr(ll n,ll r)
{
	ll s1 = fac[n],s2 = fac[r],s3 = fac[n-r];
	ll d1 = (s1*modinv(((s2*s3)%bg)))%bg;
	return d1;
}
int main()
{
	fac[0]=1;
	for(ll j=1;j<300000;j++)
	  fac[j] = (j*fac[j-1])%bg;
	ll t;
	t=1;
	while(t--)
	{
		set<ll>set1;
		ll i,j,n,m;
		cin>>n;
		for(i=-1000;i<=1000;i++)
		  for(j=-1000;j<=1000;j++)
		    {
		    	ll d=i*i*i*i*i;
		    	ll d1=j*j*j*j*j;
		    	if((d-d1)==n){
		    	  cout<<i<<" "<<j;return 0;}
			}
	}
	 return 0;
}

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

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<int> A(N+1);
  for (int i = 1; i <= N; i++) cin >> A[i];
  int roop = 0;
  ll from = 1;
  vector<int> teleporter(1,1);
  set<int> list;
  list.insert(1);
  bool one = true;
  while (true) {
    from = A[from];
    roop++;
    if (list.count(from)) {
      if (from != 1) one = false;
      break;
    }
    teleporter.push_back(from);
    list.insert(from);
  }
  if (one) cout << teleporter[K % roop] << endl;
  else {
    ll start;
    for (int i = 0; i < teleporter.size(); i++) {
      if (teleporter[i] == from) {
        start = i;
        break;
      }
    }
    vector<int> teleporter_new(1, from);
    ll reserve = from;
    int roop_new = 0;
    while (true) {
      from = A[from];
      roop_new++;
      if (from == reserve) break;
      teleporter_new.push_back(from);
    }
    if (K < start) cout << teleporter[K] << endl;
    else cout << teleporter_new[(K - start) % roop_new] << endl;
  }
}


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

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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int w,h;

void outside(int **mp, int i, int j);

int ym[]    = { 0,-1,-1,0,1, 1};
int xm[2][6]={{-1,-1, 0,1,0,-1},
              {-1, 0, 1,1,1, 0},};

int **mp = {};

int main(){
	w = read<int>();
	h = read<int>();
	
	mp = new int*[h+2];
	rep(i, h+2) mp[i]=new int[w+2];

	rep(i, h){
		rep(j, w){
			mp[i+1][j+1]=read<int>();
		}
	}
	
	outside(mp, 0, 0);
	
	// rep(i,h+2){
	// 	rep(j,w+2){
	// 		cout << mp[i][j] << "\t";
	// 	}
	// 	cout << endl;
	// }
	// cout << "----------------------" << endl;
	
	int ans = 0;
	
	Rep(i,1,h+1){
		Rep(j,1,w+1){
			// int a = 0;
			if(mp[i][j]>0){
				rep(k,6){
				int y = i + ym[k];
					int x = j + xm[i%2][k];
					if(mp[y][x]<0){
						// a++;
						ans++;
					}
				}
			}
			// cout << a << " ";
			// ans+=a;
		}
		// cout << endl;
	}
	
	cout << ans << endl;
}

// int st = 0;

void outside(int **mp, int i, int j){
	if(mp[i][j]!=0) return;
	// st++;
	// rep(i,st) cout << " " ;
	// cout << "mp (" << j << ", " << i << ")" << endl;
	mp[i][j]=-1;
	rep(k,6){
		int y = i + ym[k];
		int x = j + xm[i%2][k];
		if(0<=x && x<w+2 && 0<=y && y<h+2){
			// printf("(%d, %d)->(%d, %d)\n",j,i,x,y);
			outside(mp,y,x);
		}
	}
	// st--;
}

Measured memory_bytes: 1472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, k;
    cin>>n>>k;
    ll h[n];
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }

    ll cost[n];
    cost[0]=0;
    for(ll i=1;i<=min(k,(n-1));i++){
        cost[i]=abs(h[i]-h[0]);
    }for(ll i=k+1;i<n;i++){
        cost[i]=abs(h[i]-h[i-k])+cost[i-k];
        for(ll j=i-k;j<i;j++){
            ll t=abs(h[i]-h[j])+cost[j];
            cost[i]=min(t, cost[i]);
        }
    }

    cout<<cost[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 5144
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	char a;
	cin >> a;
	if(a=='A')cout << 'T' << endl;
	else if(a=='T')cout << 'A' << endl;
	else if(a=='C')cout << "G" << endl;
	else cout << "C" << endl;
}	


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 30.09.2017 15:59:34       
**/
#include <bits/stdc++.h>

using namespace std;

const int md = -1;

inline unsigned fasterLLMod(unsigned long long x, unsigned y) {
  return x % y;
}

inline void add(int &a, int b, const int m = md) {
  a += b;
  if (a >= m) a -= m;
}

inline void sub(int &a, int b, const int m = md) {
  a -= b;
  if (a < 0) a += m;
}

inline int mul(int a, int b, const int m = md) {
  return fasterLLMod((long long) a * b, m);
}

inline int power(int a, long long b, const int m = md) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a, m);
    }
    a = mul(a, a, m);
    b >>= 1;
  }
  return res;
}

inline int inv(int a, const int m = md) {
  a %= m;
  if (a < 0) a += m;
  int b = m, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += m;
  return u;
}

int get_phi(int m) {
  int phi = m;
  int tmp = m;
  for (int i = 2; i * i <= tmp; i++) {
    if (tmp % i == 0) {
      phi /= i;
      phi *= (i - 1);
      while (tmp % i == 0) {
        tmp /= i;
      }
    }
  }
  if (tmp > 1) {
    phi /= tmp;
    phi *= tmp - 1;
  }
  return phi;
}

long long solve(int a, int m) {
  if (m == 1) {
    return 30;
  }
  int phi = get_phi(m);
  int g = __gcd(m, phi);
  long long k = solve(a, g);
  int value = power(a, k, m);
//  cerr << "a m phi value k " << a << " " << m << " " << phi << " " << value << " " << k << endl;
  k %= phi;
  long long by_g = value % g;
  assert(k % g == by_g);
//  long long xx = 0;
//  while (xx % (m / g) != value || xx % (phi / g) != k) {
//    xx++;
//  }
//  cerr << "xx = " << xx << endl;
  long long x = value - k;
  if (x < 0) {
    x += m;
  }
  x = mul(x / g, inv(phi / g, m / g), m / g);
  long long res = k + (long long) x * phi;
  while (res < 30) {
    res += (long long) m / g * phi;
  }
//  cerr << "a m res " << a << " " << m << " " << res << endl;
//  long long res = x;
//  res = res * g + by_g;
//  long long res = x;
/*  while (res < 30) {
    res += (long long) m * phi;
  }*/
  return res;
}

int main() {
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int a, m;
    scanf("%d %d", &a, &m);
    long long k = solve(a, m);
    cout << k << endl;
    assert(power(a, k, m) == k % m);
  }
  return 0;
}


Measured memory_bytes: 256
a=int(input())
for i in range(int(2*abs(a**(1/5)))+1):
    for j in range(int(2*abs(a**(1/5)))+1):
        if i**5+j**5==a:
            ans1=i
            ans2=j*-1
            break
        elif i**5-j**5==a:
            ans1=i
            ans2=j
            break
        elif j**5-i**5==a:
            ans1=i*-1
            ans2=j*-1
        elif (i**5-j**5)*-1==a:
            ans1=i*-1
            ans2=j
print(str(ans1)+' '+str(ans2))

Measured memory_bytes: 67944
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i > 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a == 5 || a == 7) && (b == 5 || b == 7) && (c == 5 || c == 7) && a + b + c == 17 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    if(n >= 2 && m >= 2){
        ans = (n-2)*(m-2);
    }else if(n == 1 && m == 1){
        ans = 1;
    }else if(n == 1 || m == 1){
        ans = max(n,m) - 2;
    }


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

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
vector<int> in;
map<int,int> m;
vector<int> v;
int main(void){
  int a,b,n=0;
  char s[256];
  bool f = true;
  while(fgets(s,sizeof(s),stdin) != NULL){
    if(s[0] == '\n'){
      f = false;
      continue;
    }
    sscanf(s,"%d,%d",&a,&b);
    in.push_back(a);
    if(f) n++;
  }

  for(int i = 0; i < n; i++){
    m[in[i]]++;
  }

  for(int i = n; i < (int)in.size(); i++){
    if(m.find(in[i]) != m.end()){
      v.push_back(in[i]);
      m[in[i]]++;
    }
  }

  sort(v.begin(),v.end());
  v.erase( unique(v.begin(),v.end()), v.end());

  for(int i = 0; i < (int)v.size(); i++){
    printf("%d %d\n",v[i],m[v[i]]);
  }
}

Measured memory_bytes: 1216
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInteger
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
    [a,b] <- getIntList
    let ans = [x | x<-[0..1000], (floor $ x*0.08)==a, (floor $ x*0.1)==b]
    let a = if ans==[]
                then -1
                else head ans
    print $ round a

Measured memory_bytes: 636
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
m=min(a,b,c,d,e)
x=n/m
y=n//m
if x==y:
  print(int(4+x))
else:
  print(int(5+y))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int x;
  cin >> N >> x;
  
  int count = 0;
  
 vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  sort (vec.begin(), vec.end());
    
    for (int j = 0; j < N; j++){
      if (vec.at(j) <= x){
        count++;
        x -= vec.at(j);
      }
        else {
          break;
        }
      if (j == N - 1 && x == 0){
        break;
      }
    else if (j == N - 1){
        count--;
    }
      else {
      }
    }
  cout << count << endl;
}

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

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    string T;
    cin >> T;
    string ans;
    for (int i = 0; i < N; ++i)
    {
        ans += S[i];
        ans += T[i];
    }

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

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



int main() {
	int N,ans=0;
	string tmp;
	cin>> N;
	for (int i = 1; i <=  N; i++)
	{
		tmp = to_string(i);
		if (tmp.size() % 2 == 1)ans++;
	}
	cout << ans << endl;
}

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

int main() {
    int N, C;
    cin >> N >> C;

    vector<vector<pair<int, int>>> channel(C, vector<pair<int, int>>(0));
    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        channel[c - 1].push_back(make_pair(s, t));
    }
    for (int i = 0; i < C; i++) {
        sort(channel[i].begin(), channel[i].end());
    }

    const int T_MAX = 1e5 + 10;
    vector<int> time(T_MAX);
    for (int i = 0; i < C; i++) {
        int last = -1;
        for (int j = 0; j < channel[i].size(); j++) {
            int s = channel[i][j].first, t = channel[i][j].second;
            if (last == s) {
                time[last + 1]++;
                time[t + 1]--;
                last = t;
            } else {
                time[s]++;
                time[t + 1]--;
                last = t;
            }
        }
    }

    for (int i = 1; i < time.size(); i++) {
        time[i] = time[i - 1] + time[i];
    }
    cout << *max_element(time.begin(), time.end()) << endl;
    return 0;
}

Measured memory_bytes: 1920
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
def C(x):
    a = A[x]
    m = a+M
    if m<A[N-P]:
        return False
    v = V-P
    if v<0:
        return True
    cnt = 0
    for ai in A[x+1:N-P+1]:
        cnt+=max(0, min(m-ai, M))
    for ai in A[:x]:
        cnt+=max(0, min(m-ai, M))
    if cnt>=M*v:
        return True
    else:
        return False
ok = N-1
ng = -1
while ok-ng>1:
    mid = (ok+ng)//2
    if C(mid):
        ok = mid
    else:
        ng = mid
print(N-ok)
    
        


Measured memory_bytes: 70296
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

string T[] = { "remaerd", "resare","esare", "maerd"};
int tlen[] = {7,6,5,5};

int main() {
    string S;
    cin>>S;
    reverse(S.begin(), S.end());

    int len = S.size();
    S += "    ";
    for(int i=0; i<len; ){
        bool f=false;
        rep(j,4){
            if(S.substr(i,tlen[j])==T[j]){
                //cout2(i,S.substr(i,tlen[j]));
                i += tlen[j];
                f = true;
                break;
            }
        }
        if(!f){
            cout1("NO");
            return 0;
        }
    }
    cout1("YES");
}

Measured memory_bytes: 512
// CONTEST

#include <bits/stdc++.h>
using namespace std;

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
template<typename T> struct is_container {
template<typename C> static char test(typename C::const_iterator*); template<typename> static int test(...);
static bool const value = sizeof(test<T>(nullptr)) == sizeof(char) && !std::is_same<std::string, T>::value;
};
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
istream& operator>>(istream& i, T& x) { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#ifndef DEBUG
#define DEBUG 0
#endif
#define dbg(X) do { if (DEBUG) { cout << #X ": " << (X) << endl << flush; } } while (0)
#define dbg2(X) do { if (DEBUG) { cout << #X ":" << endl; for (auto& __x : (X)) { cout << __x << endl << flush; } } } while (0)
#define dbgv(...) do { if (DEBUG) { cout << "(" #__VA_ARGS__ "): " << make_tuple(__VA_ARGS__) << endl << flush; } } while (0)
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
ostream& operator<<(ostream& o, const T& x) { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  string s1, s2;
  cin >> s1 >> s2;
  int n1 = s1.size(); // <= 1000
  int n2 = s2.size();

  int res = 1 << 30;
  FOR(i, 0, n1 - n2 + 1) {
    int tmp = 0;
    FOR(j, 0, n2) {
      tmp += s1[i + j] != s2[j];
    }
    res = min(res, tmp);
  }
  cout << res << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  // [ Single case ]
  mainCase();
  return 0;
  // [ Multiple cases ]
  // int t;
  // cin >> t;
  // FOR(i, 0, t) { mainCase(); }
  // return 0;
}

/*
python misc/run.py atcoder/abc177/b/main.cpp --check

%%%% begin
cabacc
abc
%%%%
1
%%%% end
*/


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e5+10;
typedef long long LL;

int a[MR],b[MR];

int main() {
	int n,H;
	cin>>n>>H;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	int maxa=a[n-1],cnt=0;
	for(int i=n-1;i>=0;i--){
		if(b[i]>maxa && H>0){
			H-=b[i];
			cnt++;
		}
		else break;
	}
	while(H>0){
		H-=maxa;
		cnt++;
	}
	printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    ll n, w;
    cin >> n >> w;
    vl weight(n), val(n);
    for (int i = 0; i < n; ++i) {
        cin >> weight[i] >> val[i];
    }
    vvl dp(n + 1, vl(100001, INF));
    for (int i = 0; i <= n; ++i) {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= 100001; ++j) {
            chmin(dp[i][j], dp[i - 1][j]);
            if (j - val[i - 1] >= 0)
                chmin(dp[i][j], dp[i - 1][j - val[i - 1]] + weight[i - 1]);
        }
    }
    ll ret = 0;
    for (int i = 0; i < 100001; ++i) {
        if (dp[n][i] <= w)
            ret = i;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = "";
        for (int i = 0; i < 3; i++) {
            a += sc.next().split("")[i];
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 21844
let () = Scanf.scanf "%d\n%d %d\n" @@ fun n a b ->
  let ps =
    Array.to_list @@
    Array.init n @@ fun _ ->
      Scanf.scanf "%d " @@ fun p -> p in
  Printf.printf "%d\n" @@
    List.fold_left min max_int @@
    List.map List.length
    [ List.filter (fun p -> p <= a) ps;
      List.filter (fun p -> a < p && p <= b) ps;
      List.filter (fun p -> b < p) ps ]



Measured memory_bytes: 384
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut div = vec![0; 101];
    for mut i in 2..n + 1 {
        let mut j = 2;
        while j * j <= i {
            while i % j == 0 {
                i /= j;
                div[j] += 1;
            }
            j += 1;
        }
        if i != 1 {
            div[i] += 1;
        }
    }

    // 75 = 3 * 5 * 5
    // 75 = 3 * 5 * 5, 5 * 15, 3 * 25, 75

    let mut c3 = 0i32;
    let mut c5 = 0i32;
    let mut c15 = 0i32;
    let mut c25 = 0i32;
    let mut c75 = 0i32;

    for i in 2..101 {
        div[i] += 1;
        if div[i] >= 3 {
            c3 += 1;
        }
        if div[i] >= 5 {
            c5 += 1;
        }
        if div[i] >= 15 {
            c15 += 1;
        }
        if div[i] >= 25 {
            c25 += 1;
        }
        if div[i] >= 75 {
            c75 += 1;
        }
    }
    let mut ans = 0;
    ans += c5 * (c5 - 1) / 2 * (c3 - 2);
    ans += c15 * (c5 - 1);
    ans += c25 * (c3 - 1);
    ans += c75;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int a[n + 1];
	repn(i, 1, n + 1) cin >> a[i];
	int r[n + 2] = {0}, l[n + 2] = {0};
	repn(i, 1, n + 1) l[i] = gcd(a[i], l[i - 1]);
	for(int i = n; i >= 1; i--) r[i] = gcd(r[i + 1], a[i]);
	int ans = 1;
	repn(i, 1, n + 1){
		ans = max(ans, gcd(l[i - 1], r[i + 1]));
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

vector<vector<pair<int,int>>> v(300);
bool ok[300];

bool used[300];
bool dfs(int p,int end){
    used[p] = 1;
    bool ret = 0;
    if(p==end){
        return true;
    }
    for(auto i:v[p]){
        if(!used[i.first]){
            ret |= dfs(i.first,end);
            if(ret){
                ok[i.second]=1;
                return true;
            }
        }
    }
    return ret;
}


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

    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back({b,i});
        v[b].push_back({a,i});
    }
    int m;
    cin>>m;
    int a[m],b[m];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    ll ans = 1;
    for(int i=1;i<n;i++){
        //ans *= 2;
    }
    ans = 0;
    for(int bit=0;bit<(1<<m);bit++){
        for(int i=0;i<n;i++) ok[i] = false;
        int cnt = 0;
        for(int i=0;i<m;i++){
            if(bit & (1<<i)){
                for(int j=0;j<n;j++) used[j] = false;
                dfs(a[i],b[i]);
                cnt++;
            }
        }
        ll ret = 1;
        for(int i=0;i<n-1;i++){
            if(!ok[i]) ret*=2;
        }
       // cerr << bit << " " << ret << endl;
        if(cnt%2) ans -= ret;
        else ans+=ret;
    }
    cout << ans << endl;

}

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

bool sugoroku[120] = {0};

int solve(int n) {
    int maxDice = 0;
    int temp = 0;
    for (int i = 0; i <= n; i++) {
        temp++;
        if (sugoroku[i] == true) {
            continue;
        }
        maxDice = max(maxDice, temp);
        temp = 0;
    }
    return maxDice;
}

int main() {
    int n = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> sugoroku[i];
    }
    printf("%d\n", solve(n));
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> A(N+1);
	vector<int> B(N);
	rep(i,N+1){
		cin>>A[i];
	}
	rep(i,N)cin>>B[i];
	ll ans = 0;
	rep(i,N){
		if(A[i]>=B[i]){
			A[i] -= B[i];
			ans += B[i];
		}
		else{
			ans+= A[i];
			B[i] -= A[i];
			A[i] = 0;
			if(A[i+1]>=B[i]){
				A[i+1] -= B[i];
				ans += B[i];
			}
			else{
				ans += A[i+1];
				B[i] -= A[i+1];
				A[i+1] = 0;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sumb = sum(b)

for i in range(0, n):
    b[i] = b[i] - a[i]
    if b[i] > 0:
        a[i+1] = a[i+1] - b[i]
        if a[i+1] < 0:
            b[i] = abs(a[i+1])
            a[i+1] = 0
        elif a[i+1] >= 0:
            b[i] = 0
    elif b[i] <= 0:
        b[i] = 0

print(sumb - sum(b))

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

int main() {
	int h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	ch--;cw--;dh--;dw--;
	char s[h][w];
	int dirs[5] = {0, -1, 0, 1, 0};
	//int visited[h][w];
  vector<vector<int>> visited(h, vector<int>(w));
	for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
          
            cin >> s[i][j];
            if (s[i][j] == '#') visited[i][j] = -1;
            else visited[i][j] = 2000000000;
        }
    queue<pair<int, int>> q1;
    //set<pair<int, int>> q2;
  unordered_set<int> q2;
    int c = 0;
    function<void(int, int)> dfs = [&](int x, int y) {
        visited[x][y] = c;
        q1.push({x, y});
        for (int d = 0; d < 4; ++d) {
            int nx(x + dirs[d]), ny(y + dirs[d + 1]);
            if (nx < 0 || nx >= h || ny < 0 || ny >= w || visited[nx][ny] == -1 || visited[nx][ny] < 1e9) continue;
            dfs(nx, ny);
        }
        
    };
    function<void(int, int)> dfs2 = [&](int x, int y) {
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                int nx(x + i), ny(y + j);
                if (nx < 0 || nx >= h || ny < 0 || ny >= w || visited[nx][ny] == -1 || visited[nx][ny] < 1e9) continue;
                //if (q2.count({x, y})) continue;
                //q2.insert({nx, ny});
              q2.insert(nx * 10000 + ny);
            }
        }
    };
    while (c == 0 || !q2.empty()) {
        if (c == 0) {
            dfs(ch, cw);
            
        } else {
            for (const auto& xy : q2) {
                dfs(xy / 10000, xy % 10000);
            }
            q2.clear();
        }
        while (!q1.empty()) {
            auto pr = q1.front();
            q1.pop();
            dfs2(pr.first, pr.second);
        }
        if (visited[dh][dw] < 1e9) break;
        c++;
    }
    cout << (visited[dh][dw] < 1e9 ? visited[dh][dw] : -1) << endl;
	return 0;
};

Measured memory_bytes: 8784
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  int n=s.size();
  int k=n/2;
  int ans=0;
  rep(i,k){
    if(s[i]!=s[n-i-1]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template <class T> void read(T &);
template <class T> void write(const T &);

typedef long long ll;
typedef unsigned long long ull;
typedef const long long &cll;
typedef const int &ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::abs;
using std::max;
using std::min;

const int N = 200005;
const int M = 800005;
#define x(i) (a[i].first)
#define y(i) (a[i].second)

int a[N], b[N], c[N], d[N];
int n;

int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    int x, y;
    read(x), read(y);
    a[i] = x + y;
    b[i] = x - y;
    c[i] = -x + y;
    d[i] = -x - y;
  }
  std::sort(a + 1, a + n + 1);
  std::sort(b + 1, b + n + 1);
  std::sort(c + 1, c + n + 1);
  std::sort(d + 1, d + n + 1);
  write(max(max(a[n] - a[1], b[n] - b[1]), max(c[n] - c[1], d[n] - d[1]))), EL;
  return 0;
}

template <class T> inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template <class T> inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef int64_t Int;
const Int INF = 1e10;

int main(){
    int N, K; cin >> N >> K;
    vector<Int> H(100010,0);
    rep(i,N) cin >> H[i];
    
    // dp[i]:足場iまでのコストの最小値
    vector<Int> dp(100010, INF);
    dp[0] = 0;

    for(int i = 0; i<N; i++){
        for(int k=1; k<=K; k++){
            if(i+k < N) dp[i+k] = min(dp[i+k], dp[i]+abs(H[i]-H[i+k]));
        }
        
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#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 ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)



int main(){


    FAST
//	PRECISE

ll sats=0;
ll d;
cin>>d;
ve <ll> c(26);
FOR(i,0,26)
cin>>c[i];
ve <ve <ll>> v(d,ve <ll> (26));
FOR(i,0,d)
	FOR(j,0,26)
		cin>>v[i][j];
ve <ll> last(26,-1);

FOR(i,0,d){
	ve <ll> tell(26);
	FOR(j,0,26){
		tell[j]=v[i][j]+c[j]*(i-last[j]);
		sats-=c[j]*(i-last[j]);
	 }
	ll take=0;
	ll mi=tell[0];
	FOR(i,0,26){
		if(tell[i]>mi){
			take=i;mi=tell[i];
		}
	}
	cout<<take+1<<"\n";
	sats+=tell[take];
	last[take]=i;
	//cout<<sats<<"\n";
}
//cout<<sats;

return 0;
 }

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define EPS (1e-6)
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
void INIT(){
	ios::sync_with_stdio(false); cin.tie(0);
}

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	string s,t; cin>>s>>t;
	string ans="~";
	string tmp;
	For(i,0,sz(s)-sz(t)){
		tmp=s;
		bool ac=true;
		For(j,i,i+sz(t)-1){
			if(s[j]!='?' && s[j]!=t[j-i]){
				ac=false;
				break;
			}
			tmp[j]=t[j-i];
		}
		if(!ac) continue;
		for(auto &j:tmp) if(j=='?') j='a';
		ans=min(ans,tmp);
	}
	if(ans=="~") cout<<"UNRESTORABLE\n";
	else cout<<ans<<"\n";
	return 0;
}






















Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split("/");
            strSplit[0] = "2018";
            
            System.out.println(strSplit[0] + "/" + strSplit[1] + "/" + strSplit[2]);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 38112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;

#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    vector<ll> a(n),b(n);
    a[0]=1;
    rep(i,n-1) a[i+1]=a[i]+n;
    rep(i,n) b[p[i]]=a[n-1]-a[p[i]]+i+1;
    
    rep(i,n) cout << a[i] << " ";
    cout << endl;
    rep(i,n) cout << b[i] << " ";
    cout << endl;
}


Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

bool isPrime(int a) {
	int i = 2;
	while (i <= sqrt(a)) {
		if (a % i == 0)return false;
		i++;
	}
	return true;
}

int main() {
	int num, ans = 0;
	int a;
	cin >> num;
	int i;
	for (i = 0;i < num;i++) {
		cin >> a;
		if (isPrime(a))ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    string s[10002];
    int ans = 0;
    int fb = 0;
    int la = 0;
    int ba = 0;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        int l = s[i].size();
        for(int j = 0; j < l - 1; j++){
            if(s[i][j] == 'A'){
                if(s[i][j + 1] == 'B') ans++;
            }
        }
        if(s[i][0] == 'B'){
            fb++;
            if(s[i][l - 1] == 'A') ba++;
        }
        if(s[i][l - 1] == 'A') la++;
    }
    if(fb == la && fb == ba && fb != 0) ans = ans + fb - 1;
    else ans += min(fb, la);
    cout << ans << endl;
}

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

int main(){
    int a, b, c, x = 0;
    cin >> a >> b >> c;
    if(a>b){
        x = a;
        a = b;
        b = x;
    }
    if(b>c){
        x = b;
        b = c;
        c = x;
    }
    if(a>b){
        x = a;
        a = b;
        b = x;
    }
    cout << a << " " << b << " " << c << endl;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    lli n,i,j,m;

    cin>>n;
    m=0;
    rep(i,n-1){
        m+=(i+1);
    }
    cout<<m;
	
	return 0;
}


Measured memory_bytes: 256