akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc143/tasks/abc143_f>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<int> A(N);
    for(auto& in:A) cin >> in;
    
    vector<int> C(N+1);
    for(int i = 0; i < N;i++) C[A[i]]++;
    vector<int> D(N+1);
    for(int i = 0; i <= N;i++) D[C[i]]++;
    
    vector<int> f(N+1);
    vector<int> cumD(D.size()+1);
    vector<int> cumkD(D.size()+1);
    for(int k = 0; k <= N;k++){
        cumD[k+1] = cumD[k] + D[k];
        cumkD[k+1] = cumkD[k] + k*D[k];
    }
    for(int X = 1; X <= N; X++){
        f[X] = (cumkD[X] + X*(cumD[N+1] - cumD[X]))/X;
    }
    vector<int> Ans(N+1);
    for(int K = 1; K <= N; K++){
        Ans[f[K]] = max(Ans[f[K]],K);
    }
    for(int K = N-1; K >= 1; K--){
        Ans[K] = max(Ans[K+1],Ans[K]);
    }
    for(int K = 1; K <= N;K++){
        cout << Ans[K] << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>

int n,x;
int a[100001],dist[100001];

int cha(int in1,int in2){
    if(in1>in2) return in1-in2;
    return in2-in1;
}

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

int main(){
    int i,g;
    scanf("%d %d",&n,&x);
    for(i=1; i<=n; i++){
        scanf("%d",&a[i]);
        dist[i]=cha(a[i],x);
    }
    g=dist[1];
    for(i=2; i<=n; i++) g=gcd(g,dist[i]);
    printf("%d",g);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#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()
const int INF = 1<<29;

int main() {
  int n;
  while(cin>>n,n) {
    int bax[n][n], bay[n][n];
    REP(i,n) {
      REP(j,n) {
        cin >> bax[j][i] >> bay[j][i];
      }
    }
    int res = 0;
    int visited[n][n];
    memset(visited,0,sizeof(visited));
    int cnt = 1;
    REP(y,n) {
      REP(x,n) {
        if (visited[x][y]) continue;
        int xx = x, yy = y;
        while(!visited[xx][yy]) {
          visited[xx][yy] = cnt;
          int tmp = bax[xx][yy];
          yy = bay[xx][yy];
          xx = tmp;
        }
        if (visited[xx][yy] == cnt) {
          //  cout << xx <<" " << yy << endl;
          res++;
        }
        cnt++;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int descending_compare(const void *a, const void *b){
    return (int)(*(int*)b - *(int*)a);
}
 
int ascending_compare(const void *a, const void *b){
    return (int)*(int*)a - *(int*)b;
}
 
int s[100000];
int t[100000];
int c[100000];
int merge[200000];
int time[200000] = {0};
 
int main(void){
    int N, C;
    int i, j;
    int max = 0;
    scanf("%d %d", &N, &C);
 
    for (i = 0; i < N; i++){
        scanf("%d %d %d", &s[i], &t[i], &c[i]);
    }
 
    for (i = 1; i <= C; i++){
        for (j = 0; j < 200000; j++){
            merge[j] = 0;
        }
        for (j = 0; j < N; j++){
            if (c[j] == i){
                merge[s[j]*2-1] = 1;
                merge[t[j]*2] = -1;
            }
        }
        for (j = 1; j < 200000; j++){
            merge[j] += merge[j-1];
        }
        for (j = 0; j < 200000; j++){
            if (merge[j] > 0){
                time[j]++;
            }
        }
    }
 
    for (i = 0; i < 200000; i++){
        max = time[i]>max?time[i]:max;
    }
 
    printf("%d\n", max);
 
 
    return 0;
}

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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int c;
ll s, t;
string ans;

string clc(ll x){
    string ret = "";
    t /= 26;
    while(c--){
        ret += 'a' + x / t;
        x %= t;
        t /= 26;
    }
    return ret;
}

int main()
{
    t = 26;
    c = 1;
    cin >> s;
    while(s > t){
        s -= t;
        c++;
        t *= 26;
    }
    cout << clc(s - 1) << '\n';
    return 0;
}


Measured memory_bytes: 3632
//
// Created by munaiyi on 2020/3/18.
//

#include <bits/stdc++.h>

using namespace std;

const int maxn = 55;
int dep[maxn], fa[maxn];
bool flag[maxn];
int sum;
pair<int, int> res[maxn];
int h[maxn], mem;
struct {
    int v, next;
} e[maxn << 1];

void add(int u, int v) {
    e[mem].v = v;
    e[mem].next = h[u];
    h[u] = mem++;
}

void dfs(int u, int f) {
    fa[u] = f;
    dep[u] = dep[f] + 1;
    for (int i = h[u]; i + 1; i = e[i].next) {
        int v = e[i].v;
        if (v == f) continue;
        dfs(v, u);
    }
}

int main() {
    int n;
    memset(h, -1, sizeof(h));
    mem = 0;
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        add(u, v);
        add(v, u);
    }
    fa[1] = 1;
    dep[1] = 1;
    dfs(1, 1);
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &res[i].first, &res[i].second);
    }
    long long ans = 1LL<<(n-1);
    int cnt = (1<<m)-1;
    while(cnt){
        sum = n-1;
        memset(flag, 0, sizeof(flag));
        bool f = false;
        for(int i=0; i<m;i++){
            if(cnt&(1<<i)){
                f = f ^ 1;
                int u = res[i].first, v = res[i].second;
                if(dep[u]<dep[v]){
                    swap(u, v);
                }
                while(dep[u]>dep[v]){
                    if(!flag[u]){
                        flag[u] = 1;
                        sum--;
                    }
                    u = fa[u];
                }
                while(u!=v){
                    if(!flag[u]){
                        flag[u] = 1;
                        sum--;
                    }
                    u = fa[u];
                    if(!flag[v]){
                        flag[v] = 1;
                        sum--;
                    }
                    v = fa[v];
                }

            }
        }
//        printf("%d %d %d %d\n", f, sum, cnt,  m&(cnt-1));
        if(f){
            ans -= (1LL<<sum);
        }
        else{
            ans += (1LL<<sum);
        }
        cnt = ((1<<m)-1)&(cnt-1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int a, b;
int main() {
	fastio; cin >> a >> b;
  cout << a * b;
}


Measured memory_bytes: 3648
import heapq


class Edge:
    def __init__(self, dst, weight):
        self.dst, self.weight = dst, weight

    def __lt__(self, e):
        return self.weight > e.weight


class Graph:
    def __init__(self, V):
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, src, dst, weight):
        self.E[src].append(Edge(dst, weight))


class ShortestPath:
    """Dijkstra's algorithm : find the shortest path from a vertex
       Complexity: O(E + log(V))
       used in GRL1A(AOJ)
    """

    def __init__(self, G, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list (all edge in E must be 0 or positive)
            start: start vertex
            INF: Infinity distance
        """
        self.G, self.INF = G, INF

    class Node:
        def __init__(self, v, cost):
            self.v, self.cost = v, cost

        def __lt__(self, n):
            return self.cost < n.cost

    def dijkstra(self, start, goal=None):
        que = list()
        self.dist = [self.INF] * self.G.V  # distance from start
        self.prev = [-1] * self.G.V  # prev vertex of shortest path
        self.dist[start] = 0
        heapq.heappush(que, (0, start))

        while len(que) > 0:
            cost, v = heapq.heappop(que)
            if self.dist[v] < cost:
                continue
            if goal is not None and v == goal:
                return
            for e in self.G.E[v]:
                if self.dist[v] + e.weight < self.dist[e.dst]:
                    self.dist[e.dst] = self.dist[v] + e.weight
                    heapq.heappush(que, (self.dist[e.dst], e.dst))
                    self.prev[e.dst] = v

    def getPath(self, end):
        path = [end]
        while self.prev[end] != -1:
            end = self.prev[end]
        return path[::-1]

V, E, start = map(int, input().split())
G = Graph(V)
for _ in range(E):
    s, t, d = map(int, input().split())
    G.add_edge(s, t, d)
INF = 10**9
sp = ShortestPath(G, INF)
sp.dijkstra(start)
for i in range(G.V):
    print("INF" if sp.dist[i] == INF else sp.dist[i])

Measured memory_bytes: 143708
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <climits>
#include <ctime>

using namespace std;

const int len = 100010;
const int mo = 1e9+7;
long long n,m;

int main() {
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    cin >> n >> m;
    if (abs(n-m) > 1) cout << 0 << endl;
     else {
         long long k = min(n,m);
         long long ans = 1;
         for (long long i=1;i<=k;i++) {
             ans = i*ans%mo;
         }
         //cout << ans << endl;
         ans = ans*ans%mo;
         if (max(n,m) > k) ans = ans*max(n,m)%mo;
          else ans = ans*2%mo;
         cout << ans << endl;
     }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
l = [0] * (10**5)
for x in range(1,101):
  x_2 = x**2
  for y in range(1,101):
    y_2 = y**2
    xy = x*y
    for z in range(1,101):
      n = x_2 + y_2 + z**2 + xy + x*z + y*z
      l[n] += 1
      
for i in range(1,N+1):
  print(l[i])

Measured memory_bytes: 69144
#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 _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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 ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int t[100010];
const int inf=1<<30;

int main(void){
	int n,c,k;
	cin >> n >> c >> k;

	rep(i,n) cin >> t[i];

	sort(t,t+n);
	
	int ans=1,prv=0;

	rep(i,n){
		if(i-prv+1>c){
			ans++;
			prv=i;
		}

		if(t[i]>t[prv]+k){
			ans++;
			prv=i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
s = input()
is_unbalanced = False
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        is_unbalanced = True
        break
if is_unbalanced == False:
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            is_unbalanced = True
            break
if is_unbalanced == False:
    print(-1, -1)


Measured memory_bytes: 39408
#include <stdio.h>

long long l[100];

int main(void)
{
    int n;
    scanf("%d", &n);
    l[0] = 2LL;
    l[1] = 1LL;
    for (int i = 2; i <= n; i++)
        l[i] = l[i - 1] + l[i - 2];
    printf("%lld\n", l[n]);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main()
{
	int N,i;
	int ans = 0;
	int V[51], C[51];
	scanf("%d", &N);
	for (i = 1;i <= N;i++)scanf("%d", &V[i]);
	for (i = 1;i <= N;i++)
	{
		scanf("%d", &C[i]);
		if (V[i] - C[i] > 0)ans += (V[i] - C[i]);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
	long long N,B[102],A[102],i,m;
	while(cin>>N)
	{
		for(i=0;i<N-1;i++)
		{
			cin>>B[i];
		}
		A[0]=B[0];
		A[N-1]=B[N-2];
		for(i=1;i<N-1;i++)
		{
			if(B[i-1]<B[i]){
				A[i]=B[i-1];
			}
			else{
				A[i]=B[i];
			}
		}
		for(i=0,m=0;i<N;i++)
		{
			m=m+A[i];
		}
		cout<<m<<endl;
	}
}

Measured memory_bytes: 256
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int a,b,c,k;
     cin>>a>>b>>c>>k;
     int res=0;
     while(k)
     {
         if(a)
         {
             if(k>=a)
             {
                 k -= a;
                 res += a;
                 a =0;
             }
             else
             {
                 a -= k;
                 res += k;
                 k=0;
             }
             //cout<<res<<" a "<<k<<endl;
             continue;          
         }
         if(b)
         {
             if(k>=b)
             {
                 k -=b;
                 b = 0;
             }
             else
             {
                 b -= k;
                 k=0;
             }
             //cout<<res<<" b "<<k<<endl;
             continue;
         }
         if(c)
         {
             if(k>=c)
             {
                 k -= c;
                 
                 res -= c;
                 c = 0;
             }
             else
             {
                 res -= k;
                 c -= k; 
                 k = 0;
                 
             }
             //cout<<res<<" c "<<k<<endl;
             continue;
             
         }
         
     }
     cout<<res<<endl;
     
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 3680
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin>>n;
	Array d(n,0);
	REP(i,n) cin>>d[i];

	map<ll,ll> mp;

	mp[0]++;
	ll time=0LL;
	REP(i,n){
		mp[d[i]]++;
		if(mp[d[i]]==2){
			if(d[i]==0||d[i]==12){
				cout<<0<<endl;
				return 0;
			}
			time+=(1LL<<d[i]);
			time+=(1LL<<(24-d[i]));
		}
		if(mp[d[i]]==3){
			cout<<0<<endl;
			return 0;
		}
	}

	Array times2;
	for(auto i:mp){
		if(i.second==1){
			times2.push_back(i.first);
		}
	}

	ll ans=0;
	REP(bit, (1LL << times2.size())){
		ll now = time;
		REP(i,times2.size()){
			if(((1LL<<i)&bit)!=0){
				now+=(1LL<<times2[i]);
			}else{
				now+=(1LL<<(24-times2[i]));
			}
		}
		ll min=24;
		ll pre=0;//高橋くん
		REP(i,24){
			if(((1LL<<i)&now)!=0){
				chmin(min,i-pre);
				pre=i;
			}
		}

		chmin(min,24-pre);//高橋くんとの差
		chmax(ans,min);
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x, y, temp;
	while (1)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)break;
		else if (x>y)
		{
			temp = x;
			x = y;
			y = temp;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 2676
import sys
input = sys.stdin.readline
def main():
    N, L = map(int, input().split())
    AJI = 0
    INF = float('inf')
    SA = INF
    I = 0

    for i in range(1,N+1):
        if abs(L+i-1)<SA:
            SA = abs(L+i-1)
            I = i
        AJI += L + i - 1
    print(AJI-(L+I-1))

if __name__ == '__main__':
    main()

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

int main()
{
    string s, t;
    cin >> s >> t;
    reverse(t.begin(),t.end());
    reverse(s.begin(),s.end());
    for (int i = 0; i < s.size(); i++)
    {
        if (t.at(0) == s.at(i) || s.at(0) == '?')
        {
            bool flag = true;
            for (int j = 0; j < t.size(); j++)
            {
                if (i + j < s.size())
                {
                    if (t.at(j) != s.at(i + j) && s.at(i + j) != '?')
                    {
                        flag = false;
                    }
                }
                else
                {
                    flag = false;
                }
            }

            if (flag)
            {
                for (int j = 0; j < t.size(); j++)
                {
                    s.at(i + j) = t.at(j);
                }
                replace(s.begin(),s.end(),'?','a');
                reverse(s.begin(),s.end());
                cout << s << endl;
                return 0;
            }
        }
    }

    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,y,z,a,b;
    scanf("%d %d %d",&x,&y,&z);
    a=x;
    x=y;
    y=a;
    b=x;
    x=z;
    z=b;
    printf("%d %d %d\n",x,y,z);
    return 0;
}


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

int main() 
{ 
    //freopen("input.txt","r",stdin);
    //freopen("output1.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll a,b,m;
	cin>>a>>b>>m;
	vector<ll>v,v1;
	ll min1=INT_MAX,min2=INT_MAX;
	for(ll i=0;i<a;i++){
			ll temp;
			cin>>temp;
			v.push_back(temp);
			min1=min(min1,temp);
	}
	for(ll i=0;i<b;i++){
			ll temp;
			cin>>temp;
			v1.push_back(temp);
			min2=min(min2,temp);
	}
	min1+=min2;
	for(ll i=0;i<m;i++){
		ll x,y,c;
		cin>>x>>y>>c;
		min1=min(min1,v[x-1]+v1[y-1]-c);
	}	
	cout<<min1<<endl;
	
	return 0;
}


Measured memory_bytes: 2548
#include "bits/stdc++.h"
#define ll long long
#define vi vector <int>
#define vii vector <vi>
using namespace std;

const int mod = 1e9 + 7;
const int mnx = 1e6 + 9;

ll a, b;

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

    cout << a * b / __gcd(a , b) << '\n';

    return 0;
}















































Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long ll;
int Q;
int L;
int R;
int main(){
	int A[100001]={};
	A[1]=0;
	A[2]=1;

	for(int i=3;i<100001;i+=2){
		int k=0;
		for(int j=3;j<=sqrt(i);j+=2){
			if(i%j==0){
				k=1;
	 			break;
	 		}
	 	}
	 	if(k==0)A[i]=1;
	 }

	 int X[100001]={};
	for(int i=1;i<100001;i++){
		X[i]=X[i-1];
		if(A[i]==1 && A[(i+1)/2]==1){
			X[i]++;
		}
	}

	 cin>>Q;



    for(int i=0;i<Q;i++){
    	cin>>L>>R;
    	cout<<X[R]-X[L-1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 1408
n=int(input())
a=list(map(int,input().split()))
if n==1:
    print(0)
else:
    ans=0
    for i in range(1,n):
        if a[i-1]>a[i]:
            ans+=a[i-1]-a[i]
            a[i]=a[i-1]
    print(ans)


Measured memory_bytes: 32368
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF=1LL<<55LL; 
int cnt;
void merge(int *A,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++) L[i]=A[left+i];
  for(int i=0;i<n2;i++) R[i]=A[mid +i];
  L[n1]=INF;
  R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]) A[k]=L[i++];
    else A[k]=R[j++];
  }
}
void mergeSort(int *A,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  int S[n];
  for(int i=0;i<n;i++) cin>>S[i];
  cnt=0;
  mergeSort(S,0,n);
  for(int i=0;i<n;i++) cout<<S[i]<<" \n"[i==n-1];
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 10832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int p, q, r;
    cin >> p >> q >> r;
    int mi;
    mi = min(p + q, min(p + r, q + r));
    cout << mi << endl;
}


Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = s()

prev = N[0]
count = 1
for i in range(1, 4):
    if prev == N[i]:
        count += 1
        if count == 3:
            print('Yes')
            import sys
            sys.exit()
    else:
        count = 1
    prev = N[i]

print('No')


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

int main() {
  int n;
  cin >> n;
  ll sum = 0;
  rep(i, n+1) {
    if ((i % 3 != 0) && (i % 5 != 0)) {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<vector<int>>a (n,vector<int>(3));
    for(int i = 0; i < n; i++){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    for(int i = 1; i < n; i++){
        a[i][0] += max(a[i - 1][1],a[i - 1][2]);
        a[i][1] += max(a[i - 1][2],a[i - 1][0]);
        a[i][2] += max(a[i - 1][1],a[i - 1][0]);
    }
    cout << max({ a[n - 1][0],a[n - 1][1],a[n - 1][2] }) << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  vl x(n+1,0);
  rep(i,n){
    cin >> x[i];
  }
  ll ans=0;
  rep(i,n-1){
    ans +=min(b,a*(x[i+1]-x[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n, k = map(int, input().split())
s = input()

prev = ""
res = [0]
for i in range(1, n):
    if s[i] == s[i-1]:
        res.append(0)
    else:
        res.append(1)
# print(res)

ans = n - sum(res) - 1
ans += k*2
print(min(ans, n-1))


Measured memory_bytes: 45552
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a));
	int k = a[n - 1], r = INF;
	rep(i, n) {
		if (abs(k - r * 2) > abs(k - a[i] * 2))r = a[i];
	}
	printf("%d\n%d\n", k, r);

	Please AC;
}


Measured memory_bytes: 768
<?php
  $input=explode(' ',trim(fgets(STDIN)));
  $a=intval($input[0]);
  $b=intval($input[1]);
  $c=intval($input[2]);       //A,B,Cそれぞれを$a,$b,$cに格納

          if((1 <= $b)&&($b <= $a)&&($a <= 20)&&($c <= 20)&&($c >= 1)){
            $s = $a - $b;     //$sはAとBの差
            if($c >= $s){
              $t = $c - $s;     //$cから$dを注ぐ
            }else{
              $t = 0;
            }
          echo $t;

          }else{
        echo "うんこ";
      }
?>

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

using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, pair<int, int>>> v;
        int m[1010], uni[1010];
        fill(uni, uni+1010, 0);
        for(int i=0; i < n; i++){
            int id, u, a, p;
            cin >> id >> u >> a >> p;
            m[id] = u;
            v.push_back(make_pair(-a, make_pair(p, id)));
        }
        sort(v.begin(), v.end());
        int count = 0;
        for(int i=0; i< v.size(); i++){
            if(count < 10 && uni[m[v[i].second.second]] < 3 || count < 20 && uni[m[v[i].second.second]] < 2 || count < 26 && uni[m[v[i].second.second]] < 1){cout << v[i].second.second << endl; uni[m[v[i].second.second]]++; count++;}
        }
    }
}

Measured memory_bytes: 1212
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

vector<ll> prime_factorization(ll n){
    vector<ll> v;
    ll num = n;
    for(int i=2; i*i<=n; i++){
        while(num % i == 0){
            num /= i;
            v.emplace_back(i);
        }
    }

    if(num != 1){
        v.emplace_back(num);
    }

    return v;
}

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

    int n; cin>>n;

    map<int, ll> cnt;
    for(int i=1; i<=n; i++){
        auto v = prime_factorization(i);

        for(auto j:v){
            cnt[j]++;
        }
    }

    ll ans = 1;
    for(auto i:cnt){
        ans *= (i.second + 1);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
  return (a<b)?a:b;
}
int max(int a,int b){
  return (a>b)?a:b;
}
int fp(int a,int b){
  if(b==0) return 1;
  int x=fp(a,b/2);
  x=(x*x)%mod;
  if(b&1) x=(x*a)%mod;
  return x;
}

int sum(int n)
{
  return n*(n+1)/2;
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 int n;
 cin>>n;

 int ans;
 ans=sum(n)-3*sum(n/3)-5*sum(n/5)+15*sum(n/15);
 cout<<ans;
}

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

ll lcd(ll a, ll b){
    if(b == 0) return a;
    return lcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = lcd(a, b);
    return a/g * b;
}

int main(){
    int N; cin >> N;
    ll ans = 1;
    for(int i = 0; i < N; i++){
        ll tmp; cin >> tmp;
        ans = lcm(ans, tmp);
        // cout << ans << endl;
    }
    cout << ans << endl;
    // cout << lcm(2,3) << endl;



    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int T;
	cin >> T;
	while(T--){
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		++c;
		if(a < b || d < b){
			cout << "No" << endl;
			continue;
		}
		if(b <= c){
			cout << "Yes" << endl;
			continue;
		}
		const ll s = (a - c) % b;
		const ll k = __gcd(d % b, b);
		const ll t = s - (s / k * k) + c;
		if(t < b){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main (void){
  int a,b,c,d;

  scanf("%d",&a);

  b = a / 500;
  a = a - b * 500;
  c = a / 5;
  d = b * 1000 + c * 5;
  printf("%d\n",d);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int k,s;
    cin>>k>>s;
    int cnt;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(x+y>s){
                continue;
            }
            if(k>=s-x-y){
                cnt++;
            }
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int X = Integer.parseInt(in.next());
            int m[] = new int[N];
            for (int i = 0; i < N; i++) {
                m[i] = Integer.parseInt(in.next());
            }
            int ans = 0;

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += m[i];
            }

            Arrays.sort(m);

            ans = N + (X - sum) / m[0];

            // 出力
            out.println(ans);

        }

    }
}



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

int main(){
    
    int n; cin >> n;
    int s = 0,m = 0,i = 0;
    while (i < n){
        int k; cin >> k;
        s = s + k;
        if(k > m){
            m = k;
        }
        i++;
    }
    if (2 * m < s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

ll F(ll x){
	if(x <= 0)return 0;
	if(x%4 == 1)return 1;
	if(x%4 == 2)return x/4*4+3;
	if(x%4 == 3)return 0;
	if(x%4 == 0)return x/4*4;
}

signed main(){
	ll A,B;
	cin >> A >> B;
	ll ans = F(B)^F(A-1);
	cout << ans << endl;
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  int a, b, c ;
  
  cin >> a >> b >> c;

  if(a == 5 && b == 5 && c == 7)
    puts("YES");
  else if(a == 5 && b == 7 && c == 5)
    puts("YES");
  else if(a == 7 && b == 5 && c == 5)
    puts("YES");
  else
    puts("NO");

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 82;
const int M = 80*80+2;
int w[N][N],n,m;
bool dp[N][N][M*2];

int main(){
    //freopen("D:\\in.txt","r",stdin);
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;++i)
        for(int j=0;j<m;++j) scanf("%d",&w[i][j]);
    for(int i=0,u;i<n;++i){
        for(int j=0;j<m;++j){
            scanf("%d",&u);
            if(w[i][j]<u) swap(w[i][j],u);
            w[i][j]-=u;
        }
    }
    
    dp[n-1][m-1][M+w[n-1][m-1]]=true;
    dp[n-1][m-1][M-w[n-1][m-1]]=true;
    for(int i=n-1;i>=0;--i){
        for(int j=m-1;j>=0;--j){
            for(int k=0;k+w[i][j]<M*2;++k){
                dp[i][j][k]|=dp[i+1][j][k+w[i][j]];
                dp[i][j][k]|=dp[i][j+1][k+w[i][j]];
            }
            for(int k=w[i][j];k<M*2;++k){
                dp[i][j][k]|=dp[i+1][j][k-w[i][j]];
                dp[i][j][k]|=dp[i][j+1][k-w[i][j]];
            }
        }
    }
    int ans=80000000;
    for(int i=0;i<2*M;++i)
        if(dp[0][0][i]) ans=min(ans,abs(i-M));
    printf("%d\n",ans);
}



Measured memory_bytes: 84224
import sys
def l(s,n):
    o=ord(s.lower())
    if not 97<=o<=122:
        return s
    if 97<=o+n<=122:
        if 97<=ord(s)<=122:
            return chr(o+n)
        else:
            return chr(o+n).upper()
    elif o+n>122:
        if 97<=ord(s)<=122:
            return chr(o+n-26)
        else:
            return chr(o+n-26).upper()
    else:
        if 97<=ord(s)<=122:
            return chr(o+n+26)
        else:
            return chr(o+n+26).upper()

for t in sys.stdin:
    s=t[:-1]
    u=s.lower()
    for i in range(0,26):
        cv=lambda y:"".join(map(lambda x:l(x,i),y))
        if cv("this") in u or cv("that") in u or cv("the") in u:
            break
    print("".join(map(lambda x:l(x,-i),s)))



Measured memory_bytes: 5576
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007


double dp[3000][3000];

int main() {
    int N; cin >> N;
    for(int i=0; i<N; i++){
        double p; cin >> p;
        dp[0][0] = 1;
        for(int j=0; j<N; j++){
            dp[i+1][j+1] += dp[i][j] * p;
            dp[i+1][j] += dp[i][j] * (1-p);
        }
    }
    
    double ans = 0;
    for(int j=N/2+1; j<=N; j++){
        ans += dp[N][j];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

int main(void)
{
  int x;
  std::cin >> x;

  int rank;

  if (x >= 400 && x < 600) {
    rank = 8;
  }
  else if (x >= 600 && x < 800) {
    rank = 7;
  }
  else if (x >= 800 && x < 1000) {
    rank = 6;
  }
  else if (x >= 1000 && x < 1200) {
    rank = 5;
  }
  else if (x >= 1200 && x < 1400) {
    rank = 4;
  }
  else if (x >= 1400 && x < 1600) {
    rank = 3;
  }
  else if (x >= 1600 && x < 1800) {
    rank = 2;
  }
  else if (x >= 1800 && x < 2000) {
    rank = 1;
  }

  std::cout << rank << std::endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    char s;
    cin >> s;
    if (s == 'A')
    {
        cout << "T\n";
        return 0;
    }
    if (s == 'T')
    {
        cout << "A\n";
        return 0;
    }

    if (s == 'G')
    {
        cout << "C\n";
        return 0;
    }

    if (s == 'C')
    {
        cout << "G\n";
        return 0;
    }
    return 0;   
}


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

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

int main() {
  int a[4], b[4];
  int hit, blow;
  
  while(cin >> a[0]) {
    REP(i,1,4) cin >> a[i];
    rep(i,4) cin >> b[i];
    
    hit = blow = 0;
    
    rep(i,4) rep(j, 4) {
	if(a[i] == b[j]) {
	  if(i == j) hit++;
	  else blow++;
	}
    }
    
    cout << hit << " " << blow << endl;
    
  }
  
  return 0;
}

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

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int ans = 0;
  
  for( int i = 0; i < S.size()-2; i++ ){
    if( S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C' ) ans++;
  }
  cout << ans << endl;
    
      
    
}
  

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    auto T = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    long N = lread();
    auto S = sread();
    foreach (c; S)
    {
        write(T[(c - 'A' + N) % T.length]);
    }
    writeln();
}


Measured memory_bytes: 256
function main(input) {
    var n = input[0]-0;
    var lists = input[1].split(" ").map(v=>v-0);
    var list = input[1].split(" ").map((v, i)=>{
        return v-(i+1);
    }).sort((a,b)=>a-b);
    console.log(calc(lists, list[~~(n/2)]));
}
function calc(list, b){
    var ans = 0;
    list.forEach((v,i)=>{
        ans += Math.abs(list[i]-(b+i+1));
    });
    return ans;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));




Measured memory_bytes: 63988
#include <iostream>
#include <string>

int main()
{
	int n;

	std::cin >> n;

	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;

	std::string jg;
	for (size_t i = 0; i < n; i++)
	{
		std::cin >> jg;
		if (jg == "AC")
		{
			++ac;
		}
		else if (jg == "WA")
		{
			++wa;
		}
		else if (jg == "TLE")
		{
			++tle;
		}
		else if (jg == "RE")
		{
			++re;
		}
		else {}
	}

	std::cout << "AC x " << ac << std::endl;
	std::cout << "WA x " << wa << std::endl;
	std::cout << "TLE x " << tle << std::endl;
	std::cout << "RE x " << re << std::endl;

	return 0;
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100100;
const int MOD = 1e9+7;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

int main() {
    string S;
    cin >> S;
    int N = S.length();
    
    ModInt<MOD> dp[MAX_N][2]; dp[0][0] = 1;
    
    for (int i = 0; i < N; i++) {
        dp[i+1][1] += dp[i][1]*3;
        if (S[i] == '0') {
            dp[i+1][0] += dp[i][0];
        } else {
            dp[i+1][0] += dp[i][0]*2;
            dp[i+1][1] += dp[i][0];
        }
    }
    
    cout << dp[N][0] + dp[N][1] << endl;
    return 0;
}

Measured memory_bytes: 1280