akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

int d = 365;
vector<vector<int>> s(d+1, vector<int>(26+1, 0));
vector<int> c(26+1);
vector<int> t(d);

ll calc(ll v, int d, int j, vector<ll> last) {
    ll tmp = v;
    ll p = 0;
    last[j] = d;
    //
    for(int i = 0; i < d; i++) {
        tmp -= c[i]*(d-last[i]);
        p -= c[i]*(d-last[i]);
    }
    //return tmp-v;
    p += s[d-1][j];
    return p;
    //return tmp;
}

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

int main() {
    init();
    /////////////////
    vector<int> t(d, 1);
    //vector<ll> ans(d, 0);
    vector<ll> last1(26+1, 0), last2(26+1, 0);
    vector<ll> last(26+1, 0);
    ll v = 0;
    ll tmp1 = 0, tmp2 = -1;
    ll ans = 0;
    for(int i = 0; i < d; i++) {
        //v += s[i][t[i]-1];
        //last[t[i]-1] = i+1;
        for(int j = 0; j < 26; j++) {
            //ans[i] -= c[j]*((i+1)-last[j]);
            //t[i] = j+1;
            last1[j] = i+1; // d
            tmp1 = calc(v+s[i][j], (i+1), (j), last);
            if(tmp2 < tmp1) {
                tmp2 = tmp1;
                last1 = last2;
                last2[j] = i+1;
                t[i] = j+1;
                last[j] = i+1;
            }
            // v -= c[j]*((i+1)-last[j]);
        }
        last1 = last2;
        v += (tmp2-v);
        ans += tmp2;
        tmp1 = 0, tmp2 = 0;
        //cout << "v: " << v << endl;
    }
    
    for(int i = 0; i < d; i++) {
        //cout << "i: " << i << " " << t[i] << endl;
        cout << t[i] << endl;
    }
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
import collections

n = int(input())
s = []
for i in range(n):
    si = input()
    s.append(si)

str = collections.Counter(s)
cntmax = str.most_common()[0][1]

slist = list(str.items())

ans = []
for i in range(len(set(s))):
    if slist[i][1] == cntmax:
       ans.append(slist[i][0])
ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 58480
def check(a, b):
    for i in range(len(a)):
        if not(a[i] == b[i] or a[i] == '?'):
            return False
    return True


s_prime = input()
t = input()
ans_list = []
for i in range(len(s_prime) - len(t) + 1):
    if check(s_prime[i:i+len(t)], t):
        s = s_prime[:i] + t + s_prime[i+len(t):]
        ans = s.replace('?', 'a')
        ans_list.append(ans)
ans_list.sort()
if not ans_list:
    print('UNRESTORABLE')
else:
    print(ans_list[0])

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<string> ans(H);
  
  for(int i=0;i<H;i++){
  	cin>>ans.at(i);
  }
  
  for(int i=0;i<W+2;i++){
  	cout<<"#";
    if(i==W+1) cout<<"\n";
  }
  
  for(int i=0;i<H;i++){
    cout<<"#"<<ans.at(i)<<"#"<<endl;
  }
  
  for(int i=0;i<W+2;i++){
  	cout<<"#";
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#define N 100000
#define LOG 20
using namespace std;
int h[N+1];
int farthest[N+1][LOG+1]; //farthest[i][j] -> the farthest you can go from i in 2^j days
int lg[N+1];
int maximum_distance(int i, int d) //in d days, how far can you get?
{
	int j = i;
	while(d > 0)
	{
		j = farthest[j][lg[d]];
		d -= (1<<lg[d]);
	}
	return j;
}
int b_search(int a, int b)
{
	int L = 1;
	int R = 100000;
	while(R-L>1)
	{
		int M = (L+R)/2;
		if(maximum_distance(a,M) >= b)
			R = M;
		else
			L = M;
	}
	if(maximum_distance(a,L) >= b)
		return L;
	else
		return R;
}
int first_dude(int i, int dist, int n)
{
	int L = i; 
	int R = n;
	while(R-L>1)
	{
		int M = (L+R)/2;
		if(h[M]-h[i] <= dist)
			L = M;
		else
			R = M;
	}
	if(h[R]-h[i] <= dist)
		return R;
	else
		return L;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	for(int x = 0; x <= LOG; x++)
		for(int n = (1<<x); n <= N && n < (1<<(x+1)); n++)
			lg[n] = x;
		
	int n, L;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	cin >> L;
	
	for(int i = 1; i <= n; i++)
		farthest[i][0] = first_dude(i,L,n);
		
	for(int x = 1; x <= LOG; x++)
		for(int i = 1; i <= n; i++)
			farthest[i][x] = farthest[farthest[i][x-1]][x-1];
	
	int Q; cin >> Q;
	while(Q--)
	{
		int a, b; cin >> a >> b;
		cout<<b_search(min(a,b),max(a,b))<<'\n';
	}
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdtr1c++.h>
using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 3e5 + 10;
const int maxM = 3e5 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    int n;
    cin >> n;
    multiset <double> S;
    for (int i = 1; i <= n; i++) {
        double x;
        cin >> x;
        S.insert(x);
    }
    while ((int)S.size() > 1) {
        double x = *S.begin(); S.erase(S.begin());
        double y = *S.begin(); S.erase(S.begin());
        S.insert((x + y) / 2);
    }
    cout << fixed << setprecision(10) << *S.begin();
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    ll n;
    string s;
    cin >> n  >> s;
    ll ans = 0;
    rep(i, 1000){
        int c[3] = {i/100, i/10%10, i%10}, now = 0;
        rep(j, n){
            if(s[j] == '0'+c[now])now++;
            if(now == 3)break;
        }
        if(now == 3)ans++;
    }
    cout << ans;
}


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

int n, d;
int a[30][30];

bool check(int u, int v) {
	int tmp = 0;
	for (int i = 1; i <= d; ++i) tmp += abs(a[u][i] - a[v][i]) * abs(a[u][i] - a[v][i]);
	return round(sqrt(tmp)) * round(sqrt(tmp)) == tmp;
}

int main() {
	cin >> n >> d;
	for (int i = 1; i <= n; ++i) 
		for (int j = 1; j <= d; ++j) 
			cin >> a[i][j];
	int cnt = 0;
	for (int i = 1; i <= n; ++i) 
		for (int j = i + 1; j <= n; ++j) 
			if (check(i, j)) ++cnt;
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;


int main(){
  ll n,ans=1;cin>>n;
  for(int i=2;i*i<=n;i++){
    ll tmp=i;
    while(tmp<=n/i){
      tmp*=i;
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

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

int main() {
  int N, a, b, s, n, m;
  s=n=0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++) cin >> vec.at(i);
  for(int i=0;i<N;i++) s+=vec.at(i);
  for(int i=0;i<N;i++) if(vec.at(i)>=n) n=vec.at(i);
  s-=n;
  if(s>n) cout << "Yes" << endl;
  else cout << "No" << endl;
  

}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

int64_t n, res = 0LL;
void dfs(int64_t num, bool ok3, bool ok5, bool ok7){
  if(num > n) return;
  if(ok3 && ok5 && ok7) res++;
  dfs(num*10+3, true, ok5,  ok7 );
  dfs(num*10+5, ok3,  true, ok7 );
  dfs(num*10+7, ok3,  ok5,  true);
}

signed main(){
  cin >> n;
  dfs(0, false, false, false);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def mul(n, A, B, C):
    for i in range(n):
        for j in range(n):
            C[i][j] = sum(A[i][k] * A[k][j] for k in range(n))
def fast_pow(n, MA, A, k):
    R = [[0]*n for i in range(n)]
    while k:
        if k & 1:
            A = [sum(e*a for e, a in zip(MA[i], A)) for i in range(n)]
        mul(n, MA, MA, R)
        MA, R = R, MA
        k >>= 1
    return A

def solve():
    S, N, K = map(int, readline().split())
    S = abs(S)
    if S == 0:
        write("0\n")
        return
    if N == 1:
        if S % K:
            write("-1\n")
        else:
            write("%.16f\n" % (S // K))
        return
    M = N*K
    dp = [0]*(M+1)
    dp[0] = 1
    for t in range(K):
        for i in range(N*K, -1, -1):
            dp[i] = sum(dp[i-k] for k in range(1, N+1) if i >= k)
    s = sum(dp)
    mat = [[0]*(M+2) for i in range(M+1)]
    mat[0][0] = 1
    for i in range(1, M+1):
        mi = mat[i]
        for j in range(M+1):
            mi[abs(i-j)] -= dp[j]
        mi[i] += s
        for j in range(M+1):
            mi[j] /= s
        mi[M+1] = 1
    for i in range(M+1):
        v = mat[i][i]
        for j in range(M+2):
            mat[i][j] /= v
        for k in range(M+1):
            if k == i:
                continue
            e = mat[k][i]
            for j in range(M+2):
                mat[k][j] -= e * mat[i][j]
    C = [mat[i][M+1] for i in range(M, -1, -1)]
    C[-1] = 1
    if S <= M:
        write("%.16f\n" % C[M-S])
        return

    mat2 = [[0]*(M+1) for i in range(M+1)]
    for i in range(M):
        mat2[0][i] = dp[i+1] / s
    for i in range(M-1):
        mat2[i+1][i] = 1
    mat2[0][M] = mat2[M][M] = 1
    C1 = fast_pow(M+1, mat2, C, S-M)
    write("%.16f\n" % C1[0])
solve()


Measured memory_bytes: 6588
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int D;
		D = scan.nextInt();

		if (D == 25) {
			System.out.println("Christmas");
		} else if (D == 24) {
			System.out.println("Christmas Eve");
		} else if (D == 23) {
			System.out.println("Christmas Eve Eve");
		} else if (D == 22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
 string A,B;
  cin>>A>>B;
  
  if(A.size()!=B.size()){
    if(A.size()>B.size()){
      cout<<"GREATER"<<endl;
    }
    
    else if(A.size()<B.size()){
      cout<<"LESS"<<endl;
    }
    
  }
  
  else if(A.size()==B.size()){
    
    if(A==B){
cout<<"EQUAL"<<endl;
    }
    
    else {
    
    for(int i=0;i<A.size();i++){
     if(A.at(i)-'0'!=B.at(i)-'0'){
       if(A.at(i)-'0'>B.at(i)-'0'){
cout<<"GREATER"<<endl;
         break;
       }

       else if(A.at(i)<B.at(i)){
         cout<<"LESS"<<endl;
         break;
       }
     }
    }
    }
    
  
  }
}
     
     
    

     

       
     
    

Measured memory_bytes: 256
H, W, K = list(map(int, input().split()))
MAP = []
for i in range(H):
	MAP.append(list(input()))
for i in range(H):
	for j in range(W):
		if MAP[i][j] == "S":
			h = i
			w = j
			MAP[i][j] = ","
			break
		else:
			pass
length = min([h, w, H - h - 1, W - w - 1])
abl = [[h, w]]
for j in range(K):
	ln = len(abl)
	abll = []
	for i in range(ln):
		if MAP[abl[i][0] + 1][abl[i][1]] == ".":
			if abl[i][0] + 1 == H - 1:
				length = 0
				break
				break
			else:
				if H - abl[i][0] - 2 < length:
					length = H - abl[i][0] - 2
				else:
					pass
				abll.append([abl[i][0] + 1, abl[i][1]])
				MAP[abl[i][0] + 1][abl[i][1]] = ","
		else:
			pass

		if MAP[abl[i][0] - 1][abl[i][1]] == ".":
			if abl[i][0] - 1 == 0:
				length = 0
				break
				break
			else:
				if abl[i][0] - 1 < length:
					length = abl[i][0] - 1
				else:
					pass
				abll.append([abl[i][0] - 1, abl[i][1]])
				MAP[abl[i][0] - 1][abl[i][1]] = ","
		else:
			pass

		if MAP[abl[i][0]][abl[i][1] + 1] == ".":
			if abl[i][1] + 1 == W - 1:
				length = 0
				break
				break
			else:
				if W - abl[i][1] - 2 < length:
					length = W - abl[i][1] - 2
				else:
					pass
				abll.append([abl[i][0], abl[i][1] + 1])
				MAP[abl[i][0]][abl[i][1] + 1] = ","

		if MAP[abl[i][0]][abl[i][1] - 1] == ".":
			if abl[i][1] + 1 == 0:
				length = 0
				break
				break
			else:
				if abl[i][1] - 1 < length:
					length = abl[i][1] - 1
				else:
					pass
				abll.append([abl[i][0], abl[i][1] - 1])
				MAP[abl[i][0]][abl[i][1] - 1] = ","
	abl = abll
if length % K == 0:
	print(int(length // K) + 1)
else:
	print(int(length // K) + 2)

Measured memory_bytes: 10988
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    vector<int> w(N), z(N);
    REP(i, 0, N) {
        int x, y; cin >> x >> y;
        w[i] = x + y;
        z[i] = x - y;
    }

    sort(ALL(w));
    sort(ALL(z));

    cout << max(w.back() - w[0], z.back() - z[0]) << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

int n, d;
void init(){
    n = read();
    d = read();
}
void solve(){
    int ans = 0;
    while (n--){
        int x = read(), y = read();
        ll t = 1ll * x * x + 1ll * y * y;
        if (t <= 1ll * d * d)
            ++ans;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n,x,y;
  cin>>n;
  x=0;
  y=0;
  vector<int64_t>a(n);
  for(int64_t i=0;i<n;i++){
    cin>>a.at(i);
    x=(x+a.at(i))%1000000007;
    y=(y+a.at(i)*a.at(i))%1000000007;
  }
  if(((x*x-y)%1000000007)%2==0){
    cout<<((x*x-y)%1000000007)/2<<endl;
    }
  else{
    cout<<((x*x-y)%1000000007+1000000007)/2<<endl;
  
  }
}

Measured memory_bytes: 4804
#include<iostream>
using namespace std;
int main()
{
	int a[100]={0};
	int b[100][2]={0};
	int B1,B2;
	int i=0;
	for(int h=0;h<100;h++)
	{
		b[h][1]=h+1;
	}
while (cin>>a[i])
{
	b[a[i]-1][0]++;
	i++;
}
for(int j=0;j<i;j++)
{
	for(int k=j+1;k<i;k++)
	{
		if(b[k][0]>b[j][0])
		{
			B1=b[k][0];
			b[k][0]=b[j][0];
			b[j][0]=B1;
			B2=b[k][1];
			b[k][1]=b[j][1];
			b[j][1]=B2;
		}
	}
}
int l=0;
while(b[l][0]==b[0][0])
{
	cout<<b[l][1]<<endl;
	l++;
}
return 0;
}

Measured memory_bytes: 3100
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by hikigineer on 2017/03/04.
 */
public class Main {
    static Scanner in;
    static PrintWriter out;
    static String INPUT = "";

    public static void main(String[] args) throws Exception
    {
        in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
        out = new PrintWriter(System.out);
        int n = ni();
        String[] S = new String[n];

        S[0] = in.next();
        String minText = S[0];
        int i, min = minText.length();
        for(i = 1; i < n; i++)
        {
            S[i] = in.next();
            if(S[i].length() < min)
            {
                min = S[i].length();
                minText = S[i];
            }
        }
        String result = "";
        char[] minCharArray = minText.toCharArray();
        Arrays.sort(minCharArray);
        for(char mc : minCharArray)
        {
            String mcs = String.valueOf(mc);
            for (i = 0; i < n; i++)
            {
                if(!S[i].contains(mcs))
                    break;
            }
            if(i == n)
            {
                result += mcs;
                for (i = 0; i < n; i++)
                    S[i] = S[i].replaceFirst(mcs, "");
            }
        }
        out.println(result);
        out.flush();
    }

    static int ni() {
        return Integer.parseInt(in.next());
    }
}


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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int add = min(a - b, c);
  cout << c - add << endl;
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define inf 1000000007
using namespace std;
int main()
{
    ll i,j,k,n,t;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N, P = map(int, input().split())


def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


d = Counter(prime_factorize(P))
answer = 1
for i, n in d.items():
    answer *= i ** (n // N)

print(answer)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];
  vector<int> w(N,MAX_I);
  rep(i,N){
    *upper_bound(all(w),-v[i]) = -v[i];
  }
  cout << lower_bound(all(w),MAX_I) - w.begin() << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    char str1[105],str2[105];
    int n,x,y,t,flag;
    char* t1=str1;
    char* t2=str2;
    while(~scanf("%d",&n))
    {
        t=0;
        scanf("%s%s",str1,str2);
        y=0,flag=0;
        for(x=0;x<n;x++)
        {
            flag=1,y=0;
            while(flag&&y<n-x)
            {
                flag=0;
                if(str1[x+y]==str2[y])
                {
                    flag=1;
                    y++;
                }
            }
            if(x+y==n)
                break;
        }
        printf("%d\n",2*n-y);

    }
    return 0;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

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

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    if (A % 2 == B % 2) {
        int p = (A + B) / 2;
        cout << min(p - A, min(B - 1, N - A)) << endl;
    } else {
        int A1 = 1;
        int B1 = B - (A);
        int c1 = A;
        int p1 = (A1 + B1) / 2;

        int A2 = A + (N - B) + 1;

        int B2 = N;
        int c2 = N - B + 1;

        int p2 = (A2 + B2) / 2;

        int pp = min(p1 - A1 + c1, p2 - A2 + c2);
        cout << min(B - 1, min(N - A, pp)) << endl;
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	a := ReadInts(N)
	down := true
	j := N - 1
	for i := 0; i < N; i++ {
		fmt.Printf("%d ", a[j])
		if down {
			j -= 2
			if j == -2 {
				j = 1
				down = false
			}
			if j == -1 {
				j = 0
				down = false
			}
		} else {
			j += 2
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 7068
import numpy as np
import bisect

def solve(n, m, k, a, b):
    s = np.cumsum([0]+a)
    t = np.cumsum(b)
    best = 0
    for i in range(n+1):
        if s[i] > k:
            break
        j = bisect.bisect_right(t, k - s[i])
        best = max(best, i+j)
    return best

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(solve(n, m, k, a, b))

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

int main() {
  string s, t;
  cin >> s >> t;
  
  int n;
  n = s.size();
  
  int i = 0;
  while (i < n) {
    if (s.at(i) == t.at(i)) {
      i++;
    } else {
      break;
    }
  }
  
  if (i < n) {
    cout << "No" << endl;
  } else if(i = n) {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;
const double pi = acos(-1);

int main(){
  double A, B;
  cin >> A >> B;
  if(A > B) swap(A,B);
  printf("%.12f\n",B*B*B*pi*4/3);
  return 0;
}



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

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
	int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}


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

int main(){
  const int N=101;
  int c[3][3];
  string result = "No";
  int a[3] = {};
  int b[3] = {};
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++) cin >> c[i][j];
  }
  for(int i=0; i<N; i++){
    a[0] = i;
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    if(b[0] < 0 || b[1] < 0 || b[2] < 0) break;
    if( c[1][0] - b[0] == c[1][1] - b[1] && c[1][1] - b[1] == c[1][2] - b[2] && c[2][0] - b[0] == c[2][1] - b[1] && c[2][1] - b[1] == c[2][2] - b[2] ){
      result = "Yes";
      break;
    }    
  }
  cout << result << endl;
  return 0;
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	int n, m;
	cin >> n >> m;
	
	VI ans(n, 0);
	rep(i, m){
		int a,b;
		cin >>a >>b;
		ans[a-1]++;
		ans[b-1]++;
	}
	
	for(auto x: ans) cout << x <<"\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
ll gcd(int n, int m){
  return (n % m) ? gcd(m, n % m) : m;
}
ll lcm(int n, int m){
  return (ll)n * m / gcd(n, m);
}
int toint(string unit){
  int n;
  sscanf(unit.c_str(), "%x", &n);
  return n;
}
string tostr(vector<int> v){
  string res;
  REP(i, v.size()){
    int n = v[i];
    char s[100];
    sprintf(s, "%02X", n);
    res +=  string(s);
  }
  return res;
}

int main(){
  int T;
  cin>>T;
  while(T--){
    int N; cin>>N;
    string s[8];
    ll len = 1;
    REP(i, N){
      cin>>s[i];
      REP(j, s[i].size()/2) if(s[i].substr(j * 2, 2) != "00"){
        //printf("%d/%d ", j, s[i].size() /2);
        if(len <= 1024)len = lcm(len, (s[i].size() / 2 / gcd(j, s[i].size() / 2)));
      }
    }
    if(len > 1024){
      cout<<"Too complex."<<endl;
      continue;
    }
    vector<int> data(len);
    REP(i, len){
      REP(j, N){
        int l = s[j].size() / 2;
        if(i * l % len == 0) data[i] |= toint(s[j].substr(i * l / len * 2, 2));
      }
    }
    cout<<tostr(data)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
int n;
int max=0;
int min=0;
int i;
int count=0;
int x1=0;
int x2=0;
int x3=0;
int x4=0;
int x5=0;
int x6=0;
int x7=0;
int x8=0;
int a=0;
int x[100];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&x[i]);
if(x[i] >= 3200){
a=a+1;
}
if(1<=x[i]&&x[i]<400){
x1=1;
}
if(400<=x[i]&&x[i]<800){
x2=1;
}
if(800<=x[i]&&x[i]<1200){
x3=1;
}
if(1200<=x[i]&&x[i]<1600){
x4=1;
}
if(1600<=x[i]&&x[i]<2000){
x5=1;
}
if(2000<=x[i]&&x[i]<2400){
x6=1;
}
if(2400<=x[i]&&x[i]<2800){
x7=1;
}
if(2800<=x[i]&&x[i]<3200){
x8=1;
}
}
 
if(x1 ==1){
count = count+1;
}
if(x2 ==1){
count = count+1;
}
if(x3 ==1){
count = count+1;
}
if(x4 ==1){
count = count+1;
}
if(x5 ==1){
count = count+1;
}
if(x6 ==1){
count = count+1;
}
if(x7 ==1){
count = count+1;
}
if(x8 ==1){
count = count+1;
}
min = count;
if(min ==0)
min=1;
max = count+a;
printf("%d %d",min,max);
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.math.BigInteger;

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

	for(int i=0; i<n; i++){
	    BigInteger a,b,c;
	    a = sc.nextBigInteger();
	    b = sc.nextBigInteger();
	    c = a.add(b);
	    if(c.toString().length()<=80){
		System.out.println(c);
	    }else{
		System.out.println("overflow");
	    }
	}
    }
}

Measured memory_bytes: 12000
class SegmentTree:
    
    def __init__(self, n):
        self.n = n
        self.T = [0 for _ in range(2*n-1)]
        
    def add(self, i, x):
        i += self.n - 1
        self.T[i] += x
        while(i > 0):
            i = (i - 1) // 2
            self.T[i] += x
            
    def get_sum(self, a, b, k, l, r):
        if r<= a or b<= l:
            return 0
        if a <= l and r <= b:
            return self.T[k]
        vl = self.get_sum(a, b, k*2+1, l,(l+r)//2)
        vr = self.get_sum(a, b, k*2+2, (l+r)//2,r)
        return vl + vr
    

n_, q = [int(i) for i in input().split()]
n = 1
while(n < n_):
    n *= 2
T = SegmentTree(n)
for _ in range(q):
    c, x, y = [int(i) for i in input().split()]
    if c == 0:
        T.add(x - 1, y)
    else:
        print(T.get_sum(x - 1, y, 0, 0, n))


Measured memory_bytes: 10856
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt() / 50;
        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (10 * i + 2 * j + k == x) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    double l=n/3.0;
    double b=n/3.0;
    double h=n-l-b;

    double ans=l*h*b;
    cout<<PSET(ans,8);
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

class TaskA {
 public:
  void solve(std::istream &in, std::ostream &out) {
    string S;
    in >> S;
    int ans = 0;
    for (auto ch : S) {
      if (ch == '1') {
        ans++;
      }
    }
    out << ans;
  }
};


int main() {
  TaskA solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim.**/
/*gcd=--gcd(a,b);*/
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
     int a=0,b=0,c=0,d,y=0,j,n,x[100000],i,xx;
      char s[100];
     cin>>n;
     for(i=0;i<n;i++)
     {
         cin>>s;
         if(s[0]=='A') a++;
          if(s[0]=='W') b++;
          if(s[0]=='T') c++;
         if(s[0]=='R') y++;
     }

     printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,y);


}


Measured memory_bytes: 3708
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;

int main()
{
    int N, i, n;
    cin >> N;
    n = N;
    vector<int> b(N), ans;
    for (i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    while (b.size())
    {
        int z = -1;
        for (i = 0; i < b.size(); i++)
        {
            if (b[i] == i + 1)
            {
                z = i + 1;
            }
        }
        if (z == -1)
        {
            cout << z << endl;
            return 0;
        }
        ans.push_back(z);
        b.erase(b.begin() + z - 1);
    }
    reverse(ans.begin(), ans.end());
    for (i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

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

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

using namespace std;
using ll = long long int;

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll to;
    rep(i, n) {
        cin >> to;
        to--;
        a[i] = to;
    }
    vector<bool> reached(n, false);
    vector<ll> mem(n);
    ll cur = 0, cnt = 0;
    while(cnt < k) {
        if (reached[cur]) break;
        reached[cur] = true;
        mem[cur] = cnt;
        cur = a[cur];
        cnt++;
        //cout << cur << " " << cnt << endl;
    }
    if (cnt == k) {
        cout << cur + 1 << endl;
        return 0;
    }
    ll cycle = cnt - mem[cur];
    ll rep = (k - mem[cur]) % cycle;
    //cout << "cycle = " << cycle << endl;
    for (ll i = 0; i < rep; i++) {
        cur = a[cur];
        //cout << cur + 1 << endl;
    }
    cout << cur + 1 << endl;
}

Measured memory_bytes: 6424
c,d,t,u;
long s;
main()
{
	c=getchar_unlocked();
	while(c-10)
	{
		s+=t+=1;
		d=getchar_unlocked();
		if(c-d)
		{
			if(c=='>')s-=t<u?t:u;
			u=t;
			t=0;
			c=d;
		}
	}
	printf("%ld",s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const  int maxn = 3005;
typedef long long ll;
char s1[maxn], s2[maxn], s[maxn];
int dp[maxn][maxn];
int main() {
//    freopen("in.in", "r", stdin);
    cin >> s1 + 1 >> s2 + 1;
    int n = strlen(s1 + 1);
    int m = strlen(s2 + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s1[i] == s2[j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    int ans = dp[n][m];
    int i = n, j = m;
    while (i >= 1 && j >= 1) {
        if (s1[i] == s2[j] && dp[i][j] == ans) {
//            cout << s1[i];
            s[ans] = s1[i]; i--; j--; ans--;
        } else if (dp[i - 1][j] > dp[i][j - 1]) {
            i--;
        } else {
            j--;
        }
    }
//    cout << endl;
    cout << s + 1 <<endl;
    return 0;
}

Measured memory_bytes: 35456
import Control.Applicative
import Text.Printf
main = do
  v <- takeWhile (/= -1) . map (read::String->Int) . lines <$> getContents
  mapM_ (\x->putStrLn $ (printf "%.2f".fst$x)++"\n"++(printf "%.2f".snd$x)) . map (solve . ((+) (-1))) $ v

solve::Int->(Double,Double)
solve n = (map f [0..]) !! n
f 0 = (1.0,0.0)
f n = (x',y')
  where
    (x,y) = solve (n-1)
    cost = x/ sqrt(x^2+y^2)
    sint = y/ sqrt(x^2+y^2)
    cost' = -sint
    sint' = cost
    x' = x + cost'
    y' = y + sint'

Measured memory_bytes: 4668
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, p[100100];
  cin >> N;
  rep(i, N) cin >> p[i];
  int ans = 0;
  rep(i, N) {
        if(p[i] == i + 1) {
            ans ++;
            p[i + 1] = i + 1;
        }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans; 
}
void solve()
{
    int i,n;
    cin>>n;
    int a[n];
    fo(i,n)
    {
        cin>>a[i];
    }
    ll cost[n]={0};
    cost[0]=0;
    cost[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        cost[i]=min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<cost[n-1]<<nl;

       
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
}


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

typedef long long ll;
typedef vector<int> vi;

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

const string u = "#.";

int N;
string s[2];

int main() {
	scanf("%d", &N);

	bool flg = 1;

	rep(i, N) {
		bool fd = 0;
		rep(j, 4) {
			if (flg) {
				s[0].pb(u[j&1]);
				s[1].pb(u[(j/2)&1]);

				printf("%s\n%s\n", s[0].c_str(), s[1].c_str()); fflush(stdout);
				char res[4];
				scanf("%s", res);

				if (strcmp(res, "end") == 0) {
					return 0;
				}

				if (res[0] == 'T') {
					fd = 1;
					break;
				} else {
					s[0].pop_back();
					s[1].pop_back();
				}
			}
		}
		if (!fd) {
			flg = 0;
			rep(j, 4) {
				string t[2];
				t[0] = s[0], t[1] = s[1];
				t[0].insert(t[0].begin(), u[j&1]);
				t[1].insert(t[1].begin(), u[(j/2)&1]);
				printf("%s\n%s\n", t[0].c_str(), t[1].c_str()); fflush(stdout);
				char res[4];
				scanf("%s", res);

				if (strcmp(res, "end") == 0) {
					return 0;
				}

				if (res[0] == 'T') {
					s[0] = t[0];
					s[1] = t[1];
					break;
				}			
			}
		}
	}

	return 0;
}

Measured memory_bytes: 716
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s = "";
    while (n > 0)
    {
        ll mod = n % 26;
        if (mod != 0)
        {
            s.push_back('a' + mod - 1);
        }
        else
        {
            s.push_back('z');
        }
        if (mod == 0)
            n = n / 26 - 1;
        else
            n = n / 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for (int i = 0; i < N; ++i) {
            bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n, m, j, i, k, s, a;
int main(){
	scanf("%d", &n);
	if(n%1000!=0){
		m=1000-n%1000;
	}
	else m=0;
	printf("%d", m);
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int s;
    cin >> s;

    int fir = s /100;
    int sec = s %100;

    bool flagf = true;
    bool flags = true;

    if(fir > 12){
        flagf = false;
    }

    if(sec > 12){
        flags = false;
    }

    if(fir == 0 && sec == 0){
        cout << "NA";
    }else if(fir == 0 && flags){
        cout << "YYMM";
    }else if(sec == 0 && flagf){
        cout << "MMYY";
    }else if(flagf && flags){
        cout << "AMBIGUOUS";
    }else if(!flagf && !flags){
        cout << "NA";
    }else if(flagf && !flags && fir != 0){
        cout << "MMYY";
    }else if(!flagf && flags && sec != 0){
        cout << "YYMM";
    }else{
        cout << "NA";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = input().split()

for i, num in enumerate(W):
    W[i] = int(num)

S1 = []

S2 = []

minNum = 100
for i in range(N):
    S1 = W[:i]
    S2 = W[i:]
    diff = abs(sum(S1) - sum(S2))
    if diff < minNum:
        minNum = diff
print(minNum)


Measured memory_bytes: 38384