akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char cn[320010], *ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int AS = 500000;
char* di = cn;
int dat[2 * AS];

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


	int N = 0;
	while ((ct = getchar_unlocked()) >= '0') N = N * 10 + ct - '0';
	int N1 = N / 2;
	fread(cn, 1, N1, stdin);
	auto da = dat + N;
	rep(i, N1)* da++ = (1 << *ci++ - 'a');
	fread(cn, 1, N - N1, stdin);
	ci = cn;
	rep(i, N - N1)* da++ = (1 << *ci++ - 'a');
	da = dat + N - 1;
	for (auto db = dat + N * 2 - 1; da > dat; da--)* da = *db-- | *db--;
	getchar_unlocked();
	ci = cn;
	fread(cn, 1, 320010, stdin);
	int Q = getint();

	const char a[27] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6' };

	rep(j, Q) {
		char q = *ci++;
		ci++;
		if (q == '1') {
			int i = getint() - 1 + N;
			for (dat[i] = 1 << *ci++ - 'a'; i > 1; i >>= 1) dat[i >> 1] = dat[i] | dat[i ^ 1];
			ci++;
		}
		else {
			int ret = 0;
			for (int l = getint() - 1 + N, r = getint() + N; l < r; l >>= 1, r >>= 1) {
				if (l & 1) ret |= dat[l++];
				if (r & 1) ret |= dat[--r];
			}
			int kotae = __builtin_popcount(ret);
			if (kotae >= 20)* di++ = '2';
			else if (kotae >= 10)* di++ = '1';
			*di++ = a[kotae];
			*di++ = '\n';
		}
	}
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

int main(void)
{

	int a, b, k;
	cin >> a >> b >> k;

	for (int i = a; i < min(a + k, b + 1); i++) {
		cout << i << endl;
	}

	for (int i = max(a + k, b - k + 1); i < b + 1; i++) {
		cout << i << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M, K;
    cin >> N >> M >> K;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            if (i*j+(N-i)*(M-j) == K) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int a2 = Math.abs(x-a);
		int b2 = Math.abs(x-b);

		if(a2<b2){
			System.out.println("A");
		} else {
			System.out.println("B");
		}
		
		
		
		
	}

}


Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }

        System.out.println(getMinCost(h));
    }

    private static int getMinCost(int[] h) {
        int[] cost = new int[h.length];
        cost[1] = Math.abs(h[1] - h[0]);

        for (int i = 2; i < h.length; i++) {
             cost[i] = Math.min(cost[i-2] + Math.abs(h[i-2] - h[i]), cost[i-1] + Math.abs(h[i-1] - h[i]));
        }

        return cost[h.length-1];
    }
}


Measured memory_bytes: 44624
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

