akhauriyash/Code-Regression huggingface dataset:
N = int(input())
matrix = []
for i in range(N):
    matrix.append([int(i) for i in input().split()])
ans = -float("inf")
dp = [[0 for i in range(4)] for j in range(len(matrix)+1)]
for i in range(len(matrix)-1,-1,-1):
    for j in range(len(matrix[0])-1,-1,-1):
        dp[i][j] = -float("inf")
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j],dp[i+1][k]+matrix[i][j])
        ans = max(ans,dp[i][j])
print(ans)

Measured memory_bytes: 90584
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
d = [ni() for _ in range(n)]

print(len(set(d)))

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

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

using namespace std;

typedef pair<int,int> P;

int N,M;
int scene[MAX][MAX];
int s[MAX/2][MAX/2],rotate_s[MAX/2][MAX/2][4];

void rotate(){
  rep(i,3){
    rep(j,M){
      rep(k,M){
	rotate_s[j][k][i+1] = s[M-k-1][j];
      }
    }
    
    rep(j,M){
      rep(k,M){
	s[j][k] = rotate_s[j][k][i+1];
      }
    }
  }
}

void solve(){
  vector<P> v;

  rep(i,N-M+1){
    rep(j,N-M+1){

      rep(k,4){
	bool flg = true;
	rep(l,M){
	  rep(n,M){
	    if(rotate_s[l][n][k] == -1){
	      continue;
	    }

	    if(scene[i+l][j+n] != rotate_s[l][n][k]){
	      flg = false;
	      goto next;
	    }
	  }
	}
      next:;
	if(flg){
	  rep(l,M){
	    bool found = false;
	    rep(n,M){
	      if(rotate_s[l][n][k] != -1){
		v.push_back(P(i+l+1,j+n+1));
		found = true;
		break;
	      }
	    }
	    if(found){
	      break;
	    }
	  }
	}
      }

    }
  }

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

  if(!v.size()){
    cout << "NA" << endl;
  }else{
    cout << v[0].second << " " << v[0].first << endl;
  }
}

int main(){
  while(cin >> N >> M , (N | M)){
    rep(i,N){
      rep(j,N){
	cin >> scene[i][j];
      }
    }

    rep(i,M){
      rep(j,M){
	cin >> s[i][j];
	rotate_s[i][j][0] = s[i][j];
      }
    }

    rotate();
    solve();
  }

  return 0;
}

Measured memory_bytes: 1416
from bisect import bisect_left,bisect_right,insort_left

dict = {}
keytbl =[]
q = int(input())
for i in range(q):
    a = list(input().split())
    ki = a[1]
    if a[0] == "0":
        if ki not in dict:
            dict[ki] =[]
            insort_left(keytbl,ki)
        dict[ki].append(int(a[2]))
    elif a[0] == "1":
        if ki in dict and dict[ki] != []:print(*dict[ki],sep="\n")
    elif a[0] == "2":
        if ki in dict: dict[ki] = []
    else:
        L =bisect_left(keytbl,a[1])
        R = bisect_right(keytbl,a[2],L)
        for j in range(L,R):
            for k in dict[keytbl[j]]:
                print(keytbl[j],k)



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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> a(n, 0);
		for(int i=0; i<n; i++)cin >> a[i];
		int ans = 0x7f7f7f7f;
		for(int i=-100; i <= 100; i++){
			int t = 0;
			for(int j=0; j < n; j++){
				t += (a[j]-i)*(a[j]-i);
			}
			updmin(ans, t);
		}
		cout << ans << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
// Ballazt
//0a..brute force
//0b..greedy
//1..memorizatton of some sort	remember something cleverly
//2..sort
//3..binary search	keep check a particular solution
//4..dp				repeating strucutre,limited choices
//5..dfs/bfs		matrix with obstacles
//6..correlate to graph in some way		each state is a point
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"


