akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

template <typename T>
bool chmax(T &a, T &b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, T &b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}






#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;

ll RepeatedSquaring(ll N, ll P, ll M) {
  if(P==0) return 1;
  if(P%2==0) {
    ll t = RepeatedSquaring(N, P/2, M);
    return t*t % M;
  }
  return N*RepeatedSquaring(N, P-1, M) % M;
}



ll modre(ll num) {
  num %= MOD;
  if(num < 0) num += MOD;
  return num;
}

ll mod_pow(ll x,ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x*x % mod, n / 2);
	if (n & 1) res = res * x % mod;
	return res;
}
 

 
ll comb(ll n, ll x) {
	ll ret = 1,k=1;
	rep(i,x)ret = (ret * (n - i))%mod;
	rep(i,x)k = (k * (x-i))%mod;
	// k = RepeatedSquaring(k, MOD-2, MOD);
	k = mod_pow(k, mod - 2);
	ret = (ret*k + mod) % mod;
	return ret;
}
  
int main() {
  ll a,b,n;
  cin >> n >> a >> b;
  ll ans = RepeatedSquaring(2, n, MOD) - 1;
  a = comb(n,a);
  b = comb(n,b);
  cout << modre(ans - a - b) << endl;
}






Measured memory_bytes: 256
INF = 10 ** 60


def li():
    return [int(x) for x in input().split()]


N, K = li()
H = li() + [INF] * K

dp = [INF] * (N + K)

dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i + k] = min(dp[i + k], dp[i] + abs(H[i + k] - H[i]))

print(dp[N - 1])

Measured memory_bytes: 89908
int main() {
    for (;;) {
        int m, f, r;
        scanf("%d %d %d", &m, &f, &r);
        if (m + f + r == -3) break;

        char *ans = "FFFFFFDDDDCCCBBBAAAA";
        if (m == -1 || f == -1) {
            puts("F");
        } else { 
            if (ans[(m + f) / 5] == 'D' && r >= 50) {
                printf("%c\n", 'C');
            } else {
                printf("%c\n", ans[(m + f) / 5]);
            }
        }
    }
}


Measured memory_bytes: 2100
import itertools
import math

N = int(input())

lloc = list()
for i in range(N):
    lloc.append(list(map(int, input().split())))

list_per = list(itertools.permutations(list(range(N))))
num = len(list_per)

llength = list()
for i in range(num):
    length = 0
    for j in range(N-1):
        length += math.sqrt((lloc[list_per[i][j]][0] - lloc[list_per[i][j+1]][0])**2 + (lloc[list_per[i][j]][1] - lloc[list_per[i][j+1]][1])**2)
    llength.append(length)

print(sum(llength)/len(llength))

Measured memory_bytes: 9276
r,c=list(map(int,input().split()))
mat=[[0 for i in range(c+1)] for j in range(r+1)]

for i in range(r):
    mat[i]=list(map(int,input().split()))
    
for i in range(r):
    mat[i].append(sum(mat[i]))

for i in range(c):
    s=0
    for j in range(r):
        s+=mat[j][i]
    mat[r][i]=s

mat[r][c]=sum(mat[r])

for i in range(r+1):
    for j in range(c+1):
        if j==c:
            print(str(mat[i][j]))
        else:
            print(str(mat[i][j])+" ",end="")
    
        


