akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize ("-O3", "unroll-loops")

constexpr int MAX_N = 200000;
size_t n;
unsigned a[MAX_N], b[MAX_N];

int main() {
    // Input
    scanf("%lu", &n);
    for (size_t i = 0; i < n; ++i) scanf("%u", &a[i]);
    for (size_t i = 0; i < n; ++i) scanf("%u", &b[i]);


    // Solve
    constexpr size_t block_a = 4, block_b = 8192;
    unsigned ans = 0;
    for (size_t i = 0; i + (block_a - 1) < n; i += block_a) {
        for (size_t j = 0; j + (block_b - 1) < n; j += block_b)
            for (size_t k = j; k < j + block_b; ++k) {
                ans ^= (a[i] + b[k]) ^ (a[i + 1] + b[k]);
                ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
            }

        for (size_t j = n & ~(block_b - 1); j < n; ++j) {
            ans ^= (a[i] + b[j]) ^ (a[i + 1] + b[j]);
            ans ^= (a[i + 2] + b[j]) ^ (a[i + 3] + b[j]);
        }
    }

    // rest of iterations
    for (size_t i = n & ~(block_a - 1); i < n; ++i) {
        for (size_t j = 0; j + (block_b - 1) < n; j += block_b)
            for (size_t k = j; k < j + block_b; ++k)
                ans ^= a[i] + b[k];

        for (size_t j = n & ~(block_b - 1); j < n; ++j)
            ans ^= a[i] + b[j];
    }

    // Output
    printf("%u\n", ans);

    return 0;
}

Measured memory_bytes: 5368
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int n, d;
		n = s.nextInt();
		d = s.nextInt();
		int x[][] = new int[n][d];
		for (int j = 0; j < n; j++)
			for (int i = 0; i < d; i++)
				x[j][i] = s.nextInt();
		int cnt2 = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int sum2 = 0;
				for (int k = 0; k < d; k++) {
					int c;
					c = Math.abs(x[i][k] - x[j][k]);
					c *= c;
					sum2 += c;
				}
				int ans = (int) Math.sqrt(sum2);
				double ans2 = Math.sqrt(sum2);
				if (ans == ans2)cnt2++;
			}
		}
		System.out.println(cnt2);
    }
}

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

int n  , x , y , k ;

main( ) {
	cin >> k >> n;
	vector<int> v( n );
	x = 0;
	for(int i=0;i<n;++i){
		cin >> y;
		v[ i ] = abs(x - y);
		x = y;
	}
	v.push_back( k-x + v[ 0 ] );
	cout << k -*max_element(v.begin(),v.end());
}



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

int n,D[25],H[25];

struct node{
    int parent,left,right;
}nodes[25];

int setheight(int r){
    int h1,h2;
    h1=h2=0;
    if(nodes[r].left!=-1)h1=setheight(nodes[r].left)+1;
    if(nodes[r].right!=-1)h2=setheight(nodes[r].right)+1;
    H[r]=max(h1,h2);
    return H[r];
}

void setdepth(int r,int d){
    D[r]=d;
    if(nodes[r].left!=-1)setdepth(nodes[r].left,d+1);
    if(nodes[r].right!=-1)setdepth(nodes[r].right,d+1);
}

void print(){
    int i;
    for(i=0;i<n;i++){
        cout<<"node "<<i<<": ";
        if(nodes[i].parent==-1)cout<<"parent = -1, ";
        else cout<<"parent = "<<nodes[i].parent<<", ";
        if (nodes[i].parent==-1)cout<<"sibling = -1, ";
        else if(nodes[nodes[i].parent].left!=i)
            cout<<"sibling = "<<nodes[nodes[i].parent].left<<", ";
        else
            cout<<"sibling = "<<nodes[nodes[i].parent].right<<", ";
        int degree=0;
        if(nodes[i].left!=-1)degree+=1;
        if(nodes[i].right!=-1)degree+=1;
        cout<<"degree = "<<degree<<", ";
        cout<<"depth = "<<D[i]<<", ";
        cout<<"height = "<<H[i]<<", ";
        if(nodes[i].parent==-1)cout<<"root";
        else if(degree==0)cout<<"leaf";
        else cout<<"internal node";
        cout<<endl;
    }
}

