akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

ll f(ll a, ll b)
{
   return pow(a,5) - pow(b,5);
}

ll ff(ll a, ll b){
    if(a > 0){
        return a - b;
    }
    else
    {
        if(b > 0) return b -a;
        else return abs(a) -abs(b);
    }
}

int main(void) 
{
    ll x;
    cin >> x;
    int inf = 200;
    
    int L = -inf, R =inf;
    for(int a = 0; a <= inf ; a++){
        int l = -inf, r = inf;
        while(l +1 < r)
        {
            int mid = (l + r)/2;
            ll ret = f(a,mid);
            if(ret == x)
            {
                cout << a << " " << mid << endl;
                return 0;
            }
            else if(ret < x){
                r = mid;
            }
            else{
                l = mid;
            }
        }      
    }
    return 0;
}

Measured memory_bytes: 4024
import math
N, K = list(map(int, input().split()))

def combo(n, k):
    x = math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    return x

for i in range(1,K+1):
    if N-K+1 < i or K-1 < i-1:
        print(0)
    else:
        k = combo(N-K+1,i) * combo(K-1,i-1)
        ans = k%(10**9+7)
        print("%d" %(ans))


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<utility>//swapでaとbの値を入れ替える
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
int max(int a, int b) {
	if (a > b)return a;
	return b;
}


int main() {
	int n, w;
	cin >> n >> w;
	vector<int> a(n), b(n);
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
	}
	vector<vector<ll>> dp(n+1, vector<ll>(w+1,0));
	rep(i, 0, n) {
		rep(j, 0, w+1) {
			if (j - a[i] >= 0)dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - a[i]] + b[i]);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}




Measured memory_bytes: 80256
N = int(input())
M = [0]*N
for i in range(N):
    M[i] = input()

check = 0
for i in range(N-1):
    if M[i][-1] != M[i+1][0]:
        check = 1

if len(M) != len(set(M)):
    check = 1
if check == 1:
    print("No")
else :
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int sum, ans=1e9;
    int arr[5]={0, 1, 2, 3, 4};
    int input[5];
    for (int i=0; i<5; i++) cin>>input[i];
    do {
        sum=0;
        for (int i=0; i<5; i++){
            if (sum%10!=0 && sum!=0) sum=((sum/10)+1)*10;
            sum+=input[arr[i]];
        }
        ans=min(ans, sum);
    } while (next_permutation(arr, arr+5));
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int n,m;
int a[200001],b[200001];
int x[200001];
bool f=false;
int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    if(a[i]==1)x[b[i]]++;
    else if(a[i]==n)x[b[i]]++;
    else if(b[i]==n)x[a[i]]++;
  }
  for(int i=1;i<=n;i++){
    if(x[i]==2 && i!=1 && i!=n)f=true;
  }
  if(f)cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 2560
import Control.Applicative
import Data.List

inputs = fmap (read :: String -> Int) . words <$> getLine
input = (read :: String -> Int) <$> getLine