int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);

	
	
	int n,k;
	cin>>n>>k;

	int visit[n+1]={0};
	for(int i=0;i<k;i++)
	{
		int d;
		cin>>d;
		
		for(int i=0;i<d;i++)
		{
			int num;
			cin>>num;
			visit[num]=1;
			//cout<<num<<"num"<<endl;
		}
	}

	int count=0;
	for(int i=1;i<=n;i++)
	{
		if(!visit[i])

			count++;
	}

	cout<<count;
	//cout<<"end of loop";
	return 0;
	
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main(){;
    int N, K;
    string S;

    cin >> N >> S >> K;

    char same;
    same = S[K-1];
    for(int i = 0; i < N; i++){
        if(S[i] != same) S[i] = '*'; 
    }
    cout << S;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

pre = -100
c = 0
for a in A:
  i = a - 1
  c += B[i]
  if pre == a - 1:
    c += C[i - 1]
  pre = a
print(c)

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

const int M = 1e5;

int n, h[M], w[M], pre[M], mod = 1e9 + 7, half, big = 2e9;
pair<int, int> seg[4 * M];

int add(int a, int b) { return a + b - (a + b >= mod) * mod; }
int sub(int a, int b) { return a - b + (a - b < 0) * mod; }
int mul(int a, int b) { return (1ll * a * b) % mod; }
int powM(int n, int p) { return (!p ? 1 : (p & 1) ? mul(n, powM(n, p - 1)) : powM(mul(n, n), p / 2)); }
int divM(int a, int b) { return mul(a, powM(b, mod - 2)); }

pair<int, int> build(int l, int r, int i) {
    if (l == r)
        seg[i] = {h[l], l};
    else
        seg[i] = min(build(l, (l + r) / 2, i * 2 + 1), build((l + r) / 2 + 1, r, i * 2 + 2));
    return seg[i];
}
pair<int, int> q(int l, int r, int L, int R, int i) {
    if (l > R || r < L)
        return {big, big};
    if (L >= l && R <= r)
        return seg[i];
    return min(q(l, r, L, (L + R) / 2, i * 2 + 1), q(l, r, (L + R) / 2 + 1, R, i * 2 + 2));
}

int summation(int x) { return mul(mul(x, add(x, 1)), half); }
int rects(int l, int w) { return mul(summation(l), summation(w)); }

int solve(int l, int r, int bef) {
    if (l > r)
        return 0;

    int curW = sub(pre[r], l ? pre[l - 1] : 0), minH, last = l, ans = 0;
    pair<int, int> cur = q(l, r, 0, n - 1, 0);
    minH = cur.first;

    while (cur.first == minH) {
        ans = add(ans, solve(last, cur.second - 1, minH));
        last = cur.second + 1;

        if (last > r)
            break;

        cur = q(last, r, 0, n - 1, 0);
    }

    ans = add(ans, solve(last, r, minH));
    ans = add(ans, sub(rects(curW, minH), rects(curW, bef)));
    return ans;
}

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

    int n;
    cin >> n;
    int a[n];
    long long pre[n], ans = 2e18;

    for (int &x : a)
        cin >> x;

    pre[0] = a[0];
    for (int i = 1; i < n; i++)
        pre[i] = a[i] + pre[i - 1];

    for (int i = 1; i < n; i++)
        ans = min(ans, abs(pre[n - 1] - pre[i - 1] - pre[i - 1]));

    cout << ans << '\n';
}

Measured memory_bytes: 5960
#include <algorithm>
#include <iostream>
#include <climits>

using namespace std;

const int N = 5000;

int ii[N], cc[N], qu[N];
bool visited[N];