using namespace std;
/** Problem0088 : The Code A Doctor Loved **/
int main()
{
	string s;
	map<string, string> list1, list2;
	list1[" "] = "101";		list1["'"] = "000000";
	list1[","] = "000011";	list1["-"] = "10010001";
	list1["."] = "010001";	list1["?"] = "000001";
	list1["A"] = "100101";	list1["B"] = "10011010";
	list1["C"] = "0101";	list1["D"] = "0001";
	list1["E"] = "110";		list1["F"] = "01001";
	list1["G"] = "10011011";list1["H"] = "010000";
	list1["I"] = "0111";	list1["J"] = "10011000";
	list1["K"] = "0110";	list1["L"] = "00100";
	list1["M"] = "10011001";list1["N"] = "10011110";
	list1["O"] = "00101";	list1["P"] = "111";
	list1["Q"] = "10011111";list1["R"] = "1000";
	list1["S"] = "00110";	list1["T"] = "00111";
	list1["U"] = "10011100";list1["V"] = "10011101";
	list1["W"] = "000010";	list1["X"] = "10010010";
	list1["Y"] = "10010011";list1["Z"] = "10010000";
	
	list2["00000"] = "A";	list2["00001"] = "B";
	list2["00010"] = "C";	list2["00011"] = "D";
	list2["00100"] = "E";	list2["00101"] = "F";
	list2["00110"] = "G";	list2["00111"] = "H";
	list2["01000"] = "I";	list2["01001"] = "J";
	list2["01010"] = "K";	list2["01011"] = "L";
	list2["01100"] = "M";	list2["01101"] = "N";
	list2["01110"] = "O";	list2["01111"] = "P";
	list2["10000"] = "Q";	list2["10001"] = "R";
	list2["10010"] = "S";	list2["10011"] = "T";
	list2["10100"] = "U";	list2["10101"] = "V";
	list2["10110"] = "W";	list2["10111"] = "X";
	list2["11000"] = "Y";	list2["11001"] = "Z";
	list2["11010"] = " ";	list2["11011"] = ".";
	list2["11100"] = ",";	list2["11101"] = "-";
	list2["11110"] = "'";	list2["11111"] = "?";


	
	while (1) {
		getline(cin, s);
		if (cin.eof()) break;
		
		string code, sc, tmp, ans;
		rep(i, s.length()) {
			sc = s[i];
			code+=list1[sc];
		}
		
		int i=0; tmp="00000";
		while (code.length()>i) {
			tmp[i%5] = code[i];
			if (i%5==4 || code.length()-1==i) {
				ans+=list2[tmp];
				tmp="00000";
			}
			i++;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    ll N, x; cin >> N >> x;
    ll ans = 0;
    vector<ll> a(N);
    cin >> a[0];
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }
    for (int i = 1; i < N; i++) {
        cin >> a[i];
        if (a[i-1] + a[i] > x) {
            ans += a[i-1] + a[i] - x;
            a[i] = x - a[i-1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
#define Endl endl
 
struct edge{int end;int cost;};
typedef pair<int,int> P;
int V,d[114514];
vector<edge> G[114514];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    for(int i=0;i<114514;i++){d[i]=INF;}
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.end]>d[v]+e.cost){
                d[e.end] = d[v]+e.cost;
                que.push(P(d[e.end],e.end));
            }
        }
    }
}

 
signed main(){
    int n,m,s,t;
    int u[114514],v[114514],a[114514],b[114514];
    int c[114514],sum[114514];
    cin >> n >> m >> s >>t;
    s--;t--;
    REP(i,m){
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--;v[i]--;
    }
    edge h;
        
    REP(i,m){
        h.end=v[i];
        h.cost=a[i];
        G[u[i]].push_back(h);
        
        h.end=u[i];
        G[v[i]].push_back(h);
        
    }
    dijkstra(s);
    REP(i,n){
        c[i]=d[i];
    }
    REP(i,n){G[i].clear();}
    
    REP(i,m){
        h.end=v[i];
        h.cost=b[i];
        G[u[i]].push_back(h);
        
        h.end=u[i];
        G[v[i]].push_back(h);
        
    }
    dijkstra(t);
        
    RREP(i,n){
        if(i==n-1){
            sum[i]=c[i]+d[i];
        }else{
            sum[i]=min(c[i]+d[i],sum[i+1]);
        }
        
    }    
    //REP(i,n){cout << c[i] << " "<<d[i] << " " << c[i]+d[i] << endl;}cout << endl;
    
    REP(i,n){
        //cout << sum[i] << endl;
        cout << 1000000000000000-sum[i] << endl;
    }
    return 0;
}   


Measured memory_bytes: 16260
#include <iostream>
#include <vector>

int main(){
  int N;
  std::cin >> N;

  std::vector<int> p_arr = {11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511, 1531};

  for(int i = 0; i < N; i++) std::cout << p_arr[i] << ((i==N-1)?"\n":" ");

  return 0;
}



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

int main() {
  vector<char> A(3), B(3),C(3);
  for (int i = 0; i < 3; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < 3; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < 3; i++){
    cin >> C.at(i);
  }

 cout << A.at(0) << B.at(1) << C.at(2) << endl;
  }



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;

#include <stdio.h>

class Restaurant {

	public:
	unsigned int	line;		// 入力の行数
	unsigned int	score;
	string			name;