main = do
    nm <- inputs
    let n = nm !! 0
    let m = nm !! 1
    if n /= 0 then
        do
            xs <- sequence [input | x <- [1..(n+m)]]
            let as = take n xs
            let bs = map ((-1) *) $ drop n xs
            let d  = sum as + sum bs
            let ans = filter (\x -> d == 2 * (sum x)) $ sequence [as, bs]
            if null ans then
                        print (-1)
                        else
                        putStrLn $ (\x -> (show $ x !! 0) ++ " " ++ (show $ -x !! 1)) $ head ans
            main
    else do return ()

Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a)<=d) cout <<"Yes"<< endl;
    else if (abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;
int dp[100000],n,h[100000],k;
int main()
{

ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

cin>>n>>k;
for(int i=0;i<n;i++)
{
	cin>>h[i];
}

dp[0]=0;
dp[1]=abs(h[1]-h[0]);

for(int i=2;i<n;i++){
	dp[i]=INT_MAX;
	for(int j=i-1;j>=i-k;j--)
	{
		if(j>=0)
		{
			dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
		}
		else break;
	}
	
	
}
cout<<dp[n-1];

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, cnt[5];
double dp[364][364][364];
double solve(int one, int two, int three) {
	if (!three && !two && !one)return 0.0;
	if (dp[one][two][three] > 0)return dp[one][two][three];
	double res = 1.;
	if (one) {
		res += 1. * one / n * solve(one - 1, two, three);
	}
	if (two) {
		res += 1. * two / n * solve(one + 1, two - 1, three);
	}
	if (three) {
		res += 1. * three / n * solve(one, two + 1, three - 1);
	}
	res *= 1. * n / (one + two + three);
	dp[one][two][three] = res;
	return res;
}
signed main() {
	cin >> n;
	rep(i, n) {
		int a; cin >> a; cnt[a]++;
	}
	printf("%.12lf\n", solve(cnt[1], cnt[2], cnt[3]));
}

Measured memory_bytes: 311296
from collections import defaultdict

n, m = map(int, input().split())
ps = []
p = []
s = []
for i in range(m):
    p_, s_ = input().split()
    p.append(int(p_))
    s.append(str(s_))

ac = 0
pen = 0
d = defaultdict(int)
for p_, s_ in zip(p, s):
    if s_ == "WA":
        if d[p_] != -1:
            d[p_] += 1
        else:
            pass
    else:
        if d[p_] == -1:
            pass
        else:
            pen += d[p_]
            d[p_] = -1
            ac += 1
print(ac, pen)


Measured memory_bytes: 22976
#include <bits/stdc++.h>
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)

int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    A[0] = 0;
    FOR(i,1,N){
        int tmp;
        cin >> tmp;
        tmp--;
        A[tmp]++;
    }
    REP(i,N) cout << A[i] << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n + 1);
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	vector<int> flag(n + 1, 1);
	int num = n;
	for (int i = 0; i < k; i++) {
		vector<int> b(n + 2);

		for (int j = 1; j <= n; j++) {
			b[max(0, j - a[j])]++;
			b[min(n + 1, j + a[j] + 1)]--;
		}

		a[0] = b[0];
		for (int j = 1; j <= n; j++) {
			a[j] = a[j - 1] + b[j];
			if (flag[j] && a[j] == n) {
				flag[j] = 0;
				num--;
			}
		}

		if (!num) {
			break;
		}
	}

	for (int i = 1; i <= n; i++) {
		cout << a[i] << (n == i ? "\n" : " ");
	}

	return 0;
}

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

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin >> N){
    vector<string> mark(N);
    REP(i, N) cin >> mark[i];
    vector<bool> re(N);
    REP(i, N) if(mark[i][mark[i].size() - 1] == 'v'){
      re[i] = true;
      mark[i] = mark[i].substr(0, mark[i].size() - 1);
    }
    vector<string> name(N);
    vector<int> val(N);
    REP(i, N) if(mark[i] != "-" && mark[i] != ""){
      REP(j, mark[i].size())if(isdigit(mark[i][j])){
        name[i] = mark[i].substr(0, j);
        val[i] = atoi(mark[i].substr(j).c_str());
        break;
      }
    }
    map<string, vector<int> > indexes;
    map<int, vector<int> > jump;
    vector<bool> used(N);
    vector<int> ans;
    REP(i, N){
      if(val[i] >= 2){
        indexes[name[i]].push_back(i);
        continue;
      }
      if(val[i] == 1){
        jump[i] = indexes[name[i]];
        indexes[name[i]].clear();
      }
      if(re[i]){ continue; }

      stack<int> stk;
      stk.push(i);
      while(!stk.empty()){
        int k = stk.top(); stk.pop();
        if(used[k]) continue;
        ans.push_back(k);
        used[k] = true;
        REP(j, jump[k].size()){
          stk.push(jump[k][j]);
        }
        if(k - 1 >= 0 && re[k - 1]){
          stk.push(k - 1);
        }
      }
    }
    assert(ans.size() == N);
    REP(i, N) cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 4396
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(String).chars().collect::<Vec<_>>();

    let ans = if !(S.contains(&'N') ^ S.contains(&'S')) && !(S.contains(&'W') ^ S.contains(&'E')) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);

}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  if(a>b)swap(a,b);
  int rem=(b-a)%2;
  if (rem == 0) {
    cout<<"Alice"<<endl;
  }else{
    cout<<"Borys"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long LL;

LL maximum(LL a,LL b)
{
    if(a>b)
    {
        return a;
    }
    return b;
}


char a[3003];
char b[3003];
char c[3003];
char d[3003];
char e[3003];
LL ptr=0;


LL dp[3003][3003];
LL cal(LL i,LL j)
{
     if(i<1 || j<1)
        {
            return 0;
        }

        /*if(i==0 && j==0)
        {
            return (a[i]==b[j]);
        }
        else if(i==0)
        {
            
        }*/


    if(dp[i][j]==-1)
    {
       

        if(c[i]==d[j])
        {
            if(dp[i-1][j-1]==-1 && i)
            {
                dp[i-1][j-1]=cal(i-1,j-1);
            }
            //e[ptr++]=c[i];
            dp[i][j]=1+dp[i-1][j-1];
        }
        else
        {
             if(dp[i][j-1]==-1)
            {
                dp[i][j-1]=cal(i,j-1);
            }

             if(dp[i-1][j]==-1)
            {
                dp[i-1][j]=cal(i-1,j);
            }

            dp[i][j]=maximum(dp[i-1][j],dp[i][j-1]);
        }        
    }
    return dp[i][j];
}

int main()
{
    scanf("%s",a);
    scanf("%s",b);
    LL len1=strlen(a);
    LL len2=strlen(b);
    c[0]='@';
    d[0]='&';

    strcat(c,a);
    strcat(d,b);

    //printf("%s\n",c);
    //printf("%s\n",d);

    

    LL i,j,k;
    for(i=0;i<3003;i++)
    {
        e[i]='\0';
        for(j=0;j<3003;j++)
        {
            dp[i][j]=-1;
        }
    }

    LL ans=cal(len1,len2);
    dp[len1][len2]=ans;

    LL x=len1,y=len2;

    while(ans)
    {
        if(dp[x][y]==dp[x-1][y])
        {
            x--;
        }
        else if(dp[x][y]==dp[x][y-1])
        {
            y--;
        }
        else
        {
            e[ptr++]=c[x];
            x--;y--;
            ans--;
        }
        


    }
    
    //printf("%s\n",e);

    for(i=dp[len1][len2]-1;i>=0;i--)
    {
        printf("%c",e[i]);
    }
    //printf("ANSWER IS %lld\n",dp[len1][len2]);
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
                #define ll long long
                #define f   first
                #define s   second
                #define pb          push_back
                #define mod        1000000007
                #define mod1       1000000009
                #define hell        998244353
                #define inf         1000000000000000000LL
                #define pi          3.14159265358979323
                //#define N           100005 
                const int N=200005;
                using namespace std;
                ll n,k,sum,q,res,m,val,ans;
                ll x,y;
                ll xx[]={1,0,-1,0};
                ll yy[]={0,1,0,-1};  
                void solve()    
                {   
                    string a,b,c;
                    cin>>a>>b>>c;
                    int n1=a.size();
                    int n2=b.size();
                    int n3=c.size();
                    if(a[n1-1]==b[0] and b[n2-1]==c[0]) cout<<"YES\n";
                    else cout<<"NO\n";

                }   
                int main()
                {   ios_base::sync_with_stdio(false);
                    cin.tie(0);cout.tie(0);
                    ll t=1; 
                   //cin>>t;
                     for(ll i=1;i<=t;i++)
                        solve();
                }            

Measured memory_bytes: 3636
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        c = bisect.bisect_left(L,a+b)
        ans += c-j-1
print(ans)


Measured memory_bytes: 3188
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (a, b): (f64, f64);
    input!(a, b);
    p(((a + b) / 2.0).ceil());
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> P(n);
	vector<int> Q(n);
	rep(i, n) {
		cin >> P[i];
	}
	rep(i, n)
		cin >> Q[i];
	int perm[10];
	rep(i, n) perm[i] = i;
	vector<int> Ps;
	vector<int> Qs;
	do {
		string lp = "",lq = "";
		rep(i, n) {
			lp += to_string(P[perm[i]]);
			lq += to_string(Q[perm[i]]);
		}
		auto p = stoi(lp);
		auto q = stoi(lq);
		Ps.pb(p);
		Qs.pb(q);
	} while (next_permutation(perm, perm + n));
	sort(ALL(Ps));
	sort(ALL(Qs));
	string sP = "";
	string sQ = "";
	rep(i, n) sP += to_string(P[i]);
	rep(i, n) sQ += to_string(Q[i]);
	auto i1 = find(ALL(Ps),stoi(sP));
	auto a = distance(Ps.begin(), i1);
	auto i2 = find(ALL(Qs),stoi(sQ));
	auto b = distance(Qs.begin(), i2);
	auto ans = abs(a - b);
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; ll M; cin >> N >> M;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  sort(range(A));
  vector<ll> S(N + 1); rep(i, N) S[i + 1] = S[i] + A[i];
  ll l = 0;
  ll r = 200001;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    ll cnt = 0;
    rep(i, N) {
      // A[i] + A[j] >= m
      cnt += A.end() - lower_bound(range(A), m - A[i]);
    }
    if (cnt >= M) {
      l = m;
    } else {
      r = m;
    }
  }
  ll ans = 0;
  rep(i, N) {
    // A[i] > l - A[j]
    int j = upper_bound(range(A), l - A[i]) - A.begin();
    ans += S[N] - S[j];
    ans += (N - j) * A[i];
    M -= N - j;
  }
  rep(i, N) {
    // A[i] + A[j] = l
    ll cnt = upper_bound(range(A), l - A[i]) - lower_bound(range(A), l - A[i]);
    ll tukau = min(M, cnt);
    M -= tukau;
    ans += l * tukau;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
import Control.Applicative
import Data.List
import Control.Monad

data Card = S Int | H Int | C Int | D Int deriving(Show, Eq, Read, Ord)

allCards :: [Card]
allCards = [
             S 1, S 2, S 3, S 4, S 5, S 6, S 7, S 8, S 9, S 10, S 11, S 12, S 13
           , H 1, H 2, H 3, H 4, H 5, H 6, H 7, H 8, H 9, H 10, H 11, H 12, H 13
           , C 1, C 2, C 3, C 4, C 5, C 6, C 7, C 8, C 9, C 10, C 11, C 12, C 13
           , D 1, D 2, D 3, D 4, D 5, D 6, D 7, D 8, D 9, D 10, D 11, D 12, D 13
           ]


findCards :: [Card] -> [Card]
findCards cards = allCards \\ cards

main :: IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  cards <- map (read :: String -> Card) <$> replicateM n getLine
  mapM_ print $ findCards cards

Measured memory_bytes: 4092
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	int ans=0;
	int l,r,d;
	cin>>l>>r>>d;
	for(int i=l;i<=r;++i) {
		ans+=i%d==0;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;
    int ans;
    if(s == "SUN") ans = 7;
    else if(s == "MON") ans = 6;
    else if(s == "TUE") ans = 5;
    else if(s == "WED") ans = 4;
    else if(s == "THU") ans = 3;
    else if(s == "FRI") ans = 2;
    else ans = 1;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

ll t,h,w,dp[1005][1005];
char a[1005][1005];
const int MOD=1e9+7;
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> h >> w;
		for (int i=1; i<=h; i++) {
			for (int j=1; j<=w; j++) {
				cin >> a[i][j];
			}
		}	
	dp[1][1]=1;
	for (int i=1; i<=w; i++) {
		if (a[1][i]=='#') {
			dp[1][i]=0;
			break;
		}
	}
	for (int i=1; i<=h; i++) {
		if (a[i][1]=='#') {
			dp[i][1]=0;
			break;
		}
	}
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			if (a[i][j]=='.' || a[i+1][j]=='.' || a[i][j+1]=='.') {
				if(a[i][j+1]!='#')dp[i][j+1]=(dp[i][j]%MOD+dp[i-1][j+1]%MOD)%MOD;
				if(a[i+1][j]!='#')dp[i+1][j]=(dp[i][j]%MOD+dp[i+1][j-1]%MOD)%MOD;
			}
		}
	}
	
	cout << dp[h][w]%MOD;
}