int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int p; cin >> p, p--;
		ii[i] = p;
	}
	for (int i = 0; i < n; i++)
		cin >> cc[i];
	long long ans = LLONG_MIN;
	for (int i = 0; i < n; i++) {
		fill(visited, visited + n, false);
		int cnt = 0;
		int i_ = i;
		while (!visited[i_]) {
			qu[cnt++] = i_;
			visited[i_] = true;
			i_ = ii[i_];
		}
		int m = 0;
		int i__ = i;
		while (i__ != i_) {
			m++;
			i__ = ii[i__];
		}
		if (k < m) {
			long long a = 0;
			for (int h = 0; h < k; h++)
				ans = max(ans, a += cc[qu[h]]);
		} else {
			long long a = 0;
			for (int h = 0; h < m; h++)
				ans = max(ans, a += cc[qu[h]]);
			long long b = 0;
			for (int h = m; h < cnt; h++) {
				if (0 < h && h <= k)
					ans = max(ans, a + b);
				b += cc[qu[h]];
			}
			if (b > 0) {
				long long b_ = 0;
				for (int h = m; h < cnt && h <= k; h++) {
					ans = max(ans, a + (k - h) / (cnt - m) * b + b_);
					b_ += cc[qu[h]];
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3596
N, M = map(int, input().split())
A = []
for i in range(0, M):
    a = tuple(map(int, input().split()))
    A.append(a)
start = 10**(N-1)
if N == 1:
    start = 0
for x in range(start, 10**N):
    ans = str(x)
    flag = True
    for a in A:
        if ans[a[0]-1] != str(a[1]):
            flag = False
    if flag:
        print(x)
        exit(0)
print(-1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long int
using namespace std;

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t=1;
	while (t--) {
		int n;
		cin >> n;
		if(n>=30) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;

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


#define pb push_back
#define ff first
#define ss second
#define SIZE 10
#define INF int(2e9 + 9)
#define BIG_INF ll(4e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
//#pragma GCC optimize("Ofast")

const int mod = 1e9 + 7;

ll binpow(ll a, ll b, ll mod = BIG_INF)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= mod;
        res %= mod;
    }
    res %= mod;
    return res;
}




int T = 1, n, m, k;
vector<int> v;
string s;
vector<vector<char> > a;
int ans = 0;

int CNT = 0;

void check(int x, int y)
{

    vector<vector<char> > b = a;

    vector<int> cl, rw;

    for(int b = 0; b < n; b++)
    {
        if((1LL << b) & x)
            cl.pb(b);
    }

    for(int b = 0; b < m; b++)
    {
        if((1LL << b) & y)
            rw.pb(b);
    }

    int cnt = CNT;
    for(int i = 0; i < _sz(cl); i++)
    {
        int cur = cl[i];
        for(int j = 0; j < m; j++)
        {
            if(b[cur][j] == '#') cnt--;
            b[cur][j] = '.';
        }
    }

    for(int i = 0; i < _sz(rw); i++)
    {
        int cur = rw[i];
        for(int j = 0; j < n; j++)
        {
            if(b[j][cur] == '#') cnt--;
            b[j][cur] = '.';
        }
    }

    if(cnt == k) ans++;

}


void solve()
{
    cin >> n >> m >> k;
    a.resize(n, vector<char>(m));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
            if(a[i][j] == '#') CNT++;
        }
    }

    for(int i = 0; i < (1LL << n); i++)
    {
        for(int j = 0; j < (1LL << m); j++)
        {
            check(i, j);
        }
    }
    cout << ans;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    filein; fileout;

//    cin >> T;

    while(T--)
    {
        solve();
    }




    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  string s;
  cin>>s;

  cout<<s[0]<<s[1]<<s[2]<<endl;

  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
long long gcd(long long a,long long b)
{
	if(a==b)return a;
	else if(a==0)return b;
	else if(b==0)return a;
	else
		return gcd(b,a%b);
}
int main()
{
	long long a,b;
	scanf("%Ld %Ld",&a,&b);
	printf("%Ld\n",(a/gcd(a,b))*b);
	return 0;
}


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

using namespace std;

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

int main() {
	int l, a, b, c, d;
	cin >> l >> a >> b >> c >> d;

	int day = max(ceil((double)a / c), ceil((double)b / d));
	int ans = l - day;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
  string s;
  for(;cin>>s,s!="0";)
    {
      int data[3][2];
      memset(data,0,sizeof(data));
      //1st game
      for(int i=1;i<s.size();i++)
	data[0][s[i]-'A']++;
      //2nd game
     cin>>s;
      data[0][s[0]-'A']++;
      for(int i=1;i<s.size();i++)
	data[1][s[i]-'A']++;
      //3rd game
      cin>>s;
      data[1][s[0]-'A']++;
      for(int i=1;i<s.size();i++)
	data[2][s[i]-'A']++;
      if(data[2][0]>data[2][1])
	data[2][0]++;
      else
	data[2][1]++;

      for(int i=0;i<3;i++)
	cout<<data[i][0]<<" "<<data[i][1]<<endl;
    }
}

Measured memory_bytes: 1184
#include<iostream>

using namespace std;

int main()
{
	char s[11];
	cin >> s;

	int res[11];
	int cur = 0;
	res[0] = -1;
	for (int i = 0; i < 11 ; i++){
		if ( s[i] == '\0' )break;

		switch (s[i]){
			case '0':
				res[cur] = 0;
				res[cur+1] = -1;
				cur++;
				break;
			case '1':
				res[cur]=1;
				res[cur+1] = -1;
				cur++;
				break;
			case 'B':
				if(cur == 0){
					res[cur]=-1;
				} else {
					res[cur-1] = -1;
					cur--;
				}
				break;
			default:
				return 1;
		}
	}

	for (int i = 0; i < 11; i++){
		if (res[i] != -1){
			cout << res[i];
		} else {
			break;
		}
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


// 参考: https://www.geeksforgeeks.org/z-algorithm-linear-time-pattern-searching-algorithm/
void getZarr(string s, vector<int>& z) {
    int n = s.length();
    int l, r, k;
    l = r = 0;
    for (int i = 1; i < n; i++) {
        if (i > r) {
            // de novoで一致する文字列を探す。
            l = r = i;
            while (r < n && s[r-l] == s[r]) r++;
            z[i] = r-l;
            r--;
        } else {
            k = i-l;
            if (z[k] < r-i+1) {
                // 元のprefixと一致する区間[l, r]から、重なる文字列が一意に定まる。
                z[i] = z[k];
            } else {
                // 元のprefixと一致する区間[l, r]からはみ出した部分は、一致するか一つ一つ確かめる必要がある。
                l = i;
                while (r < n && s[r-l] == s[r]) r++;
                z[i] = r-l;
                r--;
            }
        }
    }
}

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

    int ans = 0;

    for (int i = 0; i < n; i++) {
        string sub = s.substr(i);
        vector<int> z(n-i);
        getZarr(sub, z);

        for (int j = 1; j < n-i; j++) {
            ans = max(ans, min(j, z[j]));
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, m;
    static pair<int, int> e[100000], ans[100000];
    static vector<pair<int, int>> edges[100000];
    static bool parity[100000], vis[100000];
    
    cin >> n >> m;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges[a].emplace_back(b, i);
        edges[b].emplace_back(a, i);
        e[i] = {a, b};
    }
    if(m & 1){ cout << -1 << endl; return 0; }

    stack<int> s;
    vector<int> ord;
    s.push(0);
    vis[0] = true;
    while(!s.empty()){
        int t = s.top();
        s.pop();
        ord.emplace_back(t);
        for(auto to: edges[t]){
            if(vis[to.first]) continue;
            vis[to.first] = true;
            s.push(to.first);
        }
    }
    for(auto it=ord.rbegin();it!=ord.rend();++it){
        // 頂点 *it を見ていく
        int cnt = 0;
        for(auto ed: edges[*it]){
            if(ans[ed.second].first == ans[ed.second].second) ++cnt;
        }
        if(cnt == 0 && parity[*it]){ cout << -1 << endl; return 0; }
        if(cnt % 2 == parity[*it]){
            for(auto ed: edges[*it]){
                if(ans[ed.second].first != ans[ed.second].second) continue;
                ans[ed.second] = { *it + 1, ed.first + 1 };
            }
        }else{
            bool first = true;
            for(auto ed: edges[*it]){
                if(ans[ed.second].first != ans[ed.second].second) continue;
                if(first){
                    first = false;
                    ans[ed.second] = { ed.first + 1, *it + 1 };
                    parity[ed.first] ^= 1;
                }else ans[ed.second] = { *it + 1, ed.first + 1 };
            }
        }
    }
    for(int i=0;i<m;++i) cout << ans[i].first << " " << ans[i].second << endl;

    return 0;
}

Measured memory_bytes: 8952
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

/// --- math {{{ ///
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll d;
  return b == 0 ? (x = a < 0 ? -1 : 1, y = 0, a < 0 ? -a : a)
    : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
}
ll modinv(ll a, ll mod) {
  ll x, y;
  extgcd(a, mod, x, y);
  if(x < 0) x += mod;
  return x;
}
ll modpow(ll a, ll b, ll mod) {
  ll r = 1;
  a %= mod;
  while(b) {
    if(b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}
/// }}}--- ///


int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  int g = 0;
  int x;
  for(int i = 0; i < n; i++) cin >> x, g = gcd(g, x);
  cout << g << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[]

dic={"AC":0,"WA":0,"TLE":0,"RE":0}

for i in range(n):
    S=input()
    s.append(S)


for a in dic.keys():
    dic[a]=s.count(a)


for a,b in dic.items():
    print(str(a)+" x "+str(b))

Measured memory_bytes: 16316
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    string ans = a == b ? "Draw" : a > b ? "Alice" : "Bob";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll 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;
}

// gcd, lcm
ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

P rotate(P vector) {
    return {-vector.second, vector.first};
}

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    P vec = {x2 - x1, y2 - y1};
    P vec2 = rotate(vec);
    P vec3 = rotate(vec2);
    cout << x2 + vec2.first;
    cout << ' ';
    cout << y2 + vec2.second;
    cout << ' ';
    cout << x2 + vec2.first + vec3.first;
    cout << ' ';
    cout << y2 + vec2.second + vec3.second;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0){
				return;
			}
			int[] a = new int[n];
			for(int i = 0;i < n;i++){
				a[i] = sc.nextInt();
			}
			int max = 0;
			Arrays.sort(a);
			if(a[0] + a[1] > m){
				System.out.println("NONE");
				continue;
			}
			for(int i = 0;i < n;i++){
				for(int j = i+1;j < n;j++){
					if(a[i] + a[j] > m){
						continue;
					}
					max = Math.max(max,a[i] + a[j]);
				}
			}
			System.out.println(max);
		}
	}
}



Measured memory_bytes: 47284
import itertools
import math
import fractions
import functools

a, b,c, k = map(int, input().split())

sum = 0

if k <= a:
    sum = k
    print(sum)
    quit()
elif k > a:
    sum += a
    k = k - a

if k <= b:
    print(sum)
    quit()
elif k > b:
    k = k - b
    sum -= k * 1

print(sum)


Measured memory_bytes: 72644
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> A(n,0);
    REP(i,n) cin >> A[i];
    ll sum=0;
    vector<ll> X(n+1,0);
    REP(i,n){
        X[i+1]+=X[i];
        X[i+1]+=A[i];
        sum+=A[i];
    }

    ll mi=1e18;
    for(int i=1; i<=n-1; i++)
        mi = min(mi, abs(X[i]-(sum-X[i])) );
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>



vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

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

  int n;
  cin>>n;

  vector<bool> prime=prime_table(60000);

  int i=0,s=0;
  while(s<n){
    if(prime[i*5+1]){
      s++;
      cout<<i*5+1<<' ';
    }
    i++;
  }

  cout<<endl;


}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