	public:
	bool operator <(const Restaurant& r) { // 大小比較用 less 演算子
		if (name == r.name) {
			return r.score < score;
		}else{
			return name < r.name;
		}
	}

};

int main()
{
	unsigned int n;			// レストランの件数
	Restaurant item[100];	// レストラン情報

	// input
	cin >> n;
	for (unsigned int i = 0; i < n; i++) {
		item[i].line = i + 1;
		cin >> item[i].name;
		cin >> item[i].score;
	}

	// calc
	std::sort(item, item + n);

	// output
	for (unsigned int i = 0; i < n; i++) {
		cout << item[i].line << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = [tuple(map(int, input().split())) for _ in range(N)]
C = [tuple(map(int, input().split())) for _ in range(M)]
for i in S:
  ans = 0
  k = 10 ** 10
  for j in range(M):
    n = abs(i[0] - C[j][0]) + abs(i[1] - C[j][1])
    if k > n:
      k = n
      ans = j + 1
  else:
    print(ans)

Measured memory_bytes: 9152
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
ans = 10**10
cnt = 0
for i in range(N):
    c = A[i]
    cnt = 0
    while c % 2 == 0:
        c //= 2
        cnt += 1
    ans = min(ans, cnt)
print(ans)
    

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005;

int n, a[N], d[N], ans[N];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
		++d[a[i]];
	}
	if (n <= 2) {
		print(-1);
		return 0;
	}
	std::set<int> S;
	std::set<std::pair<int, int>> SD;
	for (int i = 1; i <= n; ++i) {
		S.insert(i);
		SD.insert({d[i], i});
	}
	int u = 1;
	for (int i = 1; i <= n - 3; ++i) {
		if ((--SD.end())->first == n - i) {
			u = (--SD.end())->second;
		}
		ans[i] = u;
		S.erase(u), SD.erase({d[u], u});
		if (S.count(a[u])) {
			SD.erase({d[a[u]], a[u]});
			--d[a[u]];
			SD.insert({d[a[u]], a[u]});
		} else {
			--d[a[u]];
		}
		if (*S.begin() == a[u]) {
			u = *(++S.begin());
		} else {
			u = *S.begin();
		}
	}
	int k = n - 3;
	for (int v : S) {
		ans[++k] = v;
	}
	while (1) {
		bool flag = 1;
		for (int i = std::max(n - 3, 1); i < n; ++i) {
			if (a[ans[i]] == ans[i + 1]) {
				flag = 0;
				break;
			}
		}
		if (flag) {
			for (int i = 1; i <= n; ++i) {
				print(ans[i], " \n"[i == n]);
			}
			return 0;
		}
		if (!std::next_permutation(ans + n - 2, ans + n + 1)) {
			break;
		}
	}
	print(-1);
}


Measured memory_bytes: 15308
H,W=map(int,input().split())
A=["o"*(W+2)]+["o"+input()+"o" for i in range(H)]+["o"*(W+2)]
for i in range(1,H+1):
    B=""
    for j in range(1,W+1):
        count=0
        if A[i][j]==".":
            if A[i-1][j]=="#":
                count+=1
            if A[i+1][j]=="#":
                count+=1
            if A[i][j+1] == "#":
                count += 1
            if A[i][j-1] == "#":
                count += 1
            if A[i-1][j+1]=="#":
                count+=1
            if A[i-1][j-1]=="#":
                count+=1
            if A[i+1][j-1]=="#":
                count+=1
            if A[i+1][j+1]=="#":
                count+=1
            B+=str(count)
        else:
            B+="#"
    print(B)






Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll powers[11];
const int MOD=1e9+7;

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

int digits(int x)
{
	int cnt=0;
	while(x)
	{
		cnt++; x/=10;
	}
	return cnt;
}

int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

