akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){

 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++){
    cin>>a[i];
    if(i!=0){
        a[i]=a[i]+a[i-1];
    }
 }
 int m;
 for(int i=0;i<n-1;i++){
   if(i==0){
    m=(abs(a[n-1]-2*a[i]));
   }
   else{
    if(abs(a[n-1]-2*a[i])<m){
        m=(abs(a[n-1]-2*a[i]));
    }
   }
 }
 cout<<m<<endl;
}

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> p(1, 1);
  unordered_map<int, int> mp;
  mp.insert({1, 0});

  int t = 1;
  ll e = 0;
  rep(i, n) {
    t = a[t - 1];
    if (mp.count(t)) {
      e = mp[t];
      break;
    }

    p.push_back(t);
    mp.insert({t, i + 1});
  }

  ll p_size = p.size();
  if (k >= p_size) {
    k -= e;
    k %= p_size - e;
    k += e;
  }
  cout << p[k] << endl;
  return 0;
}

Measured memory_bytes: 12744
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	char w;
	char q[a][b];
	
	for(int i=0;i<a;i++){
		scanf("%c",&w);
		for(int j=0;j<b;j++){
			scanf("%c",&q[i][j]);
			//printf("%d",i);
		}
	}
	
	int flag=1;
	
	for(int i=0;i<b;i++){
		flag=1;
		for(int j=0;j<a;j++){
			if(q[j][i]=='.'){
				flag=0;
			}else{
				flag=1;
				break;
			}
		}
		if(flag==0){
			for(int j=0;j<a;j++){
				q[j][i]=' ';
			}
		}
	}
	
	for(int i=0;i<a;i++){
		flag=1;
		for(int j=0;j<b;j++){
			if(q[i][j]=='.' || q[i][j]==' '){
				flag=0;
			}else{
				flag=1;
				break;
			}
		}
		if(flag==0){
			for(int j=0;j<b;j++){
				q[i][j]=' ';
			}
		}
	}
	
	int c=0;
	
	for(int i=0;i<a;i++){
		c=0;
		for(int j=0;j<b;j++){
			if(q[i][j]!=' '){
				printf("%c",q[i][j]);
				c++;
			}
		}
		if(c!=0){
			puts("");
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

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

	vector<uint32_t> v(n + (n & 1), 0);
	for (uint32_t i = 0; i < n; i++) {
		cin >> v[i];
	}
	_sort(v, uint32_t, greater);

	int32_t sum = 0;
	for (size_t i = 0; i < v.size(); i+=2) {
		sum += (v[i] - v[i + 1]);
	}
	printf("%d\n", sum);
	return 0;
	//	std::cout << "Hello World!\n"; 
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int A, B;

	cin >> A >> B;
	if (A < 10 && B < 10)
		cout << A * B << endl;
	else
		cout << -1 << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
bool can[101][101][7][7][7];

char A[101][101];
int H, W;

bool vis[101][101][7][7][7];
void solve() {
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
		}
	}
	queue<array<int,5>>que;
	que.push({ 0,0,6,2,3 });
	vis[0][0][6][2][3] = true;
	while (!que.empty()) {
		array<int, 5>a = que.front();
		que.pop();
		int x = a[0];
		int y = a[1];
		int B = a[2];
		int D = a[3];
		int R = a[4];
		int T = 7 - B;
		int U = 7 - D;
		int L = 7 - R;
		vis[x][y][B][D][R] = true;
		//D
		if (x == H - 1 && y == W - 1) {
			print("YES"); exit(0);
		}
		if (x + 1 < H) {
			if (D == A[x + 1][y] - '0' && !vis[x + 1][y][D][T][R]) {
				vis[x + 1][y][D][T][R] = true;
				que.push({ x + 1,y,D,T,R });
			}
		}
		if (x - 1 >= 0) {
			if (U == A[x - 1][y] - '0' && !vis[x - 1][y][U][B][R]) {
				vis[x - 1][y][U][B][R] = true;
				que.push({ x - 1,y,U,B,R });
			}
		}
		if (y + 1 < W) {
			if (R == A[x][y + 1] - '0' && !vis[x][y + 1][R][D][T]) {
				vis[x][y + 1][R][D][T] = true;
				que.push({ x,y + 1,R,D,T });
			}
		}
		if (y - 1 >= 0) {
			if (L == A[x][y - 1] - '0' && !vis[x][y - 1][L][D][B]) {
				vis[x][y - 1][L][D][B] = true;
				que.push({ x,y - 1,L,D,B });
			}
		}
	}
	print("NO");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




Measured memory_bytes: 6544
//#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n ; cin >>n;
  vector<ll> a(n);
  ll sum = 0;
  rep(i,n) cin >> a[i];
  sum += abs(a[0]);
  rep(i,n-1) sum += abs(a[i+1]-a[i]);
  sum += abs(a[n-1]);
  if((a[0]>=0&&a[1]>=a[0])||(a[0]<=0&&a[1]<=a[0])){
    cout<<sum<<endl;
  }else if((a[1]>=0&&a[0]>=a[1])||(a[1]<=0&&a[0]<=a[1])){
    cout <<sum-2*abs(a[0]-a[1])<<endl;
  }else{
    cout <<sum-2*abs(a[0])<<endl;
  }
  rep2(i,1,n-1){
    if((a[i-1]<=a[i]&&a[i]<=a[i+1])||(a[i-1]>=a[i]&&a[i]>=a[i+1])){
      cout <<sum<<endl;
    }else if((a[i]<=a[i+1]&&a[i+1]<=a[i-1])||(a[i]>=a[i+1]&&a[i+1]>=a[i-1])){
      cout <<sum-2*abs(a[i]-a[i+1])<<endl;
    }else{
      cout <<sum-2*abs(a[i]-a[i-1])<<endl;
    }
  }
  if((a[n-1]>=0&&a[n-2]>=a[n-1])||(a[n-1]<=0&&a[n-2]<=a[n-1])){
    cout<<sum<<endl;
  }else if((a[n-2]>=0&&a[n-1]>=a[n-2])||(a[n-2]<=0&&a[n-1]<=a[n-2])){
    cout <<sum-2*abs(a[n-1]-a[n-2])<<endl;
  }else{
    cout <<sum-2*abs(a[n-1])<<endl;
  }
  return 0;
}
      
  

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int N;
    
    cin >> N;
    
    int a,b,c,d;
    
    a = N / 1000;                   //千
    
    b = N % 1000 / 100;             //百
    
    c = N % 1000 % 100 / 10;        //十
    
    d = N % 1000 % 100 % 10;        //一
    
    if(a == b && b == c || b == c && c == d){
        
        cout << "Yes" << endl;
        
        
    }else{
        
        cout << "No" << endl;
        
    }
    
    
    
    
    
    
}

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