long long printDivisors(long long n) {
	std::vector<long long> v;
	ll mn = 1e18;
    for (ll i=1; i*i<=n; i++)  { 
        if (n%i == 0) { 
            if (n/i == i) {
            	mn = min(mn,(i-1)+(i-1));
            }
            else {
            	ll z = n/i;
            	mn = min(mn,(i-1)+(z-1));
            }
        } 
    } 
    return mn;
} 

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

	ll x=  printDivisors(n);
	cout<<x<<endl;

	

	return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int k = (c+b-1) / b;
  int l = (a+d-1) / d;

  if (k <= l) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}



Measured memory_bytes: 3644
# vim: fileencoding=utf-8


def main():
    n = int(input())
    ans = len(str(n))
    for a in range(2, int(pow(n, 0.5) + 1)):
        if n % a != 0:
            continue
        b = n // a
        l = max(len(str(a)), len(str(b)))
        if ans > l:
            ans = l
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64784
#include<bits/stdc++.h>                          
using namespace std;
int a,b,c,d;
int main(){
    cin>>a>>b>>c>>d;
    if(a+b<c+d) cout<<"Right";
    else if(a+b==c+d) cout<<"Balanced";
    else cout<<"Left";
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

#define C first
#define N second

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;
using pci=pair<char,int>;

bool checkpair(vector<pci> &cards) {
	rep(i,cards.size()) {
		rep(j,i+1,cards.size()) {
			rep(k,j+1,cards.size()) {
				if((cards[i].N == cards[j].N && cards[j].N == cards[k].N)
				 &&(cards[i].C == cards[j].C && cards[j].C == cards[k].C)) {
					cards.erase(cards.begin() + i);
					cards.erase(cards.begin() + j-1);
					cards.erase(cards.begin() + k-2);
					return true;
				}
			}
		}
	}
	return false;
}

bool checkseq(vector<pci> &cards) {
	rep(i,cards.size()) {
		rep(j,i+1,cards.size()) {
			rep(k,j+1,cards.size()) {
				if((cards[i].N == cards[j].N-1 && cards[j].N == cards[k].N-1)
				 &&(cards[i].C == cards[j].C && cards[j].C == cards[k].C)) {
					cards.erase(cards.begin() + i);
					cards.erase(cards.begin() + j-1);
					cards.erase(cards.begin() + k-2);
					return true;
				}
			}
		}
	}
	return false;
}

int main(void){
	int T; cin >> T;
	while(T--) {
		vector<pci> cards(9);
		rep(i, 9) cin >> cards[i].N;
		rep(i, 9) cin >> cards[i].C;
		sort(cards.begin(), cards.end());

		rep(c, 3) {
			checkpair(cards);
			checkseq(cards);
		}

		cout << ((cards.size())?"0":"1") << endl;
	}
        
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define lson t << 1, l, mid
#define rson t << 1 | 1, mid + 1, r
#define mem0(x) memset(x, 0, sizeof(x))
#define mem1(x) memset(x, -1, sizeof(x))
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i > b; i--)
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
//---------------------------------------------------------//
const int N = 2e5 + 5;

int n;

int main()
{
//	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0)  cout << "Possible\n";
	else  cout << "Impossible\n";

	return 0;
}

Measured memory_bytes: 256
use proconio::input;

const M: usize = 300000;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut st = SegTree::new(M, std::cmp::max);
    for _ in 0..n {
        input! {a: usize}
        let l = if a > k {a - k} else {0};
        let r = (a + k).min(M);
        let m = st.get(l, r + 1, None) + 1;
        st.set(a, m);
    }

    println!("{}", st.get(0, M + 1, None));
}