Measured memory_bytes: 6216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int>m;
int main(){
 int n;
 cin>>n;
 int work=0;
 for(int i=0;i<n;i++){
	int a;
	cin>>a;
	if(m[a]) work=1;
	m[a]=1;
}
 if(work) puts("NO");
 else puts("YES");
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
string str1,str2;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> str1 >> str2;
	str1+=str2[sz(str2)-1];
	print1(str1==str2?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3648
import Data.List
import Data.Char
import Data.Maybe
import qualified Data.ByteString.Char8 as BS8

--sol :: [a] -> a
sol a
    | length a == 1 = head a
    | otherwise = sol (aws ++ [(mina + sma) / 2])
    where
        mina = minimum a
        awm = if length [x | x <- a, x == mina] == 1
            then [x | x <- a, x /= mina]
            else [x | x <- a, x /= mina] ++ replicate (length a - length [x | x <- a, x /= mina] - 1) mina
        sma = if length [x | x <- a, x == mina] == 1
            then minimum awm
            else mina
        aws = if length [x | x <- awm, x /= sma] == 1
            then [x | x <- awm, x /= sma]
            else [x | x <- awm, x /= sma] ++ replicate (length awm - length [x | x <- awm, x /= sma] - 1) sma

main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInteger <$> BS8.getLine
    vb <- unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getLine
    let v = [toRational x | x <- vb]

    print $ fromRational $ sol v


Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

int main() {
	int h,w;
	cin >> h >> w;

	vector<vector<bool>>  s(h+2, vector<bool>(w+2,false));

	rep(i, h) rep(j,w) {
	  char c;
	  cin >> c; s[i+1][j+1] = (c == '.');
	}

	vector<vector<int>> g(h*w, vector<int>(h*w,INF));
	for(int i_ = 1; i_ <= h; i_++) for(int j_ = 1; j_ <= w; j_++) {
	  int i = i_ -1, j = j_ -1;
		if (s[i_][j_] && s[i_-1][j_]) {
		  g[i*w+j][(i-1)*w+j] = 1; 
			g[(i-1) * w + j][i * w + j] = 1;
		}
		if (s[i_][j_] && s[i_ + 1][j_]) {
			g[i * w + j][(i + 1) * w + j] = 1; 
			g[(i + 1) * w + j][i * w + j] = 1;
		}
		if (s[i_][j_] && s[i_][j_-1]) {
			g[i * w + j][i * w + j-1] = 1; 
			g[i * w + j-1][i * w + j] = 1;
		}
		if (s[i_][j_] && s[i_][j_+1]) {
			g[i * w + j][i * w + j+1] = 1;
			g[i * w + j+1][i * w + j] = 1;
		}
	}

	rep(i,h*w) g[i][i] = 0;

	rep(k, h* w) rep(i, h* w) rep(j, h* w) {
		g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	}

	int ans = 0;
	rep(i, h* w) rep(j, h* w) {
	  if (g[i][j] != INF) ans = max(ans, g[i][j]);
		//cout << i << " -> " << j << " : " << g[i][j] << endl;
	}

	cout << ans << endl;

}


Measured memory_bytes: 896
import numpy as np

def main():
    h, w = map(int,input().split())
    arr = [0 for i in range(h)]

    for i in range(h):
        arr[i] = list(input())

    arr = np.array(arr)
    yoko = []
    tate = []

    for i in range(h):
        if np.any(arr[i]=='#') == False:
            yoko.append(i)

    for i in range(w):
        if np.any(arr.transpose()[i]=="#") == False:
            tate.append(i)

    arr = np.delete(arr, yoko, 0)
    arr = np.delete(arr, tate, 1)

    for i in arr:
        print("".join(i))



if __name__ == "__main__":
        main()


Measured memory_bytes: 21724
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		boolean First = true;
		double x,y,kaku;
		x = y = kaku = 0;

		try {
			while (true) {
				StringTokenizer st = new StringTokenizer(br.readLine(),",");
				int hosuu = Integer.parseInt(st.nextToken());
				int houkou = Integer.parseInt(st.nextToken());
				if (hosuu==0&&houkou==0) break;
				if (First) {
					x = 0;
					y = hosuu;
					kaku = (Math.PI/2)-houkou*(Math.PI/180);
					First = false;					
				} else {
					x += hosuu*Math.cos(kaku);
					y += hosuu*Math.sin(kaku);
					kaku -= houkou*(Math.PI/180);
				}
			}
			System.out.println((int)x);
			System.out.println((int)y);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16880
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	int n;
	cin >> n;
	REP(i, n) {
		string s, t;
		cin >> s >> t;

		int dif = abs((int)s.size()-(int)t.size());
		//cout << "dif:" << dif << endl;
		string tmp = "";
		REP(i, dif) tmp += '0';
		//cout << tmp << endl;
		if(s.size() < t.size()) s = tmp + s;
		else t = tmp + t;
		//cout << s << " " << t << endl;

		bool flag = false;
		for(int i=t.size()-1; i>=0; --i) {
			int tmp = (t[i]-'0')+(s[i]-'0');
			if(flag) tmp++;
			flag = false;
			if(tmp >= 10) {tmp -= 10; t[i] = tmp+'0'; flag = true;}
			else {t[i] = tmp+'0';}
			//cout << t << endl;
		}
		if(flag) t = '1' + t;
		if(t.size() > 80) cout << "overflow" << endl;
		else cout << t << endl;
	}

	return 0;
}

Measured memory_bytes: 3024
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない



int main() {

	string top;
	cin >> top;
	int rest = 0;
	int lose = 0;
	int win = 0;

	rep(i, 0, top.size()) {
		char j = top[i];
		if (j == 'g'&&rest == 0) {
			rest++;
		}
		else if (j == 'g'&&rest > 0) {
			rest--;
			win++;
		}
		else if (j == 'p'&&rest > 0) {
			rest--;
		}
		else {
			lose++;
			rest++;
		}
	}

	cout << win - lose << endl;

	return 0;
}

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

int main(){
    string s1,s2;
    cin>>s1>>s2;

    int dist[1001][1001];
    for(int i=0;i<=s1.size();++i){
        for(int j=0;j<=s2.size();++j){
            if(i==0){
                dist[i][j]=j;
            }
            else if(j==0){
                dist[i][j]=i;
            }
            else{
                int cost=(s1[i-1]==s2[j-1]?0:1);
                int add=dist[i-1][j]+1;
                int dlt=dist[i][j-1]+1;
                int exch=dist[i-1][j-1]+cost; //why * is necessary
                
                if(add<=dlt && add<=exch){
                    dist[i][j]=add;
                }
                else if(dlt<=add && dlt<=exch){
                    dist[i][j]=dlt;
                }
                else{
                    dist[i][j]=exch;
                }
            }
        }
    }
    cout<<dist[s1.size()][s2.size()]<<"\n";
}

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

const ll mod = 1e9 + 7;


struct ModComb {
    vector<long long> fact, rfact;
    long long max, mod;
    ModComb(long long ma, long long mod) :fact(ma, 0), rfact(ma, 0), max(ma), mod(mod) {
        fact[0] = 1;
        for (long long i=1; i<max; ++i) {
            fact[i] = fact[i-1]*i;
            fact[i] %= mod;
        }
        rfact[max-1] = mod_inverse(fact[max-1], mod);
        for (long long i=max-2; i>=0; --i) {
            rfact[i] = rfact[i+1]*(i+1);
            rfact[i] %= mod;
        }
    }
    long long mod_pow(long long x, long long n, long long mod) {
        long long a = 1LL;
        while (n) {
            if (n%2) a = ((a%mod)*(x%mod))%mod;
            x = ((x%mod)*(x%mod))%mod;
            n /= 2LL;
        }
        return a;
    }

    long long mod_inverse(long long a, long long m) {
        return mod_pow(a, m-2, m);
    }

    long long operator()(long long n, long long r) {
        if (n < r) return 0;
        return (((fact[n] * rfact[r]) % mod) * rfact[n - r]) % mod;
    }
};

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    u %= mod;
    return u;
}

long long mp(long long x, long long n, long long mod) {
    long long a = 1LL;
    while (n) {
        if (n%2) a = ((a%mod)*(x%mod))%mod;
        x = ((x%mod)*(x%mod))%mod;
        n /= 2LL;
    }
    return a;
}


// int main() {
//     // 計算例
//     cout << modinv(3, 7) << endl;
// }

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

    ll ans = 1;
    ans = mp(2LL, n, mod) % mod;

    ll asum = 1, asum2 = 1, bsum = 1, bsum2 = 1;
    rep(i, a) {
        asum *= (ll)(n - i) % mod;
        asum %= mod;
        asum2 *= (ll)(i+1) % mod;
        asum2 %= mod;
        //asum %= mod;
    }
    rep(i, b) {

        //cout << (double)(n - i) / (i+1) << ", " << (n - i) / (i+1) << endl;
        bsum *= (ll)(n - i) % mod;
        bsum %= mod;
        bsum2 *= (ll)(i+1) % mod;
        bsum2 %= mod;
        //bsum %= mod;
    }

    //cout << asum2 << ", " << bsum2 << endl;

    asum *= modinv(asum2, mod) % mod;
    bsum *= modinv(bsum2, mod) % mod;

    asum %= mod;
    bsum %= mod;

    ans %= mod;

    //cout << ans << endl;

    ans = (ans - asum + mod) % mod;
    ans %= mod;
    ans = (ans - bsum + mod) % mod;
    ans %= mod;
    ans = (ans - 1 + mod) % mod;
    ans %= mod;
    cout << ans<< endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    bool rev = false;
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1) {
            rev = !rev;
            continue;
        } else {
            int F;
            string C;
            cin >> F >> C;
            if (rev) {
                if (F == 1) {
                    S.append(C);
                } else {
                    S.insert(0, C);
                }
            } else {
                if (F == 1) {
                    S.insert(0, C);
                } else {
                    S.append(C);
                }
            }
        }
    }
    if (rev) reverse(S.begin(), S.end());
    cout << S << endl;
}