int main() {
	int cnt1 = 0, cnt2 = 0, n, a;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a);
		if(a & 1) cnt1++;
		else cnt2++;
	}
	if(n != 1 && cnt1 & 1) puts("NO");
	else puts("YES");
	return 0;
}


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

typedef long long LL;

#define REP(i, n) for(LL i = 0; i < (LL)(n); i++)
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL N, X, Y;
    cin >> N >> X >> Y;
    vector<LL> v(N, 0);
    FOR(i, 1, N + 1) {
        FOR(j, i + 1, N + 1) {
            LL dis = min({j - i, abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X)});
            v[dis]++;
        }
    }
    FOR(i, 1, N) {
        cout << v[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		int z = Integer.parseInt(sc.next());
		x -= z;
		int ans = 0;
		while (x > 0) {
			x = x - y - z;
			if (x >= 0) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 22740
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}

void solve(){
	string a, b;
	cin >> a >> b;
	int c, d;
	cin >> c >> d;
	string e;
	cin >> e;
	if (a == e) {
		c--;
	}
	else {
		d--;
	}
	cout << c << " " << d << endl;
}

int main() {
	init();
	solve();
}

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

int main(){
  	string s;
  	cin >> s;
  	bool flag = true;
  	for(int i=0; i<3; i++){
    	if(s[i] == s[i+1]) flag = false;
    }
  	
  	string ans = flag ? "Good" : "Bad";
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main(){
	int a;
	
	cin >> a;
	
	int temp;
	int max = 1;
	
	for(int i=2;a >= i*i;i++){
		for(int j=2;;j++){
			if(pow(i,j) > a){
				temp = pow(i,j-1);
				break;
			}
		}
		if(temp>max){
			max = temp;
		}
	}
	cout << max << endl;
	
	return 0;
}

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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


void go(){
	int n;cin>>n;
	int ans=n%1000;
	if(ans!=0) ans=1000-ans;
	cout << ans;
		
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const long long MOD = 1e9 + 7;
const int N = 4e6 + 6;
long long f[N];

long long power(long long a, long long b) {
    long long x = 1, y = a;
    while (b > 0) {
        if (b & 1) {
            x = (x * y);
            if (x > MOD)
                x %= MOD;
        }

        y = y * y;
        if (y > MOD)
            y %= MOD;

        b >>= 1;
    }
    return x;
}


long long nCr(long long n, long long r) {
    return (f[n] * power(f[r] * f[n - r] % MOD, MOD - 2)) % MOD;
}


int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    f[0] = 1;
    for (int i = 1; i < N; i++)
        f[i] = (f[i - 1] * i) % MOD;


    int n, len;
    string str;
    cin >> n >> str;
    len = SZ(str);

    //TODO : change N
    ll ans = 0;
    ll dp = 1;
    rloop(i, n + len) {
        //[i][len] => [0][0] , (-1,-1) or (-1,0) and first step is down
        if (i < len)break;
        ll cur = power(25, i - len);
        ll down = len - 1, left = i - len;
//        cout << i << " " << cur << " " << down << " " << left << endl;
        ans += nCr(down + left, down) * cur % MOD * dp % MOD;
        dp = dp * 26 % MOD;
        ans %= MOD;
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using CHY72;

namespace CHY72{

    public class PointXY<T>where T:IComparable {
        public T X , Y;
        public bool Flag = false;
        public PointXY(T _X,T _Y) {
            X = _X; Y = _Y;
        }
        public static bool operator ==(PointXY<T> P1, PointXY<T> P2) {
            return (P1.X.CompareTo( P2.X) == 0 && P1.Y.CompareTo (P2.Y) == 0);
        }
        public static bool operator !=(PointXY<T> P1, PointXY<T> P2) {return !(P1 ==P2);}
        public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}
        public override bool Equals(object obj) {
            if (obj == null || this.GetType() != obj.GetType()) {return false;}
            return (this == (PointXY<T>)obj);
        }         

    }

}    

public class Program {
    static bool ReadLine_1(ref int num1, bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str);
        return (Fin0 && num1 == 0);
    }
    static int  ReadLine_1() {
        return  int.Parse(Console.ReadLine());
    }
    static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str.Split(Spliter)[0]);
        num2 = int.Parse(str.Split(Spliter)[1]);
        return (Fin0 && num1 == 0);
    }


    


    static void Main(string[] args) {
        while (true) {
            
            int JewelNum=0;
            if (ReadLine_1(ref JewelNum)) return;
            PointXY<int>[] JewelPos = new PointXY<int>[JewelNum];
            for (int i = 0; i < JewelNum; i++) {
                int x=0, y=0; ReadLine_2(ref x,ref y,' ',false);
                JewelPos[i] = new PointXY<int>(x ,y);
            }
            var MyPos = new PointXY<int>(10,10);
            for (int k = 0; k < JewelNum; k++) {
                if (JewelPos[k] == MyPos) JewelPos[k].Flag = true;
            }         
            
            int QueriNum = ReadLine_1();
            for (int i = 0; i < QueriNum; i++) {
                string str = Console.ReadLine();
                String Direction =str.Split(' ')[0];
                int Go = int.Parse(str.Split(' ')[1]);
                for (int j = 0; j < Go; j++) {
                    if (Direction == "N") {MyPos.Y++;}
                    if (Direction == "E") { MyPos.X++; }
                    if (Direction == "S") { MyPos.Y--; }
                    if (Direction == "W") { MyPos.X--; }
                    for (int k = 0; k < JewelNum; k++) {
                        if (JewelPos[k] == MyPos) JewelPos[k].Flag = true;
                    }
                }
                
            }
            

            

            bool Clear = true;
            for (int i = 0; i < JewelNum; i++) {
                if (!JewelPos[i].Flag) { Clear = false; break; }
            }
            if (Clear) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }
                
        }


    }
}

