akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)       for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-



//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
     
       vector<int> v(3);

       for(int i = 0; i < 3; i++) cin >> v[i];
        int k;
        cin >> k;
        if(v[0] < v[1] && v[1] < v[2]){
           cout << "Yes\n";
        }
        else{
          bool ans = false;
             while(k--){
                  if(v[2] <= v[1] || v[2] <= v[0]){
                       v[2] *= 2;
                  }
                  else if(v[1] <= v[0]){
                        v[1] *= 2;
                  }
                  if(v[0] < v[1] && v[1] < v[2]){
                    cout << "Yes\n";
                    ans = true;
                    break;
                 }
            
             }
             if(!ans){
                 cout << "No\n";
             }

        }


        

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 3648
N,K = map(int, input().split())
A = list(map(int,input().split()))
t = 0
for i in range(N-1):
  for j in range(N-i-1):
    if A[i] > A[j+i+1]:
      t += 1
u = 0
for i in range(N):
  for j in range(N):
    if A[i]>A[j]:
      u += 1
T = t%(10**9+7)
U = u%(10**9+7)
Z=K*(K-1)//2%(10**9+7)
Y=T*K%(10**9+7)
X=U*Z%(10**9+7)
ans = (Y+X)%(10**9+7)
print(ans)

Measured memory_bytes: 41836
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B,C,K = map(int,input().split())

if K%2==0:
    ans = A-B
else:
    ans = B-A

if abs(ans)>10**18:
    ans ="Unfair"

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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