ll power10(int x)
{
	if(x<=9) return powers[x];
	else return ll(1e9)+10;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	powers[0] = 1;
	for(int i=1;i<=10;i++)
	{
		powers[i]=powers[i-1]*10;
	}
	ll S; cin>>S;
	int ans = 0;
	ll r = 0; ll sum = 0; int ptr = 1;
	for(ll l = 1; l < powers[7]; l++) //search for those with starting spot <= 7 digits
	{
		while(sum<S)
		{
			r++;
			if(r==powers[ptr]) ptr++;
			sum+=ptr;
		}
		if(sum==S) ans=add(ans,1);
		sum-=digits(l);
	}
	//d >= 8
	vector<ll> divisors;
	for(ll i = 1; i*i<=S; i++)
	{
		if(S%i==0)
		{
			divisors.pb(i);
			if(i*i!=S) divisors.pb(S/i);
		}
	}
	for(ll d:divisors)
	{
		if(d<=7) continue;
		int tot = modpow(10, d) - modpow(10, d - 1); //total number
		ll len = S/d;
		if(d>=9||tot>=len)
		{
			ans = add(ans, add(tot + 1, MOD - len));
		}
	}
	//2 cover
	for(ll d = 8; d <= (S+1)/2; d++)
	{
		ll r = S%d;
		if(r==0) r=d;
		ll num = (S - 1)/(d+1);
		num-=r;
		if(num<0) continue;
		ans = add(ans, num/d + 1);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int X, t;
	cin >> X >> t;
	cout << max(0, X - t) << endl;

	return 0;
}


Measured memory_bytes: 256
from sys import stdin,setrecursionlimit

n,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

jw = li[0][0]
omosa = [[] for _ in range(4)]

for i in li:
    omosa[i[0]-jw].append(i[1])

for i in range(len(omosa)):
    omosa[i].sort(reverse = True)

saidai = n
ma = 0

for i in range(len(omosa[0])+1):
    for j in range(len(omosa[1])+1):
        for k in range(len(omosa[2])+1):
            for l in range(len(omosa[3])+1):
                to_ka = omosa[0][:i]+omosa[1][:j]+omosa[2][:k]+omosa[3][:l]
                if i*jw+j*(jw+1)+k*(jw+2)+l*(jw+3) > w:
                    continue
                ma = max(ma,sum(to_ka))

print(ma)

Measured memory_bytes: 3064
import java.util.*;

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

        StringBuilder sb = new StringBuilder(sc.next());
        int move = sc.nextInt();
        int length = sb.length();

        for (int i = 0; i < length; i++) {
            if (sb.charAt(i) == 'a') continue;
            int diff = 26 - (sb.charAt(i) - 'a');
            if (diff <= move) {
                sb.setCharAt(i, 'a');
                move -= diff;
            }
            if (move == 0) break;
        }

        move %= 26;
        if (move != 0)
            sb.setCharAt(length - 1, (char) (sb.charAt(length - 1) + move));

        System.out.println(sb);
    }
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int m=1e9+7;
	int n;
	cin>>n;
	long long int a[n];
	for (int i=0;i<n;i++) cin>>a[i];
	long long int dp[n];
	dp[n-1]=a[n-1];
	for (int i=n-2;i>=0;i--) dp[i]=(dp[i+1]+a[i])%m;
	long long int ans=0;
	for (int i=0;i<n-1;i++){
	    ans+=a[i]*dp[i+1];
	    ans%=m;
	}
	cout<<ans<<"\n";
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int m; cin >> m;
    V<int> a(m + 1);
    for(int i = 1; i <= m; i++) cin >> a[i];

    V<int> ans;
    V<int> cnt(m + 1, 0);
    for(int i = m; i > 0; i--){
        int c = 0;
        for(int j = i; j <= m; j+=i){
            if(cnt[j]) c++;
        }
        if(a[i] == 1 && c % 2 == 0){
            cnt[i] = 1;
            ans.push_back(i);
        }
        if(a[i] == 0 && c % 2 == 1){
            cnt[i] = 1;
            ans.push_back(i);
        }
    }

    cout << ans.size() << endl;
    for(int i = 0; i < (int)ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}


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

const int MAX_V = 50;
const int MAX_C = 50;