Measured memory_bytes: 900
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.System;

class Main {
    public static void main(String[] a) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(r.readLine());
        String[] str = r.readLine().split(" ");

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(str[i]);
        }

        int v, j;
        printArray(n, arr);
        for (int i = 1; i < n; i++) {
            v = arr[i];
            j = i - 1;
            while (j >= 0 && arr[j] > v) {
                arr[j+1] = arr[j];
                j--;
            }
            arr[j+1] = v;
            printArray(n, arr);
        }
    }

    private static void printArray(int n, int[] arr) {
        StringBuilder s;
        s = new StringBuilder();
        for (int i = 0; i < n; i++) {
            s.append(arr[i]);
            if (i != n -1) { s.append(" "); }
        }
        System.out.println(s);
    }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int v[MAXN];

vi pos[MAXN];

ll ff[MAXN];

int n;

set<int> st;
vi vv;

int get_next_ind(int cur, ll &len) {
	int val = v[cur];
	int ind = (lower_bound(pos[val].begin(), pos[val].end(), cur) - pos[val].begin()) + 1;
	if (ind == SZ(pos[val])) {
		ind = 0;
		len++;
	}
	ind = (pos[val][ind] + 1) % n;
	if (ind == 0) {
		len++;
	}
	return ind;
}

void solve(){
	ll k;
	scanf("%d%lld", &n, &k);
	REP(i, 0, n) {
		scanf("%d", &v[i]);
		pos[v[i]].pb(i);
	}
	REP(i, 0, MAXN) {
		ff[i] = -1;
	}
	ff[0] = 0;
	int cur = 0;
	ll len = 0;
	while(1) {
		int val = v[cur];
		int ind = get_next_ind(cur, len);
		cur = ind;
		if (ff[ind] != -1) {
			ll per_len = len - ff[ind];
			ll k1 = k - ff[ind];
			k1 %= per_len;
			if (k1 == 0) {
				k1 = per_len;
			}
			if (k1 > 0) {
				k = k1;
			} else {
				cur = 0;
			}
			break;
		} else {
			ff[ind] = len;
		}
	}
	
	/*printf("%lld\n", k);
	return;*/
	
	len = 0;
	while(len + 3 < k) {
		int val = v[cur];
		int ind = get_next_ind(cur, len);
		cur = ind;
	}
	
	k -= len;
	for(; k > 0; ) {
		int tmp = v[cur];
		if (st.find(tmp) == st.end()) {
			vv.pb(tmp);
			st.insert(tmp);
		} else {
			while(1) {
				int tmp1 = vv.back();
				vv.pop_back();
				st.erase(tmp1);
				if (tmp1 == tmp) {
					break;
				}
			}
		}
		
		cur++;
		if (cur == n) {
			cur = 0;
			k--;
		}
	}
	
	REP(i, 0, SZ(vv)) {
		printf("%d ", vv[i]);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

#define ll              long long int
#define ull             unsigned long long int
#define pii             pair < int, int>
#define pll             pair < ll, ll>
#define sc              scanf
#define scin(x)         sc("%d",&(x))
#define scln(x)         sc("%lld",&(x))
#define pf              printf
#define NL              pf("\n")
#define ms(a,b)         memset(a,b,sizeof(a))
#define pb(a)           push_back(a)
#define mp              make_pair
#define db              double
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define vi              vector< int >
#define vl              vector< ll >
#define vii             vector<vector< int > >
#define vll             vector<vector< ll > >
#define DBG             pf("HI\n")
#define MOD             1000000007
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define RUN_CASE(t,T)   for(__typeof(t) t=1;t<=T;t++)
#define CASE(t)         printf("Case %d: ",t)
#define CASEL(t)        printf("Case %d:\n",t)
#define intlimit        2147483648
#define longlimit       9223372036854775808
#define infinity        (1<<28)
#define gcd(a, b)       __gcd(a,b)
#define lcm(a, b)       ((a)*(b)/gcd(a,b))
#define mx              1234567899
#define PI              2*acos(0.0)
#define rep(i,a,b)      for(ll i=a; i<=b; i++)
#define rev(i,a,b)      for(ll i=a; i>=b; i--)
#define file            freopen("E:\\file.txt", "r", stdin);ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x)            x.begin(),x.end()
using namespace std;

///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

long long BigMod(long long int a, long long int b, int M) { /// a function to determine a^b(mod M)
    long long remainder, answer = 1;                            /// set two variables for remainder and answer
    remainder = a%M;                                         /// setting remainder as
    while(b!=0)                                                     ///  loop occurs until b is not equal to 0
    {
        if(b%2==1) answer = (answer*remainder)%M;                  /// checking if b is odd
                /// taking the present remainder in the answer if b is odd
        remainder = (remainder*remainder)%M;    /// making remainder double on each turn of the loop
        b/=2;                                  /// reducing b by dividing it by 2 in every turn,
    }
    return answer;
}
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int a,b;
    cin >>a>>b;
    if(b%a==0)pf("%d", a+b);
    else pf("%d", b-a);
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a_orig = a[:]

ans1 = 0
ans2 = 0
tot = [0 for i in range(n)]
tot[0] = a[0]

if a[0] <= 0:
    a[0] = 1
    tot[0] = 1


for i in range(1, n):
    tot[i] = tot[i-1] + a[i]
    if i % 2 == 0:
        if tot[i] <= 0:
            tot[i] = 1
            a[i] = tot[i] - tot[i-1]

    else:
        if tot[i] >= 0:
            tot[i] = -1
            a[i] = tot[i] - tot[i-1]

for i in range(n):
    ans1 += abs(a[i]-a_orig[i])



a = a_orig[:]
tot = [0 for i in range(n)]
tot[0] = a[0]

if a[0] >= 0:
    a[0] = -1
    tot[0] = -1

for i in range(1, n):
    tot[i] = tot[i-1] + a[i]
    if i % 2 == 1:
        if tot[i] <= 0:
            tot[i] = 1
            a[i] = tot[i] - tot[i-1]

    else:
        if tot[i] >= 0:
            tot[i] = -1
            a[i] = tot[i] - tot[i-1]

for i in range(n):
    ans2 += abs(a[i]-a_orig[i])
print(min(ans1, ans2))


Measured memory_bytes: 14084
#include<iostream>
using namespace std;
int maxv1=-(2e9+5),minv1=2e9+5,maxv2=maxv1,minv2=minv1;
int n;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1,x,y;i<=n;i++){
		cin>>x>>y;
		maxv1=max(x+y,maxv1);
		minv1=min(x+y,minv1);
		maxv2=max(maxv2,x-y);
		minv2=min(minv2,x-y);
	}
	cout<<max(maxv1-minv1,maxv2-minv2);
} 

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