struct SegTree {
    tree: Vec<u64>,
    leaf_size: usize,
    op: fn(u64, u64) -> u64,
}

impl SegTree {
    fn new(n: usize, op: fn(u64, u64) -> u64) -> Self {
        let mut ls = 1;
        while ls < n {
            ls <<= 1;
        }
        Self {
            tree: vec![0; 2 * ls - 1],
            leaf_size: ls,
            op,
        }
    }

    fn set(&mut self, mut i: usize, v: u64) {
        i += self.leaf_size - 1;
        self.tree[i] = v;
        while i > 0 {
            i = (i - 1) / 2;
            self.tree[i] = (self.op)(self.tree[2 * i + 1], self.tree[2 * i + 2]);
        }
    }

    fn get(&self, s: usize, e: usize, rng: Option<(usize, usize, usize)>) -> u64 {
        let (i, l, r) = if let Some(rng) = rng { rng } else { (0, 0, self.leaf_size) };
        if l >= e || r <= s {
            0
        } else if l >= s && r <= e {
            self.tree[i]
        } else {
            let m = (l + r) / 2;
            let vl = self.get(s, e, Some((2 * i + 1, l, m)));
            let vr = self.get(s, e, Some((2 * i + 2, m, r)));
            (self.op)(vl, vr)
        }
    }
}