int n;
int v[MAX_V + 1], c[MAX_C + 1];

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

    int rec = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            rec += v[i] - c[i];
        }
    }
    cout << rec << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,c,d,n,i;
    while((scanf("%d",&n))!=EOF){
        for(a=0;a<10;a++){
        for(b=0;b<10;b++){
            for(c=0;c<10;c++){
                for(d=0;d<10;d++){
                    if(a+b+c+d==n){
                        i++;
                    }
                }       
            }       
        }       
    }
    printf("%d\n",i);    
    i=0;  
    }
}

Measured memory_bytes: 1696
import sys
from collections import defaultdict
from collections import deque
sys.setrecursionlimit(10 ** 7)

N = int(input())
SS = [input() for _ in range(N)]

cnt = defaultdict(int)

for s in SS:
    cnt[s] += 1

cnt = sorted(cnt.items(), key=lambda x: (x[1], x[0]), reverse=True)

ans = deque([])
mx = -1
for i, x in cnt:
    if mx == -1:
        mx = x
    elif mx != x:
        break
    ans.appendleft(i)

print("\n".join(ans))


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)


int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		pv((b - a) / 2)
	}
	else {
		ll res=0;
		if (a - 1 < n - b) {
			res += a;
			b -= a;
			res += (b - 1) / 2;
		}
		else {
			res += (n - b + 1);
			a += res;
			res += (n - a) / 2;
		}
		pv(res);
	}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
 
#define ARRAY_MAX 100005


