akhauriyash/Code-Regression huggingface dataset:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n,k=map(int,input().split())
    a=n%k
    print(min(a,abs(a-k)))

if __name__ == '__main__':
    main()



Measured memory_bytes: 38716
#include<bits/stdc++.h>
using namespace std;
int a[6];
vector<int>n(4);
vector<int>x={1,1,2,2};
int main(){
    for(int i=0;i<6;i++){
        cin>>a[i];
        n[a[i]-1]++;
    }
    sort(n.begin(),n.end());
    
    if(n==x)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int g(int a, int b) {
  int mg = 1;
  for (int i = 1; i <= 100; ++i) {
    if (a%i == 0 && b%i == 0) {
      mg = i;
    }
  }
  return mg;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int mg = g(a, b);
  cout << ((c%mg == 0) ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n; cin >> n;
  if(n % 2 == 0) cout << n << endl;
  else cout << 2*n << endl;
  
}

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



int main(){
	int n,a[5],b[100];
	while(cin>>n&&n){
		for(int i=0;i<n;i++){
			for(int j=0;j<5;j++)cin>>a[j];
			b[i]=accumulate(a,a+5,0);
		}
		cout<<*max_element(b,b+n)<<' '<<*min_element(b,b+n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
    int n,y;
    cin>>n>>y;
    int a=-1,b=-1,c=-1;
    for(int i=0;i<=n;i++){
        for(int j=0;j+i<=n;j++){
            int k=n-i-j;
            int total=10000*i+5000*j+1000*k;
            if(total==y){
                a=i;
                b=j;
                c=k;
            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int res = 0;
    int maxHeight = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h >= maxHeight) {
            ++res;
            maxHeight = h;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    int n; cin >> n;
    vector<int> so(n);
    rep(i,n){
        int a; cin >> a;
        a--;
        so.at(a) = i;
    }
    int cnt = 1;
    int ans = 0;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    rep(i,n-1){
        if(so.at(i) < so.at(i+1)){
            cnt++;
        }
        else{
            chmax(ans,cnt);
            cnt = 1;
        }
    }
    chmax(ans,cnt);
    cout << n-ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                while(n != 0){ 
                        sc.nextLine();
                        String[] s = sc.nextLine().split(" ");
                        int[] a = new int[n];
                        for(int i = 0 ; i < n ; i++){
                                a[i] = Integer.parseInt(s[i]);
                        }   
                        int counter = 0;
                        int[] b = nexta(a);
                        while(!Arrays.equals(a,b)){
                                counter++;
                                a = b;
                                b = nexta(a);
                        }   
                        System.out.println(counter);
                        print(b);
                        n = sc.nextInt();
                }   
        }   
        static int freq(int m, int[] a){
                int tmp = 0;
                for(int i = 0 ; i < a.length ; i++){
                        if(a[i] == m){ 
                                tmp++;
                        }   
                }   
                return tmp;
        }   
        static int[] nexta(int[] a){
                int[] tmp = new int[a.length];
                for(int i = 0 ; i < a.length ; i++){
                        tmp[i] = freq(a[i], a); 
                }   
                return tmp;
        }   
        static void print(int[] a){
                for(int i = 0 ; i < a.length-1 ; i++){
                        System.out.print(a[i] + " ");
                }   
                System.out.println(a[a.length-1]);
        }   
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    string S, T;
    int cnt = 0;
    cin >> S >> T;
    int n = S.length();
    rep(i, n){
        if(S[i]!=T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;

    if(B % A == 0)
    {
        cout << A + B << endl;
    }

    else
    {
        cout << B - A << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000


int main(){
	
	
	int N;
	cin>>N;
	
	vector<int> t,v;
	
	int sum = 0;
	
	
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		a*=2;
		//if(i==N-1)a--;
		t.push_back(a);

	}
	
	for(int i=0;i<N;i++){
		int b;
		cin>>b;
		b*=2;
		v.push_back(b);
	}
	
	t.push_back(1);
	v.push_back(0);
	
	vector<int> V;
	vector<int> maxi_V;
	
	for(int i=0;i<t.size();i++){
		for(int j=0;j<t[i];j++){
			V.push_back(0);
			if(j!=0||i==0)maxi_V.push_back(v[i]);
			else maxi_V.push_back(min(v[i],v[i-1]));
		}
	}
	
	
	for(int i=1;i<V.size();i++){
		V[i] = min(V[i-1] + 1,maxi_V[i]);
		
		int k = i;
		
		while(true){
			if(abs(V[k]-V[k-1])<=1)break;
			V[k-1] = V[k]+1;
			k--;
		}
	}
	
	double ans = 0.0;
	
	for(int i=1;i<V.size();i++){
		ans += ((double)V[i]+V[i-1])/2.0;
	}
	/*
	for(int i=0;i<V.size();i++){
		cout<<i<<':'<<V[i]<<endl;
	}
	*/
	
	cout<<fixed<<setprecision(15)<<ans/4.0<<endl;
		
			
	
	
	return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main() {
  cin.sync_with_stdio(false);
  int a, b , c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) {
    cout << "Yes" << endl;
  } else if (abs(a - b) <= d && abs(c - b) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i;
    cin>>n>>m;
    if(n>m||n==m)
    {
        for(i=1; i<=n; i++)
        {
            cout<<m;
        }
        cout<<endl;
    }



      else if(n<m||n==m)
    {
        for(i=1; i<=m; i++)
        {
            cout<<n;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    int maxe = 0;
    for(int i = 0; i < n; ++i){
        int h;
        cin >> h;
        if(maxe > h + 1){
            cout << "No\n";
            return 0;
        }
        chmax(maxe, h);
    }
    cout << "Yes\n";
}

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

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}
const int MAXN = 300000 + 100;
const ll mod = 998244353;

int n, k;
ll sum[MAXN << 2], pw[MAXN << 2];
ll ch[MAXN << 2];
ll inv[50];

ll qpow(ll x, ll y) {
	ll r = 1;
	while(y) {
		if (y & 1)
			r = r * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return r;
}
void pushup(int o, int l, int r) {
	int mid = l + r >> 1;
	ll len = (r - mid);
	sum[o] = (sum[ls]  * pw[len] % mod + sum[rs]) % mod;
}

void pushdown(int o, int l, int r) {
	int mid = l + r >> 1;
	int len2 = (r - mid);
	int len1 = (mid - l + 1);
	if (ch[o]) {
		ch[ls] = ch[o];
		sum[ls] = pw[len1] % mod;
		sum[ls] -= 1;
		if (sum[ls] < 0)
			sum[ls] += mod;
		sum[ls] = sum[ls] * inv[9] % mod * ch[ls] % mod;
	}
	if (ch[o]) {
		ch[rs] = ch[o];
		sum[rs] = pw[len2] % mod;
		sum[rs] -= 1;
		if (sum[rs] < 0)
			sum[rs] += mod;
		sum[rs] = sum[rs] * inv[9] % mod * ch[rs] % mod;
	}
	ch[o] = 0;
}

void build(int l, int r, int o) {
	if (l == r) {
		sum[o] = 1;
		return;
	}
	int mid = l + r >> 1;
	build(lson);
	build(rson);
	pushup(o, l, r);
}

void update(int L, int R, ll d, int l, int r, int o) {
	pushdown(o, l, r);
	if (L <= l && r <= R) {
		ch[o] = d;
		int len = r - l + 1;
		ll s = pw[len] % mod;
		s -= 1;
		if (s < 0)
			s += mod;
		sum[o] = s * inv[9] % mod * d % mod;
	//	cout << sum[o] << endl;
		return ;
	}
	int mid = l + r >> 1;
	if (L <= mid)
		update(L, R, d, lson);
	if (mid < R)
		update(L, R, d, rson);
	pushup(o, l, r);
}


int main () {
	read(n);
	read(k);
	pw[0] = 1;
	rep(i, 1, n + 10)
		pw[i] = pw[i - 1] * 10 % mod;
	rep(i, 1, 12)
		inv[i] = qpow(i, mod - 2);
	build(1, n, 1);
//	cout << sum[1] << endl;
	while(k--) {
		int l, r;
		ll d;
		read(l);
		read(r);
		read(d);
		update(l, r, d, 1, n, 1);
//		cout << ch[5] << "A" << endl;
	//	cout << sum[5] << "a" << endl;
		write(sum[1]);
		putchar('\n');
	}	
	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int e;

signed main() {
	while (1) {
		cin >> e;
		if (e==0) break;
		int m = INT_MAX;
		rept(z,100) {
			if (z*z*z>e) break;
			int t = e - z*z*z;
			rept(y,1000) {
				if (y*y>t) break;
				chmin(m, z + y + t-y*y);
			}
		}
		cout << m << ln;
	}
}


Measured memory_bytes: 3112
from collections import deque
n,m = map(int,input().split())
data = [[] for _ in range(n)]
hen = []
ans = 0
for _ in range(m):
    v,w = map(int,input().split())
    v -= 1
    w -= 1
    data[v].append(w)
    data[w].append(v)
    hen.append((v,w))
for i,j in hen:
    dq = deque([i])
    visited = [0]*n
    while dq:
        p = dq.pop()
        if p == j:
            break
        visited[p] = 1
        for k in data[p]:
            if (not visited[k]) and (not (p == i and k == j)):
                dq.append(k)
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	char str[128];
	int cnt = 0;
	while(scanf("%s", str) != EOF){
		bool palindrome = true;
		rep(i, strlen(str)/2){
			if(str[i] != str[strlen(str)-i-1]){
				palindrome = false;
				break;
			}
		}
		cnt += palindrome;
	}
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {

    public static ArrayList<String> calc(int sx, int sy, int tx, int ty) {
        ArrayList<String> result = new ArrayList<String>();

        int up = 0;
        while (sy + up < ty) {
            result.add("U");
            up++;
        }

        int right = 0;
        while (sx + right < tx) {
            result.add("R");
            right++;
        }

        while (up > 0) {
            result.add("D");
            up--;
        }
        while (right > 0) {
            result.add("L");
            right--;
        }

        // second run!
        right--;
        result.add("L");

        while (sy + up < ty + 1) {
            result.add("U");
            up++;
        }

        while (sx + right < tx) {
            result.add("R");
            right++;
        }

        up--;
        result.add("D");

        right++;
        result.add("R");

        while (up > -1) {
            result.add("D");
            up--;
        }
        while (right > 0) {
            result.add("L");
            right--;
        }

        result.add("U");
        up++;

        return result;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int sx = in.nextInt();
        int sy = in.nextInt();
        int tx = in.nextInt();
        int ty = in.nextInt();

        ArrayList<String> result = calc(sx, sy, tx, ty);

        for (String s : result) {
            System.out.print(s);
        }
        System.out.println("");
    }
}

Measured memory_bytes: 14452
#include<stdio.h>
using namespace std;

int main()
{
	int N, M, K;
	scanf("%d%d%d", &N, &M, &K);
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (i * M + j * N - 2 * i * j == K) {
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
def main
  n, k = gets.split.map(&:to_i)
  nums = gets.split.map(&:to_i)
  # puts nums

  # 美しさ（各部分列の合計）の配列を作る
  # 部分列数
  p_num = n * (n + 1) / 2
  # 部分列の美しさ配列
  b_ary = Array.new(p_num)
  i = 0
  0.upto(nums.length-1) do |l|
    # 先頭を1つずつずらしていく
    p_sum = 0
    (nums.length-l).times do |dist|
      # 先頭からの合計を加算しながら、美しさ配列に入れていく
      p_sum += nums[l+dist]
      b_ary[i] = p_sum
      i += 1
    end
  end
  # puts b_ary

  # 上位ビットから確認（最大40digits）
  prefix = 1 << 39
  39.downto(0) do |digit|
    # 所定のprefixを持つ美しさ数の配列を返す
    found_ary = find_b_nums(prefix, b_ary)
    # puts "#{digit}: #{found_ary}"

    if k <= found_ary.length
      # K個以上見つかったので、見つかった美しさセットを次の検索対象とする
      b_ary = found_ary
      # 1つ下の桁も1にする
      prefix |= (1 << (digit-1))
    else
      # 現在の桁を0にして、次の桁を1にする
      prefix ^= (1 << digit)
      prefix |= (1 << (digit-1))
    end
  end
  puts prefix

end

def find_b_nums(prefix, b_ary)
  found = []
  b_ary.each_with_index do |b, idx|
    if (b & prefix) == prefix
      found << b
    end
  end
  found
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 12216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  double w, h;
  int x, y;
  cin >> w >> h >> x >> y;
  printf("%.9lf ", w*h/2);
  if (w/2 == x && h/2 == y) printf("1");
  else printf("0");
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int w,h;
    int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
    while(cin>>w>>h,w||h){
        vector< vector<int> > field(h,vector<int>(w,1));
        int x,y;
        for(int i=0;i<h;i++){
            string s;cin>>s;
            for(int j=0;j<w;j++){
                if(s[j]=='.') field[i][j]=0;
                else if(s[j]=='@'){x=i;y=j;}
            }
        }
        queue<P> q;
        q.push(P(x,y));
        int res=0;
        while(!q.empty()){
            P p=q.front();q.pop();
            for(int i=0;i<4;i++){
                int nx=p.first+dx[i],ny=p.second+dy[i];
                if(nx<0||h<=nx||ny<0||w<=ny) continue;
                if(field[nx][ny]==1) continue;
                res++;
                field[nx][ny]=1;
                q.push(P(nx,ny));
            }
        }
        cout<<res+1<<endl;
    }
}

Measured memory_bytes: 3096
#include<stdio.h>
#include<cctype>

using namespace std;
int main(){
    char str[1200];
    scanf("%[^\n]%*c", str);
    for(int i = 0;i < 1200;i++){
        if(islower(str[i])){
            str[i] = toupper(str[i]);
        } else if(isupper(str[i])){
            str[i] = tolower(str[i]);
        } 
    }
    
    printf("%s\n",str);
}




Measured memory_bytes: 2608
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define repr(i,x,n) for(int i=x; i<(int)n; i++)
#include <string>

int main() {
    string T; cin >> T;
    for (int i = 0; i < T.size()-1; i++) {
        if (i == 0 && T[i] == '?') {
            if (T[i+1] == 'P' || T[i+1] == '?') T[i] = 'D';
            else if (T[i+1] == 'D') T[i] = 'P';
            continue;
        }
        if (T[i] == '?') {
            if (T[i-1] == 'P') T[i] = 'D';
            else T[i] = 'D';
        }
    }
    if (T[T.size()-1] == '?') T[T.size()-1] = 'D';
    cout << T << endl;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans=0;
  rep(i,s.size()){
    if(s.at(i)!=t.at(i)){
      ans++;
    }
  }
  cout << ans<<endl;
}


Measured memory_bytes: 3916
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), [](ll a, ll b){ 
        return a > b;
    });
    int ai = 1, bi = 0;
    ll l = a[0], r = a[0];
    ll ans = 0;
    while ( ai + bi < n ) {
        ll ad = max(abs(l - a[ai]), abs(r - a[ai]));
        ll bd = max(abs(l - b[bi]), abs(r - b[bi]));
        if( ad > bd ) {
            if ( abs( l - a[ai] ) < abs( r - a[ai] ) ) r = a[ai];
            else                                       l = a[ai];
            ++ai;
        }
        else {
            if ( abs( l - b[bi] ) < abs( r - b[bi] ) ) r = b[bi];
            else                                       l = b[bi];
            ++bi;
        }
        ans += max(ad, bd);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
//@chandan
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin>>c;
	cout<<((c>='A' && c<='Z')?'A':'a')<<"\n";
	return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	vint a(3);
	fori(3) cin >> a[i];
	sort(a.begin(), a.end());
	if (a[0] == a[1] && a[1] != a[2] || a[1] == a[2] && a[0] != a[1]) 
		cout << "Yes" << nl;
	else 
		cout << "No" << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b, c, x;
    cin>>a>>b>>c>>x;
    int ans = 0;
    for(int i = 0; i <= a; ++i)
        for(int j = 0; j <= b; ++j)
            for(int k = 0; k <= c; ++k)
                if(i*500 + j*100 + k*50 == x)
                    ++ans;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int X_max, Y_min;
  
  int N, M, X, Y;
  
  cin >> N >> M >> X_max >> Y_min;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    X_max = max(X_max, in);
  }
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    Y_min = min(Y_min, in);
  }
  
  if (Y_min > X_max) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

class MaxFlow:
    def __init__(self, node_count):
        self.node_count = node_count
        self.graph = [[] for _ in range(node_count)]

    def add_edge(self, u, v, cap):
        idx1 = len(self.graph[v])
        idx2 = len(self.graph[u])
        self.graph[u].append([v, cap, idx1])
        self.graph[v].append([u,   0, idx2])

    def dfs(self, u, t, f):
        if u == t:
            return f
        self.used[u] = True
        for i in range(len(self.graph[u])):
            v, cap, rev = self.graph[u][i]
            if self.used[v] == False and cap > 0:
                d = self.dfs(v, t, min(f, cap))
                if d:
                    self.graph[u][i][1] -= d
                    self.graph[v][rev][1] += d
                    return d
        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.used = [False] * self.node_count
            f = self.dfs(s, t, 1 << 29)
            if not f:
                return flow
            flow += f



n = getint()
a = [getints() for _ in range(n)]
b = [getints() for _ in range(n)]

src = n + n
dst = src + 1
nv = dst + 1
mf = MaxFlow(nv)

for i in range(n):
    mf.add_edge(src, i, 1)
    mf.add_edge(i + n, dst, 1)

for i in range(n):
    for j in range(n):
        if a[i][0] < b[j][0] and a[i][1] < b[j][1]:
            mf.add_edge(i, j + n, 1)

print (mf.max_flow(src, dst))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n; cin >> n;
    vector<string> s(n); cin >> s;
    vector<VI> edge(n), ans(n, VI(n, INF));
    FOR(i, 0, n)ans[i][i] = 0;
    VI cnt(n, 0);
    FOR(i, 0, n)FOR(j, i, n) {
        if (s[i][j] == '0')continue;
        edge[i].push_back(j);
        edge[j].push_back(i);
        ans[i][j] = 1;
        ans[j][i] = 1;
        cnt[i]++; cnt[j]++;
    }
    //FOR(i, 0, n)for (int j : edge[i])cout << i << " " << j << "\n";

    int l = INF;
    int t = -1;
    FOR(i, 0, n) {
        if (chmin(l, cnt[i])) {
            t = i;
        }
    }
    VI dis(n, -1);
    queue<int> bfs;
    bfs.push(t); dis[t] = 0;
    while (!bfs.empty()) {
        int now = bfs.front(); bfs.pop();
        for (int to : edge[now]) {
            if (dis[to] != -1) {
                if (dis[to] == dis[now]) {
                    cout << "-1\n";
                    return 0;
                }
                else continue;
            }
            dis[to] = dis[now] + 1;
            bfs.push(to);
        }
    }
    //FOR(i, 0, n)cout << dis[i] << "\n";

    FOR(k, 0, n)FOR(i, 0, n)FOR(j, 0, n) {
        chmin(ans[i][j], ans[i][k] + ans[k][j]);
    }
    VI h(n);
    FOR(i, 0, n)h[i] = *max_element(all(ans[i]));
    cout << *max_element(all(h)) + 1 << "\n";
}


Measured memory_bytes: 640
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n;
void solve()
{
    cin>>n;
    bool flag=0;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        if(a%2==0)
        {
            if(a%3&&a%5)
                flag=1;
        }
    }
    if(flag)
        cout<<"DENIED"<<endl;
    else
        cout<<"APPROVED"<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

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

const long long MOD = 1000000007;

long long gcd(long long a,long long b){
    return b ? gcd(b,a%b) : a;
}
long long lcm(long long a,long long b){
    return a / gcd(a,b) * b;
}

long long mul(long long a,long long b,const long long mod){
    return b?(mul(a*2,b/2,mod)+(b&1?a:0))%mod:0;
}

long long bpow(long long a,long long b,const long long mod){
    return (b?bpow(a*a%mod,b/2,mod)*(b&1?a:1):1)%mod;
}

long long inv(long long a,const long long mod){
    return bpow(a,mod-2,mod);
}

// to overflow
/*long long bpow(long long a,long long b,const long long mod){
    return (b?mul(bpow(mul(a,a,mod),b/2,mod),(b&1?a:1),mod):1)%mod;
}*/
class mInt{
public:
    static const long long mod = 1000000007;
    long long v;
    mInt():v(0){}
    mInt(long long v):v((v%mod+mod)%mod){}
};
mInt& operator += (mInt &a,mInt b){ return a = a.v + b.v; }
mInt& operator -= (mInt &a,mInt b){ return a = a.v - b.v; }
mInt& operator *= (mInt &a,mInt b){ return a = a.v * b.v; }
mInt& operator /= (mInt &a,mInt b){ return a = a.v * inv(b.v,mInt::mod); }
mInt operator + (mInt a,mInt b){ return a += b; }
mInt operator - (mInt a,mInt b){ return a -= b; }
mInt operator * (mInt a,mInt b){ return a *= b; }
mInt operator / (mInt a,mInt b){ return a /= b; }
ostream& operator<<(ostream& os, const mInt& x){ return os << x.v; }

template <int N,long long mod>
struct nCr{
    vector<long long> f,finv;

    long long ncr(long long n,long long r){
        if( r > n || r < 0 ) return 0;
        assert(n <= N);
        return f[n] * finv[r] % mod * finv[n-r] % mod;
    }
    nCr(){
        f.resize(N+1);
        finv.resize(N+1);
        f[0] = 1;
        for(int i = 1 ; i <= N ; i++) f[i] = i * f[i-1] % mod;
        finv[N] = inv(f[N],mod);
        for(int i = N-1 ; i >= 0 ; i--) finv[i] = finv[i+1] * (i+1)%mod;
    }
};

nCr<200010, mInt::mod> ncr;

long long H;
long long W;
long long N;

vector<long long> r,c;

bool ok(int i, int j){
    return ( r[i] <= r[j]) && c[i] <= c[j];
}
long long calc(int i,int j){
    int dy = r[j] - r[i];
    int dx = c[j] - c[i];
    return ncr.ncr(dx + dy, dx);
}


long long dp[3010][2];
long long dfs(int x,int odd){
    if( dp[x][odd] != -1 ) return dp[x][odd];

    if( r.size() == x+1 ){
        return odd == 0;
    }

    long long ans = 0;
    for(int i = 0 ; i < r.size() ; i++){
        if( x != i && ok(x, i) ){
            ans += dfs(i, odd ^ 1) * calc(x, i);
            ans %= MOD;
        }

    }
    return dp[x][odd] = ans % MOD;
}



void solve(){
    memset(dp, -1, sizeof(dp));
    r.insert(r.begin(), 1);
    c.insert(c.begin(), 1);
    r.insert(r.end(), H);
    c.insert(c.end(), W);
    long long ans = dfs(0, 0);
    long long ans2 = dfs(0, 1);
    cout << ((ans2 - ans) % MOD + MOD) % MOD << endl;
}

int main(){
    scanf("%lld",&H);
    scanf("%lld",&W);
    scanf("%lld",&N);
    r.resize(N);
    c.resize(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&r[i]);
        scanf("%lld",&c[i]);
    }
    solve();
    return 0;
}


Measured memory_bytes: 3584
N, K = map(int,input().split())
A = sorted(list(map(int,input().split())))

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

if K in A:
    print("POSSIBLE")
    exit(0)
if K > max(A) or N == 1:
    print("IMPOSSIBLE")
    exit(0)

g = 1000000000
for k in range(1,N):
    g = min(g,gcd(A[k-1],A[k]))

if K%g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 86040
t[99],h[99];
main(i,s,N,T,L){
for(scanf("%d%d%d%d",&N,&T,&L,&L),i=0;i<N;i++)scanf("%d%d",t+i,h+i);
for(i=s=0;;i=(i+1)%N)if(t[i]){
	t[i]--;
	if(++T>L)break;
	if(++s==9)s=0;
}else if(h[i]){
	h[i]--;s++;
	if(T<s)break;
	t[i]=s;T-=s;s=0;
}else break;
printf("%d\n",i+1);exit(0);}

Measured memory_bytes: 600
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]

for i in range(d):
    for j in range(n):
        if i%a[j]==0:
            x+=1

print(x)

Measured memory_bytes: 70692
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int[] c = new int[8];
        c[0] = 1;c[1] = 2;c[2] = 1;c[3] = 2;c[4] = 1;c[5] = 4;c[6] = 1;c[7] = 4;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            int[] b = a.Split(' ').Select(int.Parse).ToArray();
            int[] f = new int[3];
            f[0] = 1000000000;
            for (int i = 0; i < 8; i++)
            {
                int e = 0;
                char[] h = new char[8];
                for (int j = 0; j < 8; j++)
                {
                    int d = j + i;
                    if (d >= 8)
                        d -= 8;
                    int g = b[j] - c[d];
                    if (g < 0)
                        g = 0;
                    e += g;
                    h[j] = (char)(c[d] + '0');
                }
                if (f[0] > e)
                {
                    f[0] = e;
                    f[1] = i;
                    string k = new string(h);
                    f[2] = int.Parse(k);
                }
                if (f[0] == e)
                {
                    string k = new string(h);
                    int l = int.Parse(k);
                    if (f[2] > l)
                    {
                        f[1] = i;
                        f[2] = l;
                    }
                }
            }
            int m = f[1];
            for (int i = 0; i < 8; i++)
            {
                int n = m + i;
                if (n >= 8)
                    n -= 8;
                if (i == 0)
                    Console.Write(c[n]);
                else
                    Console.Write(" " + c[n]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9540
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-10;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int K, R, L;
ld P;
ld E;
ld T;


long long int atime(const long long int l, const long long int r) {
	if (l > LLONG_MAX / r) {
		return LLONG_MAX;
	}
	else {
		return l*r;
	}
}
long long int powint(long long int a, long long int b) {
	if (!b)return 1;
	else {
		return atime(a, powint(a, b - 1));
	}
}

long long int aplus(const long long int l, const long long int r) {
	if (l > LLONG_MAX / 3 || R > LLONG_MAX)return LLONG_MAX;
	else return l + r;
}
//ld getans(const ld amin, const ld amax,const int rest,const ld per) {
//	if (!rest||per<4e-8) {
//		return abs((amin + amax) / 2 - T) < E+eps;
//	}
//	if (amin > E + T+eps)return 0;
//	if (amax < T-E - eps)return 0;
//	if (amin > T - E - eps&&T + E + eps < amax)return 1;
//	ld amid = (amin + amax) / 2;
//	if (amid > T-eps) {
//		return getans(amin, amid,rest-1,per*(1-P))*(1-P) + getans(amid, amax,rest-1,per*P)*P;
//	}
//	else {
//		return getans(amin, amid, rest - 1,per*P)*P + getans(amid, amax, rest - 1,per*(1-P))*(1 - P);
//	}
//}

void getans(const vector<long long int>& sums,const vector<long long int>&tickets, const int now, long long int &ans,const long long int rest) {
	if (now == tickets.size()) {
		ans = min(ans, rest);
		return;
	}
	if (ans < rest - sums[now])return;
	
	if (rest >= tickets[now]) {
		getans(sums, tickets, now + 1, ans, rest - tickets[now]);
	}
	else {
		ans = min(ans, tickets[now] - rest);
	}
	getans(sums, tickets, now + 1, ans, rest);
}
int main() {
	//cin >> K >> R >> L;
	//cin >> P >> E >> T;
	//ld ans = getans(R, L, K,1);
	//cout << setprecision(22) << fixed << ans << endl;
	//return 0;
	long long int N, M, A, B, P, Q; cin >> N >> M >> A >> B >> P >> Q;
	if (A > B) {
		swap(A, B);
		swap(P, Q);
	}
	assert(A <= B);
	if (A == 1 && B == 1) {
		long long int ticdis = P + Q;
		if (atime(ticdis,N) <= M) {
			cout << M - atime(ticdis, N) << endl;
		}
		else {
			cout << min(ticdis-M%ticdis,M%ticdis) << endl;
		}
	}
	else {
		vector<long long int>tickets;
		long long	int ans = M;
		for (int k = 0; k < N; ++k) {
			long long int tic =aplus( atime(P, powint(A, k)), atime(Q, powint(B, k)));
			if (tic > M) {
				ans = min(ans, tic - M);
				break;
			}
			else {
				tickets.emplace_back(tic);
			}
		}
		reverse(tickets.begin(), tickets.end());
		vector<long long int>sums(tickets);
		for (int i = sums.size()-1; i >0; --i) {
			sums[i - 1] += sums[i];
		}
		getans(sums, tickets, 0, ans, M);
		cout << ans << endl;
	}
	return 0;
}

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

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

	int tmp = 2 * d + 1;
	int ans;
	if (n % tmp == 0) {
		ans = n / tmp;
	}
	else {
		ans = n / tmp + 1;
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<string.h>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define None cout<<"None"<<endl
#define GREATER cout<<"GREATER"<<endl
#define LESS cout<<"LESS"<<endl
#define EQUAL cout<<"EQUAL"<<endl
typedef long long ll;
using namespace std;

int main() {
	string A,B,C; cin >> A >> B;
	int a = A.size();
	int b = B.size();
	int c = min(a,b);
	for (int i = 0; i < c; ++i) {
		cout << A[i] << B[i];
	}
	if (a > b) cout << A[c] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int P,Q,R;
	scanf("%d%d%d", &P,&Q,&R);
	int A = P + Q, B = Q + R, C = R + P;
	int min=1000000000;
	if (min > A)min = A;
	if (min > B)min = B;
	if (min > C)min = C;

	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[10101][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, x, y;
	cin >> n >> x >> y;
	vector<ll>ans(n);
	for (ll i = 1;i < n;++i) {
		for (ll j = i + 1;j <= n;++j) {
			ll dist = min(abs(x - i) + abs(y - j) + 1, j - i);
			ans[dist]++;
		}
	}
	for (ll i = 1;i < n;++i) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void) {
    int a = 1, b = 1;
    for (int i = 0;; i++)
    {
        scanf ("%d %d", &a, &b);
        if (a != 0 || b != 0)
        {   
            if (a < b)
            {
                printf("%d %d\n", a, b);
            }
            else
            {
                printf("%d %d\n", b, a);
            }
        }
        else
        {
            break;
        }
    }
    return 0;
}



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

int main(void) {
	char s[100000];
	scanf("%s", s);
	int i;
	int n = strlen(s);
	char t[n], u[n];
	int countA = 0, countB = 0;
	for (i = 0;i < n; i++) {
		if (i % 2 == 0) {
			t[i] = '1';
			u[i] = '0';
		} else {
			t[i] = '0';
			u[i] = '1';
		}
		if (s[i] != t[i]) {
			countA++;
		}
		if (s[i] != u[i]) {
			countB++;
		}
	}
	/*
	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] == '0' && s[i+1] == '0') {
			s[i+1] = '1';
			count++;
		} else if (s[i] == '1' && s[i+1] == '1'){
			s[i+1] = '0';
			count++;
		}
	}
	*/
	int ans = 0;
	printf("%d\n", ans = ( (countA >= countB) ? countB : countA));
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int n,m,c,a[100][100],b[200],i,j,tmp=0,cnt=0;
	scanf("%d %d %d",&n,&m,&c);
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i<n;i++){
		tmp=0;
		for(j=0;j<m;j++){
			//printf("a[%d][%d]*b[%d] = %d\n",i,j,j,a[i][j]*b[j]);
			tmp += a[i][j]*b[j];
			//printf("%d\n", tmp);
		}
		if(tmp+c>0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 128
N = int(raw_input())
S = raw_input()

alphabet = {"A":1, "B":2, "C":3, "D":4, "E":5, "F":6, "G":7, "H":8, "I":9, "J":10, "K":11, "L":12, "M":13, "N":14, "O":15, "P":16,
            "Q":17, "R":18, "S":19, "T":20, "U":21, "V":22, "W":23, "X":24, "Y":25, "Z":26}

abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

ans = ""
for char in S:
    num = alphabet[char]
    ans = ans + abc[(num+N)%26-1]

print ans



Measured memory_bytes: 2692
def sup(A, j):
	if A[0] >= j:
		return 0
	l = 0
	r = len(A) - 1
	while True:
		i = (l+r) // 2
		if i == len(A) - 1 and A[i] < j:
			return len(A)
		elif A[i]<j and A[i+1]>=j:
			return i+1
		else:
			if A[i] >= j:
				r = i-1
			else: # A[i+1] < j
				l = i+1		

def inf(A, j): 
    if A[-1] <= j:
        return 0
    l = 0
    r = len(A) - 1
    while True:
        i = (l+r) // 2
        if i == 0 and A[i]>j:
            return len(A)
        elif A[i]>j and A[i-1]<=j:
            return len(A)-i
        else:
            if A[i] <= j:
                l = i+1
            else: # A[i-1] > j
                r = i-1		

N = int(input())
[A, B, C] = [sorted([int(i) for i in input().split()]) for j in range(3)]
ans = 0
for j in B:
	ans += sup(A, j) * inf(C, j)
print(ans)

Measured memory_bytes: 24224
#include <cstdio>
#include <vector>
#include <functional>
using namespace std;

int main()
{
  int N;
  vector<int> a;
  scanf("%d", &N);
  a.resize(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end(), greater<int>());
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
    {
      alice += a[i];
    }
    else
    {
      bob += a[i];
    }
  }
  printf("%d\n", alice - bob);
}

Measured memory_bytes: 888