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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

ll a, b;

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

	cin >> a >> b;

	ll result = b-a+1;

	ll now = 0;
	for (int i = 60; i >= 0; --i) {
		if (b & (1LL << i)) continue;
		ll now = (b >> i) << i;
		now -= now & -now;
		ll cur = now | (1LL << i); 
		//cout << cur << ' ' << a << ' ' << b << endl;
		if (cur > b) continue;
		ll rem = b % (1LL << i);
		ll l1 = 0, r1 = (1LL << i) - 1;
		ll l2 = 0, r2 = 0;
		while ((1LL << r2) <= rem) ++r2;
		r2 = (1LL << r2)-1;
		if ((a >> i) == (cur >> i)) {
			l1 = a % (1LL << i);
			result += r1-l1+1;
			// cout << "BIT: " << i << endl;
			// cout << "CUR: " << cur << endl;
			// cout << l1 << ' ' << r1 << endl;
		} else {
			if (cur < a) continue; 
			result += (1LL << i);
			// cout << "BIT: " << i << endl;
			// cout << l1 << ' ' << r1 << endl;
			// cout << l2 << ' ' << r2 << endl;
		}
		//ll inter = max(0LL, min(r1, r2) - max(l1, l2) + 1);
		//result += max(0LL, min(r1, r2) - max(l1, l2) + 1);
	}

	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

void main() {
	auto args = readln.chomp.split;
	long n = args[0].to!int;
	long c = args[1].to!long;
	alias Node = Tuple!(long, "x", long, "v");
	Node[] nodes = new Node[](n);
	foreach (i; 0..n) {
		auto p = readln.chomp.split.map!(to!long);
		long x = p[0];
		long v= p[1];
		nodes[i] = Node(x, v);
	}
	std.algorithm.sort(nodes);
	// cw
	debug stderr.writeln("CW");
	long[] cw = new long[](n);
	long[] cwMax = new long[](n);
	{
		long v = 0;
		long x = 0;
		long ans = long.min;
		foreach (i, node; nodes) {
			long dx = node.x - x;
			x += dx;
			v -= dx;
			v += node.v;
			cw[i] = v;
			ans = max(ans, v);
			cwMax[i] = max(ans, v);
		}
	}
	debug stderr.writeln(cw, " ... ", cwMax);
	// ccw
	long[] ccw = new long[](n);
	long[] ccwMax = new long[](n);
	debug stderr.writeln("CCW");
	{
		long v = 0;
		long x = c;
		long ans = long.min;
		foreach_reverse(i, node; nodes) {
			auto j = n - 1 - i;
			long dx = x - node.x;
			x -= dx;
			v -= dx;
			v += node.v;
			ccw[j] = v;
			ans = max(ans, v);
			ccwMax[j] = ans;
		}
	}
	debug stderr.writeln(ccw, " ... ", ccwMax);
	// fast cw
	long ans = 0;
	for (int i = 0; i < n; ++i) {
		long v = cw[i];
		long w = long.min;
		if (n - 2 - i >= 0)
			w = max(0, v - nodes[i].x) + ccwMax[n - 2 - i];
		debug stderr.writefln("\t[%d] max(%d, %d)", i, v, w);
		ans = max(ans, v);
		ans = max(ans, w);
	}
	// fast ccw
	for (int i = 0; i < n; ++i) {
		long v = ccw[i];
		long w = long.min;
		if (n - 2 - i >= 0)
			w = max(0, v - (c - nodes[n - 1 - i].x)) + cwMax[n - 2 - i];
		debug stderr.writefln("\t[%d] max(%d, %d)", i, v, w);
		ans = max(ans, v);
		ans = max(ans, w);
	}
	ans.writeln;
}



Measured memory_bytes: 8060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i=0; i<n; i++) {
            h[i] = sc.nextInt();
        }

        int numWaterings = 0;
        boolean nonZeroTreeFound = true;
        while (nonZeroTreeFound) {
        	nonZeroTreeFound = false;
            boolean oldBunchOfTreesEnded = false;
            for (int i=0; i<n; i++) {
            	if (h[i] > 0) {
                	nonZeroTreeFound = true;
                    h[i]--;
                    oldBunchOfTreesEnded = false;
                } else {
                	if (nonZeroTreeFound && !oldBunchOfTreesEnded) {
                      oldBunchOfTreesEnded = true;
                      numWaterings++;
                    }
                }
            }
            if (nonZeroTreeFound && !oldBunchOfTreesEnded) {
            	numWaterings++;
            }
        }
        System.out.println(numWaterings);
    }
}