int main(){

    int n;
    cin >> n;
    string s;
    int left = 0,right = 0;
    bool ans = true;
    REP(i,n){
        cin >> s;
        if(s == "A"){
            left++;
        }else if(s == "Un" && left > 0){
            left--;
        }else{
            ans = false;
            break;
        }
    }

    if(left > 0){
        ans = false;
    }

    if(ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            Console.WriteLine((n - 1) * (m - 1));
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int n;
	cin >> n;
	vector<string> w(n);
	rep(i, 0, n) cin >> w[i];

	string ans = "Yes";
	// その単語の先頭の文字は直前に発言した単語の末尾の文字と一致する
	rep(i, 0, n - 1) if (w[i].back() != w[i + 1].front()) ans = "No";
	// その単語はまだ発言していない単語である
	SORT(w);
	rep(i, 0, n - 1) if (w[i] == w[i + 1]) ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A;
    A.pb(0);
    rep (i, N) {
        ll a;
        cin >> a;
        A.pb(A[i] + a);
    }
    ll ans = linf;
    for (ll i = 1; i < N; ++i) {
        ll l = A[i];
        ll r = A[N] - A[i];
        ll a = abs(l - r);
        ans = min(a, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());sort(t.begin(),t.end(),greater<char>());
	if(s<t){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 3604
import scala.io.StdIn

object Main{

  def main(args: Array[String]): Unit = {
    val n = StdIn.readInt()
    val ls = StdIn.readLine().split(' ').toVector.map(_.toInt)
    if (ls.max * 2 < ls.sum) {
      println("Yes")
    } else {
      println("No")
    }
  }

}


Measured memory_bytes: 27356
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> as(n), bs(m);
  for (auto &v : as)
    cin >> v;
  for (auto &v : bs)
    cin >> v;

  bool flag = true;
  for (int i = 0; i <= n - m; ++i) {
    for (int j = 0; j <= n - m; ++j) {
      flag = true;
      for (int k = i; k < i + m; ++k) {
        for (int l = j; l < j + m; ++l) {
          if (as[k][l] != bs[k - i][l - j])
            flag = false;
        }
      }
      if (flag)
        break;
    }
    if (flag)
      break;
  }
  cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b>=10){
        cout << "error";
    }else{
        cout << a+b;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n;
int wa[305][305];
signed main() {
	cin >> n;
	rep(i, n)rep(j, n)cin >> wa[i][j];
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			bool b = false;
			rep(k, n) {
				if (k == i || k == j)continue;
				if (wa[i][j] > wa[i][k] + wa[k][j]) {
					cout << -1 << endl;
					return 0;
				}
				if (wa[i][j] == wa[i][k] + wa[k][j]) {
					b = true;
				}
			}
			if (!b)ans += wa[i][j];
		}
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 1024
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

long long n,a,x,y,z;

int main()
{
    cin >> n >> a;
    a/=1000;
    if (a%5==0) x=a/5-n;
    else x=a/5-n+1;
    if (x<0) x=0;
    while((a-n-9*x)%4!=0)
    {
        x++;
    }
    if (a>10*n) cout << -1 << ' ' << -1 << ' ' << -1;
    else if (x>n||x>(a-n)/9) cout << -1 << ' ' << -1 << ' ' << -1;
    else if (x==n&&10*x==a) cout << n << ' ' << 0 << ' ' << 0;
    else if (x==n&&10*x!=a) cout << -1 << ' ' << -1 << ' ' << -1;
    else
    {
        y=(a-n-9*x)/4;
        z=n-x-y;
        cout << x << ' ' << y << ' ' << z;
    }
}


Measured memory_bytes: 256
import std.stdio,std.conv,std.algorithm,std.array;

int[] 		raia()	{ return readln().split().map!(to!int).array; }		//read stdin as int[]

void main(){
	auto it = raia();
	int count;
	for(auto i=it[0];i<=it[1];i++)
		if(it[2]%i == 0) count++;
	writeln(count);
}

Measured memory_bytes: 1052
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) { cin >> a[i]; }
  for (int i = 0; i < n; i++) { cin >> b[i]; }
  for (int i = 0; i < n; i++) { cin >> c[i]; }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp_a = lower_bound(a.begin(), a.end(), b[i]) - a.begin(); // tmp_a: {a}の中でb[i]以上の値が初めて現れるときの添字
    int tmp_c = upper_bound(c.begin(), c.end(), b[i]) - c.begin(); // tmp_c: {c}の中でb[i]より大きい値が初めて現れるときの添字
    long long cnt_a = tmp_a;     // cnt_a: aの候補数
    long long cnt_c = n - tmp_c; // cnt_c: cの候補数
    ans += (cnt_a * cnt_c);
  }
  cout << ans << endl;
  return 0;
}

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

#define INF 10E+09
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  if(k == 1) cout << "OK" << endl;
  else if(a % k == 0 || b % k == 0) cout << "OK" << endl;
  else if(a / k == b / k) cout << "NG" << endl;
  else cout << "OK" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  int X,Y;
  cin>>X>>Y;
  if((2*Y-X)%3==0&&(2*X-Y)%3==0){
    int a=(2*Y-X)/3;
    int b=(2*X-Y)/3;
    COMinit();
    cout<<COM((a+b),b)<<endl;
  }
  else{
    cout<<0<<endl;
  }
}



Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  int S = 0;
  int X;
  
  for (int i = 0; i < N; i++) {
    cin >> X;
    if (X <= K/2) {
      S += 2 * X;
    }
    else {
      S += 2 * (K - X);
    }     
  }   
  
  cout << S << endl;   

}

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

const int N = 2e5 + 5;
vector< vector<int> > g (N);

vector<long long> diff (N);
vector<long long> ans (N);

void dfs (int node, int p, long long adicionar) {
  adicionar += diff[node];
  ans[node] = adicionar;
  for (auto to : g[node]) {
    if (to != p) {
      dfs (to, node, adicionar);
    }
  }
}

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; i++) {
    int st, et;
    cin >> st >> et;
    st--; et--;
    g[st].emplace_back(et);
    g[et].emplace_back(st);
  }
  while (q--) {
    int s, add;
    cin >> s >> add;
    s--;
    diff[s] += add;
  }
  dfs (0, -1, 0);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 25856
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

string toLower ( string s )
{
	string t = s;
	for ( int i = 0 ; i < s.size() ; i++ )
	{
		t[i] = tolower(s[i]);
	}
	return t;
}
int main()
{
	string s1, s2;
	cin >> s1;
	s1 = toLower (s1);
	int a = 0;

	while ( 1 )
	{
		cin >> s2;
		if ( s2 == "END_OF_TEXT" )
		{
			break;
		}
		else
		{
			s2 = toLower (s2);
			if ( s1 == s2 )
			{
				a++;
			}
		}
	}
	cout << a << endl;

	return 0;
}