namespace Atcoder
{
    class Program2
    {
        public static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int minNum = 1000;
            for (int i = 0; i < S.Length - 2;i++){
                int X = int.Parse(S.Substring(i, 3));
                if(minNum>Math.Abs(X-753)){
                    minNum = Math.Abs(X - 753);
                }
            }
            Console.WriteLine(minNum);
        }
    }
}


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

using namespace std;
#define int long long

bool prime(int n)
{
    if (n <= 1) return 0;
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return 0;
    return 1;
}

int32_t main()
{
    int n; cin >> n;
    while (!prime(n)) n++;
    cout << n << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long h, a;

	std::cin >> h >> a;

	std::cout << int(std::ceil(1.0 * h / a)) << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>

int main() {
	int n;
	int sum[4] = { 0 };

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char tmp[4];
		scanf("%s", tmp);

		if (strcmp(tmp, "AC") == 0) {
			sum[0]++;
		}
		else if (strcmp(tmp, "WA") == 0) {
			sum[1]++;
		}
		else if (strcmp(tmp, "TLE") == 0) {
			sum[2]++;
		}
		else if (strcmp(tmp, "RE") == 0) {
			sum[3]++;
		}
	}

	printf("AC x %d\n", sum[0]);
	printf("WA x %d\n", sum[1]);
	printf("TLE x %d\n", sum[2]);
	printf("RE x %d\n", sum[3]);

	return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	int N; cin >> N;
	string S; cin >> S;
	if(N % 2) {
		cout << "No\n"; return;
	}
	else {
		rep(i, 0, N / 2) {
			if(S[i] != S[i + N / 2]) {
				cout << "No\n"; return;
			}
		}
		cout << "Yes\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

class A {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int[] t = new int[N];
        for(int i = 0; i < t.length; i++)
            t[i] = sc.nextInt();
        int ans = 0;
        for(int i = 0; i < N; i++)
            if(t[i] < A || B <= t[i])
                ans++;
        System.out.println(ans);
    }
}

public class Main {
    public static void main(String... args) {
        A.main();
    }
}

Measured memory_bytes: 10320
#include <stdio.h>

int main(void)

{

int a,b,d,r ;

double f ;

a=0,b=0,d=0,f=0;


scanf("%d %d\n",&a,&b);

d=a/b;

r=a%b;

f=(double)a/(double)b;

printf("%d %d %lf\n",d,r,f);

return 0;

}

Measured memory_bytes: 640
import numpy as np
import sys
input = sys.stdin.readline

N = int(input())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = - np.array(input().split(), dtype=np.int64)

A.sort()
B.sort()
C.sort()

cnt_A = np.searchsorted(A,B,side='left')
cnt_C = np.searchsorted(C,-B,side='left')

answer = (cnt_A * cnt_C).sum()
print(answer)


Measured memory_bytes: 26764
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stack>
#include <deque>

#define mp                  make_pair
#define F                   first
#define S                   second
#define pb                  push_back
#define FOR(i,j,n)          for(int i=j;i<n;i++)
#define F0R(i,j,n)          for(int i=j;i<=n;i++)
#define RFOR(i,j,n)         for(int i=n-1;i>=j;i--)
#define RF0R(i,j,n)         for(int i=n;i>=j;i--)
#define FOREACH(x,v)        for(auto x:v)
#define ITFOR(it,v)         for(__typeof(v.begin()) it =v.begin();it!=v.end();++it)
#define __in_arr__(a,j,n)   FOR(i,j,n)cin >> a[i];
#define __out_arr__(a,j,n)  FOR(i,j,n)cout << a[i];
#define LOG                 cout << "[ !" << __LINE__ << "L ] " << endl;
#define PLOG(x)             cout << "[ !" << __LINE__ << "L ] " <<x<<endl;

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
  ll X,Y;cin >> X >> Y;
  int cnt = 0;
  while(X<=Y) X*=2,cnt++;
  cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  unsigned long int l, r;
  cin >> l >> r;
  auto l_mod = l % 2019;
  auto r_mod = r % 2019;
  if ((l + (2019 - l_mod) <= r) || (l_mod == 0) || (r_mod == 0)) {
    cout << 0 << endl;
  } else {
    auto result = 2019;
    for (auto ldx(l); ldx < r; ++ldx) {
      for (auto rdx(ldx + 1); rdx <= r; ++rdx) {
        auto prod = (ldx * rdx) % 2019;
        if (result > prod) {
          result = prod;
        }
      }
    }
    cout << result << endl;
  }
}

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,ii;
  vector<long> vec;
  cin >> n;
  vec.resize(n);
  for(ii=0;ii<n;ii++){
	cin >> vec[ii];
  }
  int sameNum = 1;
  long magicNum = 0;
  int prevCol = vec[0];
  for(ii=1;ii<n;ii++){
	if(prevCol == vec[ii]){
	  sameNum++;
	}
	else{
	  magicNum += sameNum/2;
	  sameNum = 1;
	}
	prevCol = vec[ii];
  }

  magicNum += sameNum/2;

  cout << magicNum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
