akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();

vector<ii>A[20];

int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);

  int n;
  cin >> n;

  FOR(i,0,n-1) {
    int x;
    cin >> x;
    FOR(j,1,x) {
      int xx,yy;
      cin >> xx >> yy;
      xx--;
      A[i].pb({xx,yy});
    }
  }

  int ans = 0;
  for(int mask = 0; mask < (1 << n); mask++) {
    int ff = 1;
    for(int i = 0; i < n; i++) {
      if(mask&(1<<i)) {
        for(auto &x : A[i]) {
          // x.F--;
          if(!((x.S == 1 and ((mask&(1<<x.F))>0)) or (x.S == 0 and (mask&(1<<x.F)) == 0)))ff = 0;
        }
      }
    }
    if(ff)ans = max(ans, __builtin_popcount(mask));
  }
  cout << ans << "\n";
  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[] B = new int[M];
		for(int i=0;i<M;i++) {
			B[i] = sc.nextInt();
		}
		int num = 0;
		for(int i=0;i<N;i++) {
			int sum=C;
			for(int j=0;j<M;j++) {
				sum += B[j]*sc.nextInt();
			}
			if (sum>0) num++;
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main() {
    int num;
    cin >> num;
    
    if ( num == 1 ) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//\\//\\//\\//\\//\\//\\//\\//
#define fio ios::sync_with_stdio(false); cin.tie(nullptr)
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<'\n'
#define endl '\n'
#define eb emplace_back
#define f first
#define s second
//\\//\\//\\//\\//\\//\\//\\//
using namespace::std;
using ll=long long;
using pii=pair<int,int>;
const int inf=INT_MAX,mod=1e9+7;
//\\//\\//\\//\\//\\//\\//\\//

using namespace std;

unordered_map<int,bool>have;
signed main() {
      int n; cin>>n;
      vector<int>vec(n);
      for (int i=0; i<n; i++) {
            cin>>vec[i];
            if(have[vec[i]]) {
                  puts("NO");
                  return 0;
            }
            have[vec[i]]=true;
      }

      puts("YES");
      return 0;
}

Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int H, W;
char S[30][30];
int dist[30][30];

int bfs(int sx, int sy, int gx, int gy) {
    for (int i=0; i<H; i++) for (int j=0; j<W; j++) dist[i][j] = -1;
    dist[sx][sy] = 0;
    queue<P> q;
    q.push(P(sx, sy));
    
    while (q.size()) {
        P p = q.front(); q.pop();
        int cx=p.first, cy=p.second;
        
        for (int i=0; i<4; i++) {
            int nx=cx+dx[i], ny=cy+dy[i];
            
            if (!(0<=nx && nx<H && 0<=ny && ny<W)) continue;
            if (S[nx][ny]=='.' && dist[nx][ny]==-1) {
                dist[nx][ny] = dist[cx][cy]+1;
                q.push(P(nx, ny));
            }
        }
    }
    
    return dist[gx][gy];
}

int main() {
    cin >> H >> W;
    for (int i=0; i<H; i++) for (int j=0; j<W; j++) cin >> S[i][j];
    int ans = 0;
    
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            for (int k=0; k<H; k++) {
                for (int l=0; l<W; l++) {
                    if (S[i][j]=='.' && S[k][l]=='.') {
                        ans = max(ans, bfs(i, j, k, l));
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
}

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

int main(){
    string s,t;
    cin >> s;
    cin >> t;

    long long n = s.size();
    long long m = t.size();

    vector<vector<long long> > index(30);

    for(long long i = 0; i < n; i++) index[s[i]-'a'].push_back(i+1);

    long long ans = 0;
    long long last = 0;

    for(long long i = 0; i < m; i++){
        long long nch = t[i] - 'a';
        if(index[nch].size() <= 0){
            printf("-1\n");
            return 0;
        }

        auto itr = upper_bound(index[nch].begin(), index[nch].end(), last);

        if(itr == index[nch].end()){
            ans += n;
            itr = index[nch].begin();
        }
        last = *itr;
    }
    ans += last;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4644
import java.util.Scanner;

public class Main {
  public static void main(String[] main) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  }
}

Measured memory_bytes: 39120
#include <stdio.h>

int main(){
	int n,x,count;
	while(true){
		scanf("%d %d",&n,&x);
		if(n == 0 && x == 0) break;
		count = 0;
		for(int min = 1; min < x/3 && min <= n-2;min++){
			for(int middle = min+1;middle < x - (min+middle) && middle <= n-1; middle++){
				if(x-(min+middle) <= n) count++;
			}
		}
		printf("%d\n",count);
	}

}



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

using namespace std;
const int N = 2e3 + 3, D[][2]{{1, 0},
							  {0, 1}};

int len[N][N][2], n, m;
char grid[N][N];
bool valid(int i, int j) {
	return 0 <= i && i < n && 0 <= j && j < m;
}
void calc(int i, int j, bool dir) {
	if (len[i][j][dir] || grid[i][j] == '#')
		return;
	int x = i, y = j;
	while (valid(x, y) && grid[x][y] == '.')
		x += D[dir][0], y += D[dir][1], ++len[i][j][dir];
	x = i, y = j;
	while (valid(x, y) && grid[x][y] == '.')
		x -= D[dir][0], y -= D[dir][1], ++len[i][j][dir];
	--len[i][j][dir];
	x = i, y = j;
	while (valid(x, y) && grid[x][y] == '.') {
		len[x][y][dir] = len[i][j][dir];
		x += D[dir][0], y += D[dir][1];
	}
	x = i, y = j;
	while (valid(x, y) && grid[x][y] == '.') {
		len[x][y][dir] = len[i][j][dir];
		x -= D[dir][0], y -= D[dir][1];
	}
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i)
		scanf("%s", grid[i]);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			calc(i, j, false),
					calc(i, j, true);
	int res = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			res = max(res, len[i][j][0] + len[i][j][1] - 1);
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 35456
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#define Max 1000
using namespace std;


int main(){

	int n;
	scanf("%d",&n);
	int odd = n-(n/2);

	double prob = (double)odd/n;

	printf("%lf",prob);

	return 0;
}

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

int main(){
  ll x, y;
  cin >> x;  

  ll cnt = 100;

  ll res = 0;

  bool table = true;
  while(table){
    y = cnt;
    cnt += y/100;
    res++;
    if(cnt >= x){
       table = false;
    }
  }
  cout << res;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long
#define ll long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
main() {
    int N; cin >> N;
    map<vector<int>,int> m;
    ll ans=0;
    rep(i,N){
        string S; cin >> S;
        vector<int> data(26);
        rep(j,S.size()){
            int k; k=S[j]-'a';
            data[k]++;
        }
        m[data]++;
    }
    for(auto p:m){
        int count; count=p.second;
        ans+=count*(count-1)/2;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
    string S;
    int a, b, c, d, min_dist;
    cin >> S;
    min_dist = 1000;
    for (int i = 0; i < S.size()-2; ++i) {
        a = S[i] - 48;
        b = S[i+1] - 48;
        c = S[i+2] - 48;
        d = 100*a + 10*b + c;
        if(abs(753-d) < min_dist){
            min_dist = abs(753-d);
        }
    }
    cout << min_dist << endl;
    return 0;
}

Measured memory_bytes: 256
//ABprobrem.cpp
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
    long a,b;
    double f;
    cin>>a>>b;
    f=a*1.0/b;
    cout<<a/b<<" "<<a%b<<" ";
    cout << std::fixed << std::setprecision(10) <<f<<endl;
}


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

int main() {
    int N,A=0, B=0;
    cin >> N;
    vector<int> data(N);
    for(int i=0; i<N; i++){
        cin >> data.at(i);
    }    
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    for(int i=0; i<N; i++){
        if(i % 2 == 0){
            A += data.at(i);
        }
        else B += data.at(i);
        }
        cout << A-B << endl;
    }

Measured memory_bytes: 256
#include <set>
#include <cstring>
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

char str[80010];
int len;
int memo[80010][11];

int solve(int pos, int mod){
  if(memo[pos][mod] != -1) return memo[pos][mod];
  if(mod == 0){
    if(pos == len - 1) return 1;
    else return memo[pos][mod] = 1 + solve(pos + 1, str[pos + 1] - '0');
  }else{
    if(pos == len - 1) return 0;
    int next = mod * 10 + (str[pos + 1] - '0');
    return memo[pos][mod] = solve(pos + 1, next % 11);
  }
}

int main(){
  while(scanf("%s", str)){
    len = strlen(str);
    if(len == 1 && str[0] == '0') break;
    memset(memo, -1, sizeof(memo));
    int ans = 0;
    REP(i,len) if(str[i] != '0'){
      int tmp = solve(i, str[i] - '0');
      ans += tmp;
      // printf("S: %s, pos: %d, ans: %d\n", str, i, tmp);
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll H,W,D;
    cin>>H>>W>>D;
    ll A[H][W];
    pair<ll,ll> v[H*W+10];
    vector<ll>ans(H*W+10,0);
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            cin>>A[i][j];
            v[A[i][j]].first=i;
            v[A[i][j]].second=j;
        }
    }
    for(ll i=1;i<=H*W;i++){
        if(ans[i]!=0) continue;
        for(ll j=i+D;j<=H*W;j+=D){
            ans[j]+=ans[j-D]+abs(v[j-D].first-v[j].first)+abs(v[j-D].second-v[j].second);
        }
    }

    ll Q;
    cin>>Q;
    ll L[Q],R[Q];
    for(ll i=0;i<Q;i++){
        cin>>L[i]>>R[i];
        cout<<ans[R[i]]-ans[L[i]]<<endl;
    }
}


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

int main () {
    int S;
    cin >> S;
    
    int h,m,s;
    h = S / (60 * 60);
    m = S % (60 * 60) / 60;
    s = S % (60 * 60) % 60 % 60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3104
use std::io;


fn main() {
    let n: u64 = read_line();
    println!("{}", solve(n));
}

fn solve(n: u64) -> u64 {
    let (cycles, rem) = (n / 11, n % 11); // seems there's no divMod
    let rest = match rem {
        0 => 0,
        m if m <= 6 => 1,
        _ => 2,
    };
    cycles * 2 + rest
}

fn read_line() -> u64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(o,c) printf(o,c?"Yes":"No");
#define pYN(o,c) printf(o,c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int cnt=0;
    string s; cin>>s;
    rep(i,s.size()){
       if(s[i]=='1')cnt++;
   }
   p("%d\n",cnt);
}


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


int main(){
  vector<long long> lucas(87);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for (int i=2; i < 87; i++){
    lucas.at(i) = (lucas.at(i-2) + lucas.at(i-1));
  }
  int N;
  cin >> N;
  cout << lucas.at(N) << endl;
    
}


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

int main() {
  int n, m, x, y; cin >> n >> m >> x >> y;
  vector<int> Xcity(n), Ycity(m);
  for (auto &u : Xcity) cin >> u;
  for (auto &v : Ycity) cin >> v;
  int u = *max_element(Xcity.begin(), Xcity.end());
  int v = *min_element(Ycity.begin(), Ycity.end());
  if (max(x, u) < min(y, v)) cout << "No War\n";
  else cout << "War\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

#define MAX 1<<20
int tree[MAX];
int lazy[MAX];

void update_tree(int node, int a, int b, int i, int j, int value) {

  	if(lazy[node] != 0) { // This node needs to be updated
   		tree[node] += (b-a+1)*lazy[node]; // Update it

		if(a != b) {
			lazy[node*2] += lazy[node]; // Mark child as lazy
    			lazy[node*2+1] += lazy[node]; // Mark child as lazy
		}

   		lazy[node] = 0; // Reset it
  	}

	if(a > b || a > j || b < i) // Current segment is not within range [i, j]
		return;

  	if(a >= i && b <= j) { // Segment is fully within range
    		tree[node] += (b-a+1)*value;

		if(a != b) { // Not leaf node
			lazy[node*2] += value;
			lazy[node*2+1] += value;
		}

    		return;
	}

	update_tree(node*2, a, (a+b)/2, i, j, value); // Updating left child
	update_tree(1+node*2, 1+(a+b)/2, b, i, j, value); // Updating right child

	tree[node] = tree[node*2] + tree[node*2+1]; // Updating root with max value
}

int query_tree(int node, int a, int b, int i, int j) {

	if(a > b || a > j || b < i) return 0; // Out of range

	if(lazy[node] != 0) { // This node needs to be updated
		tree[node] += (b-a+1)*lazy[node]; // Update it

		if(a != b) {
			lazy[node*2] += lazy[node]; // Mark child as lazy
			lazy[node*2+1] += lazy[node]; // Mark child as lazy
		}

		lazy[node] = 0; // Reset it
	}

	if(a >= i && b <= j) // Current segment is totally within range [i, j]
		return tree[node];

	int q1 = query_tree(node*2, a, (a+b)/2, i, j); // Query left child
	int q2 = query_tree(1+node*2, 1+(a+b)/2, b, i, j); // Query right child

	int res = q1 + q2; // Return final result

	return res;
}

vector<pii> g[1<<20];
vector<int> atleast(1<<20), atmost(1<<20);
int n, m, x, y;

int main() {

    //freopen("lazy_loading.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);
    cin>>n>>m;
    rep(i, n) {
        cin>>x>>y;
        g[y-x+1].pb(mp(x, y));
    }

    for(int i = m;i >= 1;i--) {
        atleast[i] = atleast[i+1]+g[i].size();
    }

    for(int i = 1;i <= m;i++) {
        for(int j = i;j <= m;j += i) {
            atmost[i] += query_tree(1, 1, m, j, j);
        }
        rep(j, g[i].size()) {
            // add 1 in the interval g[i][j].first g[i][j].second
            update_tree(1, 1, m, g[i][j].first, g[i][j].second, 1);
        }
    }

    for(int i = 1;i <= m;i++) cout<<atleast[i]+atmost[i]<<endl;
    return 0;
}


Measured memory_bytes: 40064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

struct union_find
{
	vector<int> p;

	union_find(int n) : p(n, -1) {}

	bool join(int u, int v)
	{
		if ((u = root(u)) == (v = root(v)))
			return false;
		if (p[u] > p[v])
			swap(u, v);
		p[u] += p[v];
		p[v] = u;
		return true;
	}

	int root(int u)
	{
		return p[u] < 0 ? u : p[u] = root(p[u]);
	}
};

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

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

	union_find ds(n);
	while(m--){
		int a, b;
		cin >> a >> b;
		a--, b--;
		ds.join(a, b);
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		int r = ds.root(i);
		ans = max(ans, -ds.p[r]);
	}

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


Measured memory_bytes: 3972
import math
n=int(input())
x=[int(0) for i in range(n)]
y=[int(0) for i in range(n)]
x[:]=(int(a) for a in input().split())
y[:]=(int(a) for a in input().split())
p1=0
p2=0
p3=0
px=0
for i in range(n):
  p1+=abs(x[i]-y[i])
  p2+=abs(x[i]-y[i])**2
  p3+=abs(x[i]-y[i])**3
  if px<abs(x[i]-y[i]):
    px=abs(x[i]-y[i])

p2=math.sqrt(p2)
p3=p3**(1/3)

print('{:.05f}'.format(p1))
print('{:.05f}'.format(p2))
print('{:.05f}'.format(p3))
print('{:.05f}'.format(px))




Measured memory_bytes: 5712
<?php

$s=new Scanner();

$str=$s->next();

$charCheck=array_fill(0,27,0);


for($i=0;$i<strlen($str);$i++){
 $charCheck[ord($str[$i])-97]++;
}

for($i=0;$i<26;$i++){
  if($charCheck[$i]==0){
    out::println(chr($i+97));
    return;
  }
}
out::println('None');


class Scanner{
  private $arr = [];
  private $count = 0;
  private $pointer = 0;
 
  public function next() {
    if ($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext(){
    return $this->pointer < $this->count;
  }
  public function nextInt(){
    return (int)$this->next();
  }
  public function nextDouble(){
    return (double)$this->next();
  }
}

class out{
  public static function println($str = ""){
    echo ($str . PHP_EOL);
  }


  public static function printVar(){
    $params = func_get_args();
    foreach ($params as $param) {
      echo ($param." ");
    }
    echo PHP_EOL;
  }
}


Measured memory_bytes: 3852
import collections
N = int(input())
S = [input() for _ in range(N)]

if len(S) == len(set(S)):
  ans = S
else:
  ans = []
  c = collections.Counter(S)
  c_common = c.most_common()
  max_vote = c_common[0][1]
  for k in range(len(set(S))):
    if c_common[k][1]== max_vote:
      ans.append(c_common[k][0])
    else:
      break
[print(a) for a in sorted(ans)]

Measured memory_bytes: 37492
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <cctype> 
using namespace std;

int main(){
    char buf[256];
    stack<int> stk;
    
    while(scanf("%s", buf) != EOF){
        if(isdigit(buf[0])){
            stk.push(atoi(buf));
        }else{
            int b = stk.top(); stk.pop();
            int a = stk.top(); stk.pop();
            switch(buf[0]){
                case '+':
                    stk.push(a + b);break;
                case '-':
                    stk.push(a - b);break;
                case '*':
                    stk.push(a * b);break;
            }
        }
    }
    printf("%d\n", stk.top());

    return 0;
}



Measured memory_bytes: 2736
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
     
using namespace std;
     
typedef long long ll;
     
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
     
#define MOD 1000000007

int main(){
  ll k;
  cin>>k;
  ll a = 7;
  ll c = 1;
  ll flag = 0;
  rep(i,0,10000000){
    if(a%k==0){
      flag = 1;
      break;
    }
    a*=10;
    a+=7;
    a%=k;
    c++;
  }
  if(flag==1){
    cout << c << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
// In the name of God
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <bitset>
#define sqr(a) (a)*(a)
#define all(a) (a).begin(), (a).end()
using namespace std;
 
template <typename T>
T next_int() {
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if(ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return p * x;
}
 
string next_token() {
    char ch;
    string ans = "";
    do { ch = getchar(); } while(ch <= ' ');
    while(ch > ' ') {
        ans += ch;
        ch = getchar();
    }
    return ans;
}
 
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;    
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;
 
long long bin_pow(long long a, long long b) {
    if(!b) return 1;
    long long ans = bin_pow(a, b / 2);
    ans = ans * ans;
    if(b % 2) ans = ans * a;
    return ans;
}

long long n, m;

bool f(long long c) {
    return m - max(0LL, -(n - c)) * 2 - c * 2 >= 0;
}

int main() {
    // freopen(".in", "r", stdin);

    cin >> n >> m;

    long long l = 0;
    long long r = (long long)1e18;

    while(r - l > 1) {
        long long c = (l + r) / 2;

        if(f(c))
            l = c;
        else
            r = c;
    }

    if(f(r))
        cout << r << "\n";
    else
        cout << l << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long int gcd(int i,int j,int kk)
{
    long long int s = __gcd(i, __gcd(j, kk));
    return s; 
             
}
int main()
{
    long long int k,sum=0;
    cin>>k;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int kk=1;kk<=k;kk++)
            {
                sum+=gcd(i,j,kk);
            }
        }
    }
    //cout<<"hi "<<__gcd(1,__gcd(1,1))<<endl;
    cout<<sum<<endl;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,cnt;
	for(int i=0;i<5;i++){
		cin>>x;
		if(x==0){
			cnt=i+1;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

const int N = 3005;
const long long inf = 1e18;

int n;
int a[N];
long long f[N][N];

long long calc(int l,int r) {
	if (l > r) {
		return 0;
	}
	if (f[l][r] > -inf) {
		return f[l][r];
	}
	if ((l - 1 + n - r) % 2 == 0) {
		long long res = calc(l + 1, r) + a[l];
		res = max(res, calc(l, r - 1) + a[r]);
		return f[l][r] = res;
	} else {
		long long res = calc(l + 1, r) - a[l];
		res = min(res, calc(l, r - 1) - a[r]);
		return f[l][r] = res;
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	memset(f, -123, sizeof f);
	printf("%lld\n", calc(1, n));
}

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

using namespace std;

typedef long long ll;

const ll N = 2e5 + 10;

ll n, m, k;
ll a[N], b[N];
ll res = 0;

int main() {
	cin >> n >> m >> k;
	for (ll i = 1; i <= n; i++) cin >> a[i];
	for (ll i = 1; i <= m; i++) cin >> b[i];

	for (ll i = 2; i <= n; i++) a[i] += a[i - 1];
	/*
	for (ll i = 1; i <= n; i++) cout << a[i] << " ";
	cout << endl;
	*/
	for (ll i = 2; i <= m; i++) b[i] += b[i - 1];
	/*
	for (ll i = 1; i <= m; i++) cout << b[i] << " ";
	cout << endl;
	*/
	ll j = m;
	for (ll i = 0; i <= n; i++) {
		ll t = k - a[i];
		for ( ; j >= 0; j--) {
			if (b[j] <= t) {
				res = max(res, i + j);
				//cout << i << " " << j << endl;
				break;
			}
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6744
from functools import reduce
from fractions import gcd
def lcm(x,y):return x*y//gcd(x,y)
def lcmm(l):return reduce(lcm,l)
a,b,c,d = map(int,input().split())
l =[c, d]
num = a // c
if a%c==0:
  num -= 1
num1 = b // c
num2 = a // d
if a%d==0:
  num2 -= 1
num3 = b// d
e = lcmm(l)
num4 = a // e
if a%e==0:
  num4 -= 1
num5 = b // e
print((b-a+1)-((num1-num)+(num3-num2)-(num5-num4)))

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

int main() {
	long n,m,i,j,k,ans,cur,res;
	string s;
	cin >> s;
	if(s=="ABC"){
		cout << "ARC" << endl;
	}else{
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>
int main()
{
    int L,R,D,i,cnt=0;
    scanf("%d %d %d",&L,&R,&D);
    for(i=L;i<=R;i++)
    {
        if(i%D==0)
        {
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll x; cin >> x;
    ll sum = 0;
    for(int i = 1; sum <= x; i++){
        sum += i;
        if(x <= sum){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static public void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b = scan.nextLong();
		scan.nextLong(); // c
		long k = scan.nextLong();
		scan.close();

		if (Math.abs(a - b) > Math.pow(10, 18)) {
			System.out.println("Unfair");
		} else {
			if (k % 2 == 0) {
				System.out.println(a - b);
			} else {
				System.out.println(b - a);
			}
		}
	}
}


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

const int inf = 1e9;

int main() {
	int r, n;
	while(cin >> r >> n, r) {
		vector<int> h1(2 * r + 1), h2(2 * r + 1);
		vector<int> flag(2 * r + 1);
		const int center = r;
		for(int i = 0; i < n; ++i) {
			int xl, xr, hi;
			cin >> xl >> xr >> hi;
			xl = max(-r, xl);
			xr = min(r, xr);
			xl += r;
			xr += r;
			for(int j = xl; j <= xr; ++j) {
				if(j == xl) flag[j] |= 1;
				else if(j == xr) flag[j] |= 2;
				else flag[j] |= 3;
				if(j == xl) h1[j] = max(h1[j], hi);
				else if(j == xr) h2[j] = max(h2[j], hi);
				else {
					h1[j] = max(h1[j], hi);
					h2[j] = max(h2[j], hi);
				}
			}
		}
		vector<int> h(2 * r + 1);
		for(int i = 0; i <= 2 * r; ++i) {
			h[i] = min(h1[i], h2[i]);
		}
		for(int i = 0; i <= 2*r; ++i) {
			if(flag[i] != 3) {
				h[i] = 0;
			}
		}
		
		double ans = inf;
		for(int i = 1; i < 2 * r; ++i) {
			double hh = sqrt(r * r - abs(r - i) * abs(r - i));
			double cp = max(h[i] - hh, -(double)r);
			ans = min(ans, cp + r);
		}
		
		cout << fixed << setprecision(10) << ans << endl;
	}
}


Measured memory_bytes: 3260
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









ll n,sz,c[30],mn[30];
char s[60];

void solve()
{
	cin>>n;
	for(int j=0;j<26;j++)mn[j]=1000;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		sz=strlen(s);
		for(int j=0;j<26;j++)c[j]=0;
		for(int j=0;j<sz;j++)
		{
			c[s[j]-'a']++;
		}
		for(int j=0;j<26;j++)
		{
			mn[j]=min(mn[j],c[j]);
		}
	}
	for(int j=0;j<26;j++)
	{
		for(int k=1;k<=mn[j];k++)cout<<(char)(j+'a');
	}
	cout<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define mk make_pair
#define pb push_back
#define P pair<int,int>
#define fi first
#define se second
#define F(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
struct E{int v,nxt;};
int n,a[200005];
ll s1,s2,ans;
int main(){
	n=read();for(int i=1;i<=n;++i)a[i]=read();
	int j=1;s1=s2=a[1];
	for(int i=1;i<=n;++i){
		while(j<n&&(s1^a[j+1])==s2+a[j+1])j++,s1^=a[j],s2+=a[j];
		if(s1==s2)ans+=j-i+1;
		s1^=a[i],s2-=a[i];
	}
	printf("%lld",ans);
} 

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

int main(){
    int a,b = 0;
    cin >> a;
    if(a%10 == 1)
        b++;
    a /= 10;
    if(a%10 == 1)
        b++;
    a /= 10;
    if(a%10 == 1)
        b++;
    a /= 10;
    cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
const int mod = 1e9 + 7;
typedef pair<lint, lint> pi;

int n, a[100005], p, q;

int trial(int t){
	lint ans = 0;
	for(int i=1; i<=n; i++){
		lint w = a[i] - 1ll * p * t;
		w = max(w, 0ll);
		ans += (w + q - p - 1) / (q - p);
	}
	return ans <= t;
}

int main(){
	cin >> n >> q >> p;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	int s = 0, e = 1e9;
	while(s != e){
		int m = (s+e)/2;
		if(trial(m)) e = m;
		else s = m+1;
	}
	cout << s << endl;
}


Measured memory_bytes: 640
#include <math.h>
#include <stdio.h>
#include <string.h>
int a, b, c, d;
int main(void) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    do {
        c = c - b;
        if (c < 1) {
            printf("Yes\n");
            break;
        }
        a = a - d;
        if (a < 1) {
            printf("No\n");
            break;
        }
        

    } while (1);
}

Measured memory_bytes: 1640
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h2=sorted(h)
start=0
goal=k-1
ans=10000000000
while goal<=n-1:
    ans=min(ans,h2[goal]-h2[start])
    start+=1
    goal+=1
print(ans)

Measured memory_bytes: 8288
#include <iostream>
#include <vector>
using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

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

    vector<ll> vec;
    repe(i, 1, 9) vec.push_back(i);

    int idx = 0;
    while (true) {
        repe(i, -1, 1) {
            int d = vec[idx] % 10 + i;
            if (d < 0 || 9 < d) continue;
            vec.push_back(vec[idx] * 10 + d);
        }
        if (vec.size() > k) break;
        idx++;
    }

    cout << vec[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 1400
N,u,v=map(int,input().split())
G=[set() for i in range(N)]
for i in range(N-1):
  A,B=map(int,input().split())
  G[A-1].add(B-1)
  G[B-1].add(A-1)
disA=[-1]*N
disB=[-1]*N
disA[u-1]=0
disB[v-1]=0
import collections

q=collections.deque([u-1])
while(q):
  x=q.popleft()
  for y in G[x]:
    if disA[y]==-1:
      disA[y]=disA[x]+1
      q.append(y)

q.append(v-1)      
while(q):
  x=q.popleft()
  for y in G[x]:
    if disB[y]==-1:
      disB[y]=disB[x]+1
      q.append(y)
ans=0
for i in range(N):
  if disA[i]<disB[i]:
    ans=max(ans,disB[i]-1)
print(ans)

Measured memory_bytes: 40616
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    ll X, Y; cin >> X >> Y;

    map<ll, ll> kane;

    kane[0] = 300000;
    kane[1] = 200000;
    kane[2] = 100000;

    

    ll ans = kane[X-1] + kane[Y-1];

    if(X == 1 && Y == 1){
        ans += 400000;
    }

    cout << ans << endl;

}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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


    vector<ll> v(2); int k;
    cin>>v[0]>>v[1]>>k;


    for (int i=0; i<k; i++) {
	if (v[i%2]%2) {
	    v[i%2]--;
	} else {
	}
	int o = 1^(i%2);
	v[o] += (v[i%2]/2);
	v[i%2] /= 2;

    }

    cout<<v[0]<<" "<<v[1]<<endl;

    
    
    
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
typedef vector<int> vi;
typedef long long int ll;
#define LL_MAX LLONG_MAX


//DIJKSTRA
struct edge {
    int to;
    int cost;
};

typedef pair<ll, int> P;  // first: 最短距離, second: 頂点番号

ll V, d[50*5000];
vector<edge> G[50*5000]; // 隣接リスト表現

void dijkstra(int s) {
    fill(d, d + V, LL_MAX);
    d[s] = 0;  // 始点sへの最短距離は0

    priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
        if (d[v] < p.first) {
            continue;
        }
        for (auto e : G[v]) {  // 頂点vから出る辺eを走査
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
//



int main() {
  int n, m, s;
  cin >> n >> m >> s;
  s = min(s, 4999);
  V = n * 5000;
  int u, v, a, b;
  rep(i,m) {
    cin >> u >> v >> a >> b;
    --u; --v;
    for (int i=a; i<5000; ++i) {
      G[u*5000+i].push_back({v*5000+i-a, b});
      G[v*5000+i].push_back({u*5000+i-a, b});
    }
  }
  int c, dd;
  rep(i,n){
    cin >> c >> dd;
    for(int j=0; j<5000-c; ++j) {
      G[i*5000+j].push_back({i*5000+j+c, dd});
    }
  }
  dijkstra(s);
  for(int i=1;i<n;++i){
    ll ans = LL_MAX;
    rep(j,5000) ans = min(ans, d[i*5000+j]);
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 31700
def main():
    ss = [input(), input(), input()]
    players = 'ABC'
    indices = {'a': 0, 'b': 1, 'c': 2}
    i = 0
    while True:
        if ss[i] == '':
            print(players[i])
            break
        i_next = indices[ss[i][0]]
        ss[i] = ss[i][1:]
        i = i_next


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string S;
  
  bool flag = false;
  REP(i,n){
      cin >> S;
      if(S=="Y"){
          flag = true;
      }
  }
  if (flag)cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
n=int(input())
k=int(input())
x=input().split(" ")
for i in range(len(x)):
  x[i]=int(x[i])
y=[]
for i in x:
  y.append(k-i)
c=0
for i in range(len(x)):
  c+=min(x[i],y[i])*2

print(c)
  

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int ac[10];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    ac[a]++;
    ac[b]++;
    ac[c]++;
    int flag1=0;
    int flag2=0;
    for(int i=1;i<=9;i++)
    {
        if(ac[i]==1)
        {
            flag1=1;
        }
        if(ac[i]==2)
        {
            flag2=1;
        }
    }
    if(flag1&&flag2)//
    {
        cout<<"Yes"<<'\n';
    }
    else
        cout<<"No"<<'\n';

}


Measured memory_bytes: 256
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._

  solve
  def solve: Unit = {
    val Array(c, n, m, s, d) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0) return
    val towns = Array.tabulate(n){_ ⇒ Nil: List[(Int, Int)]}
    for (_ ← 0 until m){
      val Array(a, b, f) = readLine.trim.split(' ').map(_.toInt)
      towns(a - 1) ::= (b - 1, f)
      towns(b - 1) ::= (a - 1, f)
    }
    val minCost = Array.tabulate(c + 1){_ ⇒ Array.tabulate(n){_ ⇒ Int.MaxValue}}.also{a ⇒ a(c)(s - 1) = 0}
    val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int, Int), Int](_._3).reverse).also{q ⇒ q.enqueue((c, s - 1, 0))}
    while (queue.nonEmpty){
      val (rest, current, cost) = queue.dequeue()
      if (minCost(rest)(current) == cost){
        for ((next, c) ← towns(current)) {
          if (minCost(rest)(next) > cost + c){
            minCost(rest)(next) = cost + c
            queue.enqueue((rest, next, cost + c))
          }
          if (rest > 0 && minCost(rest - 1)(next) > cost + c / 2){
            minCost(rest - 1)(next) = cost + c / 2
            queue.enqueue((rest - 1, next, cost + c / 2))
          }
        }
      }
    }
    println((0 to c).map(i ⇒ minCost(i)(d - 1)).min)
    solve
  }
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 100964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,m;
    ll ans=0;
    cin >>n;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    cin >> m;
    vector<int>x(m);
    vector<int>p(m);
    rep(i,m){
        cin >> p[i];
        cin >> x[i];
    }
    
    rep(i,m){
        vector<int>ato(n);
        ato = t;
        
        ato[p[i]-1] = x[i];
        
        rep(j,n){
            ans += ato[j];
        }
        cout << ans << endl;
        ans =0;
    }
    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    int K;
    Scd2(N,K);

    vi a(N);
    vi s;

    Rep(i,N){
        Scd(a[i]);
    }

    bool en = false;
    Rep(k,K){
        s.assign(N+1,0);
        Rep(i,N){
            int l = max((ll)0,i-a[i]);
            int r = min((ll)N,i+a[i]+1);
            s[l]++;
            s[r]--;
        }
        en = true;
        Rep(i,N){
            s[i+1] += s[i];
            a[i] = s[i];
            if( a[i] != N ) en = false;
        }
        if( en ) break;
    }

    Rep(i,N){
        printf ("%d%s", a[i], i==N-1?"\n":" " );
    }

    return 0;
}



Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;


int main()
{
	int size;
	int a[100];
	int t;
	int ch;
	int count=1;
	
	cin >> size;
	for (int i = 0; i < size; i++) cin >> a[i];


	for (int i = 0; i < size - 1; i++) {
		for (int j = size - 1; j > i; j--) {
			if (a[j - 1] > a[j]) {
				int t = a[j];
				a[j] = a[j - 1];
				a[j - 1] = t;
			}
		}
	}

	ch = a[size]; 
	for (int i = size; i>0; i--) {
		if (ch != a[i - 1]) {
			count++;
			ch = a[i - 1];
		}
	}
	cout << count-1 << endl;
	

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    vector<int> dp(W + 1, 0);
    rep(i, N)
      for(int j = W; j >= w[i]; --j)
        dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read(){
	int ans=0;
	bool f=1;
	char ch=gc();
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return f?ans:-ans;
}
const int N=1e5+5;
int n,ans[N];
vector<int>e[N];
struct Tree{
	vector<int>g[N];
	int rt,stk[N],top;
	void dfs(int p){
		for(ri i=0,v;i<g[p].size();++i)dfs(v=g[p][i]);
		if(!(((int)g[p].size())&1))stk[++top]=p;
		while(top>1){
			e[stk[top]].pb(stk[top-1]);
			e[stk[top-1]].pb(stk[top]);
			top-=2;
		}
	}
	inline void init(){
		for(ri ft,i=1;i<=n;++i){
			ft=read();
			if(ft==-1)rt=i;
			else g[ft].pb(i);
		}
	}
	inline void solve(){
		top=0;
		dfs(rt);
	}
}t[2];
bool vs[N],col[N];
void dfs(int p,int cl){
	if(vs[p])return;
	vs[p]=1;
	col[p]=cl;
	for(ri i=0;i<e[p].size();++i)dfs(e[p][i],cl^1);
}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	for(ri i=0;i<2;++i)t[i].init();
	for(ri i=1;i<=n;++i)if(((int)t[0].g[i].size()+(int)t[1].g[i].size())&1){
		puts("IMPOSSIBLE");
		return 0;
	}
	puts("POSSIBLE");
	for(ri i=0;i<2;++i)t[i].solve();
	for(ri i=1;i<=n;++i)dfs(i,0);
	for(ri i=1;i<=n;++i)cout<<((((int)t[0].g[i].size())&1)?0:(col[i]?1:-1))<<' ';
	return 0;
}

Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define INT_MAXi 10e15

long long int dp[401][401];
long long int a[401];
long long int b[401];

long long int fn(int i,int j)
{ 
	if(i > j) return INT_MAXi;
	if(dp[i][j] != -1) return dp[i][j];
	if(i == j) {
		return 0;
	}
	long long int count = INT_MAXi;
	for(int l = i;l < j; l++)
	{
		long long int z = fn(i,l) + fn(l + 1,j);
		count = min(count,z);
	}
	dp[i][j] = count + b[j];
	if(i > 0) dp[i][j] -= b[i - 1];
 	return dp[i][j];
	
}

int main()
{
	int n;
	cin>>n;
	cin>>a[0];
	b[0] = a[0];
	for (int i = 1; i < n; ++i)
	{
		cin>>a[i];
		b[i] += b[i - 1] + a[i];
	}
	memset(dp,-1,sizeof(dp));
	fn(0,n - 1);
	long long int ans = dp[0][n-1];
	ans = ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1536
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
vector<int>vec;

int main(){
	cin >> n;
	repn(i,n){
		int a; cin >> a;
		vec.pb(a-i);
	}
	SORT(vec);
	
	ll ans = 0, val = vec[n/2];
	rep(i,vec.size()) ans += abs(val-vec[i]);
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  string S;
  cin >> S;
  cout << 2 * min(count(ALL(S), '0'), count(ALL(S), '1')) << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace ABC092_B_Chocolate
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] input = Console.ReadLine().Split(' ');
			int d = int.Parse(input[0]);
			int x = int.Parse(input[1]);

			List<int> aArr = new List<int>();
			for (int i = 0; i < n; i++) {
				aArr.Add(int.Parse(Console.ReadLine()));
			}
			
			int resultNumberOfChoco = x;

			for (int i = 0; i < n; i++)
			{
				for (int j = 0; ; j++) {
					int day = j * aArr[i] + 1;

					if (day > d)
					{
						break;
					}

					resultNumberOfChoco += 1;
				}
			}
			
			Console.WriteLine(resultNumberOfChoco);
		}
	}
}

Measured memory_bytes: 13140