Measured memory_bytes: 9088
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define eps 1e-9
 
int n,a,b,r,j,f,m;
long long v[55],w;
double ans;

long long ncr (int o,int p)
{
	long long l;
	l=1;
	if (p>o-p) {
	  p=o-p;	
	}
	FOD(i,o,o-p+1) l=l*i/(o-i+1);
	//printf("%d %lld\n",p,l);	
	return l;	
}

int main () {
	scanf("%d %d %d",&n,&a,&b);
	FOE(i,1,n) {
		scanf("%lld",&v[i]);	
	}
	sort(v+1,v+n+1);
	reverse(v+1,v+n+1);
	FOE(i,1,a) {
		ans=ans+v[i];	
	}
	ans=ans/a;
	j=a;
	r=1;
	m=1;
	while ((j>1) and (v[j-1]==v[j])){
		++r;
		--j;
		++m;	
	}
	j=a;
	while ((j<n) and (v[j+1]==v[j])){
		++j;	
		++m;
	}
	
	j=a;
	w=ncr(m,r);
    while ((j<b) and (v[j+1]==v[1])){
    	++j;
    	++r;
    	w+=ncr(m,r);
		//printf("%lld\n",w);	
	}
	printf("%0.6f\n",ans);
	printf("%lld\n",w);
	return 0;	
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
#define Maxn 65000

int n;
long long J[Maxn], p;

int main()
{
    while (scanf("%d", &n) && (n))
    {
        int Sig=0;
        for (int i=1; i<=n; i++) { scanf("%lld", &p); Sig += p; }
        for (int i=1; i<n; i++) { scanf("%lld", &J[i]); Sig += J[i]; }
        sort(J+1, J+n);
        
        long long Res=Sig, Leap=1;
        for (int i=1; i<n; i++)
        {
            long long tmp = (Sig - J[i]) * (Leap + 1);
            if (tmp > Res)
            {
                Res = tmp;
                Sig -= J[i];
                Leap++;
            }
        }
        printf("%lld\n", Res);
    }
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,a,b;
  	while(1){
  	cin>>H>>W;
  	 if ( H==0&&W==0){
 		break;
 	}
 		for ( int a=0 ; a<H ; a++ ){
 			for ( int b=0 ; b<W ; b++){
 				cout << "#";
 				}
 				cout<<endl;
 				 }
	cout<<endl;
 				 
 	}return 0;
}


Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	long long a, b, x;
	cin >> a >> b >> x;
	long long ans = ( b / x ) - ( max( a - 1, 0LL ) / x ) + ( ( a == 0 ) ? 1 : 0 );
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

abc=0

for i in range(n):
	if(a[i]==0):
		abc=1
		break
if(abc==1):
	print(0)
else:
	ans=1
	for i in range(n):
		ans*=a[i]
		if(ans>1000000000000000000):
			break

	if(ans>1000000000000000000):
		print(-1)
	else:
		print(ans)


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

const int MAX = 8005;
int kx[MAX];
int ky[MAX];

int main() {
	// freopen("a.in", "r", stdin);
	string s; cin >> s;
	int x, y; cin >> x >> y;
	bool r = true; // right
	s += 'T';
	int n = s.length();
	bool seent = false;
	vector<int> dx, dy;
	int ct = 0;
	int fixedx = 0;
	for (int i=0; i<n; i++) {
		if (s[i] == 'T') { 
			if (!seent) { seent = true; fixedx = ct; ct = 0; r = !r; continue; }
			if (r) { dx.push_back(ct); }
			else { dy.push_back(ct); }
			ct = 0; r = !r;
		}
		else {
			ct++;
		}
	}
	int sumx = 0; for (int i : dx) { sumx += i; }
	int sumy = 0; for (int i : dy) { sumy += i; }
	kx[0] = true;
	for (int i : dx) {
		for (int j = MAX-1-i; ~j; j--) {
			if (kx[j]) { kx[j+i] = true; }
		}
	}
	ky[0] = true;
	for (int i : dy) {
		for (int j = MAX-1-i; ~j; j--) {
			if (ky[j]) { ky[j+i] = true; }
		}
	}
	kx[0] = true; ky[0] = true;
	bool okx = false, oky = false;
	for (int i=0; i<MAX; i++) {
		if (kx[i]) {
			int j = sumx - i;
			if (fixedx + i-j == x) { okx = true; }
		}
	}
	for (int i=0; i<MAX; i++) {
		if (ky[i]) {
			int j = sumy - i;
			if (i-j == y) { oky = true; }
		}
	}
	cout << ((okx && oky)?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int>L(N);
  for(int i=0; i<N; i++){
    cin >> L[i];
  }
  
  sort(L.begin(),L.end());
  
  int sum=0;
  
  for(int i=0; i<N-1; i++){
    sum += L[i];
  }
  
  if(sum>L[N-1]) cout << "Yes";
  else cout << "No";
  
  
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
count=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        count+=1
print(count)

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);


    int n,m;
    cin>>n>>m;
    Yes(n==m)

}

Measured memory_bytes: 380
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
int mod = 1000000007;


class Solution {
public:
    ll d(int n) {
        ll res = 0;
        res += (ll)n * ((ll)n + 1) / 2;
        for(int i = 2; i <= n; ++i) {
            int t = n / i;
            //cout << t * (i + i + (t - 1) * i) / 2 << endl;
            res += (ll)t * (i + i + (ll)(t - 1) * (ll)i) / 2;
        }
        return res;
    }
};

int main() {
    int n;
    cin >> n;
    Solution zhy;
    cout << zhy.d(n) << endl;
    return 0;
}

Measured memory_bytes: 3544
import java.util.Scanner;

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

		int cnt = 0;
		for (int i = 1; i < n; i++) {
			if (s.charAt(i) == 'E') {
				cnt++;
			}
		}

		int ans = cnt;
		for (int i = 1; i < n; i++) {
			if (s.charAt(i - 1) == 'W') {
				cnt++;
			}
			if (s.charAt(i) == 'E') {
				cnt--;
			}
			ans = Math.min(ans, cnt);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 29928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    ll l;cin>>l;
    string s[n];rep(i,0,n-1)cin>>s[i];
    sort(s,s+n);
    rep(i,0,n-1)cout<<s[i];
    cout<<endl;
    
    
    
    return 0;
}


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

int main(){
    int N;
    scanf("%d", &N);
    vector<int> A(1<<N);
    for (int i = 0; i < (1<<N); i++) scanf("%d", &A[i]);
    vector<vector<pair<int, int>>> dp(1<<N, vector<pair<int, int>>(N+1, {0,0}));
    for (int i = 0; i < (1<<N); i++) dp[i][0] = {A[i], 0};
    
    for (int i = 0; i < (1<<N); i++) {
        for (int j = 1; j <= N; j++) {
            if (i & (1 << (j-1))) {
                int k = i - (1<<(j-1));
                vector<int> p(4);
                p = {dp[i][j-1].first, dp[i][j-1].second, dp[k][j-1].first, dp[k][j-1].second};
                sort(p.begin(), p.end());
                dp[i][j] = {p[3], p[2]};
            }
            else {
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    int ans = 0;
    for (int i = 1; i < (1<<N); i++) {
        ans = max(ans, dp[i][N].first+dp[i][N].second);
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 51200
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;

#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};
LL n,m,l,dis[305][305],newdis[305][305];

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    cin>>n>>m>>l;
    for(int i=1;i<305;i++)
    {
        for(int j=1;j<305;j++)
        {
            dis[i][j]=newdis[i][j]=inf;
        }
        dis[i][i]=newdis[i][i]=0;
    }
    for(int i=0;i<m;i++)
    {
        int u,v;
        LL w;
        cin>>u>>v>>w;
        newdis[u][v]=dis[u][v]=w;
        newdis[v][u]=dis[v][u]=w;
    }
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(dis[i][k]!=inf&&dis[k][j]!=inf)
                    dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            newdis[i][j]=(dis[i][j]<=l?1:inf);
        }
        newdis[i][i]=0;
    }
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(newdis[i][k]!=inf&&newdis[k][j]!=inf)
                    newdis[i][j]=min(newdis[i][j],newdis[i][k]+newdis[k][j]);
            }
        }
    }
    int q;
    cin>>q;
    int s,t;
    while(q--)
    {
        cin>>s>>t;
        if(newdis[s][t]==inf)
        {
            cout<<"-1\n";
        }
        else
        {
            cout<<newdis[s][t]-1<<"\n";
        }
    }
	return 0;
}


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