Measured memory_bytes: 21844
a, b, c = map(int, input().split())
rem = a % b
tmp = 0
fa = a
ans = "NO"
if(rem!=0):
    while (tmp != rem):
        a += fa
        tmp = a % b
        if (tmp == c):
            ans = "YES"
            break
else:
    if(c==0):
        ans = "YES"
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    string s;
    cin >> s;
    bool good = true;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(i % 2){
            if(s[i] == 'R') good = false;
        }else{
            if(s[i] == 'L') good = false;
        }
    }
    if(good) puts("Yes");
    else puts("No");
}


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    for(int i = a;i <= min(b,a+k-1);i++) cout << i << endl;
    for(int i = max(b-k+1,a+k);i <=b;i++) cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
	fastio();
	ll N,K;
	cin>>N>>K;
	ll ar[N];
	cn(ar,N);
	ll dp[K+1]={0};
	for(ll i=0;i<ar[0];i++)
	{
		dp[i]=2;
	}
	for(ll i=ar[0];i<=K;i++)
	{
		for(ll j=0;j<N;j++)
		{
			if(i<ar[j])
				break;
			if(dp[i-ar[j]]==2)
			{
				dp[i]=1;
				break;
			}
		}
		if(dp[i]==0)
			dp[i]=2;
	}
	if(dp[K]==1)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
}	


Measured memory_bytes: 1024
// icpc.cpp : R\[ AvP[VÌGg |Cgðè`µÜ·B
//


#include <iostream>
#include <stdio.h>
struct P{
	int x, y;
};

int main(int argc, char* argv[])
{
	int N;
	
	while(1){
		scanf("%d", &N);
		if(N == 0){
			break;
		}
		P dia[20];
		for(int i = 0; i < N; i++){
			scanf("%d %d", &dia[i].x, &dia[i].y);
			if(dia[i].x == 10 && dia[i].y == 10){
				dia[i].x = dia[i].y = -1;
			}
		}
		int x = 10, y = 10;
		int M;
		scanf("%d", &M);
		for(int i = 0; i < M; i++){
			char ch;
			int dx, dy;
			scanf(" %c", &ch);
			switch(ch){
			case 'N': dx = 0; dy = 1; break;
			case 'E': dx = 1; dy = 0; break;
			case 'S': dx = 0; dy = -1; break;
			case 'W': dx = -1; dy = 0; break;
			}
			int d = 0;
			scanf("%d", &d);
			for(int j = 0; j < d; j++){
				x += dx; y += dy;
				for(int k = 0; k < N; k++){
					if(dia[k].x == x && dia[k].y == y){
						dia[k].x = dia[k].y = -1;
						break;
					}
				}
			}
		}
		bool f = false;
		for(int k = 0; k < N; k++){
			if(dia[k].x != -1 && dia[k].y != -1){
				f = true;
				break;
			}
		}
		printf(f ? "No\n" : "Yes\n");


	}
	return 0;
}

Measured memory_bytes: 0
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()

  if len(s)<5:
    print('NO')
  else:
    if s[-4:]=='BARA':
      if s.count('A')>4:
        print('NO')
      elif s.count('A')==4:
        if s=='AKIHABARA':
          print('YES')
        else:
          print('NO')
      else:
        if s.count('KIH')==1:
          print('YES')
        else:
          print('NO')

    elif s[-3:]=='BRA' or s[-3:]=='BAR':
      if s.count('A')>3:
        print('NO')
      elif s.count('A')==3:
        if s=='AKIHABRA' or s=='AKIHABAR':
          print('YES')
        else:
          print('NO')
      else:
        if s.count('KIH')==1:
          print('YES')
        else:
          print('NO')

    elif s[-2:]=='BR':
      if s.count('A')>2:
        print('NO')
      elif s.count('A')==2:
        if s=='AKIHABR':
          print('YES')
        else:
          print('NO')
      else:
        if s.count('KIH')==1:
          print('YES')
        else:
          print('NO')
    else:
      print('NO')

main()