Measured memory_bytes: 8780
#include <stdio.h>
#include<string.h>
int main()
{
long int a=0,b=0,c=0,d=0,w=0,i,str1=0,str2=0,flag,j,count=0,max=0;
char x[101];
scanf("%ld\n%s",&a,x);
count=0;
for(i=0;i<a;i++)
{
    if(x[i]=='I')
    {
        count++;
    }
     if(x[i]=='D')
    {
        count--;
    }
    if(max<count)
    {
        max=count;
    }
}
printf("%ld",max);

 return 0;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int n,m;cin>>n>>m;
	vvi g(n);vi h(n);
	repi(i,n) cin>>h[i];
	int a,b;
	while(m--){
	   cin>>a>>b;--a;--b;
	   g[a].pb(b);g[b].pb(a);
	}
	int c=0;bool ch=true;
	repi(i,n){
		ch=true;
		for(auto z: g[i] )
			if(h[z]>=h[i]) ch=false;
		if(ch) c++;
	}
	db(c);
	/*
	int q;cin>>q;while(q--){ 
		
	 }
	 //*/
return 0;
}



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

int max(int x, int y, int z) {
  int max = -200;
  if (max < x)
    max = x;
  if (max < y)
    max = y;
  if (max < z)
    max = z;
  
  return max;
}

int main() {
  int a, b;
  int sum, div, prod;
  cin >> a >> b;
  
  sum = a + b;
  div = a - b;
  prod = a * b;
  
  cout << max(sum, div, prod) << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String S = s.next();
    String T = s.next();
    System.out.println(changesRequired(S, T));
    s.close();
  }

  private static Integer changesRequired(String S, String T) {
    int ans = T.length();
    for (int start = 0; start <= S.length() - T.length(); start++) {
      int diff = 0;
      for (int i = 0; i < T.length(); i++) {
        if (T.charAt(i) != S.charAt(start + i)) {
          diff++;
        }
      }
      ans = Math.min(ans, diff);
    }
    return ans;
  }
}


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

template <int B> // (1 << B) >= MAX_LEN
struct lowest_common_ancestor {
    vector<vector<int> > graph;
    int N, root;  int parent[B][1 << B], depth[1 << B];

    lowest_common_ancestor() {}
    void init(int _root) {
        root = _root;
        N = graph.size();

        set_parent(root, -1, 0);
        for (int b = 1; b < B; ++b) {
            for (int i = 0; i < N; ++i) {
                parent[b][i] = parent[b-1][i] == -1 ? -1 : parent[b-1][parent[b-1][i]];
            }
        }
    }

    int query(int u, int v) {
        if (depth[u] > depth[v]) {
            int t = u; u = v; v = t;
        }

        for (int i = 0; i < B; ++i) {
            if ((((depth[v] - depth[u]) >> i) & 1) != 0)
                v = parent[i][v];
        } // depth[u] == depth[v]

        if (u == v) return u;
        for (int b = B-1; b >= 0; --b) {
            if (parent[b][u] != parent[b][v]) {
                u = parent[b][u];  v = parent[b][v];
            }
        }

        return parent[0][u];
    }

private:
    void set_parent(int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for (int i = 0; i < graph[v].size(); ++i) {
            int e = graph[v][i];
            if (e != p) set_parent(e, v, d+1);
        }
    }
};

int N;
lowest_common_ancestor<17> lca;

int main() {
    cin >> N; lca.graph.resize(N);
    for (int j = 0; j < N; ++j) {
        int k; cin >> k;
        for (int x = 0; x < k; ++x) {
            int c; cin >> c;
            lca.graph[j].push_back(c);
        }
    }

    lca.init(0);

    int Q; cin >> Q;
    for (int j = 0; j < Q; ++j) {
        int u, v;
        cin >> u >> v;
        cout << lca.query(u, v) << endl;
    }
    return 0;
}

Measured memory_bytes: 18332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll n;

ll a[3], b[3], dp[25000010];