using namespace std;

int main(){
	long long int a;
	long long int b;
	long long int x;
	scanf("%lld%lld%lld", &a, &b, &x);
	long long int cnt = b / x;
	long long int cnt2 = max(0LL,a-1LL) / x;
	if (a == 0){
		cnt++;
	}
	cnt -= cnt2;
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>

#define IN(x) scanf("%d",&(x));
#define IN2(x,y) IN((x));IN((y));
#define IN3(x,y,z) IN2((x),(y));IN((z);

#define OUT(x) printf("%d\n",x);
#define OUT2(x,y) printf("%d %d\n",x,y);
#define OUT3(x,y,z) printf("%d %d %d\n",x,y,z);

#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

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

const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 20;
const int OFF = (1 << LOG);
const double EPS = 1e-9;
const double PI = 3.1415926535;

int sm = 0,n,bio[N];

int main(){
    scanf("%d",&n);
    int c = 2;
    for(int i = 0;i<n - 1;i++){
        while(c % 2 != 0 && c % 3 != 0) c++;
        printf("%d ", c);
        sm += c;
        bio[c] = 1;
        c++;
    }
    for(int i = 1;i<N;i++){
        if(bio[i]) continue;
        if(__gcd(sm , i) != 1 && (sm + i) % 2 == 0 && (sm + i) % 3 == 0){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;        
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    int cnt=0;
    int ans=0;
    string S;cin>>S;
    rep(i,3){
        if(S[i]=='R'){
            cnt++;
            ans=max(cnt,ans);
        }
        else{
            cnt=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
n=int(input())
cnt=0
Arm=[]
for i in range(n):
    x,l=map(int,input().split())
    Arm.append([x+l,x-l])
Arm.sort()

dis=-float('inf')
for i in range(n):
    if dis<=Arm[i][1]:
        cnt+=1
        dis=Arm[i][0]
print(cnt)


Measured memory_bytes: 20104
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;

typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;

typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	loop(i,1,10)
	{
		loop(j,1,10)
			printf("%dx%d=%d\n",i,j,i*j);
	}
	return 0;
}  

Measured memory_bytes: 1096
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int n;

int dp[35][35];

void solve() {
	memset(dp, 0, sizeof(dp));
	
	dp[0][0] = 1;
	for (int i=0; i<n; i++) {
		for (int j=0; j<=n; j++) {
			if (j>=1) dp[i+1][j] += dp[i][j-1];
			if (j>=2) dp[i+1][j] += dp[i][j-2];
			if (j>=3) dp[i+1][j] += dp[i][j-3];
		}
	}
	
	int sum = 0;
	for (int i=0; i<n; i++) {
		sum += dp[i+1][n];
	}
	sum /= 10;
	int ans = ceil((double)sum/365.0);
	if (sum > 0) cout << ans << endl;
	else cout << 1 << endl;
}

int main() {
	while (1) {
		cin >> n; if (n==0) break;
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if((a+b)>(c+d))
	{
		cout <<"Left"<<endl;
		return 0;
	}
	else if((a+b)<(c+d))
	{
		cout <<"Right"<<endl;
		return 0;
	}
	else
	{
		cout <<"Balanced"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int N;
	char S[100][11];
	char tail;
	int i, j;

	scanf("%d", &N);
	
	for ( i = 0; i < N; i++)
	{
		scanf("%s", S[i]);
		if (i!=0)
		{
			//	tail = initial?
			if (tail!=S[i][0])
			{
				printf("No");
				return 0;
			}

			//	reuse
			for ( j = 0; j < i; j++)
			{
				if (strcmp(S[i],S[j])==0)
				{
					printf("No");
					return 0;
				}
			}
		}
		tail = S[i][strlen(S[i]) - 1];
	}
	printf("Yes");
	return 0;
}

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

//long long a[4];
int a[4];
long long sum;
int main() {
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	/*
	if (a[0] == a[1] && a[1] == a[2]) {
		puts("-1"); return 0;
	}
	*/
	int lev = 0;
	while (a[0]%2==0 && a[1]%2==0 && a[2]%2==0) {
		int v1 = a[1] / 2 + a[2] / 2;
		int v2 = a[0] / 2 + a[2] / 2;
		int v3 = a[0] / 2 + a[1] / 2;
		if (v1 == a[0] && v2 == a[1] && v3 == a[2]) {
			puts("-1"); return 0;
		}
		
		a[0] = v1, a[1] = v2, a[2] = v3;
		++lev;
	}
	printf("%d", lev);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

char gr[510][510];
int dp[510][510];

main(){
  int h,w;
  while(cin>>h>>w,h|w){
    rep(i,h)scanf(" %s ",gr[i]);

    memset(dp,0,sizeof(dp));
    rep(i,h)rep(j,w){
      if(gr[i][j]=='.')dp[i+1][j+1]=dp[i][j+1]+1;
    }

    int ans=0;
    rep(i,h+2){
      queue<PI> st;
      rep(j,w+2){
	if(dp[i][j])st.push(mp(j,dp[i][j]));
	
	queue<PI> nst;
	bool dd=true;
	while(!st.empty()){
	  int cj=st.front().F,ta=st.front().S;
	  st.pop();
	  if(ta<=dp[i][j]){
	    ans=max(ans,ta*(j-cj+1));
	    nst.push(mp(cj,ta));
	  }else if(dd){
	    ans=max(ans,dp[i][j]*(j-cj+1));
	    nst.push(mp(cj,dp[i][j]));
	    dd=false;
	  }
	}
	st=nst;
      }
      //cout<<ans<<endl;
    }
    printf("%d\n",ans);
  }
}

	

Measured memory_bytes: 2236
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

typedef pair<int, int> P;

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

    vector<ll> A(N+1, 0);
    vector<ll> acc(N+2, 0);
    REP(i, N)
    {
        cin >> A[i+1];
        acc[i+1] = acc[i] + A[i+1];
    }
    A[0] = A[N];

    vector<ll> X(N+1, 0);
    X[1] = acc[N];
    for (int i = 2; i < N; i++)
    {
        if (i % 2 == 0)
        {
            X[1] -= 2*A[i];
        }
    }
    for (int index = 1; index <= N; index++)
    {
        cout << X[index] << " ";
        X[index+1] = 2 * A[index] - X[index];
    }
    cout << endl;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
const int N = 103;
int dp[N][4];
int dp2[N][4][2];
string s;
int k;
int req;
int solve1(int idx,int nz){
	if(idx>req){
		if(nz == k)
			return 1;
		return 0;
	}
	if(nz>k)
		return 0;
	if(dp[idx][nz]!=-1)
		return dp[idx][nz];
	int ans = 0;
	for(int i=0;i<=9;i++){
		if(idx == 1 && i == 0)
			continue;
		if(i == 0)
			ans+=solve1(idx+1,nz);
		else ans+=solve1(idx+1,nz+1);
	}
	dp[idx][nz] = ans;
	return ans;
}
int solve2(int idx,int nz,int flag){
	if(idx>req){
		if(nz == k){
			return 1;
		}
		return 0;
	}
	if(nz>k)
		return 0;
	if(dp2[idx][nz][flag]!=-1)
		return dp2[idx][nz][flag];
	int ans = 0;
	if(flag == 0){
		for(int i = 0;i<=(s[idx-1]-'0');i++){
			if(idx == 1 && i == 0)
				continue;
			if(i<(s[idx-1]-'0')){
				if(i == 0)
					ans+=solve2(idx+1,nz,1);
				else ans+=solve2(idx+1,nz+1,1);
			}
			else{
				if(i == 0)
					ans+=solve2(idx+1,nz,0);
				else ans+=solve2(idx+1,nz+1,0);
			}
		}
	}
	else{
		for(int i=0;i<=9;i++){
			if(idx == 1 && i == 0)
				continue;
			if(i == 0)
				ans+=solve2(idx+1,nz,1);
			else ans+=solve2(idx+1,nz+1,1);
		}
	}
	dp2[idx][nz][flag] = ans;
	return ans;
}
signed main()
{
    fast;
    cin>>s;
    cin>>k;
    int n = s.size();
    int ans = 0;
    for(int i=1;i<=n-1;i++){
    	memset(dp,-1,sizeof(dp));
    	req = i;
    	ans+=solve1(1,0);
    }
    req = n;
    memset(dp2,-1,sizeof(dp2));
    ans+=solve2(1,0,0);
    cout<<ans;
}   

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

void bfs(int v,vector<vector<pair<int,int>>> &G,vector<int> &d){
    for(auto g : G[v]){
        int to = g.first;
        int weight = g.second;
        if(d[to] != -1) continue;
        d[to] = (d[v]+weight)%2;
        bfs(to,G,d);
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> G(n,vector<pair<int,int>>());
    rep(i,n-1){
        int from,to,weight;
        cin >> from >> to >> weight;
        from--; to--;
        G[from].push_back(make_pair(to,weight));
        G[to].push_back(make_pair(from,weight));
    }
    vector<int> d(n,-1);
    d[0] = 0;
    bfs(0,G,d);
    rep(i,n) cout << d[i] << endl;
}

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	string s;
	cin >> s;
	if (s.back() != 's') s.push_back('s');
	else if (s.back() == 's') s.push_back('e'), s.push_back('s');
	cout << s << "\n";
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n)    for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define _for(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define ALL(x)      begin (x), end (x)
#define TAIL(x)     next (begin (x)), end (x)
#define FOR(...)    _for (__VA_ARGS__)
using namespace std;

template <typename T = int64_t>
static constexpr auto inf = static_cast <T> (0x0de0b6b43b9aca00);

template <typename Iterator>
inline auto solve (Iterator first, Iterator last, int64_t a, int64_t b, int64_t c, int64_t a_cnt, int64_t b_cnt, int64_t c_cnt)
{
  if (first == last)
  {
    if (a_cnt > 0 && b_cnt > 0 && c_cnt > 0)
    {
      return abs (a) + abs (b) + abs (c) + (a_cnt + b_cnt + c_cnt - 3) * 10;
    }
    return inf <>;
  }
  return min ({
    solve (next (first), last, a - * first, b, c, a_cnt + 1, b_cnt, c_cnt),
    solve (next (first), last, a, b - * first, c, a_cnt, b_cnt + 1, c_cnt),
    solve (next (first), last, a, b, c - * first, a_cnt, b_cnt, c_cnt + 1),
    solve (next (first), last, a, b, c, a_cnt, b_cnt, c_cnt),
  });
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;

  int64_t a, b, c;
  cin >> a >> b >> c;

  vector <int64_t> l (n);
  rep (i, n) cin >> l [i];

  cout << solve (ALL (l), a, b, c, 0, 0, 0) << endl;
}



Measured memory_bytes: 256