Measured memory_bytes: 3240
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector

// #define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve() {

	int n; cin >> n ;
	
	int ans = 0 ; 

	rep(i,1,n) {
		int t = n- i ; 
		for(int j = 1 ; j * j <= t ; ++j ) {
			if(t%j==0) 
				if(j * j != t ) ans += 2 ; 
				else ++ans ; 
		}
	}

	cout << ans ; 
}

int32_t main() {

#ifdef LOCAL
    freopen("error.txt", "w", stderr);
#endif

    fast;

	// int t; cin >> t; while(t--)
		solve() ;

	//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


Measured memory_bytes: 3624
using System;

namespace codespace
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N % 1000 == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                //必要な1000円札の枚数
                int a = (N / 1000) + 1;
                int b = 1000 * a;
                int ans = (b - N);
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 27504
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
const int INF = (1LL<<30);

signed main(){
    int N;cin >> N;
    vector<vector<Int>> A(N,vector<Int>(N)),dp(N,vector<Int>(N));
    rep(i,N)rep(j,N) cin >> A[i][j],dp[i][j] = A[i][j];
    
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i==j||k==i||k==j||dp[i][k]==INF||dp[k][j]==INF) continue;

                if(dp[i][k]+dp[k][j]==A[i][j]) dp[i][j] = INF;
                else if(dp[i][k]+dp[k][j]<A[i][j]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    Int ans = 0;
    rep(i,N)rep(j,N){
        if(dp[i][j]!=INF) ans+=dp[i][j];
    }
    cout << ans/2 << endl;
}



Measured memory_bytes: 1664
#include <stdio.h>
int main(void){
	int A,B,C,D,X,Y;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	if( A > C){
		X = A;
	}else{
		X = C;
	}
	if( B > D){
		Y = D;
	}else{
		Y = B;
	}
	if( Y - X <= 0){
		printf("0");
		return 0;
	}else{
		printf("%d",Y-X);
		return 0;
	}
	
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int mass[n];
    for(int i = 0; i < n; i++){
        cin >> mass[i];
    }
    int res[n + 2] = {0};
    res[1] = abs(mass[1] - mass[0]);
    for(int i = 2; i < n; i++){
        int temp1 = abs(mass[i] - mass[i - 1]);
        int temp2 = abs(mass[i] - mass[i - 2]);
        res[i] = res[i-1] + temp1; 
        res[i] = min(res[i] , res[i-2] + temp2); 
    }
    cout << res[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
N = input()
arr = [int(x) for x in input().split()]

q = int(input())
ans = sum(arr)

hashmap = {}
for val in arr:
    if val in hashmap:
        hashmap[val] += 1
    else:
        hashmap[val] = 1


while q > 0:

    [x, y] =  [int(x) for x in input().split()]
    if x in hashmap:
        if y in hashmap:
            hashmap[y] += hashmap[x]
            ans -= hashmap[x]*x
            ans += y*hashmap[x]
            del hashmap[x]
        else:
            diff = hashmap[x] * x
            ans -= diff
            hashmap[y] = hashmap[x]
            del hashmap[x]
            add = hashmap[y] * y
            ans += add
        
    print(ans)
    q -=1

Measured memory_bytes: 20780
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

D, G = map(int, input().split())
P = [] * D
C = [] * D
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

ans = float('inf')
for i in range(1<<D):
    total = 0
    num = 0
    for j in range(D):
        if ((i >> j) & 1):
            total += C[j] + 100*P[j]*(j+1)
            num += P[j]

#    print(total, num)
    if total >= G:
        ans = min(ans, num)
    else:
        for j in range(D-1, -1, -1):
            if ((i >> j) & 1):
                continue

#            print('i=', i)
#            print('j=',j)
#            print('-', total, num)
            for k in range(P[j]-1):
                if total >= G:
                    break
#                print('?', total, num)
#                print('k=', k)
                total += 100*(j+1)
                num += 1
#                print('?', total, num)

#        print('Z', total, num, ans)
#        print('----')
        if total >= G:
#            print('x', total, num, ans)
            ans = min(ans, num)

print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

namespace practice_csharp
{

    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            System.Console.WriteLine(6 - (a + b));
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(x,y) lower_bound(ALL(x), y) - x.begin() - 1;
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first 
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111


ll d[MAX];
bool stt[MAX];
int main(void) {
  ll k, x;
  deque<ll> dq;
  cin >> k;
  FOR(i, 0, k) d[i] = INF;

  d[1] = 1;
  dq.push_front(1);
  while (!dq.empty()) {
	x = dq.front();
	dq.pop_front();
	if (x == 0) break;
	if (stt[x]) continue;
	if (d[(x * 10) % k] > d[x]) {
	  d[(x * 10) % k] = d[x];
	  dq.push_front((x * 10) % k);
	}
	if (d[(x + 1) % k] > d[x] + 1) {
	  d[(x + 1) % k] = d[x] + 1;
	  dq.push_back((x + 1) % k);
	}
	stt[x] = true;
	x = (x * 10) % k;
  }
  cout << d[0] << endl;

  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n);i++)
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int ans = -100000;
    ans = max(ans, a * b);
    ans = max(ans, a + b);
    ans = max(ans, a - b);
    cout << ans << endl;
}

Measured memory_bytes: 256
from functools import reduce
def gcd(a,b):
        while b:
            a,b=b,a%b
        return a
def solve(lis,x):
    ans=abs(lis[0]-x)
    lis=[abs(c-x) for c in lis]
    for x in lis:
        if x!=0:
            ans=gcd(ans,x)
    return ans 
n,x=map(int,input().split())
l=list(map(int,input().split()))
print(solve(l,x))


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

int main() {
	int N, tmp = 0;
	cin >> N;
	vector<long> A(N);
	long sum = 0;
	for (long& i : A) {
		cin >> i;
		if (i < 0) ++tmp;
		sum += labs(i);
	}
	if (tmp % 2) {
		sort(A.begin(), A.end(), [](long& a, long& b)->bool { return labs(a) < labs(b); });
		cout << sum - 2 * labs(A[0]);
	}
	else cout << sum;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<int> b(n,0),v(n,-1),ans(0);
    rep(i,n) cin>>b[i];
    rep(_,n){
        for(int i=b.size()-1;i>=0;i--){
        if(b[i]==i+1){
            ans.push_back(b[i]);
            b.erase(b.begin()+i);
            break;
        }
    }
    }
    if(ans.size()==n){
        reverse(al(ans));
        rep(i,n) cout<<ans[i]<<endl;
    }
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <stack>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
#define INF 99999999
typedef std::pair<int, int> pii;
int main() {
    int N, M;
    std::stack<int> stk;
    char ch;
    while (std::cin >> ch) {
        if (isdigit(ch)) {
            std::cin.putback(ch);
            int i;
            std::cin >> i;
            stk.push(i);
        }
        else {
            int a = stk.top();
            stk.pop();
            int b = stk.top();
            stk.pop();
            switch(ch) {
                case '+': stk.push(a + b);
                          break;
                case '-': stk.push(b - a);
                          break;
                case '*': stk.push(a * b);
                          break;
            }
            
        }
    }
    std::cout << stk.top() << std::endl;
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, k;

vector<int> divisor(int n) {
  vector<int> res;
  for(int i=1; i*i<=n; i++) {
    if(n % i == 0) {
      res.push_back(i);
      if(i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

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

  cin >> n >> k;
  vector<int> a(n);

  int sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  auto v = divisor(sum);

  int ans = 1;
  REP(i, v.size()) {
    vector<int> r(n);
    REP(j, n) r[j] = a[j] % v[i];
    sort(r.begin(), r.end());

    ll B = 0;
    REP(j, n) B += v[i] - r[j];
    ll A = 0;
    ll need = 1e18;
    REP(j, n) {
      A += r[j];
      B -= v[i]-r[j];
      need = min(need, max(A, B));
    }

    if(need <= k) ans = max(v[i], ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640