Measured memory_bytes: 5528
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

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

    vector<int> dp(100010, INT_MAX);
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
        if(i > 1)
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
import Control.Applicative

isInner :: Int -> Int -> Int -> Int -> Int -> Bool
isInner w h x y r
    | x < r || x > w - r || y < r || y > h - r
        = False
        
    | otherwise
        = True
    
solve :: [Int] -> Bool
 
solve input
    = isInner w h x y z where
        w = input !! 0
        h = input !! 1
        x = input !! 2
        y = input !! 3
        z = input !! 4
 
output :: Bool -> String
 
output True
    = "Yes"
    
output False
    = "No"
     
main :: IO ()
     
main
    = do
        input <- map read.words <$> getLine
        putStrLn $ output $ solve input

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    deque<int> card[3];
    rep(i,3){
        string s;cin>>s;
        for(auto c:s)card[i].pb(c-'a');
    }
    int t=0;
    while(1){
        if(card[t].empty()){cout<<"ABC"s[t]<<endl; break;}
        int nt=card[t][0];
        card[t].pop_front();
        t=nt;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  long long ans=0, s=a[0];
  for(int i=0;i<n;i++){
    if(s < a[i]){
      s = a[i];
      ans += a[i] -s;
    }
    else ans += s - a[i];
  }
  cout << ans << endl;
      
}


Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N;
	string S, T;
	cin >> N >> S >> T;
	for(int i = 0; i < N; i++){
		cout << S[i] << T[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define INF 1000000000
typedef pair<int,int> P;
typedef long long int ll;
queue<P> que[2];
char mas[1001][1001];
int cou[1001][1001]={{0}};

int main(){
	int h,w;
	int ans=0;
	cin >> h >> w;
	for(int i=0;i<h;i++){
		scanf("%s",mas[i]);
	}
	for(int i=1;i<h-1;i++){
		for(int j=1;j<w-1;j++){
			for(int k=-1;k<=1;k++){
				for(int o=-1;o<=1;o++){
					int nx = i + k;
					int ny = j + o;
					if(mas[nx][ny]=='.') cou[i][j]++;
				}
			}
			if(mas[i][j]!='.' && cou[i][j]>=mas[i][j]-'0') que[ans].push(P(i,j));
		}
	}
	while(!que[ans%2].empty()){
		while(!que[ans%2].empty()){
			P p = que[ans%2].front(); que[ans%2].pop();
			int x = p.first;
			int y = p.second;
			for(int i=-1;i<=1;i++){
				for(int j=-1;j<=1;j++){
					int nx = x + i;
					int ny = y + j;
					cou[nx][ny]++;
					if(mas[nx][ny]!='.' && cou[nx][ny]==mas[nx][ny]-'0') que[(ans+1)%2].push(P(nx,ny));
				}
			}
		}
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6152
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  map<int, int> mp;
  rep(i, 0, n){
    int a;  cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    if(itr->second >= itr->first) ans += itr->second - itr->first;
    else  ans += itr->second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]

h.sort()

ans = float("inf")

for i in range(0,n-k+1):
    h_max = h[i+k-1]
    h_min = h[i]
    c = h_max - h_min
    if c < ans:
        ans = c
print(ans)

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

typedef long long ll;
const int N = 2000006;

long double a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	
	string s;
	cin>>s;
	int k;
	cin>>k;
	int n = (int)s.size();
	if(k == 1){
		ll ans = (n-1)*9 + s[0]-'0';
		cout<<ans<<endl;
		return 0;
	}
	if(k == 2){
		ll ans = 0;
		for(int i=1;i<n-1;i++){
			ans += 9ll * (i*9);
		}
		
		ans += max(0,(s[0]-'0'-1) * (n-1) * 9);
		
		for(int i=1;i<n;i++){
			if(s[i] != '0'){
				
				ans += s[i]-'0';
				ans += max(0,(n-i-1)*9);
				
				break;
			}
		}
		
		cout<<ans<<endl;
		return 0;
	}
	
	ll ans = 0;
	for(int i=2;i<n-1;i++){
		ans += (i*(i-1))/2 * 9 * 9 * 9;
	}
	ans += max(0,(s[0]-'0'-1) * (n-1) * (n-2) / 2 * 9 * 9);
	for(int i=1;i<n;i++){
		if(s[i] != '0'){
			ans += max(0,(s[i]-'0'-1) * (n-i-1) * 9);
			ans += max(0,(n-i-1)*(n-i-2) / 2 * 9 * 9);
			for(int j=i+1;j<n;j++){
				if(s[j] != '0'){
					
					ans += s[j]-'0';
					ans += max(0,(n-j-1)*9);
					
					break;
				}
			}
			break;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3592
N=int(input())
a = list(map(int,input().split()))
s = set(a)
sl = list(s)
if len(s)==1:
    if sl[0]==0:
        print('Yes')
    else:
        print('No')
elif len(s)==2:
    if N%3==0:
        if sl[0]==0 or sl[1]==0:
            if a.count(0)==N/3:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
elif len(s)==3:
    if N%3==0:
        if sl[0]^sl[1]^sl[2]==0:
            if a.count(sl[0])==N/3 and a.count(sl[1])==N/3:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 14212
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

void move(vector<vector<int>> &stn, int num)
{
	rep(i, num)
	{
		rep(j, 5)
		{
			if (stn[i][j] == 0)
			{
				stn[i][j] = stn[i + 1][j];
				stn[i + 1][j] = 0;
			}
		}
	}
}
int check(vector<vector<int>> &stn, int num)
{
	int poi = 0;
	rep(i, num)
	{
		int tmp = 0;
		rep(j, 3)
		{
			if (stn[i][j] == stn[i][j + 1] && stn[i][j + 1] == stn[i][j + 2])
			{
				tmp += stn[i][j] * 3;
				if (j < 2 && stn[i][j + 2] == stn[i][j + 3])
				{
					if (j == 0 && stn[i][j + 3] == stn[i][j + 4])
					{
						tmp += stn[i][j + 4];
						stn[i][j + 4] = 0;
					}
					tmp += stn[i][j + 3];
					stn[i][j + 3] = 0;
				}
				stn[i][j] = 0, stn[i][j + 1] = 0,	stn[i][j + 2] = 0;
			}
		}
		poi += tmp;
	}
	return poi;
}

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

	int num = 0;
	while (cin >> num && num != 0)
	{
		vector< vector<int> > stn(num + 1, vector<int>(5));
		rep(i, num) { cin >> stn[num - i - 1][0] >> stn[num - i - 1][1] >> stn[num - i - 1][2] >> stn[num - i - 1][3] >> stn[num - i - 1][4]; }
		int ans = 0, tmp = 0;
		rep(i, 10)
		{
			ans += check(stn, num);
			rep(i, 10) { move(stn, num); }
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3272
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int dx[] = {0, 1, 0, 1}, dy[] = {0, 0, 1, 1};
struct P{ int x, y; };
int main()
{
	int w, h;
	while(cin >> w >> h && (w || h))
	{
		vector<vint> field(w, vint(h, 0));
		P s, g;
		cin >> s.x >> s.y >> g.x >> g.y;
		s.x--, s.y--, g.x--, g.y--;

		int n;
		cin >> n;
		rep(i, n)
		{
			int c, d, x, y;
			cin >> c >> d >> x >> y; x--, y--;

			rep(i, 4)
				field[x + dx[i]][y + dy[i]] = c;
			rep(i, 4)
				field[x + dx[i] + 2 * !d][y + dy[i] + 2 * d] = c;
		}

		
		int c = field[s.x][s.y];
		if(!c || !field[g.x][g.y] || field[s.x][s.y] != field[g.x][g.y])
		{
			cout << "NG" << endl;
			continue;
		}

		queue<P> que;
		for(que.push(s); !que.empty(); que.pop())
		{
			P p = que.front();

			int ddx[] = {1, -1, 0, 0}, ddy[] = {0, 0, -1, 1};
			rep(i, 4)
			{
				int nx = p.x + ddx[i], ny = p.y + ddy[i];
				
				if(0 <= nx && nx < w && 0 <= ny && ny < h && field[nx][ny] == c)
				{
					field[nx][ny] = -1;
					P next; next.x = nx, next.y = ny;
					que.push(next);
				}
			}
		}

		cout << (field[g.x][g.y] == -1? "OK" : "NG") << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] str = br.readLine().split(" ");
        int w = Integer.parseInt(str[0]);
        int h = Integer.parseInt(str[1]);
        int x = Integer.parseInt(str[2]);
        int y = Integer.parseInt(str[3]);
        int r = Integer.parseInt(str[4]);
        //System.out.println(w+" "+h+" "+x+" "+y+" "+r);
        if((x>=-100 && x<=100 && y>=-100 && y<=100) && (w>0 && h>0 && r>0 && w<=100 && h<=100 && r<=100)){
            if((x-r<0 || x+r>w) || (y-r<0 || y+r>h)){
                System.out.println("No");
            }else if((x-r>=0 && x+r<=w) || (y-r>=0 && y+r<=h)){
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 16964
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[3];
  for(int i=0;i<3;i++)
  {
    cin>>a[i];
  }
  sort(a,a+3);
  if((a[1]-a[0])==(a[2]-a[1]))
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

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

const int MOD = 1e9 + 7;
const int INF = 1001001001;

map<ll, int> factor(ll n){
    map<ll, int> res;

    for (ll i = 2; i*i <= n; ++i) {
        while(n % i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;

    return res;
}

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

    ll n;
    cin >> n;

    map<ll, int> mp = factor(n);

    for (auto& p : mp) {
        int i = 2;
        while(p.second - i > 0){
            mp[pow(p.first, i)]++;
            p.second -= i;
            i++;
        }
    }

    cout << mp.size() << "\n";

    return 0;
}


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

#define MAX_N 100
#define MAX_V 1000
#define INF 10000000000
ll dp[MAX_N][MAX_V* MAX_N + 1];
//dp[n][v]: n番目までの品物を用いて価値の総和をvとした時の重さの最小値（vとならない場合は十分大きな数INF）
vector<ll> wei(MAX_N), val(MAX_N);
void knapsack(int n, ll v){
    if (v == 0) dp[n][v] = 0;
    else if (n >= 1){
      if (v -  val.at(n)>= 0){
          dp[n][v] = min(dp[n-1][v-val.at(n)] + wei.at(n), dp[n-1][v]);
      }
      else dp[n][v] = dp[n-1][v];
    }
    else{
        if (v == val.at(n)) dp[n][v] = wei.at(n);
        else dp[n][v] = INF;
    }
}

int main(){
    int N, W;cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> wei.at(i) >> val.at(i);
    }
    for (int i = 0; i < N; i++){
        for (ll j = 0; j <= MAX_N * MAX_V; j++)
        {
           knapsack(i, j);
        }
    }
    int res = 0;
    for (ll i = 0; i <= MAX_N * MAX_V; i++)
    {
        if (dp[N-1][i] <= W) res = i;
    }
    cout << res << endl;
}


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


//頭3文字を取り除けばいいんだな
//逆だった
//2秒だけど慣れるとAは全部2秒なんだろうな
int main() {
  string N;
  cin>>N;
  

  

    cout<<"ABC"<<N<<endl;
 
    }

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  int n;
  cin >> n;
  int ans = -n;
  rep(i, n) {
    int a;
    cin >> a;
    ans += a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 2e6+5;
char arr[10][10];

int32_t main(){
   
   speed_cubing
   
   int n;
   cin>>n;

   vector<int> a(n);

   for(int i=0;i<n;i++)
      cin>>a[i];

   sort(a.rbegin(),a.rend());

   int cnt = n-2;

   int sum = a[0];

   int ind = 1;

   while(cnt){
        
        if(cnt>=2)
          cnt-=2,sum+=a[ind]+a[ind];
        else 
          cnt--,sum+=a[ind];

        ind++;
     
   }

   cout<<sum; 
   

   return 0;
}

Measured memory_bytes: 4752
#include <iostream>

int main() {
    int n, k;
    std::string s;
    std::cin >> n >> k >> s;
    for (int i=0; i<n; ++i) {
        if (i+1 == k) {
            std::cout << (s[i] == 'A' ? 'a' : (s[i] == 'B' ? 'b' : 'c'));
        } else {
            std::cout << s[i];
        }
    }
    std::cout << '\n';
    return 0;
}

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

#define int long long

int t;
string num;
int ans;
int cnt;
vector<int> ans_arr;

void dfs(int n, int sum, vector<int> arr) {
  if ( sum > t ) return;  
  if ( n == num.size() ) {
    if ( sum == ans ) {
      cnt++;      
    } else if ( sum > ans ) {
      cnt = 1;
      ans = sum;      
      ans_arr = arr;
    }
    return;    
  }
  int now = 0;
  for ( int i = n; i < (int)num.size(); i++ ) {    
    now *= 10;
    now += num[i]-'0';
    vector<int> nxt_arr = arr;
    nxt_arr.emplace_back(now);    
    dfs(i+1, sum+now, nxt_arr);    
  }
  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while ( cin >> t >> num ) {
    if ( t == 0 && num == "0" ) break;
    ans = -1;
    cnt = 0;

    dfs(0, 0, {});    

    if ( cnt >= 2 ) cout << "rejected" << endl;
    else if ( ans == -1 ) cout << "error" << endl;
    else {
      cout << ans << " ";
      for ( int i = 0; i < (int)ans_arr.size(); i++ ) {
	if ( i ) cout << " ";
	cout << ans_arr[i];
      }
      cout << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define prf pair<ld,ld>
#define vct vector<ll>
#define vpt vector<pr>
#define vcf vector<ld>
#define vpf vector<prf>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)
 
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
 
void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}
 
mat getRzMat(ll m,ll n, ll ini=0){mat mt;mt.assign(m,vector<ll>(n,ini));return mt;}
 
ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}
 
vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, x, y, z;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 1e9+7;
ld epi = 0.00000001;
ll cas=0;

void init(){}

void solve(){
    cin>>n;
    string ans="";
    F(i,n)ans+="ACL";
    prs(ans);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<fixed<<setprecision(10);
    init();
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}
 


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

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}
using namespace std;

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  rep(i, N)
    cin >> p[i];

  int a = 100000;
  int res = 0;
  rep(i, 102) {
    if (include(p, i)) {
      continue;
    }
    int absd = abs(X-i);
    if (absd < a) {
      a = absd;
      res = i;
    } else if (absd == a) {
      res = min(res, i);
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

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

ll intpow(const int &a, const int &n) {
    if (n == 0)
        return 1;
    else if (n & 1)
        return intpow(a * a, n / 2) * a;
    else
        return intpow(a * a, n / 2);
}

signed main() {
    cin >> X;
    auto v = divisor(X);
    for (auto a : v) {
        dump(a);
        A = 0;
        while (intpow(A, 5) - intpow(A - a, 5) > X) {
            A++;
        }
        if (intpow(A, 5) - intpow(A - a, 5) == X) {
            cout << A << " " << A - a << endl;
            return 0;
        }

        A = a;
        while (intpow(A, 5) - intpow(A - a, 5) < X) {
            A++;
        }
        if (intpow(A, 5) - intpow(A - a, 5) == X) {
            cout << A << " " << A - a << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r;
    cin>>r;
    if(r<1200)
    {
        cout<<"ABC";
    }
    else if(r>=1200&&r<2800)
    {
        cout<<"ARC";
    }
    else if(r>=2800)
    {
        cout<<"AGC";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;
const int N=132000;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,son[N][2],a[N],v[N];
vector <pair <LL,LL> > dp[N],tmpL,tmpR,tmp;
LL Min[N],val[N];
LL Limit;
bool cmp1(pair <LL,LL> a,pair <LL,LL> b){
	if (a.first!=b.first)
		return a.first<b.first;
	return a.second<b.second;
}
bool cmp2(pair <LL,LL> a,pair <LL,LL> b){
	if (a.second!=b.second)
		return a.second<b.second;
	return a.first<b.first;
}
void update(vector <pair <LL,LL> > &v){
	if (v.empty())
		return;
	sort(v.begin(),v.end(),cmp2);
	tmp.clear();
	tmp.pb(v[0]);
	for (int i=1;i<v.size();i++)
		if (v[i].second!=v[i-1].second)
			tmp.pb(v[i]);
	sort(tmp.begin(),tmp.end(),cmp1);
	v.clear();
	v.pb(tmp[0]);
	for (int i=1;i<tmp.size();i++)
		if (tmp[i].first!=tmp[i-1].first)
			v.pb(tmp[i]);
}
void solve(int x){
	if (!son[x][0]){
		dp[x].clear();
		dp[x].pb(mp(0LL,0LL));
		return;
	}
	int ls=son[x][0],rs=son[x][1];
	solve(ls+1);
	solve(rs+1);
	tmpL.clear(),tmpR.clear();
	for (auto i : dp[ls+1])
		tmpL.pb(mp(i.first+v[ls],i.second+v[ls]));
	for (auto i : dp[rs+1])
		tmpR.pb(mp(i.first+v[rs],i.second+v[rs]));
	if (tmpL.size()>tmpR.size())
		swap(tmpL,tmpR);
	sort(tmpR.begin(),tmpR.end(),cmp1);
	for (int i=0;i<tmpR.size();i++){
		if (i>0)
			Min[i]=min(Min[i-1],tmpR[i].second);
		else
			Min[i]=tmpR[i].second;
		val[i]=tmpR[i].first;
	}
	dp[x].clear();
	for (int i=0;i<tmpL.size();i++){
		int p=upper_bound(val,val+(int)tmpR.size()
				,Limit-tmpL[i].second)-val-1;
		if (p==-1)
			continue;
		dp[x].pb(mp(tmpL[i].first,Min[p]));
		dp[x].pb(mp(Min[p],tmpL[i].first));
	}
	update(dp[x]);
}
bool check(LL x){
	Limit=x;
	solve(1);
/*	printf("Divide x = %lld ------------------------\n",x);
	for (int i=1;i<=n;i++){
		printf("Node : %d : ",i);
		for (auto j : dp[i])
			printf(" <%lld,%lld> ",j.first,j.second);
		puts("");
	}
	printf("Finished ---------------------------------------\n");*/
	return ((int)dp[1].size())>0;
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		a[i]=read();
		v[i]=read();
		son[a[i]][(bool)son[a[i]][0]]=i;
	}
	LL L=0,R=1LL<<36,mid,ans=R;
	while (L<=R){
		mid=(L+R)>>1;
		if (check(mid))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 31448
#include<iostream>
using namespace std;
int main(){
	int n,a,b=1000000,c=-1000000;
	long long d=0;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>a;
	if(a<b){b=a;}
	if(c<a){c=a;}
	d=d+a;
	}
	cout<<b<<" "<<c<<" "<<d<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>

int hondana_dansuu;
int book_num;
int book_atusa[100];

int is_possible(int width) {
	int now_dansuu;
	int now_width;
	int i;
	now_width=0;now_dansuu=1;
	for(i=0;i<book_num;i++) {
		now_width+=book_atusa[i];
		if(now_width>width) {
			now_width=book_atusa[i];
			if(now_width>width)return 0;
			now_dansuu++;
		}
	}
	return (now_dansuu<=hondana_dansuu)?1:0;
}

int main(void) {
	int i;
	int left,right,mid;
	while(1) {
		scanf("%d%d",&hondana_dansuu,&book_num);
		if(hondana_dansuu==0 && book_num==0)break;
		for(i=0;i<book_num;i++) {
			scanf("%d",&book_atusa[i]);
		}
		left=1;right=1500000;
		while(left<=right) {
			mid=(left+right)/2;
			if(is_possible(mid)) {
				right=mid-1;
			} else {
				left=mid+1;
			}
		}
		printf("%d\n",right+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const ll mod=1e9+7;
ll n;
ll q_pow(ll x,ll y,ll mod){
    ll ans=1;
    while(y){
        if(y&1) ans=ans*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return ans;
}
int main(){
    n=read();
    if(n==1){
        printf("0\n");
        return 0;
    }
    if(n==2){
        printf("2\n");
        return 0;
    }
//  ll ans=n*(n-1)%mod;
//  n-=2;
//  ll x=(2*q_pow(9,n,mod)+q_pow(2,n,mod)-q_pow(8,n,mod)-2+mod)%mod;
//	printf("%lld\n",ans*x%mod);
    printf("%lld\n",(q_pow(10,n,mod)+q_pow(8,n,mod)-2*q_pow(9,n,mod)+2*mod)%mod);
	return 0;
}


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

using namespace std;

int main()
{
	int N, H, W;
	cin >> N >> H >> W;

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int A, B;
		cin >> A >> B;
		if (A >= H && B >= W) {
			++ans;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,I,v,hs=0,ts=0,l,p;
  int h[100],t[100];
  while(1){
    scanf("%d %d",&n,&m);
    ts=0;
    hs=0;
    if(n==0&&m==0) break;
    else {
      for(i=0;i<n;i++){
	scanf("%d",&t[i]);

      }
      for(i=0;i<m;i++){
	scanf("%d",&h[i]);

      }
      for(i=0;i<n;i++){
	l=i;
	for(I=0;I<m;I++){
	  hs=0;
	  ts=0;
	 
	  v=t[l];
	  t[l]=h[I];
	  h[I]=v;
	  for(p=0;p<n;p++){
	    ts+=t[p];
	  }
	  for(p=0;p<m;p++){
	    hs+=h[p];
	  }
	 
	  if(ts==hs) break;
	  else { 
	    v=t[l];
	    t[l]=h[I];
	    h[I]=v;
	  }
	}
	if(ts==hs) break;
	else continue;
      }
    }
    if(ts==hs) printf("%d %d\n",h[I],t[l]);
    else printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 1040
#include <stdio.h>

int main()
{
	int N,tmp,i,j;
	float A[50];
	scanf("%d", &N);
	for (i = 0; i <= N-1; i++) {
		scanf("%f", &A[i]);
	}
	for (i = 0; i <= N - 1; i++) {
		for (j = i + 1; j <= N - 1; j++) {
			if (A[i] > A[j]) {
				tmp = A[i];
				A[i] = A[j];
				A[j] = tmp;
			}
		}
	}
	float sum = A[0];
	for (i = 1; i <= N - 1; i++) {
		sum = (sum + A[i]) / 2;
	}
	printf("%f", sum);
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.System.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S[] = new String[N];
        int T[]=new int[N];
        int total = 0;
        
        for (int i = 0; i < N; i++) {
            S[i] = sc.next();
            T[i] = sc.nextInt();
        }
        int nanban=0;
        String ans = sc.next();
        for (int i = 0; i < N; i++) {
            if (ans.equals(S[i])) {
                nanban = i;
                break;
            }
        }
        for (int i = (nanban + 1); i < N; i++) {
            total += T[i];
        }
        out.print(total);
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

int main() {
  int n;
  int a[200];

  cin >> n;
  for (int i=0; i<n; ++i) cin >> a[i];

  int ans = 0;
  while (true) {
    bool has_odd_num = false;
    for (int i=0; i<n; ++i) {
      if (a[i]%2 != 0) has_odd_num = true;
      a[i] /= 2;
    }
    if (true == has_odd_num) break;
    ++ans;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int INF = 2000000000;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int main(){
	string s; cin >> s;
	cout << s;
	if(s[s.size()-1] == 's'){
		cout << "es" << endl;
	}else cout << "s" << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int n;
char s[N];
int chk(int d){
	int i,j;
	char c='2';
	for(i=n-d+1;i<=d;++i){
		if(c!='2'&&s[i]!=c)return 0;
		c=s[i];
	}
	return 1;		
}
int main(){
	//freopen("aa.in","r",stdin);
	int i,j;
	scanf("%s",s+1);
	n=strlen(s+1);
	int l=2,r=n;
	for(;l<=r;){
		int mid=(l+r)>>1;
		if(chk(mid))l=mid+1;
		else r=mid-1;
	}
	printf("%d",l-1);
	return 0;
}

Measured memory_bytes: 384