Measured memory_bytes: 7740
n=int(input())
t_won=0
h_won=0
for _ in range(n):
    t_wd,h_wd = input().split()
    if   t_wd > h_wd: t_won += 1
    elif t_wd < h_wd: h_won += 1
print(t_won*3 + (n-t_won-h_won), h_won*3 + (n-t_won-h_won))


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

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

	int n = s.size();
	int a = -1;
	int b = -1;

	for( int i = 0; i < n-1; ++i ) {
		if( s.at( i ) == s.at( i+1 ) ) {
			a = i+1;
			b = i+2;
			break;
		}
		else if( i < n-2 && s.at( i ) == s.at( i+2 ) ) {
			a = i+1;
			b = i+3;
			break;
		}
	}

	cout << a << ' ' << b << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<vector<int>> to(n), cost(n);
    for(int i = 0; i < n - 1; i++) {
        int u; cin >> u; u--;
        int v; cin >> v; v--;
        int w; cin >> w;
        to[u].push_back(v); cost[u].push_back(w);
        to[v].push_back(u); cost[v].push_back(w);
    }

    vector<int> ans(n, -1);
    queue<int> q;

    ans[0] = 0;
    q.push(0);

    while(!q.empty()) {
        int target = q.front(); q.pop();
        for(int i = 0; i < to[target].size(); i++) {
            int e = to[target][i];
            int c = cost[target][i];
            if(ans[e] != -1) continue;
            ans[e] = (ans[target] + c) % 2;
            q.push(e);
        }
    }

    for(int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 13184
X = int(input())

p = [0]*1000

flag = False
for i in range(1000):
    p[i] = i**5

for i in range(1000):
    for j in range(1000):
        if p[i]-p[j] == X:
            a = i
        
            b = j
            flag=True
        if p[i] + p[j] ==X:
            a=i
            b=-j
            flag=True


        if flag:
            break
    if flag:
        break

print(str(a)+" "+str(b))


Measured memory_bytes: 9136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
ll f[10000001];
int n;
void solve(){
    cin>>n;
    ll ans=0;
    memset(f,0,sizeof f);
    for(int i=1;i<=n;i++){
        f[i]+=i;
        for(int j=i+i;j<=n;j+=i) f[j]+=j;
    }
    for(int k=1;k<=n;k++){
        ans+=f[k];
    }
    cout<<ans;
    return;
}
int main(){
    //IO FO
    //TEST
    solve();

    return(0);
}


Measured memory_bytes: 81756
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll mod=998244353;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


int main()
{
	fast;
	ll s,w;
	cin>>s>>w;
	if (w>=s)
		cout<<"unsafe";
	else
		cout<<"safe";
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if((e-a)<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}

Measured memory_bytes: 256
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from itertools import accumulate

    n, k = map(int, readline().split())
    a = [*map(int, readline().split())]
    for _ in range(min(k, 41)):
        memo = [0] * n
        for i, aa in enumerate(a):
            if i > aa:
                memo[i - aa] += 1
            else:
                memo[0] += 1
            j = i - ~ aa
            if j < n:
                memo[j] -= 1
        a = [*accumulate(memo)]
    print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29316
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    use std::collections::HashMap;
    let mut candidates = HashMap::new();
    for _ in 0..N {
        let v: usize = read();
        let entry = candidates.entry(v).or_insert(0);
        *entry += 1;
    }
    let M: usize = read();
    let mut problems = HashMap::new();
    for _ in 0..M {
        let v: usize = read();
        let entry = problems.entry(v).or_insert(0);
        *entry += 1;
    }
    for (p, count) in problems {
        match candidates.get(&p) {
            None => {
                println!("NO");
                return;
            }
            Some(a) => {
                if *a < count {
                    println!("NO");
                    return;
                }
            }
        }
    }
    println!("YES");
}


Measured memory_bytes: 19580
#include <cstdio>
#include <cctype>
#include <utility>
#include <climits>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

struct min_max {
	int min {INT_MAX}, max {INT_MIN};
	void update(int x) {
		if (x < min) min = x;
		if (max < x) max = x;
	}
};

int main() {
	for (int n; (n = in());) {
		min_max m;
		while (n--) {
			int a {};
			for (int j {}; j < 5; j++)
				a += in();
			m.update(a);
		}
		outl(m.max, ' ', m.min);
	}
}


Measured memory_bytes: 2520
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	string s;
	char b[8][8],nb[8][8];
	rep(i,8) {
		cin >> s;
		rep(j,8) {
			b[i][j] = s[j];
		}
	}
	rep2(i,1,4) {
		cout << 90*i << endl;
		rep(i,8) {
			rep(j,8) {
				nb[i][j] = b[7-j][i];
			}
		}
		rep(i,8) {
			rep(j,8) {
				b[i][j] = nb[i][j];
				cout << b[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

int main(){
    int n;cin>>n;
    ll l[n];
    for(int i=0;i<n;++i) cin>>l[i];
    sort(l,l+n);
    int ans=0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            for(int k=j+1;k<n;++k){
                if(l[i]==l[j]||l[j]==l[k]||l[k]==l[i]) continue;
                if(l[k]<l[i]+l[j]) ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
t[3000];c;f(x,i){if(!--t[x])for(;i;f(x+="33h6h25"[--i]-52,8));}main(h){for(;scanf("%d%d",t,&h)**t;printf("%d\n",c)){for(;h;--h)for(c=*t;c;)scanf("%d",h*52+c--+t);for(h=3e3;--h;f(h,8))c+=t[h]>0;}}

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

using namespace std;

int main() {
	int a, b, c, d, e, t1, t2, t3;

	cin >> a >> b >> c >> d >> e;
	if (a > 0) {
		t1 = 0;
		t2 = 0;
		t3 = b - a;
	}
	else {
		t1 = -a;
		t2 = 1;
		t3 = b;
	}
	cout << t1*c + t2*d + t3*e << endl;

	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int fin=0,ans=0;
bool vis[200050];
vector <  int  > v[200050];
int dfs(int x)
{
    if(vis[x]) return 0;
    vis[x]=true; ans++;
    for(auto it: v[x]) if(!vis[it]) dfs(it);
  return 0;
}
int main()
{
     int n,m;
     cin>>n>>m;

     for(int i=0;i<m;i++)
     {
         int a,b;
         cin>>a>>b;
         v[a].push_back(b);
         v[b].push_back(a);
     }
     memset(vis,false,sizeof(vis));
     for(int i=1;i<=n;i++)
     {
         if(!vis[i])
         {
             ans=0;
             dfs(i);
         }
         fin=max(fin,ans);
     }
     cout<<fin;

    }

Measured memory_bytes: 24068
#include <iostream>

using namespace std;

const int N_MAX = 2e5 + 5;

int tot_w[N_MAX] = {0};
int tot_b[N_MAX] = {0};

int main() {
    int N;
    string S;

    cin >> N >> S;

    //  ww...wwbb..bb

    for (int i = 0; i < N; i++) {
        tot_w[i + 1] = tot_w[i];
        if (S[i] == '.') {
            tot_w[i + 1]++;
        }
    }

    int ans = N;
    for (int i = 0; i <= N; i++) {
        // iより前の黒の数
        int b_cnt = i - tot_w[i];
        // iより後ろの白の数
        int w_cnt = tot_w[N] - tot_w[i];
        ans = min(ans, b_cnt + w_cnt);
    }

    cout << ans << endl;
}

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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

const int maxn = 2228;
int d[maxn][maxn];
signed main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int i, j, n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    for (i = 0; i < n; i++){
        for (j = i + 1; j < n; j++){
            d[i][j] = min(j - i, abs(x - i) + 1 + abs(y - j));
            d[i][j] = min(d[i][j], abs(y - i) + 1 + abs(x - j));
        }
    }
    vector < int > c(n + 1);
    for (i = 0; i < n; i++){
        for (j = i + 1; j < n; j++){
            c[d[i][j]]++;
        }
    }
    for (i = 1; i < n; i++){
        cout << c[i] << endl;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 35072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n; cin >> n;
    if (n % 1000 == 0) {
       cout << 0 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt();
			int[] sn = new int[N];
			int[] sm = new int[M];
			int sumn = 0;
			for (int i = 0; i < N; ++i) {
				sn[i] = sc.nextInt();
				sumn += sn[i];
			}
			int summ = 0;
			for (int i = 0; i < M; ++i) {
				sm[i] = sc.nextInt();
				summ += sm[i];
			}
			int ansn = -1;
			int ansm = -1;
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < M; ++j) {
					if (sumn - sn[i] + sm[j] == summ - sm[j] + sn[i]) {
						if (ansn == -1 || ansn + ansm > sn[i] + sm[j]) {
							ansn = sn[i];
							ansm = sm[j];
						}
					}
				}
			}
			if (ansn == -1) {
				System.out.println(-1);
			} else {
				System.out.println(ansn + " " + ansm);
			}
		}
	}
}

Measured memory_bytes: 21164
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	for {
		sc.Scan()
		s := sc.Text()

		if si, _ := strconv.Atoi(s); si == 0 {
			return
		}

		t := 0
		for _, r := range s {
			ri := int(r - '0')
			t += ri
		}
		fmt.Println(t)
	}
}



Measured memory_bytes: 1068
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
gu,pa=0,0
win,lose=0,0
for i in s:
    if i=="g":
        if pa+1<=gu:
            pa+=1
            win+=1
        else:
            gu+=1
    else:
        if pa+1<=gu:
            pa+=1
        else:
            gu+=1
            lose+=1
print(win-lose)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
typedef long long ll;
#define rep(i,n) for (ll i=0;i<n;i++)
#include <bits/stdc++.h>


using namespace std;


int main(){
	ll N,sum=0;
  cin >> N;
 // vector <pair<int, int>> p;
  map <ll,ll> p;
  vector <ll> tmp(N);
  set <ll> S;
  
  rep(i,N){
    cin>> tmp.at(i); 
    S.insert(tmp.at(i));
  }
  //cout << S.size() << endl;
  //ll n=S.size();
 /* rep(i,n){
    //cout << *begin(S) << endl;
    p[*begin(S)]=0;
    S.erase(*begin(S));
    //cout << p.at(i).first << p.at(i).second << endl;
  }*/
  
  for (auto value : S) {
  p[value]=0;
}
  
  rep(i,N){
    p.at(tmp.at(i))++;
  }
  for (auto q : p) {
    
  auto k = q.first;
  auto v = q.second;
    
    sum+=(v-1)*v/2;
  //cout << k << " => " << v << endl;
}
  //cout << p.size() << endl;
  //vector <ll> a(p.size());
  
  
 /* rep(i,p.size()){
    //cout << p.at(tmp.at(i)) << endl;
    sum+=(p.at(tmp.at(i))-1)*p.at(tmp.at(i))/2;
   // a.at(i)=(p.at(tmp.at(i))-1)*p.at(tmp.at(i))/2;
  }*/
  //cout << sum << endl;
  rep(i,N){
    ll sum2=sum;
    sum2-=(p.at(tmp.at(i))-1)*p.at(tmp.at(i))/2;
    //cout << sum2 << endl;
    p.at(tmp.at(i))--;
    sum2+=(p.at(tmp.at(i))-1)*p.at(tmp.at(i))/2;
    cout << sum2 << endl;
    p.at(tmp.at(i))++;
  }
}

Measured memory_bytes: 18844
#include<stdio.h>
int main()
{
    
    int n,v,j;
    scanf("%d",&n);
    int A[n];
    
    for(int i=0; i<n; i++){
        scanf("%d",&A[i]);
        
    }
    for(int i=0; i<n; i++){
        printf("%d",A[i]);
        if(i<n-1)printf(" ");
    }
    printf("\n");
    for (int i=1; i<n; i++) {
        v=A[i];
        j = i-1;
        while (j>=0 && A[j]>v) {
            A[j+1] = A[j];
            j--;
        }
         A[j+1]=v;
        for(int k=0; k<n; k++){
            printf("%d",A[k]);
            if(k<n-1) printf(" ");
        }
        printf("\n");
    }

    return 0;
}



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

int main(void)
{
    string s;
    cin >> s;
    int Ai{0}, Zi{0};
    for(int i{0}; i<s.size(); ++i){
        if(s[i]=='A'){
            Ai = i;
            break;
        }
    }
    for(int i{s.size()-1}; i>0; --i){
        if(s[i]=='Z'){
            Zi = i;
            break;
        }
    }

    cout << Zi - Ai + 1 << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int MOD=1000000007;
#define IOS() ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;

int main()
{
  IOS();
 int a;
 cin>>a;
 cout<<a+a*a+a*a*a<<endl;
return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void) {
	string S; cin >> S;
	int d_sum = 0;
	for (int i = 0; i < (int)S.length(); ++i)
		d_sum += (int)(S[i] - '0');
	if (d_sum % 9 == 0)
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>

main(){
    int N;
    int a;
    int i;
    long long int rt=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&a);
        while(!(a%2)){
            a/=2;
            rt++;
        }
    }
    printf("%lld\n",rt);
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int s(int x){
    int r = 0;
    while (x) {
        r += x % 10;
        x /= 10;
    }
    return r;
}

int main() {
    int n;
    cin >> n;
    cout << (n % s(n) == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
# ABC055C - Scc Puzzle (ARC069C)
def main():
    n, m = list(map(int, input().rstrip().split()))
    ans = min(n, m // 2)  # S + CC
    ans += (m - ans * 2) // 4  # CCCC -> SCC
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include "iostream"
#include "vector"
 
using namespace std;

long long int N, Q;
 
class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node) return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v) return;
		if (rank[u] < rank[v]) parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v]) rank[u]++;
		}
	}
	bool Check(int u, int v) {
		return Find(u) == Find(v);
	}
};
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N >> Q;
	UnionFind uf(N);
	vector<vector<int>> com(Q, vector<int>(3));
	for (int i = 0; i < Q; i++) {
		cin >> com[i][0] >> com[i][1] >> com[i][2];
	}
	for (int i = 0; i < Q; i++) {
		if (com[i][0] == 0) {
			uf.Unite(com[i][1], com[i][2]);
		} else if (com[i][0] == 1) {
			if (uf.Check(com[i][1], com[i][2]))
				cout << 1 << endl;
			else
				cout << 0 << endl;
		}
	}
	return 0;
}


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        ll r=0,g=0,b=0;
        loop(i,0,n-1)
        {
            if(s[i]=='R') r++;
            if(s[i]=='G') g++;
            if(s[i]=='B') b++;
        }
        ll tot=r*g*b;
        //int rgb=(int)'R'+(int)'G'+(int)'B';
        loop(i,0,n-1)
        {
            loop(j,i+1,n-1)
            {
                int k=2*j-i;
                if(k<n)
                {
                    if(s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]) tot--;
                }
            }
        }
        cout<<tot;

    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