int main(){
    cin >> n;
    rep(i, 3) cin >> a[i];
    rep(i, 3) cin >> b[i];

    rep(i, 3){
        for (int v = 0; v + a[i] <= n; v++) {
            dp[v + a[i]] = max(dp[v + a[i]], dp[v] + b[i]);
        }
    }
    ll res = n;
    rep(i, n + 1) res = max(res, dp[i] + n - i);
    n = res;

    memset(dp, 0, sizeof(dp));
    rep(i, 3) {
        for (int v = 0; v + b[i] <= n; v++) {
            dp[v + b[i]] = max(dp[v + b[i]], dp[v] + a[i]);
        }
    }
    res = n;
    rep(i, n + 1) res = max(res, dp[i] + n - i);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 198908
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 10010
#define X 210
typedef pair<ll,ll> P;
typedef pair<ll,P>PP;
ll d[N][X*2],n,m,x;
ll t[N];
vector<P> v[N];
priority_queue<PP,vector<PP>,greater<PP> > Q;
void Qpush(ll cost,ll a,ll b){
	Q.push(make_pair(cost,make_pair(a,b)));
}
int main(){
	cin>>n>>m>>x;
	lol(i,n){
		cin>>t[i+1];
	}
	lol(i,n+1)lol(j,2*X)d[i][j]=-1;
	lol(i,m){
		ll a,b,c;cin>>a>>b>>c;
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,c));
	}
	v[0].push_back(make_pair(1,0));
	Qpush(0,0,X);
	while(!Q.empty()){
		ll cost=Q.top().first;
		ll a=Q.top().second.first;
		ll b=Q.top().second.second;
		Q.pop();
		if(d[a][b]!=-1)continue;
		d[a][b]=cost;
		for(auto to:v[a]){
			ll ver=to.first,len=to.second;
			ll ind=b;
			if(b>=X)ind=max((ll)X,b-len);
			if(b<=X)ind=min((ll)X,b+len);
			if(t[ver]==0&&ind>=X){
				Qpush(cost+len,ver,X+x);
			}
			if(t[ver]==2&&ind<=X){
				Qpush(cost+len,ver,X-x);
			}
			if(t[ver]==1){
				Qpush(cost+len,ver,ind);
			}
		}
	}
	ll ans=(ll)mod*(ll)mod;
	lol(i,2*X){
		if(d[n][i]!=-1)ans=min(ans,d[n][i]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 37524
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 2007;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
char s[maxN][maxN];
int a[maxN], b[maxN], c[maxN];
int mat[maxN][maxN];
int stack[maxN], Top, ans = 0;

int main() {

	n = ri(), m = ri();
	rep (i, 1, n) scanf("%s", s[i]+1);

	For (i, 1, n) {
		rep (j, 1, m) a[j] = s[i][j] == '.' ? 1 : 0;
		rep (j, 1, m) b[j] = s[i+1][j] == '.' ? 1 : 0;

		rep (k, 0, 1) {
			rep (j, 1, m) b[j] ^= k;
			per (j, m, 1) c[j] = (a[j] == b[j]) ? 1 + c[j+1] : 0;
			rep (j, 1, m) mat[i][j] = max(mat[i][j], c[j]);
		}
	}

	rep (j, 1, m) {
		Top = 0;
		For (i, 1, n) {
			for (; Top && mat[stack[Top]][j] >= mat[i][j]; --Top) {
				ans = max(ans, mat[stack[Top]][j] * (i - stack[Top-1]));
			}
			stack[++Top] = i;
		}
		for (; Top; --Top) { 
			ans = max(ans, mat[stack[Top]][j] * (n - stack[Top-1]));
		}
	}

	printf("%d\n", max(ans, m));

	return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto& e : a) cin >> e;

  ll r = 0;
  for (int i = 0; i <= 60; i++) {
    int c = 0;
    for (auto e : a) c += (e >> i) & 1ll;
    r += (1ll << i) % MOD * c % MOD * (n - c) % MOD;
    r %= MOD;
  }
  cout << r << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

#define NIL 2000000001

typedef struct{
  int k; //key
  int lk; //left key
  int rk; //right key
}Node;

int main(){
  int k, h, i;
  Node *T;

  scanf("%d", &h);

  T = malloc((h + 1)*sizeof(Node));

  //initialize
  for(i = 1; i < h + 1; i++){
    T[i].k = NIL;
    T[i].lk = NIL;
    T[i].rk = NIL;
  }

  for(i = 1; i < h + 1; i++){
    scanf("%d", &k);

    T[i].k = k;

    if(i % 2 == 0) T[i/2].lk = k; //even number is left key;
    else T[i/2].rk = k; //odd number is right key;
  }

  //output
  for(i = 1; i < h + 1; i++){
    if(i == 1) printf("node 1: key = %d, left key = %d, right key = %d, \n", T[i].k, T[i].lk, T[i].rk);
    else{
      printf("node %d: key = %d, parent key = %d, ", i, T[i].k, T[i/2].k);

      if(T[i].lk != NIL) printf("left key = %d, ", T[i].lk);
      if(T[i].rk != NIL) printf("right key = %d, ", T[i].rk);

      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		int size = 0;
		while(scan.hasNext()){
			int in = scan.nextInt();
			size = list.size();
			if(in == 0){
				System.out.printf("%d\n", list.get(size - 1));
				list.remove(size - 1);
			} else{
				list.add(in);
			}
		}
	}
}

Measured memory_bytes: 25836
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() 
{
	int A, B, T, i, k, s;
	scanf("%d%d%d", &A, & B, &T);
	i = 1;
	k = A;
	s = 0;
	while (k <= T) {
		i++;
		k = A * i;
		s = s + B;
	}
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
const int mod = 1000000007;
int k,x;
int main(){
  cin >> k >> x;
  cout << (k*500 >= x ? "Yes": "No") << endl; 
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a-1] = 1
    count = 0
    for j in range(M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    LL n;
    cin >> n;
    LL i;
    for (i = (LL)sqrt(n); i > 0; i--) {
        if (n % i == 0) break;
    }
    LL b = n / i;
    int cnt = 1;
    while(b >= 10) {
        b /= 10;
        cnt++;
    }
    cout << cnt << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  if(a+b >= 10) {
    cout << "error" << endl;
  }
  else {
    cout << a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, K := sc.nextInt(), sc.nextInt()
	min := 100000000
	for i := 0; i <= N; i++ {
		for j := N - i; j <= N; j++ {
			num := pow(2, i) + j*K
			if num < min {
				min = num
			}
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main (void) {
    string S;

    cin >> S;

    bool diff = true;
    for (int i = 0; i < S.length() - 1; i++) {
        for (int j = i + 1; j < S.length(); j++) {
            if (S[i] == S[j]) diff = false;
        }
    }

    if (diff) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

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

void main(){
    string[] inputStr = readln().split;

    int n = to!int(inputStr[0]);
    int k = to!int(inputStr[1]);
    string[] d = readln().split;

    int count = 0;
    while(true){
        count = 0;
        for(int j=0;j<to!string(n).length;j++){
            for(int a=0;a<d.length;a++){
                if((to!int(to!string(n)[j])-48) == to!int(d[a])) count++;
            }
        }
        if(count == 0) break;
        n++;
    }
    write(n);
}


Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>

#define ll unsigned long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");`

int main() {
    uint64_t n, m;
    cin >> n >> m;
    vector<uint64_t> v;
    v.push_back(0);
    for (uint64_t i = 0; i < n; i++) {
        uint64_t x;
        cin >> x;
        v.push_back(x);
    }
    for (uint64_t i = 1; i < v.size(); i++) {
        v[i] += v[i - 1];
    }
    ll tot = 0;
    map<ll, ll> mp;
    for (int i = 1; i < v.size(); i++) {
        mp[v[i] % m] = mp[v[i] % m] + 1;
        if (v[i] % m == 0) {
            tot++;
        }
    }
    for (auto item : mp) {
        ll it = item.second;
        tot += it * (it - 1l) / 2;
    }
    cout << tot;
    return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	long long X;
	cin>>X;
	
	long long a = 100;
	
	for(int i=0;true;i++){
		if(a>=X){
			cout<<i<<endl;
			return 0;
		}
		a += a/100;
	}
	
	return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;

	if ((a <= 8) && (b <= 8)){
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}

	return 0;
}


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

int main(void){
    // Your code here!
    long long n;
    vector<vector<vector<long long>>> edges(100000, vector<vector<long long>>());
    
    cin >> n;
    for(long long i = 0; i < n - 1; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        edges[a-1].push_back(vector<long long>{b-1, c});
        edges[b-1].push_back(vector<long long>{a-1, c});
    }
    
    long long q, k;
    cin >> q >> k;
    
    deque<vector<long long>> d{vector<long long>{k-1, 0}};
    long long dist_k[100000];
    
    for(long long i = 0; i < n; i++)
        dist_k[i] = -1;
    dist_k[k-1] = 0;
    
    while(d.size() > 0){
        vector<long long> front = d.front();
        d.pop_front();
        
        for(auto e:edges[front[0]]){
            if(dist_k[e[0]] == -1){
                d.push_back(vector<long long>{e[0], front[1]+e[1]});
                dist_k[e[0]] = front[1] + e[1];
            }
        }
    }
    
    for(long long i = 0; i < q; i++){
        long long a, b;
        cin >> a >> b;
        cout << dist_k[a-1] + dist_k[b-1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 22448
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main(void) {
	string s;
	cin >> s;
	int n = 0;
	n = s.size();

	bool can = true;
	for (int i = 0; i < (n - 1) / 2; i++) {
		if (s[i] != s[n - 1 - i]) {
			can = false;
		}
		if (s[i] != s[((n - 1) / 2) - 1 - i]) {
			can = false;
		}
	}
	int j = 0;
	for (int i = (n + 3) / 2; i < n; i++) {
		if (s[i - 1] != s[n - j - 1]) {
			can = false;
		}
		j++;
	}
	cout << (can ? "Yes" : "No" )<< endl;
}


Measured memory_bytes: 256