int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(c%max(a,b))cout<<c/max(a,b)+1<<endl;
	else cout<<c/max(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Jun  6 21:15:08 2019

@author: hisaki
"""

import numpy as np

N,M = map(int,input().split())
L_array = np.zeros(M)
R_array = np.zeros(M)
for i in range(M):
    L,R = map(int,input().split())
    L_array[i] = L
    R_array[i] = R
    
L_max = np.max(L_array)
R_min = np.min(R_array)

if L_max <= R_min:
    print (int (R_min - L_max + 1))    
else:
    print (0)





Measured memory_bytes: 14024
#include <iostream>
#include <vector>
#include <queue>
#include <map>

using namespace std;
const long long Inf =  1e+16;

void dijkstra(vector<vector<pair<long long, long long>>>& graph, vector<long long>& used, long long r) {
    priority_queue<pair<long long, long long>,vector<pair<long long, long long>>,greater<pair<long long, long long>>> pq;
    pq.push(make_pair(0, r));
    while (pq.empty() == false) {
        long long corr_score = pq.top().first; // ????????????????????????????????¢
        long long corr_v = pq.top().second; // ?????????????????????
        pq.pop();
        if (used[corr_v] != Inf) {
            continue; 
        }
        used[corr_v] = corr_score;
        for (long long i = 0; i < graph[corr_v].size(); i ++) {
            long long tgt = graph[corr_v][i].first;
            long long score = graph[corr_v][i].second;
            if (used[tgt] == Inf) {
                pq.push(make_pair(score + corr_score, tgt));
            }
        }
    }
}

// dijkstra ?????¢?????´????????? ~ ??£??\?????????????????¨
int main() {
    long long v;
    long long e;
    long long r;
    cin >> v >> e >> r;
    vector<vector<pair<long long, long long>>> graph(v);
    for (long long i = 0; i < e; i ++) {
        long long s;
        long long t;
        long long d;
        cin >> s >> t >> d;
        graph[s].push_back(make_pair(t, d));
    }

    vector<long long> used(v, Inf);
    dijkstra(graph, used, r);

    for (long long i = 0; i < v; i ++) {
        if (used[i] == Inf) {
            cout << "INF" << endl;
        } else {
            cout << used[i] << endl;
        }
    }

}

Measured memory_bytes: 21500
/* In The Name of Anton*/

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

void pre(){

}

void solve(){
  string s; cin>>s;
  int sum=0;

  rep(i,s.size()){
    sum+=(int)(s[i]-'0');
  }

  if(sum%9!=0) cout<<"No"<<"\n";
  else cout<<"Yes"<<"\n";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;cin>>n>>k;
    ll h[n];
    rep(i,0,n)cin>>h[i];
    sort(h,h+n);
    if(k>=n)cout<<0<<endl;
    else{
        ll ans=0;
        rep(i,0,n-k)ans+=h[i];
        cout<<ans<<endl;
    }
}



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

int main() {
  int N;
  scanf("%d",&N);
  int L[2*N];
  for (int i=0; i<2*N; i++) {
    scanf("%d",&L[i]);
  }
  sort(L,L+2*N);
  int ans=0;
  for (int i=0; i<2*N; i+=2) {
    ans+=min(L[i],L[i+1]);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
#define int ll
ll Ans = 0;
int n;
vector<int> edge[105];
int ans[105],fa[105],deep[105];
void dfs(int u){
	ans[deep[u]] = max(ans[deep[u]],(ll)edge[u].size()-1);
	for(unsigned i=0;i<edge[u].size();++i){
		int v = edge[u][i];
		if(v == fa[u]) continue;
		fa[v] = u;
		deep[v] = deep[u] + 1;
		dfs(v);
	}
}
void solve(int u,int v){
//	printf("[%d %d]\n",u,v);
	//u -> v这条边
	mem(ans,0);
	deep[u]=1;fa[u]=v;dfs(u);
	deep[v]=1;fa[v]=u;dfs(v);
	int answ = 1;
	for(int i=1;i<=n;i++){
		if(ans[i]) answ = answ * ans[i];
//		if(ans[i]){
//			printf("(%d %d)\n",i,ans[i]);
//		}
	}
	Ans = min(Ans,answ*2);
}
signed main(){
	Ans = 1e18;
	n = rd();
	rep(i,1,n){
		int a = rd(),b = rd();
		edge[a] . push_back(b);
		edge[b] . push_back(a);
	}
	deep[1] = 1;fa[1]=0;dfs(1);
	int u = 1;
	Rep(i,1,n){
		if(deep[i] > deep[u]) u = i;
		fa[i] = 0;
	}
	deep[u] = 1;fa[u]=0;dfs(u);
	int v = u;
	Rep(i,1,n){
		if(deep[i] > deep[v]) v = i;
	}
//	printf("%d %d\n",u,v);
	printf("%d ",(deep[v]+1)/2);
//debug(deep[v]);
	if(deep[v] & 1){
		int need = deep[v] / 2;
		while(need--){
			v = fa[v];
		}
		//v是中间那个点
		for(unsigned i=0;i<edge[v].size();++i){
			solve(v,edge[v][i]);
		}
		mem(ans,0);
		deep[v]=1;fa[v]=0;dfs(v);
		ans[1] = edge[v].size();
		int answ = 1;
		for(int i=1;i<=n;i++){
			if(ans[i]) answ = answ * ans[i];
//			printf("(!!!)%d %d\n",i,ans[i]);
		}	
		Ans=min(Ans,answ);
	}//中间那个是个点
	else{
	 	int need = deep[v] / 2;
	 	u = v;
	 	while(need--){
//	 		printf("[%d %d]\n",u,v);
	 		v = u;
	 		u = fa[v];
		}
		solve(u,v);
	}//中间那个是一条边 
	writeln(Ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;

int main(){
	while (cin >> n&&n){
		int MAX = -1, MIN = 10000;
		REP(i, n){
			int sum = 0;
			REP(j, 5){
				int a;
				cin >> a;
				sum += a;
			}
			MAX = max(MAX, sum);
			MIN = min(MIN, sum);
		}
		cout << MAX << " " << MIN << endl;
	}
}

Measured memory_bytes: 1160
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {

		Scanner sc = new Scanner(System.in);

		int dir[][] = { { -1, 0 }, { 1, 0 }, { 0, 1 } };

		while (true) {
			final int w = sc.nextInt();
			final int h = sc.nextInt();

			if (w == 0 && h == 0) {
				break;
			}

			final int amount = sc.nextInt();
			final int capacity = sc.nextInt();
			final int init = sc.nextInt();

			int[][] map = new int[h][w];

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
				}
			}

			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			for (int i = 0; i < w; i++) {
				Walk walk = new Walk(0, init, i, 0, h, w);
				walk.sanso--;
				queue.add(walk);
			}

			boolean flag = false;
			while (!queue.isEmpty()) {
				Walk walk = queue.poll();

				// System.out.println(walk.x + " " + walk.y + " " + walk.cost +
				// " " + walk.sanso);

				if (walk.sanso <= 0) {
					continue;
				} else if (walk.y >= h) {
					flag = true;
					System.out.println(walk.cost);
					break;
				}

				walk.visited[walk.y][walk.x] = true;

				if (map[walk.y][walk.x] <= 0) {
					walk.cost += (-map[walk.y][walk.x]);
				} else {
					walk.sanso = Math.min(map[walk.y][walk.x] + walk.sanso,
							capacity);
				}

				if (walk.cost > amount) {
					continue;
				}

				for (int i = 0; i < 3; i++) {
					if (walk.x + dir[i][0] >= 0
							&& walk.x + dir[i][0] <= w - 1
							&& walk.y + dir[i][1] >= 0
							&& walk.y + dir[i][1] <= h - 1
							&& !walk.visited[walk.y + dir[i][1]][walk.x
									+ dir[i][0]]) {

						Walk wa = new Walk(walk);
						wa.x += dir[i][0];
						wa.y += dir[i][1];
						wa.sanso--;
						queue.add(wa);
					} else if (i == 2 && walk.y == h - 1) {
						Walk wa = new Walk(walk);
						wa.y++;
						queue.add(wa);
					}
				}
			}

			if (!flag) {
				System.out.println("NA");
			}

		}
	}
}

class Walk implements Comparable<Walk> {
	int cost;
	int sanso;
	int x, y;
	boolean[][] visited;

	public Walk(int cost, int sanso, int x, int y, int h, int w) {
		super();
		this.cost = cost;
		this.sanso = sanso;
		this.x = x;
		this.y = y;
		visited = new boolean[h][w];
	}

	public Walk(Walk w) {
		this.cost = w.cost;
		this.sanso = w.sanso;
		this.x = w.x;
		this.y = w.y;
		visited = new boolean[w.visited.length][w.visited[0].length];
		for (int i = 0; i < w.visited.length; i++) {
			System.arraycopy(w.visited[i], 0, this.visited[i], 0,
					w.visited[i].length);
		}
	}

	@Override
	public int compareTo(Walk arg0) {
		return this.cost - arg0.cost;
	}
}

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

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

using namespace std;

class F2{
	bool x;
public:
	F2():x(false){}
	F2(long long n){ assert(n==0||n==1); x=(n==1); }
	F2& operator+=(const F2& a){ x=(x!=a.x); return *this; }
	F2& operator-=(const F2& a){ return (*this)+=a; }
	F2& operator*=(const F2& a){ x=(x&&a.x); return *this; }
	F2& operator/=(const F2& a){ assert(a.x); return *this; }
	F2 operator+(const F2& a)const{ return F2(*this)+=a; }
	F2 operator-(const F2& a)const{ return F2(*this)-=a; }
	F2 operator*(const F2& a)const{ return F2(*this)*=a; }
	F2 operator/(const F2& a)const{ return F2(*this)/=a; }
	bool operator==(const F2& a)const{ return x==a.x; }
	bool operator!=(const F2& a)const{ return !((*this)==a); }
	int to_int()const{ return x; }
};

template<class T> struct edge{
	int to;
	T wt;
	edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using weighted_graph=vector<vector<edge<T>>>;

vector<F2> cnt;
vector<bool> vis;
vector<int> ans;

weighted_graph<int> G;

void dfs(int i){
	vis[i]=true;
	for(const auto& e:G[i]) if(!vis[e.to]) {
		dfs(e.to);
		if(cnt[e.to]==1){ // use this edge
			cnt[i]+=1;
			cnt[e.to]+=1;
			ans.emplace_back(e.wt);
		}
	}
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> a(n),b(n),l(m),r(m);
	rep(i,n) scanf("%d%d",&a[i],&b[i]);
	rep(j,m) scanf("%d%d",&l[j],&r[j]);

	{
		vector<pair<int,int>> p(n);
		rep(i,n) p[i]={a[i],b[i]};
		sort(p.begin(),p.end());
		rep(i,n) tie(a[i],b[i])=p[i];
	}

	// 差分をとる
	cnt.resize(n+1);
	rep(i,n) cnt[i]=b[i];
	for(int i=n;i>0;i--) cnt[i]-=cnt[i-1];

	G.resize(n+1);
	rep(j,m){
		int il=lower_bound(a.begin(),a.end(),l[j])-a.begin();
		int ir=upper_bound(a.begin(),a.end(),r[j])-a.begin();
		if(il<ir){
			G[il].emplace_back(ir,j);
			G[ir].emplace_back(il,j);
		}
	}

	vis.resize(n+1);
	rep(i,n+1) if(!vis[i]) dfs(i);

	if(count(cnt.begin(),cnt.end(),0)<n+1){
		puts("-1");
	}
	else{
		sort(ans.begin(),ans.end());
		printf("%lu\n",ans.size());
		rep(i,ans.size()) printf("%d%c",ans[i]+1,i+1<ans.size()?' ':'\n');
	}

	return 0;
}


Measured memory_bytes: 15472
#include<iostream>
using namespace std;
 
int main()
{
  int N;
  int value;
  cin >> N >> value;
  int number[3];

  number[0] = value / 10000;
  while (number[0] > -1) {
    number[1] = (value - 10000 * number[0]) / 5000;

    while (number[1] > -1) {
      number[2] = N - number[0] - number[1];

      if (value == 10000 * number[0] + 5000 * number[1] + 1000 * number[2]) {
        cout << number[0] << " " << number[1] << " " << number[2];
        return 0;
      }
      number[1]--;
    }
  number[0]--;
  }

  cout << "-1 -1 -1";
  return 0;
}

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;
	cin >> n >> K;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	vector<int> dp(K + 1, 0);
	for (int i = 1; i <= K; i++) {
		set<int> s;
		for (int x : a) {
			if (i < x) continue;
			s.insert(dp[i - x]);
		}
		for (int j = 0; ; j++) {
			if (s.find(j) == s.end()) {
				dp[i] = j;
				break;
			}
		}
	}
	cout << (dp[K] == 0 ? "Second" : "First") << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        sc.close();
        int seven = 7;
        if(K % 2 == 0 || K % 5 == 0){
            System.out.println(-1);
        }else{
            for(int i = 1;;i++){
                if(seven % K == 0){
                    System.out.println(i);
                    break;
                }
                seven = ((seven * 10) + 7) % K;
                
            }
        }
    }
}


Measured memory_bytes: 35816
import java.util.Arrays;
import java.util.Scanner;


class Main {

	public static void main(String[] a){
		
		int inputCount = 5;
		
		Scanner in = new Scanner(System.in);
		String input = in.nextLine();
		String[] numArray = input.split(" ");
		
		
		int[] temp = new int [inputCount];
		for (int i=0; i<inputCount; i++){
			temp[i] = Integer.parseInt(numArray[i]);
		}

		Arrays.sort(temp);
		
		System.out.println(temp[4] + " " +
						   temp[3] + " " +
						   temp[2] + " " +
						   temp[1] + " " +
						   temp[0]);
	}
}

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

int main(){
  string s;
  cin >> s;
  rep(i,3){
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }
  cout << s << endl;
  return 0;
}


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

F = [1, 1]
Fi = [1, 1]
I = [0, 1]
for i in range(2, N + 1):
  F.append((F[-1] * i) % MOD)
  I.append(MOD - I[MOD % i] * (MOD // i) % MOD)
  Fi.append(Fi[-1] * I[i] % MOD)

if A > B:
  A, B = (B, A)
Rk = min(N, K // A)

Ans = 0
for i in range(Rk + 1):
  R = i
  if (K - (A * R)) % B != 0:
    continue
  C = (K - (A * R)) // B
  if C > N:
    continue
  Rc = F[N] * (Fi[R] * Fi[N - R] % MOD) % MOD
  Cc = F[N] * (Fi[C] * Fi[N - C] % MOD) % MOD
  Ans += (Rc * Cc) % MOD

print(Ans % MOD)


Measured memory_bytes: 38956
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

ans = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ok = False
            if 0 < i and s[i - 1][j] == '#':
                ok = True
            if i + 1 < h and s[i + 1][j] == '#':
                ok = True
            if 0 < j and s[i][j - 1] == '#':
                ok = True
            if j + 1 < w and s[i][j + 1] == '#':
                ok = True
            if not ok:
                ans = "No"
print(ans)

Measured memory_bytes: 40788
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 
template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}
 
const int N = 200005;
 
int main(){
  FASTER;
  map<string, string>mp;
  mp["ABC"] = "ARC";
  mp["ARC"] = "ABC";
  string s;
  cin >> s;
  cout << mp[s] << "\n";  
  return 0;
}

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

int main(){
    string a;
    cin >> a;
    if ((int)a.find("a") != -1 && (int)a.find("b") != -1 && (int)a.find("c") != -1) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl; 
}

Measured memory_bytes: 256
//abc142_c.cpp
//Sat Sep 28 20:49:53 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

bool compare_by_b(P a, P b) {
	if(a.first != b.first){
		return a.first < b.first;
	}else{
		return a.second > b.second;
	}
}

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

	vector<P> pairs;
	for (int i=0;i<n;i++){
		int temp;
		cin >> temp;
		pairs.push_back(make_pair(temp,i));
	}

	sort(pairs.begin(),pairs.end());

	for (int i=0;i<n;i++){
		cout << pairs[i].second+1 << " ";
	}
	printf("\n");

}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>d(k);
  int i;
  for(i=0;i<k;i++)cin>>d[i];
  bool chk=false;
  while(!chk){
    int tmp=n;
    chk = true;
    while(tmp>0){
      for(i=0;i<k;i++){
        if(tmp%10 == d[i]){
          chk = false;
          n++;
          tmp = 0;
          break;
        }
      }
      tmp/=10;
    }
  }
 cout << n << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
first_black = 0
count = 0
for i in range (N):
    if first_black == 0 and S[i]=='#':
        first_black = 1
    if first_black == 1 and S[i]== '.':
        count +=1
        
first_white = 0
white_count = 0
for i in range (N):
    if first_white == 0 and S[N-i-1]=='.':
        first_white = 1
    if first_white == 1 and S[N-i-1]== '#':
        white_count +=1

white_black = 10**6

black_count_left = 0
white_count_right = S.count('.')
ans = black_count_left + white_count_right

for i in range (N):
    if S[i] == '#':
        black_count_left+=1
    elif S[i] == '.':
        white_count_right-=1
    if ans >= black_count_left+white_count_right:
        ans = black_count_left+white_count_right
        
print(min(count,white_count, ans))

Measured memory_bytes: 3500
INF = float('inf')
dp = [INF] * (10**5 + 10)
dp[0] = 0
h = [0] * (10 ** 4)
N, K = map(int, input().split())
h = list(map(int, input().split())) + h
for i in range(1, N+1):
    for k in range(1, K+1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]))
print(dp[N-1])


Measured memory_bytes: 56320
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A')
            a++;
        else if(s[i]=='B')
            b++;
    }
    if(a==3||b==3)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

}


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

int main()
{
    map<string, bool> T;
    int n;
    cin >> n;
    char str[13], com[13];
    for (int i = 0; i < n; i++)
    {
        cin >> com >> str;
        if (com[0] == 'i')
        {
            T[str] = true;
        }
        else
        {
            if (T[str] == true)
                cout << "yes\n";
            else
                cout << "no\n";
        }
    }
    return 0;
}


Measured memory_bytes: 47424
#include <stdio.h>

int kai(int n);

int main(void)
{
	int n;
	
	scanf("%d", &n);
	
	if (n <= 16){
		printf("%d\n", kai(n));
	}
	switch (n){
		case (17):
		  printf("355687428096000\n");
		  break;
			  
		case (18):
		  printf("6402373705728000\n");
		  break;
		  
		case (19):
		  printf("121645100408832000\n");
		  break;
		  
		case (20):
		  printf("2432902008176640000\n");
		  break;
	}
	return (0);
}
int kai(int n)
{
	if (n == 1){
		return (1);
	}
	else {
		return (kai(n - 1) * n);
	}
}

Measured memory_bytes: 576
#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>;

const ll mod = 998244353;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
} c(2e5 + 1);

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  mint ans = 0;
  mint col = m;
  for (int x = n - 1; x >= 0; --x) {
    mint now = col;
    now *= c(n - 1, x);
    if (x <= k) {
      ans += now;
    }
    col *= m - 1;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 6236
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
map<int, int> cnt;
int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
// D - All Your Paths are Different Lengths

using namespace std;

vector<pair<pair<int,int>,int>> ans;

int main() {
    int N,L,i;

    scanf("%d",&L);

    N = ((int) log2(L)) + 1;
    for (i = 1;i < N;i++) {
        ans.push_back({{i,i + 1},0});
        ans.push_back({{i,i + 1},(1 << (i - 1))});
    }

    for (i = 1;i < N;i++) {
        if (L & 1)
            ans.push_back({{i,N},(L - 1) << (i - 1)});

        L >>= 1;
    }

    printf("%d %d\n",N,ans.size());
    for (pair<pair<int,int>,int> a : ans)
        printf("%d %d %d\n",a.first.first,a.first.second,a.second);

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
/* Properties of modulo:Fermat's little theorem
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define pb push_back
#define gcd __gcd
#define nl cout<<"\n"
#define endl "\n"
#define rep(i,n) for(ll i = 0 ; i < n ; i++)
#define fo(i,a,b) for(ll i = a ; i <= b ; i++)
#define foi(i,a,b) for(ll i = a ; i >= b ; i--)
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
//sorting in reverse order
bool compare(ll x, ll y){
    return x>y;
}
// checking whether a number is prime or not
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
// returning vector containing all prime numbers less than a given number
vector<ll> get_prime_factors_less_than(ll n){
    vector<ll> factor;
    vector<ll> prime(n,1);
    prime[0]=0,prime[1]=0;
    for(ll i = 2 ; i <= n ; i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
//returns x^y in order logn 
ll power(ll x, ll y) { 
    if (y == 0) return 1; 
    ll a = power(x,y/2);
    if (y % 2 == 0) return a * a; 
    else return x * a * a; 
} 
int main(){
    IOS;
    ll test,i;
    test = 1;
  //  cin>>test;
    while(test--){
        ll n ,m;
        cin>>n>>m;
        ll array[m];
        ll s = 0;
        rep(i , m) {
            cin >> array[i];
            s = s + array[i];
        }
        if(s <= n) cout<< n - s <<endl;
        else cout<<"-1"<<endl;
    
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3900
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 1000;
int N, T, A;
double H[MAX_N];

int main() {
    cin >> N >> T >> A;
    auto temp_ans = double(INF);
    int ans = 0;
    REP(i, N) {
        cin >> H[i];
        H[i] = abs(A - (double(T) - H[i] * 0.006));
        if (H[i] < temp_ans) {
            temp_ans = H[i];
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A, B, K = sc.nextInt()
  val (a, b) = 1.to(K).foldLeft(A -> B) {
    case ((a, b), i) =>
      if (i % 2 != 0) {
        (a / 2, b + a / 2)
      } else {
        (a + b / 2, b / 2)
      }
  }
  println(s"$a $b")
}


Measured memory_bytes: 55564
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int a,b;cin >> a >> b;
  for(int i = 0; i < 30; ++i){
    int tmp = 1 + i * (a-1);
    if(b<=tmp){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        String x = "";
        for (int i = 0; i < s.length(); i++){
           x += "x";
        }
        System.out.println(x);
    }
}


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

int main(){
    using namespace std;
    
    vector<int> Ax(9);
    for(int i = 0; i<9; i++){
            cin >> Ax.at(i);
        }

    int n;
    cin >> n;
    vector<int> bingo(9);
    vector<int> bn(n);
    for(int i = 0; i<n; i++){
        cin >> bn.at(i);
        for(int j = 0; j<9; j++){
            if(Ax.at(j) == bn.at(i)){
                bingo.at(j) = 1;
            }
        }
    }
    bool isBingo = false;
    int bingo1 = bingo.at(0) + bingo.at(1) + bingo.at(2);
    int bingo2 = bingo.at(3) + bingo.at(4) + bingo.at(5);
    int bingo3 = bingo.at(6) + bingo.at(7) + bingo.at(8);
    int bingo4 = bingo.at(0) + bingo.at(3) + bingo.at(6);
    int bingo5 = bingo.at(1) + bingo.at(4) + bingo.at(7);
    int bingo6 = bingo.at(2) + bingo.at(5) + bingo.at(8);
    int bingo7 = bingo.at(0) + bingo.at(4) + bingo.at(8);
    int bingo8 = bingo.at(2) + bingo.at(4) + bingo.at(6);

    vector<int> bingo_n = {bingo1, bingo2, bingo3, bingo4, bingo5, bingo6, bingo7, bingo8};
    for(int i = 0; i<8; i++){
        if(bingo_n.at(i) == 3){
            isBingo = true;
            break;
        } 
    }
    if(isBingo ==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

ifstream in("fractal.in");
ofstream out("fractal.out");

const int EXP = 2;
const int DIM = 1002;
const int MOD = 1000000007;

int mat[EXP][EXP], aux[EXP][EXP], ans[EXP][EXP];
char arr[DIM][DIM]; bitset<DIM> oki;

void mul(int a[EXP][EXP], int b[EXP][EXP], int c[EXP][EXP]) {
    for (int i = 0; i < EXP; ++i) {
    for (int j = 0; j < EXP; ++j) {
        aux[i][j] = 0;
        
        for (int k = 0; k < EXP; ++k)
            aux[i][j] = (1LL * a[i][k] * b[k][j] + aux[i][j]) % MOD;
    } }
    
    memcpy(c, aux, sizeof aux);
    return;
}

int main(void) {
    
    int n, m; long long k;
    cin >> n >> m >> k;
    
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    
    bool hc = false;
    for (int i = 0; i < n; ++i)
        if (arr[i][0] == '#' and arr[i][m - 1] == '#')
            hc = true, ++mat[1][1];
    
    bool vc = false;
    for (int j = 0; j < m; ++j)
        if (arr[0][j] == '#' and arr[n - 1][j] == '#')
            vc = true, ++mat[1][1];
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (arr[i][j] == '#')
                ++mat[0][0];
            if (hc and arr[i][j] == '#' and arr[i][j + 1] == '#')
                --mat[0][1];
            if (vc and arr[i][j] == '#' and arr[i + 1][j] == '#')
                --mat[0][1];
        }
    }
    
    if (hc and vc) {
        cout << 1; return 0; }
    else
    if (!hc and !vc)
        mat[0][1] = mat[1][1] = 0;
    else
        mat[0][1] = (MOD - mat[0][1]) % MOD;
    
    ans[0][0] = ans[1][1] = 1;
    for (--k; k > 0; k >>= 1) {
        if (k & 1)
            mul(ans, mat, ans);
        mul(mat, mat, mat);
    }
    
    cout << (ans[0][0] - ans[0][1] + MOD) % MOD;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int n,k;
	cin >> n >> k;
	ll ans=0;
	if(k%2==0){
		int num1=n/(k/2);
		int num2=n/(k);
		ans=pow(num2,3)+pow((num1-num2),3);
	}else{
		int num=n/k;
		ans=pow(num,3);
	}
	cout << ans << endl;
	return 0;
}

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int gcd(int a,int b){
	if(b>a){
		int temp=a;
		a=b;
		b=temp;
	}
	if(b==0){
		return a;
	}
	return (b,b%a);
}


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

signed main () {
    int n;
    cin >> n;
    vector < int64_t > t(n), a(n);
    for (int i = 0; i < n; ++i)
        cin >> t[i] >> a[i];
    int64_t cur_t = t[0], cur_a = a[0];
    for (int i = 1; i < n; ++i) {
        int64_t l = 1, r = 1000000000000000020 / (t[i] + a[i]);
        while (r - l > 1) {
            int64_t m = (l + r) / 2;
            if (m * t[i] >= cur_t && m * a[i] >= cur_a)
                r = m;
            else
                l = m;
        }
        if (l * t[i] >= cur_t && l * a[i] >= cur_a)
            cur_t = l * t[i], cur_a = l * a[i];
        else
            cur_t = r * t[i], cur_a = r * a[i];
    }
    cout << cur_t + cur_a << '\n';
}


Measured memory_bytes: 256
# ABC 151C
n, m = map(int, input().split())
ac = 0
wa = 0
cnt = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    elif s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
print(ac, wa)


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int h,w,n;

int main()
{
    cin >> h >> w >> n;
    int a = max(h, w);

    cout << (n / a) + (n % a == 0 ? 0 : 1) << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

void solve(){
	string s;
	int z = 0, o = 0;
	cin >> s;
	for(int i=0;i<s.size();++i){
		if(s[i] == '0') z++;
		else o++;
	}
	cout << 2*min(z,o) << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Measured memory_bytes: 512
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


H, W = na()
A_array = naa(H)
B_array = naa(H)
C_array = [[abs(aa-bb) for aa, bb in zip(a, b)]
           for a, b in zip(A_array, B_array)]
# print(C_array)

K = 6400

ans_array = [[[0] * (K+1) for _ in range(W)] for _ in range(H)]

ans_array[0][0][C_array[0][0]] = 1

for i in range(H):
    for j in range(W):
        if i != 0:
            for k in range(K+1):
                ans_array[i][j][k] = ans_array[i][j][k] | ((ans_array[i-1][j][abs(k+C_array[i][j])] if abs(
                    k+C_array[i][j]) <= K else 0) | ans_array[i-1][j][abs(k-C_array[i][j])])
        if j != 0:
            for k in range(K+1):
                ans_array[i][j][k] = ans_array[i][j][k] | ((ans_array[i][j-1][abs(k+C_array[i][j])] if abs(
                    k+C_array[i][j]) <= K else 0) | ans_array[i][j-1][abs(k-C_array[i][j])])

# print(ans_array)

for k in range(K+1):
    if ans_array[H-1][W-1][k] == 1:
        print(k)
        exit()


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    ll n, m;
    cin >> n >> m;

    auto ok = [&](ll x) {
        ll a = n, b = m;
        if (x > a) {
            b -= (x - a) * 2;
        }
        return b >= x * 2;
    };

    ll lo = 0, hi = TEN(13);

    while (hi - lo > 1) {
        ll x = (lo + hi) / 2;
        if (ok(x)) {
            lo = x;
        } else {
            hi = x;
        }
    }
    cout << lo << endl;

    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 500003;
string s;
int n;
vector<int> a[26];

void put() {
    int i;
    char c;
    cin >> i >> c;
    i--;
    int cur = s[i] - 'a';
    a[cur].erase(lower_bound(a[cur].begin(), a[cur].end(), i));
    int nxt = c - 'a';
    a[nxt].insert(lower_bound(a[nxt].begin(), a[nxt].end(), i), i);
    s[i] = c;
}

void ask() {
    int l, r; cin >> l >> r;
    l--; r--;
    int ans = 0;
    for(int i = 0; i < 26; ++i) {
        auto itl = lower_bound(a[i].begin(), a[i].end(), l);
        auto itr = upper_bound(a[i].begin(), a[i].end(), r);
        if(itl < itr) {
            ans++;
        }
    }
    cout << ans << '\n';
}

void init() {
    for(int i = 0; i < n; ++i) {
        int letter = s[i] - 'a';
        a[letter].push_back(i);
    }
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> s;

    init();
    
    int q; cin >> q;
    while(q--) {
        int x; cin >> x;
        if(x == 1) {
            put();
        } else {
            ask();
        }
    }
    
    return 0;
}


Measured memory_bytes: 7316
import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Main extends App {
    var inp = readLine.split(" ").map(_.toInt)
    val n = inp(0)
    val m = inp(1)
    val h = readLine.split(" ").map(_.toInt)
    var ok = Array.fill(n){1}
    for(i <- 0 until m) {
        val ab = readLine.split(" ").map(_.toInt);
        val a = ab(0)-1
        val b = ab(1)-1
        if(h(a)<=h(b)) ok(a)=0;
        if(h(a)>=h(b)) ok(b)=0;
    }
    print(ok.sum)
}

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

int main(void) {
	long long x,y;
	cin>>x>>y;
	long long u = __gcd(x,y);
	int ans=0;
	while(u%2==0)
	{
		u=u/2;
		ans++;
	}
	if(ans>0)
	ans=1;
	int lam=0;
	for(long long i=3;i<sqrt(u);i=i+2)
	{
		lam=0;
		while(u%i==0)
		{
			u=u/i;
			lam++;
		}
		if(lam>0)
		ans++;
	}
	if(u>2)
	ans++;
	cout<<ans+1;
}

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

using namespace std;
using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

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

    ll bdash = b * 100 + 0.5;
    cout << (ll)(a * bdash / 100) << endl;
    return 0;
}

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

using namespace std;

int main(){
int n;
cin>>n;
long long a;
long long x=1000000,y=-1000000,sum=0;
if(n==1){
	cin>>a;
	x=a;
	y=a;
	sum=a;
}
else{
for(int i=1;i<=n;i++){
	cin>>a;
	x=min(a,x);
	y=max(a,y);
	sum= sum+a;
}
}
cout<<x<<' '<<y<<' '<<sum<<endl;
}



Measured memory_bytes: 3116
#import <Foundation/Foundation.h>

int main(void){

    @autoreleasepool {
    
        NSStringEncoding enc = NSUTF8StringEncoding;
        NSFileHandle *stdin = [NSFileHandle fileHandleWithStandardInput];
        NSFileHandle *stdout = [NSFileHandle fileHandleWithStandardOutput];
        
        NSData *indata = [stdin readDataToEndOfFile];
        NSMutableString *str = [NSMutableString alloc];
        [str initWithBytes:indata.bytes length:indata.length encoding:enc];
        
        NSScanner *scan = [NSScanner alloc];
        [scan initWithString:str];
        
        NSString *n_str = [NSString alloc];
        [scan scanUpToString:@"\n" intoString:&n_str];
        NSInteger n = [n_str integerValue];
        
        [stdout writeData:[(n < 1200?@"ABC":@"ARC") dataUsingEncoding:enc]];
    }
    
    return 0;
}

Measured memory_bytes: 2404
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	if (n % 2) {
		cout << 0 << endl;
		return 0;
	}

	vector<ll>kek(19);
	ll pw = 2;
	ll sum1 = 0;
	for (ll i = 1; i <= 27; i++) {
		pw *= 5;
		sum1 += n/pw;
	}
	sum1 /= 1;
	cout << sum1 << endl;
	return 0;	
}

/*

*/

Measured memory_bytes: 256
function merge(A,left,mid,right){
    let n = mid-left;
    let m = right -mid;
    let L = A.slice(left,mid);
    let R = A.slice(mid,right);
    L.push(Infinity);
    R.push(Infinity);
    let i = 0,
        j = 0;
    for(let k =left;k<right;k++){
        if(L[i]<=R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
        steps++;
    }
}

function mergeSort(A,left,right){
    if(left+1<right){
        let mid = Math.floor((left+right)/2);
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

let lines = require("fs").readFileSync("/dev/stdin","utf-8").trim().split("\n");
let count = parseInt(lines[0]);
let nums = lines[1].split(" ").map(Number);
let steps = 0;
mergeSort(nums,0,count);
console.log(nums.join(" "));
console.log(steps);


Measured memory_bytes: 131732