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

int main(){
  int n,l;
  cin>>n>>l;
  int sum=0;
  if(l>=0){
    cout<<((l+l+n-1)*n/2)-l<<endl;
    return 0;
  }
  if(l+n-1<0){
    cout<<((l+l+n-1)*n/2)-(l+n-1)<<endl;
    return 0;
  }
  sum+=((l+l+n-1)*n/2);
  cout<<sum<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define sort(a, b) sort(((a) + 1), ((a) + (b) + 1))
#define ll long long
#define N 100010
using namespace std;

ll m, A, B, ans = INT_MAX, a[N], b[N];

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline void work(){
	A = read(), B = read(), m = read();
	REP(i, 1, A) a[i] = read();
	REP(i, 1, B) b[i] = read();
	REP(i, 1, m){
		ll x = read(), y = read(), c = read();
		ans = min(ans, a[x] + b[y] - c);
	}
	sort(a, A);
	sort(b, B);
	printf("%lld\n", min(ans, a[1] + b[1]));
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

fn main() {
    let a:i32 = read();
    let b:i32 = read();

    let ans:i32 = max(a+b, max(a-b, a*b));

    println!("{}", ans);
    
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, W, w[100], v[100], dp[200001];

int main() {
	cin >> n >> W;
	inc(i, n) { cin >> w[i] >> v[i]; }
	
	inc(i, n) {
	decII(j, 0, W) {
		setmax(dp[j + w[i]], dp[j] + v[i]);
	}
	}
	
	LL ans = 0;
	incII(j, 0, W) { setmax(ans, dp[j]); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
using ull = unsigned long long;

int main(){
    ull N, M, K;
    scanf("%llu %llu %llu", &N, &M, &K);
    ull ruiseki[N];
    scanf("%llu", ruiseki);
    for (size_t i = 1; i < N; i++){
        ull tmp;
        scanf("%llu", &tmp);
        ruiseki[i] = ruiseki[i-1] + tmp;
    }
    unsigned answer = distance(ruiseki, upper_bound(ruiseki, ruiseki + N, K)), candidate;
    ull sum = 0;
    for (size_t i = 1; i <= M; i++)
    {
        ull tmp;
        scanf("%llu", &tmp);
        if((sum += tmp) > K){
            printf("%u\n", answer);
            return 0;
        }
        if(candidate = i + distance(ruiseki, upper_bound(ruiseki, ruiseki + N, K - sum)); answer < candidate) answer = candidate;
    }
    printf("%u\n", answer);
	return 0;
}

Measured memory_bytes: 3288
N,M = map(int,input().split())
lis = list(map(lambda x: -int(x),input().split()))

import heapq
heapq.heapify(lis)
for _ in range(M):
    tmp = -heapq.heappop(lis)
    tmp //= 2
    heapq.heappush(lis,-tmp)

print(-sum(lis))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main(){
  int N;
  vector<int>v;
  cin >> N;
  for(int i = 1;i <= N;i++){
    if(N - i >= 0){
      N -= i;
      v.pb(i);
    }
  }
  int cnt = 1;
  for(int i = v.size() - 1;i >= 0;i--,cnt++){
    if(N >= cnt){
      cout << v[i] + 1 << endl;
    }else{
      cout << v[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    string s;
    cin>>s;
    V vec;
    for (ll i = s.size() - 1; i >= 0;i--){
        if(s[i]=='0'){
            vec.push_back(s.size()-i);
        }
    }
    
    //cout<<endl;
    ll temp=1;
    V res;
    if(vec.empty()){
        cout<<-1<<endl;
        return 0;
    }
    if(vec[0]!=1){
        
        cout<<-1<<endl;
        return 0;
    }
    ll prev=0;
    bool h=false;
   // cout<<m<<endl;
   ll prevk=-1;
   ll k=-100;
    while(1){
        //cout<<temp+m<<endl;
        prev=temp;
        prevk=k;
        k = upper_bound(all(vec), temp + m)-vec.begin()-1;
      //  cout <<k<<" "<< vec[k] << endl;
    //  cout<<k<<endl;
        if(vec[k]==vec[vec.size()-1]){
            res.push_back(n+1-prev);
            break;
        }
        if(prevk==k){
        
            cout<<-1<<endl;
            return 0;
        }
        
        temp=vec[k];
        res.push_back(temp-prev);
    }
    reverse(all(res));
    rep(i,res.size())cout<<res[i]<<" ";
    cout<<endl;
    
}


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

int main() {
  string s,t;
  cin >> s >> t;
  if( s < t ){
    cout << "Yes" << endl;
    return 0;
  }
  for(int i=0;i<=s.size()+1;i++){
    s = s.substr(1) + s.front();
    for(int j=0;j<=t.size()+1;j++){
      if( s < t ){
        cout << "Yes" << endl;
        return 0;
      }
      t = t.substr(1) + t.front();
    }
  }
  
  cout << "No" << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--) 

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
 
signed main(){
    fast;
    int k;
    cin >> k;
    int a, b;
    cin >>a >>b;
    if(b/k > a/k || b%k==0 || a%k==0)
        cout << "OK";
    else
        cout << "NG";       
}

Measured memory_bytes: 3612
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Bug Hunt
public class Main{

	int line, bug, INVALID = -1;
	Map<Character, R> array;
	
	char[] s;
	int id;
	char get(){
		return s[id++];
	}
	class R{
		int n;
		Map<Integer, Integer> val;
		public R(int n) {
			this.n = n;
			val = new HashMap<Integer, Integer>();
		}
		int get(int x){
			if(x<0||n<=x||!val.containsKey(x))return INVALID;
			return val.get(x);
		}
		int assign(int x, int v){
			if(x<0||n<=x||v==INVALID)return INVALID;
			val.put(x, v);
			return 1;
		}
	}
	
	void program(){
		char name = get();
		get();
		int e = exp();
		char ch = get();
		if(ch!='='){
			array.put(name, new R(e));
			return;
		}
		if(e==INVALID){
			bug = line; return;
		}
		
		int val = exp();
		int res = array.get(name).assign(e, val);
		if(res==INVALID)bug = line;
	}
	int exp(){
		char ch = get();
		if(Character.isDigit(ch)){
			int x = ch-'0';
			for(;;){
				ch = get();
				if(!Character.isDigit(ch))break;
				x = x*10+ch-'0';
			}
			return x;
		}
		char name = ch;
		get();
		int e = exp();
		get();
		return array.get(name).get(e);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			String str = sc.next();
			if(".".equals(str))break;
			line = 1; bug = 0;
			array = new HashMap<Character, R>();
			for(;;){
				s = (str+"$").toCharArray();
				id = 0;
				if(bug==0)program();
				str = sc.next();
				if(".".equals(str))break;
				line++;
			}
			System.out.println(bug);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    int sum=0,range=0;
    long long int m,n,o,i,j,k;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>m>>n>>o>>k;
    m=m-n;
    if(k%2==1) m=-m;
    cout<<m;
    return 0;
}





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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector< vector<bool> > connect = vector< vector<bool> >(101, vector<bool>(101, true));

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

    int N;
    cin >> N;

    int M;
    if (N & 1)
    {
        for (int i = 1; i <= N; ++i)
        {
            connect[i][N - i] = false;
        }
        M = (N - 1) * (N - 1) / 2;
    }
    else
    {
        for (int i = 1; i <= N; ++i)
        {
            connect[i][N - i + 1] = false;
        }
        M = N * (N - 2) / 2;
    }

    cout << M << "\n";
    for (int i = 1; i <= N; ++i)
    {
        for (int j = i + 1; j <= N; ++j)
        {
            if (connect[i][j])
            {
                cout << i << " " << j << "\n";
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int sosu[10010]={1,1,0};
	for(int i=2;i<10010;i++)if(sosu[i]==0)
	for(int j=i*2;j<10010;j+=i)sosu[j]=true;
	
	vi dp(1);
	rep(i,10010)if(sosu[i]==0)dp.pb(i);
	rep(i,dp.size())dp[i+1]+=dp[i];
	map<int,int>m;
	rep(i,dp.size())loop(j,i+1,dp.size())m[dp[j]-dp[i]]++;
	int n;
	while(cin>>n,n){
		cout<<m[n]<<endl;
	}
}

Measured memory_bytes: 33760
#include<stdio.h>
#include<string.h>
#define LEN 100005

/* ?????????????????¨????§??????? */
typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b; } /* ????°????????????? */

int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  /* ??¨??????????????????????????\??????????????????????????? */
  for ( i = 1; i <= n; i++ ) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
  
  /* ????????\??¬????????§??? */
  while ( head != tail ) {
    u = dequeue();
    c = min(q, u.t); /* q ???????????????????????? u.t ????????????????????? */
    u.t -= c; /* ?????????????????????????¨???? */
    elaps += c; /* ????????????????????? */
    if ( u.t > 0 ) enqueue(u); /* ???????????????????????????????????°?????\???????????? */
    else {
      printf("%s %d\n",u.name, elaps);
    }
  }

   return 0;
}

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

typedef long long ll;
typedef long double ld;

int mat[1005][1005];
int a[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m, k;
    cin >> n >> m >> k;
    for(int i=1; i<=k; i++){
        cin >> a[i];
    }
    int t = 1;
    for(int i=1; i<=n; i++){
        if(i%2){
            for(int j=1; j<=m; j++){
                a[t]--;
                mat[i][j] = t;
                if(a[t] == 0) t++;
            }
        }
        else{
            for(int j=m; j>=1; j--){
                a[t]--;
                mat[i][j] = t;
                if(a[t] == 0) t++;
            }
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            cout << mat[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		if(A*B >= C*D) {
			System.out.println(A*B);
		}else {
			System.out.println(C*D);
		}
	}
}

Measured memory_bytes: 23764
n, a, b = map(int, input().split())
mod = 10**9 + 7


def neko(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


print((pow(2, n, mod) - 1 - neko(n, a) - neko(n, b)) % mod)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cctype>
using namespace std;

string getBit(char ch){
  int x = isdigit(ch) ? ch - '0' : ch - 'a' + 10;
  string res = "";
  for(int i = 8; i >= 1; i /= 2){
    if(x & i) res += "1";
    else      res += "0";
  }
  return res;
}

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

  while(Q--){
    string ts;
    cin >> ts;

    string s;

    for(int i = 0; i < ts.size(); i++){
      s += getBit(ts[i]);
    }

    if(s[0] == '1'){
      cout << "-";
    }

    double sum = 0;

    for(int i = 0; i < 24; i++){
      if(s[i + 1] == '0') continue;
      sum += (1 << (23 - i));
    }

    bool flg = true;
    double p = 0.5;

    for(int i = 0; i < 7; i++, p /= 2){
      if(s[25 + i] == '0') continue;
      flg = false;
      sum += p;
    }

    cout << setprecision(30) << sum;
    if(flg){
      cout << ".0";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1292
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
int main(){
  char b;
  cin >>b;

  if(b=='A') cout<<'T'<<endl;
  else if(b=='T') cout<<'A'<<endl;
  else if(b=='C') cout<<'G'<<endl;
  else cout<<'C'<<endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
from itertools import product, permutations, combinations

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

q = list(range(N))
c = defaultdict(int)
t = [0]*N
r = 0

while q:
    r += 1
    nq = []
    for i in q:
        j = A[i][t[i]] - 1
        k = i
        if k < j:
            j, k = k, j
        c[(j, k)] += 1
        if c[(j, k)] == 2:
            t[j] += 1
            t[k] += 1
            if t[j] < N-1:
                nq.append(j)
            if t[k] < N-1:
                nq.append(k) 
    q = nq

for tt in t:
    if tt != N-1:
        print(-1)
        exit()

print(r)

Measured memory_bytes: 133340
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    string a,b,s="";
    cin>>a>>b;
    if(a.size()==b.size()){
    for(int i=0;i<a.size();i++){
        s+=a[i];
        s+=b[i];
    }
    }
    else if(a.size()>b.size()){
        for(int i=0;i<b.size();i++){
            s+=a[i];
            s+=b[i];
        }
        s+=a[a.size()-1];
    }
    cout<<s<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {

    int n, k,h;
    scanf("%d %d", &n,&k);

    int cnt=0;
    
    for(int i=0;i<n;i++){
        scanf("%d",&h);
        if(h>=k){
            cnt++;
        }
    }
    printf("%d",cnt);

    return 0;

}

Measured memory_bytes: 128
n, k, c = map(int, input().split())
s = input()

chuncks = []
last_workday = -c-10
for i in range(n):
	if s[i] == 'o':
		if len(chuncks) > 0 and i - chuncks[-1][0] <= c:  # in one chunck 
			chuncks[-1].append(i)
		else:
			chuncks.append([i])
		last_workday = i

# print("chuncks before", chuncks)

l = len(chuncks)
for i in range(l):
	if i != 0:
		# check with previous
		to_start = 0
		for j in range(len(chuncks[i])):
			if chuncks[i][j] <= chuncks[i-1][0] + c:
				to_start = j+1
		chuncks[i] = chuncks[i][to_start:]

for i in range(l-1, -1, -1):
	if i != l-1:
		# check with the next one
		to_finish = len(chuncks[i]) # not inclusive
		for j in range(len(chuncks[i])-1, -1, -1):
			if chuncks[i][j] + c >= chuncks[i+1][-1]:
				to_finish = j
		chuncks[i] = chuncks[i][:to_finish]

# print("chuncks after", chuncks)

l = 0
for item in chuncks:
	if len(item) > 0:
		l += 1 

if l > k:
	pass
else:
	for i in range(len(chuncks)):
		if len(chuncks[i]) == 1:
			print(chuncks[i][0]+1)

# print("chuncks after", chuncks)


Measured memory_bytes: 95516
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum1 = 0;
		for(int i = 0 ; i < 4;i++){
			sum1 += sc.nextInt();
		}
		int sum2 = 0;
		for(int i = 0 ; i < 4;i++){
			sum2 += sc.nextInt();
		}
		if(sum1 > sum2){
			System.out.println(sum1);
		} else {
			System.out.println(sum2);
		}
	}	

}

Measured memory_bytes: 17168
def II():return int(input())
def MI():return map(int,input().split())
def LI():return list(MI())
def ok():print("Yes")
def ng():print("No");exit()

n,x,y=MI()

ans=[0]*n
for i in range(1,n+1):
    for j in range(i+1,n+1):
        num=min(abs(i-j),abs(x-i)+abs(y-j)+1)
        ans[num]+=1

for an in ans[1:]:
    print(an)

Measured memory_bytes: 46812
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)


int main() {

	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && A != C) cout << "Yes" << endl;
	else if (A == C && A != B) cout << "Yes" << endl;
	else if (B == C && A != B) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,i;
  scanf("%d",&a);
  int s,e;
  scanf("%d %d",&s,&e);
  for(i=s;i<=e;i++){
    if(i%a==0){
      printf("OK");
      return 0;
    }
  }
  printf("NG");
  return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int n; cin >> n;
	vector<int> a(3 * n);//入力受け取り
	vector<ll> left_max(3 * n);//左からi番目まででn個取れる最大値
	vector<ll> right_max(3 * n);//右からi番目まででn個取れる最大値
	for (int i = 0; i < 3 * n; i++) {
		cin >> a[i];
	}

	priority_queue<int, vector<int>, greater<int>> left;
	ll sum_left = 0;//左から取れるn個の総和の最大値を格納する。

	for (int i = 0; i < n; i++) {
		left.push(a[i]);
		sum_left += (ll)a[i];
	}
	left_max[n - 1] = sum_left;//左からn個全てとった値。

	for (int i = n; i < 2 * n; i++) {//nから2*n-1までの要素で、左側の値がとれる最大値を格納していく。
		left.push(a[i]);
		sum_left += (ll)a[i];
		sum_left -= (ll)left.top();
		left.pop();
		left_max[i] = sum_left;
	}

	priority_queue<int> right;
	ll sum_right = 0;//右から取れるn個の総和の最小値を格納する。

	for (int i = 3 * n - 1; i >= 2 * n; i--) {
		sum_right += (ll)a[i];
		right.push(a[i]);
	}
	right_max[2 * n] = sum_right;

	for (int i = 2 * n - 1; i >= n; i--) {//2*n-1からnまでの要素で、右側の値がとれる最大値を格納。
		right.push(a[i]);
		sum_right += (ll)a[i];
		sum_right -= (ll)right.top();
		right.pop();
		right_max[i] = sum_right;
	}

	ll ans = -LONGINF;
	//left_maxはn-1から2*n-1まで。
	//right_maxは2*nからnまで。
	for (int i = n; i <= 2 * n; i++) {
		ans = max(ans, left_max[i - 1] - right_max[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7288
#include<iostream>
#include<string.h>

using namespace std;

char mat[1002][1002];
int m, n;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int ans;


int dfs(int x, int y, char ch){
    mat[x][y] = '.';

    for(int i = 0; i < 4; ++i){
        int gx = x + dx[i], gy = y + dy[i];
        if(0 <= gx && gx < m && 0 <= gy && gy < n
           && mat[gx][gy] == ch){
               dfs(gx, gy, ch);
           }
    }
    return 0;
}

void solve(){
    memset(mat, 0, sizeof(mat));
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < n; ++j){
            cin>>mat[i][j];
        }
    }

    ans = 0;
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < n; ++j){
            if(mat[i][j] != '.'){
                ans++;
                dfs(i, j, mat[i][j]);
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    while(cin>>m>>n && m > 0 && n > 0){
        solve();
    }
    return 0;
}



Measured memory_bytes: 4540
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
#define MAX_N 100
const ll INF = 1000000000000000;
ll d[MAX_N][MAX_N];

void init(){
	rep(i,MAX_N){
		rep(j,MAX_N) d[i][j] = INF;
		d[i][i] = 0;
	}
}

void warshall_floyd(int n){
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if( d[i][k] == INF || d[k][j] == INF){
					// do nothing
				}else{
					d[i][j] = min(d[i][j],d[i][k] + d[k][j]);	
				}
			}
		}
	}
}

bool existNegativeCycle(int n){
	for(int start = 0; start < n; start++){
		if(d[start][start] < 0){
			return true;
		}
	}
	return false;
}

int main()
{
	init();
	int v,e;
	cin>>v>>e;
	rep(i,e){
		ll s,t,c;
		cin>>s>>t>>c;
		d[s][t] = c;
	}
	warshall_floyd(v);
	if( existNegativeCycle(v) == true){
		cout<<"NEGATIVE CYCLE"<<endl;
	}else{
		rep(i,v){
			rep(j,v-1){
				if(d[i][j] == INF){
					cout<<"INF ";
				}else{
					cout<<d[i][j]<<" ";
				}
			}
			if(d[i][v-1] == INF){
				cout<<"INF"<<endl;
			}else{
				cout<<d[i][v-1]<<endl;
			}
		}
	}
	return 0;
}




Measured memory_bytes: 3196
import java.util.*;

public class Main {

    static final int D = 365;
    static final int[] c = new int[27];
    static final int[][] s = new int[365][27];
    static final int[] ans = new int[365];
    static final int[] last = new int[27];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int fla = 0;
        for (int i = 1; i <= 26; i++) {
            c[i] = sc.nextInt();
            fla += c[i];
        }
        for (int i = 0; i < D; i++) {
            for (int j = 1; j <= 26; j++) {
                s[i][j] = sc.nextInt();
            }
        }
        StringBuilder sb = new StringBuilder();
        int score = 0;
        for (int i = 0; i < D; i++) {
            score -= fla;
            int max = score;
            int idx = 0;
            for (int j = 1; j <= 26; j++) {
                int tmp = score + s[i][j] +  c[j] *(i - last[j] + 1);
                if(max < tmp){
                    max = tmp;
                    idx = j;
                }
            }
            score = max;
            ans[i] = idx;
            last[idx] = i+1;
            sb.append(idx + "\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 47912
while True :
    try :
        n = int(input())
        
    except :
        break
    
    S = [(0, 0, 0, 0) for i in range(10000)]
    s = 0
        
    for a in range(10) :
        for b in range(10) :
            for c in range(10) :
                for d in range(10) :
                    if(a + b + c + d == n) :
                        S[s] = (a, b, c, d)
                        s += 1
                    else :
                        pass
        
    S = set(S)
        
    print(len(S) - 1)


Measured memory_bytes: 5756
// EducationalDPContest.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 1 << 30;
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()
{
	// D - Knapsack 1
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for (int i = 0; i < n; i++)	cin >> weight[i] >> value[i];

	vector<vector<long long>> dp(n+1, vector<long long>(w+1, 0));
	for (int i = 0; i < n; i++) {
		for (int sum_w = 0; sum_w <= w; sum_w++) {
			// i番目を入れる場合
			if (sum_w - weight[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}

			// i番目を入れない場合
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);
		}
	}
	cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

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

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

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#define INF 1<<30
#define eps 1e-9

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

// This should not compile if used.
const int MAXN = 120000;

vector<int> aa[MAXN];
int dfs(int v, int p) {
    int res = 0;
    for (int a : aa[v]) {
        if (a == p) continue;
        res ^= 1 + dfs(a, v);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in online problems!
    int N;
    cin >> N;
    for (int i = 0; i < N-1; i++) {
        int a,b;
        cin >> a >> b;
        a--, b--;
        aa[a].push_back(b);
        aa[b].push_back(a);
    }
    cout << (dfs(0, -1) ? "Alice" : "Bob");
}



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

int main() {
  int a, b;
  char op;
  
  for (int i=0; ;) {
    cin >> a >> op >> b;
    if (op == '+') {
      cout << a+b << endl;
    }
    else if (op == '-') {
      cout << a-b << endl;
    }
    else if (op == '*') {
      cout << a*b << endl;
    }
    else if (op == '/') {
      cout << a/b << endl;
    }
    else if (op == '?') break;
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout << "NO" << "\n";
            return 0;    
        }
    }
    cout << "YES" << "\n";
    return 0;
}

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 100005

char s[305][305] ;
int h , w ;

int dp[305][305][305] ;
int cnt[2][305][305][305] ;

int f(int c , int i, int j)
{
    if( max(i,j) == h ) return 0 ;
    if( dp[c][i][j] != -1 ) return dp[c][i][j] ;

    int ans ;

    if( i<=j ) ans = cnt[1][c][j-i][h-j-1] ;
    else ans = cnt[0][c][i-j][h-i-1] ;

    ans += min( f(c,i+1,j) , f(c,i,j+1) ) ;

    return dp[c][i][j] = ans ;
}

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

    for(int i=0 ; i<h ; i++) scanf("%s",s[i]) ;

    for(int i=1 ; i<w ; i++)
    {
        for(int j=0 ; j<h ; j++)
        {
            for(int k=0 ; k+j<h ; k++)
            {
                cnt[0][i][j][k] = ( s[k][i-1]==s[k+j][i] ) ;
                if( k>0 ) cnt[0][i][j][k] += cnt[0][i][j][k-1] ;
            }
            for(int k=0 ; k+j<h ; k++)
            {
                cnt[1][i][j][k] = ( s[k+j][i-1] == s[k][i] ) ;
                if( k>0 ) cnt[1][i][j][k] += cnt[1][i][j][k-1] ;
            }
        }
    }

    memset(dp,-1,sizeof(dp)) ;

    int ans = 0 ;

    for(int i=1 ; i<w ; i++) ans += f(i,0,0) ;

    printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 332544
#include<iostream>

using namespace std;

struct straight{
	double xA,yA,xB,yB;
};

int main(void){
	struct straight str[2];
	while(cin>>str[0].xA>>str[0].yA>>str[0].xB>>str[0].yB
		  	 >>str[1].xA>>str[1].yA>>str[1].xB>>str[1].yB){
		
		double temp,tline[4];
		
		tline[0]=str[0].yA-str[0].yB;
		tline[1]=str[1].yA-str[1].yB;
		tline[2]=str[0].xA-str[0].xB;
		tline[3]=str[1].xA-str[1].xB;
		
		temp=(tline[0]*tline[1])/(tline[2]*tline[3]);
		
		if(tline[0]==0 && tline[3]==0 || tline[1]==0 && tline[2]==0 || temp==-1){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
}

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

long long ans[200050];
int last[200050],nex[400050],dm[400050];
int n,q,siz;

void add(int x, int y)
{
	siz++,nex[siz]=last[x],last[x]=siz,dm[siz]=y;
	siz++,nex[siz]=last[y],last[y]=siz,dm[siz]=x;
}

void dfs(int x, int y, int fa)
{
	ans[x]+=y;
	for (int i=last[x]; i; i=nex[i])
		if (dm[i]!=fa) dfs(dm[i],ans[x],x);
}

int main()
{
	scanf("%d%d",&n,&q);
	for (int i=1,x,y; i<n; i++)
		scanf("%d%d",&x,&y),add(x,y);
	for (int i=1,x; i<=q; i++)
		scanf("%d%d",&x,&ans[0]),ans[x]+=ans[0];
	dfs(1,0,0);
	for (int i=1; i<=n; i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 17152
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll MAX_L=10000;
 

int main(){
    ll n,t;
    cin >> n >> t;
    vector<Pair> vec;
    rep(i,n){
        ll a,b;
        cin >> a >>b;
        vec.pb(make(a,b));
    }
    sort(vec.begin(),vec.end());
    ll dp[n+1][t+10];
    //初期化
    rep(i,t) dp[0][i]=0;
    
    //dp
    rep(i,n){
        rep(j,t){
            if(j<vec[i].first) dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j],dp[i][j-vec[i].first]+vec[i].second);
        }
    }
    ll ans=0;
    rep(i,n){
        ans=max(ans,dp[i][t-1]+vec[i].second);
    }
    kaku(ans);
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int a, b;
  cin >> a >> b;
  if (a <= b)
    print(a);
  else
    print(a - 1);
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

ll inp[3333];

int main(){
    int n;
    fastScan(n);
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        fastScan(inp[i]);
        ans += inp[i] - 1;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    product_dict = {}
    for i in range(N):
        p_name, number = input().split()
        number = int(number)
        try:
            product_dict[p_name] += number
        except KeyError:
            product_dict[p_name] = number
    view_list = product_dict.items()
    view_list = sorted(view_list, key=lambda x: (len(x[0]), x[0]))
    [print(' '.join(map(str, list_el))) for list_el in view_list]



Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  
  ll res=1e+15;
  ll tmp=0;
  rep(i,n){
    res = min(res,abs(sum-2*tmp));
    tmp += a[i];
  }
  
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            if (n < 1000) {
                out.println("ABC");
            } else {
                out.println("ABD");
            }
        }

    }
}



Measured memory_bytes: 22612
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			if(x==0 && y==0)
				break;
			System.out.println(x<y?(x+" "+y):(y+" "+x));
		}
	}
}

Measured memory_bytes: 27188
package main

import (
	"fmt"
	"sort"
)

func solve() {
	var N int
	fmt.Scan(&N)

	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&p[i])
	}

	for i := 0; i < N; i++ {
		for j := i; j < N; j++ {
			p[i], p[j] = p[j], p[i]
			if sort.IntsAreSorted(p) {
				fmt.Println("YES")
				return
			}
			p[i], p[j] = p[j], p[i]
		}
	}

	fmt.Println("NO")
}

func main() {
	solve()
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        char[] a=fsc.next().toCharArray();
        char[] b=fsc.next().toCharArray();
        fsc.close();
        if(a.length<b.length) System.out.println("LESS");
        else if(a.length>b.length) System.out.println("GREATER");
        else{
            for(int i=0;i<a.length;i++){
                if(a[i]>b[i]){
                    System.out.println("GREATER");
                    return;
                }
                if(a[i]<b[i]){
                    System.out.println("LESS");
                    return;
                }
            }
            System.out.println("EQUAL");
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

typedef unsigned long long ull;

int main()
{
  int a, b, c, d;
  cin>>a>>b>>c>>d;



  if (max(a, c) - min(a, c) <= d
      || (max(a, c) - b <= d && b - min(a, c) <= d))
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256