int main()
{
    cin>>n;
    int i,j,r;
    for(i=0;i<n;i++){
        nodes[i].parent=-1;
    }
    for(i=0;i<n;i++){
        int ii;
        cin>>ii;
        int left,right;
        cin>>left>>right;
        nodes[ii].left=left;
        nodes[ii].right=right;
        if(left!=-1)nodes[left].parent=ii;
        if(right!=-1)nodes[right].parent=ii;
    }
    for(i=0;i<n;i++){if(nodes[i].parent==-1)r=i;}
    int rh=setheight(r);
    setdepth(r,0);
    print();
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> vec(3, -1);
  rep(i, m) {
    int d, v;
    cin >> d >> v;
    if (vec[d-1] != -1 && vec[d-1] != v) {
      cout << -1 << endl;
      return 0;
    }
    vec[d-1] = v;
  }
  if (n != 1 && vec[0] == 0) {
    cout << -1 << endl;
    return 0;    
  }
  if (n == 1) {
    int v = vec[0] != -1 ? vec[0] : 0;   
    cout << v << endl;
    return 0;    
  }
  int ans = 0;
  int k = n-1;
  rep(i, n) {
    int v = (vec[i] != -1) ? vec[i] : (i == 0 ? 1 : 0);
    ans += v * pow(10, k);
    k--;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int x, y, z; cin >> x >> y >> z;
	int amari = x % (y + z);

	if(amari == 0 ) cout << x / (y + z) - 1<< endl;
	else
	{
		if (amari < z) cout << x / (y + z) - 1 << endl;
		else cout << x / (y + z) << endl;
	}
}

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

int N,D,X;
int P[11][11];
int dp[11][11][100010];

int main(){
    cin >> N >> D >> X;
    for(int i=1;i<=D;i++){
        for(int j=1;j<=N;j++){
            cin >> P[i][j];
        }
    }
    int value = X;
    int ans = value;
    for(int d=1;d<D;d++){
        for(int i=1;i<=N;i++){
            for(int j=0;j<=value;j++){
                if(j-P[d][i]>=0) dp[d][i][j] = max({dp[d][i][j],dp[d][i-1][j],dp[d][i-1][j-P[d][i]]+P[d+1][i],dp[d][i][j-P[d][i]]+P[d+1][i]});
                else dp[d][i][j] = max(dp[d][i][j],dp[d][i-1][j]);
            }
        }
        int res = 0;
        for(int j=0;j<=value;j++) res = max(res,dp[d][N][j]+value-j);
        value = res;
        ans = max(ans,value);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4916
import sys
n, q = map(int, input().split())
queue = [[label, int(num)] for label, num in map(lambda line: line.strip().split(), sys.stdin.readlines())] 
i = 0
time = 0
while len(queue) > 0:
    i = i % len(queue)
    time += q
    queue[i][1] -= q
    if queue[i][1] <= 0:
        time += queue[i][1]
        print("{} {}".format(queue[i][0], time))
        queue.pop(i)
        i -= 1
    i += 1


Measured memory_bytes: 16224
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    //今から文字入力
    //xが入力されたらcase i: xとして出力する
    //x=0ならプログラム終了する
    int i=1;
    while(1)
    {
        int x;
        cin>>x;
        if(x==0) break;
        cout<<"Case "<<i<<": "<<x<<endl;
        i++;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>

using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int pre=0;
    ll ans=0;
    for(int i=1; i<=n; i++){
        int x;
        cin>>x;
        if(x<pre)ans+=pre-x,x=pre;
        pre=x;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3188
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<pair<int,int>> G[1000000];
vector<int> color(1000000,0);

void dfs(int startpoint, int frompoint, int fromcolor, int maxjisuu){

    for(pair<int,int> i : G[startpoint]){
        if(i.first == frompoint) continue;
        color[i.second] = (fromcolor+=1) % maxjisuu;
        dfs(i.first, startpoint, color[i.second], maxjisuu);
    }
}

int main(void){

    int N; cin>>N;

    for (int i = 1; i <= N-1; ++i) {
        int a,b; cin>>a>>b;
        G[a].push_back(make_pair(b,i));
        G[b].push_back(make_pair(a,i));
    }
    int maxjisuu = 0;
    for (int i = 0; i <= N; ++i) {
        maxjisuu = max(maxjisuu, (int)G[i].size());
    }
    cout<<maxjisuu<<endl;

    dfs(1,0,0,maxjisuu);

    for (int i = 1; i <= N-1; ++i) {
        cout<<color[i]+1<<endl;
    }
}

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        var p = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var sum = p.Take(K).Sum();
        var max = sum;
        Console.Error.WriteLine(sum);
        for (int left = 0, right = K; right < N; left++, right++)
        {
            sum += p[right] - p[left];
            max = Math.Max(sum, max);
        }

        // ave = (1+p)/2
        var expect = (max + K) / (double)2;
        Console.WriteLine(expect);
    }
}

Measured memory_bytes: 34524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;

int n, m, p, y;
int before[N];

map<pair<int, int>, int> order;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    
    vector<pair<int, int>> a(m);
    for (int i = 0; i < m; i++) {
		cin >> p >> y;
		a[i] = {p, y};
		order[{p, y}] = i;
	}
	sort(a.begin(), a.end());
	
	vector<string> ans(m);
	
	for (int i = 0; i < m; i++) {
		string pre, id;
		pre = to_string(a[i].first);
		before[a[i].first]++;
		id = to_string(before[a[i].first]);
		while (pre.size() < 6) pre = '0' + pre;
		while (id.size() < 6) id = '0' + id;
		string fin = pre + id;
		ans[order[{a[i].first, a[i].second}]] = fin;
	}
	
	for (auto s : ans) cout << s << "\n";
    return 0;
}


Measured memory_bytes: 14464
def merge(A, left, mid, right):
	global count

	L = A[left:mid] + [1000000001]
	R = A[mid:right] + [1000000001]

	i = j = 0
	for k in range(left, right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
	count += right - left

def m_Sort(A, left, right):
	if left + 1 < right:
		mid = (left + right) // 2
		m_Sort(A, left, mid)
		m_Sort(A, mid, right)
		merge(A, left, mid, right)

if __name__ == '__main__':
	n = int(input())
	A = list(map(int, input().split()))
	count = 0
	m_Sort(A, 0, n)
	print(*A)
print(count)



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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    st s;
    cin >> s;
    st ans;
    for(ll i = 0; i < s.size(); i += 2) ans += s.at(i);
    cout << ans << endl;
}

Measured memory_bytes: 512
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
    [n] <- readInt
    a   <- readInt
    print $ solve n a

solve n a = a' !! 0 * a' !! 1
  where
    a' = (\x -> x ++ [0, 0, 0]) $ concatMap
        (\(a, b) -> replicate b a)
        ( map (\(a, b) -> (a, b `div` 2))
        $ filter (\x -> snd x > 1)
        $ map (\x -> (head x, length x))
        $ group
        $ sortOn Down a
        )


Measured memory_bytes: 25852
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


double dot(Point a, Point b){
  return (a.real()*b.real() + a.imag()*b.imag());
}
double cross(Point a, Point b){
  return (a.real()*b.imag() - a.imag()*b.real());
}
double to_rad(double deg){return (deg/180*M_PI);}
double to_deg(double rad){return (rad/M_PI*180);}


double get_area(Point a, Point b, Point c){
  return abs(cross(b-a, c-a))/2;
}

signed main(){
  vector<Point> vec;
  double x, y;
  while(~scanf("%lf,%lf", &x, &y)){
    if(x == -1.0)break;
    vec.push_back(Point(x, y));
  }
  int n = vec.size();
  double s = 0;
  while(n >= 3){
    stack<int> st;
    for(int i = 0;i < n-2;i+=2){
      s += get_area(vec[i], vec[i+1], vec[i+2]);
      st.push(i+1);
    }
    while(!st.empty()){vec.erase(vec.begin()+st.top());st.pop();}
    n = vec.size();
    // cout << vec << endl;
  }
  printf("%.8lf\n", s);
	return 0;
}

/*
0.0,0.0
0.0,1.0
1.0,1.0
2.0,0.0
1.0,-1.0
-1,-1
*/







Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a>=b && a>=c) cout<<a*10+b+c<<endl;
    else if(b>=a && b>=c) cout<<b*10+a+c<<endl;
    else if(c>=b && c>=a) cout<<c*10+b+a<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string s;
  int ans=0;
  bool b;
  cin>>s;
  if(s[0]=='B') b=true;
  else b=false;
  rep(i,s.size()){
    if(b && s[i]=='W'){ans++;b=false;}
    else if(!b && s[i]=='B'){ans++;b=true;}
  }
  cout<<ans<<endl;
  return 0;
}


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

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