int main(void) {
  int a;
  scanf("%d", &a);
  if(a < 1200){
    printf("ABC");
  }else if(a < 2800){
    printf("ARC");
  }else{
    printf("AGC");
  }
  return 0;
}

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

int main() {
  int N,K,x;
  int sum = 0;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    cin >> x;
    int A = 2*x;
    int B = (x-K)*2;
    if(B < 0){
      B=-1*B;
    }
    
    if(A - B > 0){
      sum += B;
    } else {
      sum += A;
    }  
  }
  cout << sum << endl;
}


Measured memory_bytes: 3576
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int N = Integer.parseInt(br.readLine());

        System.out.println(N + N*N + N*N*N);
    }

}


Measured memory_bytes: 32664
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

struct Combination {
    vector<lint> fac, finv, inv;
    Combination(lint maxN) : fac(maxN + 100), finv(maxN + 100), inv(maxN + 100) {
        maxN += 100; // for safety
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1]            = 1;
        for (lint i = 2; i <= maxN; ++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;
        }
    }
    lint operator()(lint n, lint k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    Combination nCk(1000000);
    vector<mint> facto(1000001, 0);
    facto[0] = 1;
    facto[1] = 1;
    for (int i = 2; i <= 1000000; ++i) {
        facto[i] = facto[i - 1] * i;
    }
    if (n < 4) {
        if (n == 2) {
            cout << 1 << "\n";
        } else if (n == 3) {
            cout << 4 << "\n";
        }
        return 0;
    }
    mint ret  = 0;
    mint prev = 0;
    for (int i = (n - 4) / 2 + 2; i < n; ++i) {
        ret += mint(i) * ((mint)nCk(i - 1, n - 1 - i) * facto[i] * facto[n - 1 - i] - prev);
        prev += ((mint)nCk(i - 1, n - 1 - i) * facto[i] * facto[n - 1 - i] - prev);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 39296
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut ans = 0;
    let mut cur = 1;
    for i in 0..n {
        if a[i] != cur {
            ans += 1;
        } else {
            cur += 1;
        }
    }

    if ans == n {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUT2(n1,n2) cout << n1 << " " << n2 << endl
#define OUT3(n1,n2,n3) cout << n1 << " " << n2 << " " << n3 << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c; bool flg;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  ll l,r;
  IN2(l,r);

  if (r-l > 2500) {
    OUT(0);
    return 0;
  }

  ans = 2019;
  FOR(i,l,r) {
    FOR(j,i+1,r+1) {
      ll can = (i * j) % 2019;
      //debug(can);
      if (ans > can) ans = can;
    }
  }

  OUT(ans);
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(long[]), N = ip[0], M = ip[1];
	auto A = readAs!(long[]);
	auto mh = heapify(A);

	while(M != 0) {
		auto f = mh.front;
		mh.removeFront;
		mh.insert(f/2);
		M--;
	}
	mh.array.sum.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 6324
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main()
{
  double x,y = 0;
  int walk;
  int rad;
  int sumrad = 90;
  while( scanf("%d,%d", &walk, &rad), walk){
    x += walk*cos((double)sumrad*3.141592/180);
    y += walk*sin((double)sumrad*3.141592/180);
    sumrad -= rad;
  }
  cout << (int)x << endl
       << (int)y << endl;

  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum = 0;
    cin >> n;
    vector<int> v,c;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        if(v.at(i) - a > 0)
        {
            sum += v.at(i) - a;
        }
    }
    cout << sum;

    return 0;
}

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

int main()
{
    int H,W=0;
    cin>>H>>W;
	do
	{
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	} while ((H != 0) || (W != 0));
    return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    typedef pair<int,int> P;
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    REP(i,H) cin>>S[i];
    int ans=0;
    REP(a,H) REP(b,W) if(S[a][b]=='.'){
        int dx[4]={-1,1,0,0},dy[4]={0,0,1,-1};
        vector<vector<int>> d(H,vector<int> (W,-1));
        queue<P> que;
        que.push(P(a,b));
        d[a][b]=0;
        while(!que.empty()){
            P p=que.front();que.pop();
            int x=p.first,y=p.second;
            REP(j,4){
                int nx=x+dx[j],ny=y+dy[j];
                if(0<=nx&&nx<H&&0<=ny&&ny<W&&d[nx][ny]==-1){
                    if(S[nx][ny]=='#') continue;
                    que.push(P(nx,ny)); d[nx][ny]=d[x][y]+1;
                    ans=max(d[nx][ny],ans);
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

ll n,W;
ll w[101],v[101];
ll dp[101][100010];
ll totalV=0;

ll minWeight(ll end, ll Val)
{
  if(Val<=0)
  return 0;
  if(end==0)
  // return 1000000010;
  return INT_MAX;
  // 2147483647
  if(dp[end][Val]!=1000000010)
  return dp[end][Val];
  if(v[end-1]>Val)
  return dp[end][Val]=minWeight(end-1,Val);
  else
  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));
}

ll bottomUp()
{
  ll i,j;
  for(i=0;i<=n;i++)
  {
    for(j=0;j<=totalV;j++)
    {
      if(j==0)
      dp[i][j]=0;
      else if(i==0)
      dp[i][j]=INT_MAX;
      else if(j>=v[i-1])
      dp[i][j]=min(w[i-1]+dp[i-1][j-v[i-1]], dp[i-1][j]);
      else 
      dp[i][j]=dp[i-1][j];
    }
  }
  for(j=totalV;j>=1;j--)
  {
    if(dp[n][j]<=W)
    break;
  }
  return j;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j;
    cin>>n>>W;
    for(i=0;i<n;i++)
    {
      cin>>w[i]>>v[i];
      totalV+=v[i];
    }

    for(i=0;i<=n;i++)
      for(j=0;j<=totalV;j++)
        dp[i][j]=1000000010;

    // for(i=totalV;i>=1;i--)
    // {
    //   if(minWeight(n,i)<=W)
    //   break;
    // }
    // cout<<i;
    cout<<bottomUp();
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if (s == "SSS"){
        cout << 0 << endl;
    }else if(s == "RRR"){
        cout << 3 << endl;
    }else if(s == "SRR" || s == "RRS"){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    rep(i, n)
    {
        cin >> a[i];
        a[i]--;
    }
    rep(i, n)
    {
        cin >> b[i];
    }

    rep(i, n - 1) cin >> c[i];
    int ans = 0;
    int prev = -2;
    rep(i, n)
    {
        ans += b[a[i]];
        if (prev + 1 == a[i])
        {
            ans += c[prev];
        }
        prev = a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,j,n) for(ll i=j;i<n;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
ll i;

int main(){
    ll N;
    cin>>N;
    vector<ll> d(N);
    rep(i,0,N)cin>>d.at(i);
    sort(d.begin(),d.end());
    ll sa=d.at(N/2)-d.at(N/2-1);
    cout<<sa<<endl;

}

Measured memory_bytes: 1024