const ll MOD = 1000000007;
const int MAX = 1001001;

int memo[MAX];
int rec(int n){
    if(n==0) return 0;
    if(memo[n]!=-1) return memo[n];
    int ret=n;
    for(int i=0;i<=8;i++) {
        int six=pow(6,i);
        int nine=pow(9,i);
        if(n-six>=0) chmin(ret,rec(n-six)+1);
        if(n-nine>=0) chmin(ret,rec(n-nine)+1);
    }
    return memo[n]=ret;
}

signed main(){
    int n; cin >> n;
    memset(memo,-1,sizeof(memo));
    cout << rec(n) << endl;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>

#define mp make_pair
#define pb push_back
#define ppb pop_back

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;

ll doOp(string op);

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define forn1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forn11(i, n) for (int i = 1; i < (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#define prOk(ok) cout << ((ok) ? "Yes" : "No")
#define in insert
#define rem remove

#define linf ((ll) 1e9)
#define inf ((int) 1e5)

vvb a;

int main()
{

	ll w, h, n;

	cin >> w >> h >> n;

	map<pll, ll> m;

	ll res[10] = {};
	res[0] = (w-2)*(h-2);

	forn(i, n)
	{
		ll x, y;
		cin >> x >> y;
		for(int dx = -1; dx <= 1; dx++)
		{
			for(int dy = -1; dy <= 1; dy++)
			{
				if (x + dx <= 1 ||
						x + dx >= w ||
						y + dy <= 1 ||
						y + dy >= h)
					continue;

				res[m[mp(x+dx, y+dy)]]--;
				m[mp(x+dx, y+dy)]++;
				res[m[mp(x+dx, y+dy)]]++;
			}
		}

		//pt.insert(mp(x - 1, y - 1), 1);
	}


	forn(i, 10)
		cout << res[i] << endl;

	return 0;
}


Measured memory_bytes: 56448
import math
import itertools as its
x=int(input())
y=[[float(i) for i in input().split()] for _ in range(x)]
l=0
def di(i1,i2):
  return math.sqrt((y[i1][0]-y[i2][0])**2+(y[i1][1]-y[i2][1])**2)
z=[[di(j,-i-1) for i in range(x-1-j)]for j in range(x)]
yit=list(its.permutations(range(x)))
for i in yit:
  now=0
  while now<x-1:
    if i[now]<i[now+1]:
      l+=z[i[now]][-i[now+1]+i[now]]
    else:
      l+=z[i[now+1]][+i[now+1]-i[now]]
    now+=1
print(l/(len(yit)))

Measured memory_bytes: 8052
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int a, b, c, N, I[1010], J[1010], K[1010], R[1010];
int check[333];

void solve() {
	fill(check, check + 333, 2);
	
	for_(i,0,N) if (R[i]) check[ I[i] ] = check[ J[i] ] = check[ K[i] ] = 1;
	
	for_(i,0,N) {
		if (!R[i]) {
			if (check[ I[i] ] == 1 && check[ J[i] ] == 1) check[ K[i] ] = 0;
			if (check[ J[i] ] == 1 && check[ K[i] ] == 1) check[ I[i] ] = 0;
			if (check[ K[i] ] == 1 && check[ I[i] ] == 1) check[ J[i] ] = 0;
		}
	}
	
	for_(i,1,a+b+c+1) cout << check[i] << endl;
}

int main() {
	while (cin >> a >> b >> c, a) {
		cin >> N;
		for_(i,0,N) cin >> I[i] >> J[i] >> K[i] >> R[i];
		solve();
	}
	return 0;
}

Measured memory_bytes: 1176
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define pi acos(-1.0)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
typedef long long LL;
typedef unsigned long long ULL;

int a[10];

int main()
{
    int n,x,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x<3200)a[x/400+1]++;
        else a[9]++;
    }
    for(int i=1;i<=8;i++)
    {
        if(a[i])sum++;
    }
    if(sum)cout<<sum<<' ';
    else cout<<1<<' ';
    cout<<a[9]+sum<<endl;
    return 0;
}





















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

typedef long long ll;
static const int MOD = 1e9+7;
static const int INF = 1<<30;

int main(){
    char c;
    cin>>c;
    if(c >= 'a' && c <= 'z') cout<<"a"<<endl;
    else cout<<"A"<<endl;
}

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


int main(){
     int t;
     cin>>t;
     int t0=0;
     int x_pos=0;
     int y_pos=0;
     while(t--){
         int sec;
         cin>>sec;
         int req_x,req_y;
         cin>> req_x;
         cin>> req_y;
         int diff= abs(req_x - x_pos)+abs(req_y - y_pos);
         int check= abs(sec-t0);
         if(check%diff==0){
             x_pos= req_x; y_pos=req_y; t0=sec;        
             
         }
        else{
            cout<<"No"; return 0;
        }         
         
         
     }
     cout<<"Yes";   
    return 0;
}

Measured memory_bytes: 256
N, M = gets.chomp.split(' ').map(&:to_i)
ab_list = N.times.map { gets.chomp.split(' ').map(&:to_i) }
ab_list = ab_list.sort_by { |(a, _)| a }
rest = M
ans = 0
ab_list.each do |(a, b)|
  count = [rest, b].min
  ans += a * count
  rest -= count
  break if rest == 0
end
puts ans


Measured memory_bytes: 12664
#include <cstdio>
#include <cstring>
typedef long long int64;
static const int MAXD = 10;

int N;
int pow10[MAXD];

inline bool query(int64 n)
{
    static char r[20];
    printf("? %lld\n", n); fflush(stdout);
    scanf("%s", r);
    return r[0] == 'Y';
    /*sprintf(r, "%lld", n);
    static char s[20];
    sprintf(s, "%d", N);
    bool result = ((strcmp(r, s) <= 0) == (n <= N));
    static int ct = 0;
    printf("%d > ", ++ct);
    puts(result ? "Y" : "N");
    return result;*/
}

bool result[MAXD];

int main()
{
    //scanf("%d", &N);

    pow10[0] = 1;
    for (int i = 0; i < MAXD - 1; ++i)
        pow10[i + 1] = pow10[i] * 10;

    for (int i = 0; i < MAXD; ++i)
        result[i] = query(pow10[i]);

    // Corner cases
    if (result[MAXD - 1] == true) {
        for (int i = 0; i < MAXD; ++i)
            if (query(2 * pow10[i])) { printf("! %d\n", pow10[i]); break; }
    } else {
        int dg;
        for (dg = 0; result[dg]; ++dg) ;
        int64 accum = 0;
        for (int i = 0; i < dg - 1; ++i) {
            int lo = 0, hi = 10, mid;
            while (lo < hi - 1) {
                mid = (lo + hi) >> 1;
                if (query(accum * 10 + mid)) lo = mid; else hi = mid;
            }
            accum = accum * 10 + lo;
        }
        for (int j = (dg == 1 ? 1 : 0); j <= 9; ++j)
            if (query(accum * 100 + j * 10)) {
                printf("! %lld\n", accum * 10 + j); break;
            }
    }

    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

constexpr int MOD = 1000000007;
struct ModInt {
    ll x;
    ModInt (ll a) : x((a % MOD + MOD) % MOD) {}
    ModInt operator- () const {
        return ModInt(-x);
    }
    ModInt &operator+= (const ModInt &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    ModInt &operator-= (const ModInt &a) {
        if ((x -= a.x) < 0) x += MOD;
        return *this;
    }
    ModInt &operator*= (const ModInt &a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    ModInt operator+ (const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator- (const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator* (const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(ll t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(MOD - 2);
    }
    ModInt &operator/= (const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator/ (const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend istream &operator>> (istream &is, ModInt &a) {
        is >> a.x;
        return is;
    }
    friend ostream &operator<< (ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};
vector<ModInt> fact, ifact;
void init(int n) {
    fact.resize(n + 1, ModInt{0});
    ifact.resize(n + 1, ModInt{0});
    fact[0] = ModInt{1};
    for (int i = 1; i <= n; ++i) {
        ModInt M(i);
        fact[i] = fact[i - 1] * M;
    }
    ifact[n] = fact[n].inv();
    for (int i = n; i > 0; --i) {
        ModInt M(i);
        ifact[i - 1] = ifact[i] * M;
    }
}
ModInt comb(int x, int y) {
    if (x < y) return ModInt{0};
    else return fact[x] * ifact[y] * ifact[x - y];
}

int main() {
    int N, M;
    cin >> N >> M;
    init(M);
    ModInt ans = 0;
    REP(i, N + 1) {
        if (i & 1) {
            ans -= comb(N, i) * fact[M - i] * ifact[M - N];
        } else {
            ans += comb(N, i) * fact[M - i] * ifact[M - N];
        }
    }
    ans *= fact[N];
    ans *= comb(M, N);
    cout << ans << "\n";
    return 0;
}


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



template< typename Monoid >
struct segTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  segTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid get(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

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

  int n,q;
  cin>>n>>q;
  segTree<int> seg(n,[](int a,int b){return min(a,b);},inf);

  while(q--){
    int t,x,y;
    cin>>t>>x>>y;
    if(t==0) seg.update(x,y);
    else cout<<seg.get(x,y+1)<<endl;
  }


}


Measured memory_bytes: 4852
#include <iostream>
#include <string>
using namespace std;
 
int main(){
 string s;
  int k;
  cin>>k>>s;
  for(auto c : s){
  	if(!k){
    	cout << "...";
      break;
    }
	cout << c;
    --k;
  }
  
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

string s;

int main()
{
	cin>>s;
	
	int len=s.length();
	s+="233333";
	for (int i=0;i<len;i+=2)
	if (!(s[i]=='h' and s[i+1]=='i'))
	{
		printf("No");
		return 0;
			}	
	printf("Yes");	
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin>>n;
  vector<int> v1(n),v2(n);
  for(int i=0;i<n;++i)cin >> v1[i];
  for(int i=0;i<n;++i)cin >> v2[i];
  vector<int> sum1(n,0),sum2(n,0);
  sum1[0] = v1[0];
  sum2[n-1] = v2[n-1];
  for(int i=1;i<n;++i){
    sum1[i] = sum1[i-1] + v1[i];
  }
  for(int i=n-2;i>=0;--i){
    sum2[i] = sum2[i+1] + v2[i];
  }
  int max_v = 0;
  for(int i=0; i<n;++i){
    max_v = max(max_v, sum1[i]+ sum2[i]);
  }
  cout << max_v << endl;
  return 0;
}


Measured memory_bytes: 256