using namespace std;

signed main()
{
    int N, M;
    cin >> N >> M;

    int ans = (1900 * M + 100 * (N - M)) * pow(2, M);
    cout << ans << endl;

    return 0;
}

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

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

    for ( int i = 3 ; i <= n ; i++ ){
      	int x = i;
        if ( x % 3 == 0 ){
            cout << " " << i;
            continue;
        }
      	bool judge = true;
      	while(judge){
        	if ( x % 10 == 3 ){
				cout << " " << i;
          		break;
        	}
			else{
              x /= 10;
              if ( x == 0 ) judge = false;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 100010;

LL f[N][4], c[N], a[N];
char op[2];

int main()
{
	int n;
	scanf("%d", &n);
	Rep(i, n) {
		if (i != 1) scanf("%s", op);
		if (i == 1 || op[0] == '+') c[i] = 1;
		else c[i] = -1;
		scanf("%lld", &a[i]);
	}
	Rep0(i, n) Rep0(j, 2) f[i][j] = -1e18;
	f[0][0] = 0;
	Rep0(i, n) Rep0(j, 2){
		LL tt = j == 1 ? -1 : 1;
		if (j) {
			f[i + 1][j - 1] = max(f[i + 1][j - 1], f[i][j] - tt * c[i + 1] * a[i + 1]);
			if (c[i + 1] == -1) f[i + 1][j] = max(f[i + 1][j], f[i][j] + tt * a[i + 1]);
		}
		if (c[i + 1] == -1)
			f[i + 1][j + 1] = max(f[i + 1][j + 1], f[i][j] + tt * c[i + 1] * a[i + 1]);
		f[i + 1][j] = max(f[i + 1][j], f[i][j] + tt * c[i + 1] * a[i + 1]);
	}
	printf("%lld\n", max(f[n][0], max(f[n][1], f[n][2])));
	
	return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input_(R"(
atcoderandatcodeer
5
)");
#define cin input_
#endif

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

	set<string> kyu;

	int length = s.size();

	for (int i=1; i<=length; i++)
	{
		for (int j=0; j<length; j++)
		{
			kyu.insert(s.substr(j,i));

			if (j+i > length)
				break;
		}

		if (i > 5)
			break;
	}

	int count=0;

	for (auto h = kyu.begin(); h != kyu.end(); h++)
	{
		count++;
		if (count == k)
		{
			cout << *h << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll d(ll a, ll x) {
	if (a < 0) { return 0; }
	return a / x +1;
}

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

	cout << d(b, x) - d(a - 1, x);

	system("PAUSE");
}

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

int main() {
	string S;

	cin >> S;

	int h = atoi( S.substr( 0, 2 ).c_str() );
	int l = atoi( S.substr( 2, 2 ).c_str() );
	string ans = "NA";
	if( 0 < h && h <= 12 ) {
		if( 0 < l && l <= 12 ) {
			ans = "AMBIGUOUS";
		}
		else if( 0 <= l && l <= 99 ) {
			ans = "MMYY";
		}
	}
	else if( 0 < l && l <= 12 ) {
		if( 0 <= h && h <= 99 ) {
			ans = "YYMM";
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define longlongvector vector<long long> 
#define intvector vector<int> 
#define size size()
using namespace std;

int n, m, k;



int main()
{
	double r; 
	cin >> r; 


	cout << fixed << setprecision(4) <<  2.0 * 3.14159 * r << endl;
//	return 0;
	system("pause");
}

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

int main(){
int n,k;
  cin>>n>>k;
   vector<int> h(n);
  for(int i=0;i<n;i++){
  cin>>h[i];
  }
  vector<ll> dp(n,INT_MAX);
  dp[0]=0;
  
  for(int i=1;i<n;i++){
    //cout<<i<<" ";
      for(int j=1;j<=k && j<=i;j++){
        dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]) );
       // cout<<dp[i-j] +abs(h[i]-h[i-j])<<" ";
      }
     //cout<<dp[i]<<"\n"; 
  }
 
  cout<<dp[n-1]<<"\n";
  return 0;
}

Measured memory_bytes: 4560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int ans=0,l=s.length();
  rep(i,l/2){
    if(s[i]!=s[l-1-i])ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    fast

    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])cnt++;
    }
    cout<<cnt;




	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/


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

int main(){
	long long n;
    cin >> n;
    
	string ans = "";

    while (n > 0){
       n--;
       ans += (char)('a' + n % 26);
       n /= 26;
    }
    
	for (int i=ans.size()-1; i>=0; i--)
	   cout << ans[i];
    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
char s[2010];
char ans[4010];
int n,k;
int l,r,lp,rp;
struct Node{
	int l,s; //least,step
	void add(const Node&b){
		if(b.l+2<l)l=b.l+2,s=b.s;
		else if(b.l+2==l)s=min(s+b.s,k+1);
	}
}dp[2010][2010];
void read(){
	scanf("%s",s);
	cin>>k;
	n=strlen(s);
}
void init(){
	for(int i=0;i<n;i++)dp[i][i].l=dp[i][i].s=1;
	for(int i=1;i<=n;i++)dp[i][i-1].s=1;
	for(int i=1;i<n;i++)
		for(int j=0;j+i<n;j++){
			dp[j][j+i].l=INF;
			if(s[j]==s[j+i])dp[j][j+i].add(dp[j+1][j+i-1]);
			else{
				dp[j][j+i].add(dp[j+1][j+i]);
				dp[j][j+i].add(dp[j][j+i-1]);
			}
		}
}
void solve(){
	if(dp[0][n-1].s<k){
		puts("NONE");
		return;
	}
	r=n-1,rp=dp[0][n-1].l-1;
	while(l<=r){
		if(s[l]==s[r]){
			ans[lp++]=ans[rp--]=s[l];
			l++,r--;
		}else if(s[l]<s[r]){
			if(dp[l+1][r].l+2==dp[l][r].l)
				if(dp[l+1][r].s<k){
					k-=dp[l+1][r].s;
					ans[lp++]=ans[rp--]=s[r--];
				}else ans[lp++]=ans[rp--]=s[l++];
			else ans[lp++]=ans[rp--]=s[r--];
		}else
			if(dp[l][r-1].l+2==dp[l][r].l)
				if(dp[l][r-1].s<k){
					k-=dp[l][r-1].s;
					ans[lp++]=ans[rp--]=s[l++];
				}else ans[lp++]=ans[rp--]=s[r--];
			else ans[lp++]=ans[rp--]=s[l++];
	}
	cout<<ans<<endl;
}
signed main(){
	read();
	init();
	solve();
	return 0;
}



Measured memory_bytes: 42012
public class Main {
  public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        String[] s = new String[h];
        for (int i = 0; i < h; i++) {
           s[i] = scanner.next();
        }
        for (int i = 0; i < h; i++) {
            boolean isUe = (i - 1) >= 0;
            boolean isShita = (i+1) < h;
            StringBuilder builder = new StringBuilder();
            for (int j = 0; j < w; j++) {
               if (s[i].charAt(j) == '#') {
                 builder.append("#");
                 continue;
               }
            int count = 0;
              boolean isHidari = ((j-1) >= 0);
              boolean isMigi = (j+1) < w;
              if (isUe) {
                 if (isHidari && s[i - 1].charAt(j - 1) == '#') { count++; };
                 if (s[i-1].charAt(j) == '#') { count++; };
                 if (isMigi && s[i - 1].charAt(j + 1) == '#') { count++; }
              }
                 if (isHidari && s[i].charAt(j - 1) == '#') { count++; }
                 if (isMigi && s[i].charAt(j + 1) == '#') { count++; }
              if (isShita) {
                 if (isHidari && s[i + 1].charAt(j - 1) == '#') { count++; }
                 if (s[i+1].charAt(j) == '#') { count++; }
                 if (isMigi && s[i + 1].charAt(j + 1) == '#') { count++; }
              }
            builder.append(count);
            }
        System.out.println(builder.toString());
        }
 }

}


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

ll g(ll a){
  if(a%2==1) {
    ll pair = a / 2;
    if(pair%2==0){
      return 1;
    }else{
      return 0;
    }
  }
  else {
    ll pair = (a-1) / 2;
    if(pair%2==0){
      return (1ll^a);
    }else{
      return (a);
    }
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll a,b;cin>>a>>b;
  if(!b) cout<<0<<endl;
  else if(a>=2)cout<< (g(a-1)^g(b)) <<endl;
  else cout<<g(b)<<endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
int main()
{
    zzz;
    int n; string s;
    cin>>n>>s;
    cout<<(n>=3200? s: "red");
}


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

typedef long long ll;
ll N;
vector<ll> A;

int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  vector<ll> b = A;
  sort(b.begin(), b.end(), greater<ll>());
  for (ll i = 0; i < N; ++i) {
    cout << (A[i] == b[0] ? b[1] : b[0]) << endl;
  }
  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string O,E,ans="";

  cin >> O >> E;

  if(O.size()==E.size()){
    for(int i=0;i<O.size();i++){
      ans+=O.at(i);
      ans+=E.at(i);
    }
  }

  else{
    for(int i=0;i<E.size();i++){
      ans+=O.at(i);
      ans+=E.at(i);
    }

    ans+=O.at(O.size()-1);

  }
  
  
  cout << ans << endl;
  
  return 0;
}//地味にマイナスにも対応できるからa>b>cにも対応可能

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){

    int N; cin >> N;
    vector<int> L(N);
    rep(i,N) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    for (int i = 0; i < N; i++){
        for (int j = i + 1; j < N; j++){
            int ab = L[i] + L[j];
            int ng = N;
            int ok = -1;
            while(abs(ok-ng)>1){
                int mid = (ok+ng) / 2;
                if (L[mid] < ab) ok = mid;
                else ng = mid;
            }
            int count = ok - j;
            if (count > 0) ans += count;
        }
    }
    cout << ans << endl;

}

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

int n;
string s;
vector<int> v, w;
int ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> s;
	for(auto i:s){
		v.push_back(i=='.'?1:0);
		w.push_back(i=='#'?1:0);
	}
	for(int i=n-2; i>=0; --i) v[i] += v[i+1];
	for(int i=1; i<n; ++i) w[i] += w[i-1];
	ans = min(v[0], w[n-1]);
	for(int i=0; i<n-1; ++i) ans = min(ans, w[i]+v[i+1]);
	cout << ans << "\n";
}

Measured memory_bytes: 2448
# 2020/07/26
# diverta 2019 Programming Contest - B

# Input
r, g, b, n = map(int,input().split())

ans = 0

# Calc
for ir in range(n+1):
    vr = r * ir 
    if vr > n:
        break

    for ig in range(n+1):
        vg = g * ig 
        if vg + vr > n:
            break
        cb = n - vr - vg
        if cb % b == 0:
            ans = ans + 1

# Output
print(ans)


Measured memory_bytes: 9112
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n,k,m;
    cin >> n >> k >> m;
    int arr[n];
    
    fff(i,n) {
        arr[i]=(-m);
    }
    
    fff(i,m) {
        int x;cin >> x;
        arr[x-1]++;
    }
    
   
    fff(i,n) {
        arr[i]+=k;
        if(arr[i]>0)
        cout << "Yes" << endl;
        else
        cout << "No" << endl;
    }
    
    
	return 0;
    
}

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

int main() {
    int h;
    while (cin >> h, h) {
        vector<vector<int>> field(5, vector<int>(h));
        for (int j = h - 1; j >= 0; j--) {
            for (int i = 0; i < 5; i++) cin >> field[i][j];
        }
        int ans = 0;
        bool update = true;
        while (update) {
            update = false;
            // check
            vector<vector<int>> alive(5, vector<int>(h, 1));
            vector<vector<int>> v_idxs = {
                {0, 1, 2, 3, 4}, {0, 1, 2, 3}, {1, 2, 3, 4},
                {0, 1, 2}, {1, 2, 3}, {2, 3, 4}
            };
            for (int j = 0; j < h; j++) {
                for (int k = 0; k < 6; k++) {
                    auto& idxs = v_idxs[k];
                    int size = idxs.size();
                    bool f = true;
                    for (int i2 = 0; i2 < size - 1; i2++) { // i2, i2 + 1: zip
                        if (field[idxs[i2]][j] + field[idxs[i2 + 1]][j] == 0) {
                            f = false;
                        }
                        f &= field[idxs[i2]][j] == field[idxs[i2 + 1]][j];
                    }
                    if (f) {
                        for (int i: idxs) alive[i][j] = 0, ans += field[i][j];
                        update = true;
                        break;
                    }
                }
            }
            // update
            for (int i = 0; i < 5; i++) {
                int jt = 0;
                for (int j = 0; j < h; j++) if (alive[i][j]) {
                    field[i][jt++] = field[i][j];
                }
                while (jt < h) field[i][jt++] = 0;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,i,j,k,l;
	cin >> n >> k;
	ll h[n+1];
	ll dp[n+1];
	for(i=0;i<n;i++)
	{
		cin >> h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		for(j=2;j<=k;j++)
		{
			if(i-j<0)
			{
				break;
			}
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<LL, LL> LLLL;
typedef pair<LL, int> LLI;

int main(int argc, char *argv[]) {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	--s, --t;
	map<int, LLLL> edges[100000];
	for (int i = 0; i < m; ++i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u, --v;
		edges[u][v] = LLLL(a, b);
		edges[v][u] = LLLL(a, b);
	}

	priority_queue<LLI, vector<LLI> > queue;

	LL mcy[100000];
	fill(mcy, mcy + 100000, -(1LL << 60));
	mcy[s] = 0;
	queue.push(LLI(0, s));
	while (queue.size()) {
		LLI top = queue.top();
		queue.pop();
		LL x = top.first;
		LL node = top.second;
		for (auto kv : edges[node]) {
			int next = kv.first;
			LL y = x - kv.second.first;
			if (y > mcy[next]) {
				mcy[next] = y;
				queue.push(LLI(y, next));
			}
		}
	}

	LL mcs[100000];
	fill(mcs, mcs + 100000, -(1LL << 60));
	mcs[t] = 0;
	queue.push(LLI(0, t));
	while (queue.size()) {
		LLI top = queue.top();
		queue.pop();
		LL x = top.first;
		LL node = top.second;
		for (auto kv : edges[node]) {
			int next = kv.first;
			LL y = x - kv.second.second;
			if (y > mcs[next]) {
				mcs[next] = y;
				queue.push(LLI(y, next));
			}
		}
	}

	vector<LL> ans(n + 1);
	for (int i = n - 1; i >= 0; --i) {
		ans[i] = max(ans[i + 1], 1000000000000000LL + mcy[i] + mcs[i]);
	}
	for (int i = 0; i < n; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 22008
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int N, K;
    cin >> N >> K;
    vector<int> v(N + 1);
    rep(i, N) {
        cin >> v[i + 1];
    }
    int ans = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = i + 1; j <= N + 1; j++) {
            vector<int> vv;
            int x = 0;
            for (int a = 1; a <= i; a++) {
                vv.push_back(v[a]);
                x += v[a];
            }
            for (int a = j; a <= N; a++) {
                vv.push_back(v[a]);
                x += v[a];
            }
            if (vv.size() > K) {
                continue;
            }
            sort(vv.begin(), vv.end());
            for (int a = 0; a < K - vv.size() && a < vv.size(); a++) {
                if (vv[a] < 0)x -= vv[a];
            }
            ans = max(ans, x);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using namespace std;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    long long n,mx=0;
    cin >> n;
    map<string, long long> s;
    rep(i,n){
        string m;
        cin >> m;
        s[m] ++;
    }
    for(auto p : s) mx = max(mx,p.second);
    for(auto p : s){
        if(p.second == mx){
            cout << p.first << endl;
        }
    }
}


Measured memory_bytes: 25216
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100005;
int n,m,a[N],b[N],head[N],adj[N*2],nxt[N*2],c[N],p[N],l,Head[N],Adj[N*2],Nxt[N*2],id[N],i,j,k,fa[N];
ll sum[N],f[N];
int find(int x)
{
	return !fa[x]?x:fa[x]=find(fa[x]);
}
bool cmp(int a,int b)
{
	return c[a]<c[b];
}
void Addedge(int u,int v)
{
	Adj[++l]=v;
	Nxt[l]=Head[u];
	Head[u]=l;
}
void dfs(int x)
{
	int j;
	sum[x]=b[x];
	for(j=Head[x];j;j=Nxt[j])
	{
		dfs(Adj[j]);
		sum[x]+=sum[Adj[j]];
	}
	f[x]=sum[x]+c[x];
	for(j=Head[x];j;j=Nxt[j])
		f[x]=min(f[x],sum[x]-sum[Adj[j]]+max(1ll*c[x],f[Adj[j]]));
}
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
	{
		scanf("%d%d",a+i,b+i);
		c[i]=max(0,a[i]-b[i]);
	}
	for(i=1;i<=m;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
	}
	for(i=1;i<=n;++i)
		p[i]=i;
	sort(p+1,p+1+n,cmp);
	for(i=1;i<=n;++i)
		id[p[i]]=i;
	for(i=1;i<=n;++i)
		for(j=head[p[i]];j;j=nxt[j])
			if(id[adj[j]]<i&&find(adj[j])!=find(p[i]))
			{
				Addedge(p[i],find(adj[j]));
				fa[find(adj[j])]=p[i];
			}
	dfs(p[n]);
	printf("%lld",f[p[n]]);
	return 0;
}


Measured memory_bytes: 10112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		 try {
		 BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		
		 String ln;
		ln = buf.readLine();
		
//       String[] strAry = ln.split(" ");
//       int x = Integer.parseInt(strAry[0]);
//       int y = Integer.parseInt(strAry[1]);
		
       int z = Integer.parseInt(ln);
       int min = z/60;
       int hour = min/60;
       min = min - hour*60;
       int sec = z - hour*3600 - min*60;
       
       System.out.println(hour + ":" + min + ":" +  sec);
			} catch (IOException e) {
				// TODO ????????????????????? catch ????????????
				e.printStackTrace();
			}
    }
}

Measured memory_bytes: 24424
#include<iostream>
#include<complex>
#include<math.h>
using namespace std;
int main(){
	int n,k[20];
	while(true){
		cin>>n;
		if(n==0)
			break;
		int sum=0;
		for(int i=0;i<n;i++){
			cin>>k[i];
			sum+=k[i];
			k[i]*=2;
		}
		int best=1000000;
		int m=pow(2.0,n+0.0);
		for(int i=0;i<m;i++){
			int bit=i;
			int count=0;
			for(int j=0;j<n;j++){
				if(((bit>>(j+1))&1)==1)count+=k[j];}
			int r=abs(count-sum);
			best=min(best,r);
		}
		cout<<best<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    void solve()
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int A = int.Parse(input[1]);
        int B = int.Parse(input[2]);
        if ((A + B) % 2 == 1)
        {
            Console.WriteLine("Borys");
        }
        else
        {
            Console.WriteLine("Alice");
        }
    }

    public static int Main()
    {
        bool loop = false;
#if ES_DEBUG
        loop = true;
#endif
        do
        {
            new Program().solve();
        } while (loop);
        return 0;
    }
}


Measured memory_bytes: 11092
s = input()

q = int(input())
x = []
y = []

flag = 0

for i in range(q):
    li = list(input().split())
    if flag%2 == 0:
        if li[0] == "2":
            if li[1] =="1":
                x.append(li[2])
            else:
                y.append(li[2])
        else:
            flag += 1

    else:
        if li[0] == "2":
            if li[1] =="1":
                y.append(li[2])
            else:
                x.append(li[2])
        else:
            flag += 1

if flag%2 == 0:
    x = x[::-1]
    print("".join(x)+s+"".join(y))

else:
    s = s[::-1]
    y = y[::-1]
    print("".join(y)+s+"".join(x))



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

int main() {

	int n, m; cin >> n >> m;
    vector<vector<int>> s(m, vector<int>(n, -1));
    for (int i = 0; i < m; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int t; cin >> t;
            s[i][j] = --t;
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<bool> onSwitch(n, false);
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                onSwitch[i] = true;
            }
        }
        int lightCnt = 0;
        for (int i = 0; i < m; i++) { // light
            int tmpSwitchOnCnt = 0;
            for (int j = 0; j < n; j++) { // switch
                if (s[i][j] == -1) continue;
                if (onSwitch[s[i][j]]) {
                    tmpSwitchOnCnt++;
                }
            }
            if (tmpSwitchOnCnt % 2 == p[i]) {
                lightCnt++;
            }
        }
        if (lightCnt == m) {
            ans++;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n + 1)]

l, r = 0, a[0] + 1
while True:
    m = (l + r) // 2
    b[0] = m
    for i in range(1, n + 1):
        b[i] = a[i - 1] - b[i - 1]
    if b[0] == b[-1]:
        break
    elif b[0] < b[-1]:
        l = m
    else:
        r = m
print(' '.join(map(lambda x: str(2 * x), b[:-1])))

Measured memory_bytes: 85604
N = gets.to_i
v = gets.split.map(&:to_i).sort!.reverse!

loop do
  vmin = v.pop
  vmin2 = v.pop
  vmin_n = (vmin + vmin2)/2.0
  v << vmin_n
  v.sort!.reverse!
  break if v.size == 1
end

puts v.pop

Measured memory_bytes: 1788
#include<stdio.h>
int main(void) {
  char a[1001],  b[1001], temp, sa;
  int i = 0;
  scanf("%s", a);

  while(1){
    if ( a[i] == '\0') {
      b[i] = '\0';
      break;
    } 
    temp = a[i];
    temp = temp - 3;
    if(temp < 'A' ){;
      temp = temp + 26;
    }
    b[i] = temp;
    i++;
  }
  printf("%s\n", b);
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

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

int main() {
    string n;
    cin >> n;
    
    if (n[0] == n[1] && n[1] == n[2]) cout << "Yes" << endl;
    else if (n[2] == n[3] && n[1] == n[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
bool a[N];
int h[N],n,m,u,v,ans;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)  cin>>h[i];
    for(int i=0;i<m;i++)
	{
        cin>>u>>v;
        if(h[u]<=h[v]) a[u]=true;
        if(h[v]<=h[u]) a[v]=true;
    }
    for(int i=1;i<=n;i++)
        if(!a[i]) ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4220
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static final int N_MAX=40;
	private static final int AB_MAX=10;
	private static final int INF=1000000;
	private static int[] a=new int[N_MAX];
	private static int[] b=new int[N_MAX];
	private static int[] c=new int[N_MAX];
	private static int[][][] dp=new int[N_MAX+1][N_MAX*AB_MAX+1][N_MAX*AB_MAX+1];
	public static void main(String[] args){
		int n,ma,mb;
		n=sc.nextInt();
		ma=sc.nextInt();
		mb=sc.nextInt();
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			c[i]=sc.nextInt();		
		}
		for(int i=0;i<=n;i++){
			for(int ca=0;ca<=N_MAX*AB_MAX;ca++){
				for(int cb=0;cb<=N_MAX*AB_MAX;cb++){
					dp[i][ca][cb]=INF;
				}
			}
		}
		dp[0][0][0]=0;
		for(int i=0;i<n;i++){
			for(int ca=0;ca<=N_MAX*AB_MAX;ca++){
				for(int cb=0;cb<=N_MAX*AB_MAX;cb++){
					if(dp[i][ca][cb]==INF) continue;
					dp[i+1][ca][cb]=Math.min(dp[i][ca][cb],dp[i+1][ca][cb]);
					dp[i+1][ca+a[i]][cb+b[i]]=Math.min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i]);
				}
			}
		}
		int ans=INF;
		for(int ca=1;ca<=N_MAX*AB_MAX;ca++){
			for(int cb=1;cb<=N_MAX*AB_MAX;cb++){
				if(ca*mb==cb*ma) ans=Math.min(ans,dp[n][ca][cb]);
			}
		}
		if(ans==INF) ans=-1;
		System.out.println(ans);
	}	
}

Measured memory_bytes: 55508
//https://atcoder.jp/contests/arc076/tasks/arc076_d

#include<bits/stdc++.h>
const int N = 2e5 + 5;
const int inf = 1e9;
using namespace std;

int n, m, l[N], r[N], p[N], it[N << 2], sum[N << 2];
int ans;

void init(int i, int l, int r){
    int mid = (l + r) >> 1;
}

void update(int i, int l, int r, int id){
    if (l == r){
        if (it[i] == -inf) it[i] = 1 - (m - l + 1);
        else it[i]++;
        sum[i]++;
        return;
    }
    int mid = (l + r) >> 1;
    if (id <= mid) update(i << 1, l, mid, id);
    else update(i << 1 | 1, mid+1, r, id);
    sum[i] = sum[i << 1] + sum[i << 1 | 1];
    it[i] = max(it[i << 1] + sum[i << 1 | 1], it[i << 1 | 1]);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> l[i] >> r[i], p[i] = i;
    sort(p+1, p+1+n, [](int x, int y){return (l[x] < l[y] || (l[x] == l[y] && r[x] > r[y]));});
    for (int i = 0; i < 4 * N; i++) it[i] = -inf;
    ans = max(0, n - m);
    for (int i = 1; i <= n; i++){
        int id = p[i];
        update(1, 1, m + 1, r[id]);
        ans = max(ans, it[1] - l[id]);
    }
    cout << ans;
}


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

int main()
{
  int n; cin >> n;
  vector<int> t(n+1,0);
  vector<P> xy(n+1,make_pair(0,0));
  rep2(i,n){
    int a,b;
    cin >> t[i] >> a >> b;
    xy[i] = make_pair(a,b);
  }
  bool flg = true;
  rep2(i,n){
    int t1 = t[i] - t[i-1];
    int x1 = abs(xy[i].first - xy[i-1].first);
    int y1 = abs(xy[i].second - xy[i-1].second);
    if(t1 < x1+y1) flg = false;
    if((t1-x1-y1)%2!=0) flg = false;    
  }
  
  puts(flg?"Yes":"No");
  return 0;
}

/*
Ctrl+@
g++ a.cpp
./a.out
*/


Measured memory_bytes: 4092
MOD = 10**9 + 7


def main():
    def prime_factorize(n):
        res = []
        for i in range(2, n+1):
            if i*i > n:
                break
            if n % i != 0:
                continue
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append((i, ex))
        if n != 1:
            res.append((n, 1))
        return res

    c = [0]*1001
    N = int(input())
    for p in range(2, N+1):
        divs = prime_factorize(p)
        for d, v in divs:
            c[d] += v
    ans = 1
    for i in range(2, N+1):
        if c[i] == 0:
            continue
        ans *= (c[i]+1)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71236