akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll a, b;
	cin >> a >> b;
	rep1(i, 4) if (i != a && i != b) cout << i << endl;
	return 0;
}


Measured memory_bytes: 3588
import sys

lines = sys.stdin.readlines()
for line in lines:
    winner = 'd'
    for i in range(0, 7, 3):
        if (line[i] == line[i+1] and line[i+1] == line[i +2]):
            if line[i] != 's':
                winner = line[i]
                
    for i in range(0, 3):
        if (line[i] == line[i+3] and line[i+3] == line[i+6]):
            if line[i] != 's':
                winner = line[i]
               
    if ((line[0] == line[4] and line[4] == line[8]) or (line[2] == line[4] and line[4] == line[6])) and line[4] != 'd':
        winner = line[4]
        
    print(winner)
        

Measured memory_bytes: 7356
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  vector<ll> abc(3);
  ll K;
  rep(i,3) cin >> abc.at(i);
  sort(abc.begin(), abc.end());
  cin >> K;
  ll res = pow(2, K) * abc[2] + abc[1] + abc[0];
  cout << res << endl;
}


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

int main() {
  int x;
  cin >> x;
  for (int a = 1; a < 1000; ++a) {
    ll a5 = 1;
    rep(i,5) a5 *= a;
    for (int b = -1000; b < 1000; ++b) {
      ll b5 = 1;
      rep(i,5) b5 *= b;
      if (a5-b5 == x) {
        printf("%d %d\n", a, b);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3768
/**
 *    author:  FromDihPout
 *    created: 2020-07-26
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    long long ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i-1] + t < a[i]) {
            ans += t;
        }
        else {
            ans += a[i] - a[i-1];
        }
    }
    ans += t;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

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

typedef long long ll;

int n, m, h, k;
int data[1001][1000]; // (i, j) number
int a[100000], b[100000];
int s[1000];
int score[1000];
vector<int> bou[2][100000]; // 0:left, 1:right

int main() {
	while (cin >> n >> m >> h >> k, n || m || h || k) {
		REP(i, 2) REP(j, m) bou[i][j].clear();
		
		REP(i, n) scanf("%d", &s[i]);
		
		fill(data[0], data[h + 1], -1);
		REP(i, m) {
			scanf("%d %d", &a[i], &b[i]);
			a[i]--; b[i]--;
			data[b[i]][a[i]] = i;
			data[b[i]][a[i] + 1] = i;
		}
		
	 	REP(i, n) {
	 		int pos = i;
	 		int d = 0;
	 		
	 		while (d < h) {
	 			int num = data[d][pos];
	 			
	 			if (num == -1) {
	 				d++;
	 				continue;
	 			}
	 			
	 			// right to left
	 			if (a[num] != pos) {
	 				bou[0][num].push_back(i);
	 				pos--;
	 			}
	 			//left to right
	 			else {
	 				bou[1][num].push_back(i);
	 				pos++;
	 			}
	 			d++;
	 		}
	 		
	 		score[i] = s[pos];
	 	}
	 	
	 	int ans = 0;
	 	
	 	REP(i, m) {
	 		int cnt[2] = {};
	 		REP(j, 2) {
	 			REP(l, bou[j][i].size()) {
	 				if (bou[j][i][l] < k) cnt[j]++;
	 			}
	 		}
	 		
	 		if (cnt[1] > cnt[0]) ans = max(ans, (cnt[1] - cnt[0]) * (score[bou[1][i][0]] - score[bou[0][i][0]]));
	 		else ans = max(ans, (cnt[0] - cnt[1]) * (score[bou[0][i][0]] - score[bou[1][i][0]]));
	 	}
	 	
	 	int st = 0;
	 	REP(i, k) st += score[i];
	 	ans = st - ans;
	 	cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 18740
M=1000003
f=[1]
for i in range(1,M):
	f.append(f[i-1]*i%M)
Q=int(input())
for _ in'_'*Q:
	x,d,n=map(int,input().split())
	if d==0:
		print(pow(x,n,M))
	else:
		t=x*pow(d,M-2,M)%M
		if t==0 or t+n-1>=M:
			print(0)
		else:
			print(f[t+n-1]*pow(f[t-1],M-2,M)*pow(d,n,M)%M)


Measured memory_bytes: 45076
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

string str[] = {"null", "one pair", "two pair", "three card",
    "straight", "full house", "four card"};

int main()
{
    int hand[5];
    while (scanf("%d", &hand[0]) != EOF) {
        for (int i = 1; i < 5; i++) {
            scanf(",%d", &hand[i]);
        }
        int data[14];
        fill(data, data+14, 0);
        for (int i = 0; i < 5; i++) {
            data[hand[i]]++;
        }
        int ans = 0;
        for (int i = 1; i < 14; i++) {
            if (data[i] == 4) {
                ans = 7;
            }
            if (data[i] == 2) {
                if (ans == 2) {
                    ans = 3;
                } else if (ans == 4) {
                    ans = 6;
                } else {
                    ans = 2;
                }
            }
            if (data[i] == 3) {
                if (ans == 2) {
                    ans = 6;
                } else {
                    ans = 4;
                }
            }
        }
        sort(hand, hand+5);
        if (!ans) {
            for (int i = 1; i < 5; i++) {
                if (hand[i-1]+1 != hand[i] ) {
                    ans = 1;
                }
            }
            if (ans != 1) {
                ans = 5;
            }
            if (hand[0] == 1 && hand[1] == 10 && hand[2] == 11 &&
                    hand[3] == 12 && hand[4] == 13) {
                ans = 5;
            }
        }
        cout << str[ans-1] << endl;

    }

    return 0;
}

Measured memory_bytes: 3288
n,M =map(int,input().split())
inf = 10**15

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(M):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]


for a in range(n):
    for b in range(n):
        for c in range(n):
            #print(a,b,c)
            if dist[b][a]+dist[a][c] < dist[b][c]:
                route[b][c] = copy.deepcopy(route[b][a]) + (copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]


#for i in range(n):
    #print(route[i])

used = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    for k in range(n):
        for m in range(len(route[i][k])-1):
            used[route[i][k][m]][route[i][k][m+1]] = 1
            used[route[i][k][m+1]][route[i][k][m]] = 1
#for i in range(n):
    #print(used[i])

ans = 0
for i in range(n):
    for k in range(n):
        if used[i][k]:
            ans += 1

print(M-(ans//2))


Measured memory_bytes: 70104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll a[N];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n);
	int l=0,r=n-1,w=1; 
	ll ans=1;
	if(k&1) ans=a[r--],k--,w=(ans<0?-1:1);
	while(k){
		ll x=a[l]*a[l+1],y=a[r]*a[r-1];
		if(x*w>y*w) ans=(ans*(x%mod))%mod,l+=2;
		else ans=(ans*(y%mod))%mod,r-=2;
		k-=2;
	}
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 5352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String d = sc.nextLine();
		char[] ds = d.toCharArray();
		StringBuffer res = new StringBuffer();
		
		for(int i = ds.length -1 ; i >=0; i--){
			res.append(ds[i]);
		}
		
		System.out.println(res.toString());
	}

}

Measured memory_bytes: 11000
h,w=map(int,input().split())
M=[['.']*(w+2),['.']*(w+2)]
for i in range(h):
    m=list(input())
    m.append('.')
    m.insert(0,'.')
    M.insert(-1,m)
K=[]

for i in range(1,h+1):
    k=[]
    for j in range(1,w+1):
        if M[i][j]=='#':
            k.append('#')
        else:
            c=0
            for r in range(j-1,j+2):
                if M[i-1][r]=='#':
                    c+=1
            for r in range(j-1,j+2):
                if M[i+1][r]=='#':
                    c+=1
            if M[i][j-1]=='#':
                c+=1
            if M[i][j+1]=='#':
                c+=1
            k.append(str(c))
    K.append(k)
for i in range(len(K)):
    print(''.join(K[i]))
    

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

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		int sum = 0, maxP = 0, minP = 1000;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			minP = min(minP, x);
			maxP = max(maxP, x);
			sum += x;
		}
		sum -= minP + maxP;
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        
        // n (10^12以下なら高速)
        long n = sc.nextLong();
        
        // map: nの素因数の頻度 (60 => (2 => 2, 3 => 1, 5 => 1)
        // list: nの素因数のリスト (60 => [2, 2, 3, 5])
        Map<Long, Integer> map = new HashMap<Long, Integer>();
        List<Long> list = new ArrayList<Long>();
        
        long m = n;
        for (long i = 2; (i * i) <= n; i++) {
            int cnt = 0;
            
            while ((m % i) == 0) {
                cnt++;
                m /= i;
                list.add(i);
            }
            
            if (cnt > 0) {
                map.put(i, cnt);
            }
        }
        if (m > 1) {
            map.put(m, 1);
            list.add(m);
        }
        
        int ans = 0;
        for (Long key : map.keySet()) {
            int val = map.get(key);
            int tmp = 1;
            while (true) {
                val -= tmp;
                if (val >= 0) {
                    ans++;
                    tmp++;
                } else {
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37472
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int a,b,c,ans=0;
    cin>>a>>b>>c;
    ans++;
    if(a!=b)ans++;
    if(a!=c&&b!=c)ans++;
    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

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

    int n, k, w = 1;
    cin >> n >> k;

    for (int i = 0; i < n; ++i)
        w = min(2 * w, w + k);

    cout << w << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll l=1, r=big, m;
  ll num;
  while(l<r) {
    m = (l+r)/2;
    num = 0;
    for(int i=0;i<N;++i) {
      if(A[i]%m==0) num += A[i]/m-1;
      else num += A[i]/m;
    }
    if(num<=K) r = m;
    else l = m+1;
  }
  cout<<l<<endl;
}



Measured memory_bytes: 5080
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N, L;
    cin >> N >> L;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    sort(ALL(S));
    string ans = "";
    for(auto s : S) ans += s;
    print(ans);

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> firstRow = Arrays.asList(br.readLine().split(""));
            List<String> secondRow = Arrays.asList(br.readLine().split(""));

            int result = 0;
            for (int i = 0; i < 3; i++) {
                if (firstRow.get(i).equals(secondRow.get(i))) {
                    result += 1;
                }
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22996
a, b, c = map(int, input().split())
ans = 0
while a%2==0 and b%2==0 and c%2==0:
    d, e, f = b//2 + c//2, a//2 + c//2, a//2 + b//2
    if [a, b, c] == [d, e, f]:
        print(-1)
        break
    ans += 1
    a, b, c = d, e, f
else:
    print(ans)

Measured memory_bytes: 3064
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
  struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;cin>>s>>t;
	ll n1=s.size(),n2=t.size(),i,j;
	ll mn=1e10;
	for(i=0;i<n1 and i+n2<=n1;i++){
		ll c=0;
	for(j=0;j<n2;j++)	{

		if(s[i+j]!=t[j])
			c++;
	}
	mn=min(mn,c);
}

cout<<mn;
	return 0;
} 

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,D,H,K,L,M,N,T,W,X;
  string S;
  cin >> S;
  if (S[0]=='7' || S[1]=='7' || S[2]=='7') {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
  
  
  
}

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

using namespace std;

const int N = 110;
int dp[N][N][2];
int n, a, b;

int main (){
	cin >> n >> a >> b;
	
	int dif = b - a;
	
	if(dif % 2 == 0){
		cout << "Alice\n";
	}else{
		cout << "Borys\n";
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
  char[] S;
  public static void main(String[] args) {
    Main m = new Main();
    m.input();
    m.solve();
    m.out();
  }

  public void input() {
    Scanner sc = new Scanner(System.in);
    S = sc.next().toCharArray();
    sc.close();
  }

  public void solve() {
    S[3] = '8';
  }

  public void out() {
    System.out.println(String.valueOf(S));
  }
}


Measured memory_bytes: 21588
<?php

function chmax(&$a, $b) {
    if ($a < $b) {
        $a = $b;
    }
}

fscanf(STDIN, "%d %d", $n, $m);
$h = explode(' ', trim(fgets(STDIN)));

$max_h = array_fill(0, $n, 0);

for ($i = 0; $i < $m; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);

    chmax($max_h[$a - 1], $h[$b - 1]);
    chmax($max_h[$b - 1], $h[$a - 1]);
}


$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    if ($h[$i] > $max_h[$i]) {
        ++$cnt;
    }
}
echo $cnt;


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

int main(){
  int N;
  cin >> N;
  int A[N],B[N + 1];
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int sum = 0;
  B[0] = abs(0 - A[0]);
  sum += B[0];
  for (int i = 0; i < N - 1; i++){
    B[i + 1] = abs(A[i] - A[i + 1]);
    sum += B[i + 1];
  }
  B[N] = abs(0 - A[N - 1]);
  sum += B[N];
  cout << sum - B[0] - B[1] + abs(0 - A[1]) << endl;
  for (int i = 0; i < N - 2; i++){
    cout << sum - B[i + 1] - B[i + 2] + abs(A[i] - A[i + 2]) << endl;
  }
  cout << sum - B[N - 1] - B[N] + abs(0 - A[N - 2]) << endl;
  return 0;
}

Measured memory_bytes: 2048
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

int n, p;
lint dp[52][5111];
vec<lint> a;

lint dfs(int idx, int sum) {
  if (idx == n) {
    return sum % 2 == p ? 1 : 0;
  }

  lint& ret = dp[idx][sum];
  if (ret != -1) {
    return ret;
  }
  ret = dfs(idx + 1, sum + a[idx]) + dfs(idx + 1, sum);

  return ret;
}

signed main() {
  cin >> n >> p;
  a.resize(n);
  rep(i, n) cin >> a[i];

  memset(dp, -1, sizeof(dp));

  print(dfs(0, 0));
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N,K;
	cin >> N >> K;
	vector<int>cnt(N);
	REP(i,K){
		int d;
		cin >> d;
		REP(j,d){
			int t;
			cin >> t;
			cnt[t - 1]++;
		}
	}
	int ans = 0;
	REP(i,N)if(cnt[i] == 0)++ans;
	out(ans);
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Numerics;

class Program
{

    static void Main(string[] args)
    {
        label:
        if (ReadLine() == "1")
        {
            WriteLine("Hello World");
        }
        else
        {
            int n = Parse(ReadLine()), m = Parse(ReadLine());
            WriteLine(n + m);
        }
        //goto label;
    }
}


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

int main() {
  string A;
  cin >> A;
  vector<int> X(4);
  for(int i = 0; i < 4; i++){
    X.at(i) = (int)(A.at(i)-48);
  }
  
  for (int tmp = 0; tmp < (1 << 4); tmp++) {
    bitset<4> s(tmp);  
  
	int sum = 0;
  	for (int i = 0; i < 4; i++) {
      if (s.test(i)) {
        sum += X.at(i);
      }
      else sum -= X.at(i);
    }
      if (sum == 7) {
      cout << X.at(0);
        if(s.test(1)) cout << "+";
        else cout << "-";
      cout << X.at(1);
        if(s.test(2)) cout << "+";
        else cout << "-";
      cout << X.at(2);
        if(s.test(3)) cout << "+";
        else cout << "-";
      cout << X.at(3);
      cout << "=7" << endl;
      break;
      }
    }
}


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

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a < b)
	{
		for (int i = 0; i < b; i++)
		{
			cout << a;
		}
	}
	else {
		for (int i = 0; i < a; i++)
		{
			cout << b;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import numpy as np
from collections import defaultdict

N, M = map(int, input().split())  #

A = list()
cnt = 0
for i in range(N):
    a = [int(k) for k in input().split()] 
    #print(a[1:])
    A.append(set(a[1:]))
    pass
for i in range(M):
    i = i+1
    flag = True
    for a in A:
        s = set()
        s.add(i)
        if s <= a:
            pass
        else:
            flag = False
            break
        pass
    if flag == True:
        cnt += 1
    pass

print(cnt)

# a2,b2=map(int, input().split())  #
# a3,b3=map(int, input().split())  #





# import os.path
# import re
# from urllib.parse import quote



# p = "curl -kI https://kotobank.jp/word/" + quote("犬") + " -o header"
# print(p)
# req = os.system(p)
# f = open('header')
# tmp = f.read()  # ファイル終端まで全て読んだデータを返す
# hit_list = re.findall("Location:.*", tmp)
# print(hit_list[0])
# print(hit_list[0][10:])

# p = "curl -k https://kotobank.jp" + hit_list[0][10:] + " > raw.html"
# print(p)

# req = os.system(p)
# # print("aa")
# # p = "sed \":a;N;$!ba;s/\n//g\" raw.html > f "
# # req = os.system(p)
# # print("aa")
# # p = " sed -e 's/ //g' f > t"
# # req = os.system(p)
# # print("aa")


# print(req)
# f = open('raw.html')
# data1 = f.read()  # ファイル終端まで全て読んだデータを返す
# print(type(data1))
# # print((data1))
# data1 = data1.replace("\n", "")
# data1 = data1.replace(" ", "")
# data1 = data1.replace("\t", "")
# # print(data1)
# hit_list = re.search("<sectionclass=\"description\">.*</section></div><!--/.ex解説--><pclass=\"source\">", data1)
# # print("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww")
# # print(hit_list.group())
# # print("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww")

# t = hit_list.group()
# k = t.find('</section>')
# t = t[:k]
# # print(t)
# # print("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww")

# t = re.sub("<[^>]*?>", "", t)
# print(t)


# # p = "cat raw.html > sed -e \"s/<section class=\"description\">(.|\n)*<\/section>/\1/"

# # req = os.system(p)


Measured memory_bytes: 12396
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	n=II()
	a=1
	b=1

	for n in range(n):
		x,y=MI()
		if a<=x and b<=y:
			a,b=x,y
		elif a>x and b>y:
			t=max((a-1)//x,(b-1)//y)+1
			a,b=t*x,t*y
		elif a>x:
			t=(a-1)//x+1
			a,b=t*x,t*y
		else:
			t=(b-1)//y+1
			a,b=t*x,t*y

	print(a+b)





















if __name__ == "__main__":
	main()


Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std ;
typedef long long ll ;
#define rep(i, n) for ( int i =0; i < n ; i ++)
int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main ()
{
  scanf("%d%d", &N ,&M);
  rep(i, M) scanf("%d%d", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
  rep(i, N) sort(yd[i+1].begin(), yd[i+1].end());
  rep(i, M) printf("%012lld\n", ll(P[i]) * 1000000 + int(lower_bound(yd[P[i]].
      begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);
}


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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(k >= a && k < a + b){cout << 0 << " " << b-k+a << endl;}
  if(k < a){cout << a-k << " " << b << endl;}
  if(k >= a+b){cout << 0 << " " << 0 << endl;}
  return 0;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<stdio.h>

using namespace std;

int main(){

  int in;
  while(1){
    cin >> in;
    if(in == 0) break;
    
    map<char, char> M;
    char a, b;  

    for(int i = 0; i < in; i++){
      cin >> a >> b;
      M[a] = b;
    }
    cin >> in;
    
    for(int i = 0; i < in; i++){
      cin >> a;
      if(M[a] != NULL) cout << M[a];
      else cout << a;
    }
    cout << endl;
  }
    
  return 0;
}

Measured memory_bytes: 0
// Problem : F - Yakiniku Optimization Problem
// Contest : AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

#define EPS 1e-9

struct Point {
    double x, y;
    
    Point(double _x, double _y) : x(_x), y(_y) {}
    
    Point operator + (const Point &other) const {
        return {x + other.x, y + other.y};
    }
    
    Point operator - (const Point &other) const {
        return {x - other.x, y - other.y};
    }
    
    Point operator * (double d) const {
        return {x * d, y * d};
    }
    
    Point operator / (double d) const {
        return {x / d, y / d};
    }
    
    Point perp() {
        return {-y, x};
    }
};

struct Circle {
    int x, y, c;
} circles[60];

int n, k;
double m;

bool check(double x, double y) {
    int cnt = 0;
    for (int i=0; i<n; i++)
        cnt += (hypot(x - circles[i].x, y - circles[i].y) * circles[i].c - m < EPS);
    return cnt >= k;
}

double sq(double x) {
    return x * x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    cin >> n >> k;
    for (int i=0; i<n; i++)
        cin >> circles[i].x >> circles[i].y >> circles[i].c;
    
    double l = 0, r = 1e9;
    for (int rep=0; rep<200; rep++) {
        m = (l + r) / 2;
        
        bool ok = false;
        for (int i=0; i<n; i++)
            ok |= check(circles[i].x, circles[i].y);
        for (int i=0; i<n; i++)
            for (int j=i+1; j<n; j++) {
                Point d(circles[j].x - circles[i].x, circles[j].y - circles[i].y);
                double r1 = m / circles[i].c, r2 = m / circles[j].c;
                double d2 = sq(circles[i].x - circles[j].x) + sq(circles[i].y - circles[j].y);
                double pd = (d2 + sq(r1) - sq(r2)) / 2;
                double h2 = sq(r1) - sq(pd) / d2;
                if (h2 >= 0) {
                    Point p = Point(circles[i].x, circles[i].y) + d * pd / d2, h = d.perp() * sqrt(h2 / d2);
                    Point a = p - h;
                    ok |= check(a.x, a.y);
                    Point b = p + h;
                    ok |= check(b.x, b.y);
                }
            }
        
        if (ok)
            r = m;
        else
            l = m;
    }
    
    cout << fixed << setprecision(10) << l << "\n";

    return 0;
}


Measured memory_bytes: 256
/*    
                                                                             
	1. Practice makes a man perfect.
	2. Let go of the past.
	3. Without pain, without sacrifice, we would have nothing.
	4. Great things never come from comfort zones.
	5. Turn your wounds into wisdom.
	6. No pain ... no palm, no throne, no glory,no cross, no crown.
	7. You never know how strong you are until being strong is your only choice.
	8. Smooth seas do not make skillful sailors.
	9. I am not what happened to me, I am what I choose to become.
	10. No matter how fail life pushes you down, No matter how much you hurt,You can always bounce back.
		
		
	--> This lines keep me motivated.		

	Author:- Gaurang_Kothiya
	
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;


 
void Solve()
{	
	int n,m;
	cin>>n>>m;
	v(string) vec(n);
	fe(x,vec) cin>>x;
	sort(all(vec));
	fe(x,vec) cout<<x;	
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3680
#include <iostream>
using namespace std;
int main(void){
    int n,k,h[100002],c[100002];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
        c[i]=1e9+7;
    }
    c[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k&&i-j>=0;j++){
            c[i]=min(c[i],c[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<c[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;

int head[N],link[N];
bool vis[N],col[N];
ll cnt,n,m;

struct Edge
{
    int to;
    int next;
};

Edge edge[N << 1];

void Init()
{
    cnt = 0;
    memset(head,-1,sizeof(head));
    memset(col,0,sizeof(col));
}

void add(int u,int v)
{
    edge[cnt].to = v;
    edge[cnt].next = head[u];
    head[u] = cnt++;
}

bool Color(int u)
{
    for(int i=head[u]; ~i; i=edge[i].next)
    {
        int v = edge[i].to;
        if(!col[v])
        {
            col[v] = !col[u];
            if(!Color(v)) return false;
        }
        else if(col[v] == col[u])
            return false;
    }
    return true;
}

bool dfs(int u)
{
    for(int i=head[u]; ~i; i=edge[i].next)
    {
        int v = edge[i].to;
        if(!vis[v])
        {
            vis[v] = 1;
            if(link[v] == -1 || dfs(link[v]))
            {
                link[v] = u;
                return true;
            }
        }
    }
    return false;
}

int match()
{
    int ans = 0;
    memset(link,-1,sizeof(link));
    for(int i=1; i<=n; i++)
    {
        memset(vis,0,sizeof(vis));
        if(dfs(i)) ans++;
    }
    return ans;
}

int main()
{
    while(cin >> n >> m)
    {
        Init();
        for(int i=0;i<m;++i)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            add(u,v);
            add(v,u);
        }
        col[1] = 1;
        if(!Color(1))
        {
            cout << (n * (n - 1) / 2) - m << endl;
            continue;
        }
        ll a = 0, b = 0;
        for(int i = 1; i <= n; ++i) {
            if(col[i]) ++a;
            else ++b;
        }
        cout << a * b - m << endl;
    }
    return 0;
}


Measured memory_bytes: 6400
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, N = MAP()

x = min(N, B-1)

print((A*x)//B)

Measured memory_bytes: 27228
n=int(input())
s=[""]*n
for i in range(n):
  s[i]=input()
m=int(input())  
t=[""]*m
for j in range(m):
  t[j]=input()
C=[0]
 
for i in range(n):
  p=s[i]
  c=s.count(str(s[i]))-t.count(str(s[i]))
  C.append(c)
  
print(max(C))

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int q;
int x;
int l;
int r;
char c;
int type;
string s;
set<int> g[26];
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n >> s;
    for(int i = 0; i < n; i ++){
        g[s[i] - 'a'].insert(i + 1);
    }
    cin >> q;
    for(int i = 1; i <= q; i ++){
        cin >> type;
        if(type == 1){
            cin >> x >> c;
            x --;
            g[s[x] - 'a'].erase(x + 1);
            s[x] = c;
            g[s[x] - 'a'].insert(x + 1);
        }
        else{
            int cnt = 0;
            cin >> l >> r;
            for(int i = 0; i < 26; i ++){
                auto pos = g[i].lower_bound(l);
                if(pos != g[i].end() && *pos <= r){
                    cnt ++;
                }
            }
            cout << cnt << "\n";
        }
    }
}



Measured memory_bytes: 24220
import math,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
A,B,H,M = LI()
angle = abs((H+M/60)/12*360-M/60*360)
angle = min(angle,360-angle)
print((A**2+B**2-2*A*B*math.cos(math.radians(angle)))**0.5)


Measured memory_bytes: 9564
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  int l = 0, r = n - 1;
  for (int i = 0; i < n; i++) {
    b[i % 2 == 0 ? l++ : r--] = a[n-i-1];
  }
  for (int x: b) {
    cout << x << " ";
  }
  cout << endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> T(N+1);
  for(int i=0;i<N;i++) cin>>T[i];

  int M;
  cin>>M;
  for(int i=0;i<M;i++){
    int P,X,total=0;
    cin>>P>>X;
    for(int j=0;j<N;j++){
      if(P==j+1) total+=X;
      else total+=T[j];
    }
    cout<<total<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		int A[4]; rep(i, 4) cin >> A[i];
		sort(A, A + 4);
		cout << abs(A[3] + A[0] - A[1] - A[2]) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}



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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(ll D, const vector<ll> &c, const vector<vector<ll>> &s, const vector<ll> &t) {
  vector<ll> last(26, -1);
  ll score = 0;
  REP(d, D) {
    ll i = t[d];
    score += s[d][i];
    last[i] = d;
    REP(j, 26) {
      score -= c[j] * (d - last[j]);
    }
  }
  return score;
}

ll area(ll D, ll d, const vector<ll> &t, ll target) {
  ll l = -1;
  for (int i = d - 1; i >= 0; i--) {
    if (t[i] == target) {
      l = i;
      break;
    }
  }
  ll r = D;
  FOR(i, d + 1, D) {
    if (t[i] == target) {
      r = i;
      break;
    }
  }
  ll x = r - d;
  ll y = d - l;
  return x * y;
}

ll calc_diff(ll D, ll pre, ll next, const vector<ll> &c, const vector<vector<ll>> &s, ll d, const vector<ll> &t) {
  ll diff = s[d][next] - s[d][pre];
  diff += c[next] * area(D, d, t, next);
  diff -= c[pre] * area(D, d, t, pre);
  return diff;
}

void solve(ll D, vector<ll> c, vector<vector<ll>> s) {
  vector<ll> t(D, 0);
  REP(d, D) {
    ll m = 0;
    ll cur = 0;
    FOR(i, 1, c.size()) {
      t[d] = i;
      ll diff = calc_diff(d + 1, 0, i, c, s, d, t);
      if (diff > m) {
        m = diff;
        cur = i;
      }
    }
    t[d] = cur;
  }

  auto start = std::chrono::system_clock::now();
  std::mt19937 mt{1};
  std::uniform_int_distribution<int> dist2(0, D - 1);
  std::uniform_int_distribution<int> dist3(0, 25);
  ll count = 0;
  while (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start).count() <
         1980) {
    count++;
    if (count % 2 == 0) {
      ll d = dist2(mt);
      ll d2 = dist2(mt);
      ll pre = t[d];
      ll next = t[d2];
      t[d] = next;
      ll diff = calc_diff(D, pre, next, c, s, d, t);
      t[d2] = pre;
      diff += calc_diff(D, next, pre, c, s, d2, t);
      if (diff > 0) {
        // cout << "swap" << endl;
      } else {
        swap(t[d], t[d2]);
      }
    } else {
      ll d = dist2(mt);
      ll pre = t[d];
      ll next = dist3(mt);
      t[d] = next;
      ll diff = calc_diff(D, pre, next, c, s, d, t);
      if (diff > 0) {
        // cout << "change" << endl;
      } else {
        t[d] = pre;
      }
    }
  }

  REP(d, D) {
    cout << t[d] + 1 << "\n";
  }
}

int main() {
  ll D;
  scanf("%lld", &D);
  vector<ll> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  solve(D, move(c), move(s));
  return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a+b==15){
    cout<<"+\n";
  }
  if(a*b==15){
    cout<<"*\n";
  }
  if(a+b!=15 && a*b!=15){
    cout<<"x\n";
  }
}


Measured memory_bytes: 256
n,m,q=map(int,input().split())
l=[[0 for i in range(n+1)] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  l[a][b]+=1
for i in range(1,n):
  for j in range(i+1,n+1):
    l[i][j]+=l[i][j-1]
for i in range(2,n+1):
  for j in range(i,0,-1):
    l[j-1][i]+=l[j][i]
for i in range(q):
  a,b=map(int,input().split())
  print(l[a][b])
  

Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    long long int A,B; cin>>A>>B;
    long long int k=0;
    if((A+B)%2==0){
        k=(A+B)/2;
        cout<<k;
    }
    else{
        cout<<"IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;


int main() {
	map<int, int> mp;
	long long int a, b = 0, num[200005], sum[200005] = {}, n, cou = 0, res = 0, memo,min=10000;
	string str,str2,str3;
	cin >>n>> str>>str2;
	
	for (int i = 0; i < n; i++) {
		cou = 0;
		for (int j = i; j < n; j++) {
			if (str[j] != str2[j - i]) { cou++; }
		}
		if (cou == 0) { cout << n + i; return 0; }
	}
	cout << 2 * n;
}


Measured memory_bytes: 256
// failed to generate code

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

long long a[16][16];
int main(){	
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++) {
            cin >> a[i][j];
        }
    }

    long long calc[1<<16] = {};
    long long dp[1<<16];
    for(int i = 0 ; i < (1<<n) ; i++) dp[i] = -1e18;

    for(int i = 0 ; i < (1<<n) ; i++){
        for(int j = 0 ; j < n ; j++){
            for(int k = j ; k < n ; k++) {
                calc[i] += (i >> j & 1) * (i >> k & 1 ) * a[j][k];
            }
        }
    }

    dp[0] = 0;
    for(int i = 0 ; i < (1<<n) ; i++){
        for(int j = i ; j > 0 ; j = (j-1) & i){
            dp[i] = max(dp[i], dp[i^j] + calc[j]);
        }
    }
    cout << dp[(1<<n)-1] << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 10000000000007LL
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

int a[105];
int b[105];

int dp[105][100005];

void solve(){
	int n,w;
	cin>>n>>w;
	rep(i,0,n){
		cin>>a[i]>>b[i];
	}
	rep(i,0,w+1){
		dp[0][i]=-M;
	}
	dp[0][0]=0;
	dp[0][a[0]]=b[0];
	rep(i,1,n){
		rep(j,0,w+1){
			dp[i][j]=dp[i-1][j];
		}
		rep(j,a[i],1+w){
			dp[i][j]=max(dp[i][j],b[i]+dp[i-1][j-a[i]]);
		}
	}
	int ans=0;
	rep(i,0,w+1){
		// cout<<dp[n-1][i]<<" ";
		ans=max(ans,dp[n-1][i]);
	}
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 80128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll inf=1LL<<60;
ll ans,s,n,m;
int i,j,k;
ll calc(ll a,ll b,ll c){
	return max(a,max(b,c))-min(a,min(b,c));
}
int main(){
	scanf("%lld%lld",&n,&m);ans=inf;
	if (n%3==0||m%3==0){
		puts("0");return 0;
	}
	if (n>=3) ans=m;
	if (m>=3) ans=min(ans,n);
	for (i=1;i<n;i++){
		s=i*m;
		k=(m)/2+(m)%2;
		ans=min(ans,calc(s,k*(n-i),(m-k)*(n-i)));
	}
	for (i=1;i<m;i++){
		s=i*n;
		k=(n)/2+(n)%2;
		ans=min(ans,calc(s,k*(m-i),(n-k)*(m-i)));
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(void) {
    long n;
    cin >> n;
    vector<tuple<long,long,long>> csf(n-1);
    for(auto &e: csf) {
        long c, s, f;
        cin >> c >> s >> f;
        e = make_tuple(c, s, f);
    }

    for(long i=0; i<n-1; i++) {
        long r = 0;
        for(long j=i; j<n-1; j++) {
            long c, s, f;
            tie(c, s, f) = csf[j];
            long t = (r + f-1) / f * f;
            r = max(s, t) + c;
        }
        cout << r << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
let print_array l = Array.fold_left (fun x y -> (if x = "" then "" else x^" ")^(string_of_int y)) "" l |> print_endline;;
let to_list s = Str.split (Str.regexp_string " ") s |> List.map (fun x -> int_of_string x) |> Array.of_list;;

let rec sort l = function
    i when i = Array.length l -> print_array l;l
  | i -> print_array l;
         let key = l.(i) in
         let rec insert l2 = function
             j when j < 0 || l2.(j) <= key -> l2.(j+1) <- key;l2
           | j -> l2.(j+1) <- l2.(j); insert l2 (j-1)
         in sort (insert l (i-1)) (i+1);;

let _ = read_int () and
    a = read_line () |> to_list;;
let _ = sort a 1;;

Measured memory_bytes: 4344