akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}

int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}

int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

vector<ll> prime_factor(int64_t n) {
	//map< ll, ll > ret;
	vector<ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			//ret[i]++;
			ret.push_back(i);
			n /= i;
		}
	}
	if (n != 1)ret.push_back(n);// ret[n] = 1;
	return ret;
}

const int MAX = 1000000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int X, Y;
	cin >> X >> Y;

	int m = (2 * Y - X) / 3, n = (2 * X - Y) / 3;
	if ((2 * Y - X) % 3 != 0 || (2 * X - Y) % 3 != 0) {
		cout << "0" << endl;
		goto ProgramEndPointLabel;
	}

	if (m < 0 || n < 0) {
		cout << "0" << endl;
		goto ProgramEndPointLabel;
	}

	COMinit();
	cout << COM(m + n, min(m, n)) << endl;

ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




Measured memory_bytes: 23928
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int main()
{
    // freopen("toad.in","r",stdin);
    // freopen("toad.out","w",stdout);
	scanf("%d",&n);
	int m=1;
	while(m<n) m<<=1;
	if(n<3||m==n)
    {
        printf("No");
        return 0;
    }
	printf("Yes\n");
    printf("%d %d\n",1,n+2);
    printf("%d %d\n",n+2,3);
    printf("%d %d\n",3,n+1);
    printf("%d %d\n",n+1,2);
    printf("%d %d\n",2,n+3);
    for(int i=4;i<n;i+=2)
    {
        printf("%d %d\n",i,n+1);
        printf("%d %d\n",i,n+i+1);
        printf("%d %d\n",i+1,n+1);
        printf("%d %d\n",n+i,i+1);
    }
    if(n%2==0)
    {
        for(int i=2;i<n;i++)
            if((n^(i^1))<n)
            {
                printf("%d %d\n",n,i);
                printf("%d %d\n",n+n,n^i^1);
                break;
            }
	}
	return 0;
}

Measured memory_bytes: 2816
import sys
 
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
a = na()


s = set()
x = 0
for v in a:
    if v < 3200:
        s.add(int(v / 400))
    else:
        x += 1

y = len(s)
z = x + y

if x > 0:
    y = max(1, y)

print("%d %d" % (y, z))


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  ll n , m ;
  scanf("%lld %lld" ,&n ,&m) ;

  if(n>m/2) {
    printf("%lld\n" , m/2) ;
  }
  else {
    printf("%lld", n + (m-n*2)/4) ;
  }
  return 0 ;
}



Measured memory_bytes: 256
/**
 * Yes, I have a number
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			if (line.equals("END OF INPUT")) break;

			line = line + " ";
			int head = 0;
			for (int i = 0; i < line.length(); i++) {
				if (line.charAt(i) == ' ') {
					System.out.print(i - head);
					head = i + 1;
				}
			}
			System.out.println();
		} //end while
	} //end main
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()

struct Log{
    int id, s, e;
    Log(int id, int s, int e):id(id), s(s), e(e){}
};

int main(){
    int N, M;
    while(cin >> N >> M, N|M){
        vector<vector<Log> > usr(M);
        int r;
        cin >> r;
        while(r--){
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            m--;
            if(s)usr[m].emplace_back(n, t, 0);
            else (*find_if(all(usr[m]), [&](Log& l){return l.id == n && l.e == 0;})).e = t;
        }
        int q;
        cin >> q;
        while(q--){
            int s, e, m, res = 0;
            cin >> s >> e >> m;
            m--;
            for(auto& x: usr[m]){
                if(e < x.s)break;
                if(x.s < s && x.e < s)continue;
                res += min(e, x.e) - max(s, x.s);
                s = max(max(s, x.s), min(e, x.e));
            }
            cout << res << '\n';
        }
    }
    return 0;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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; }

class Dice
{
public:
    int u, d, n, e, s, w;
    Dice(int u, int d, int n, int e, int s, int w)
        :u(u), d(d), n(n), e(e), s(s), w(w)
    {

    }

    void roll(char dir)
    {
        if(dir == 'N')
        {
            int tmp = u;
            u = s;
            s = d;
            d = n;
            n = tmp;
        }
        else if(dir == 'E')
        {
            int tmp = u;
            u = w;
            w = d;
            d = e;
            e = tmp;
        }
        else if(dir == 'S')
        {
            int tmp = u;
            u = n;
            n = d;
            d = s;
            s = tmp;
        }
        else if(dir == 'W')
        {
            int tmp = u;
            u = e;
            e = d;
            d = w;
            w = tmp;
        }
    }
};

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    vi n(6); REP(i, 6) cin >> n[i];
    Dice dice(n[0], n[5], n[4], n[2], n[1], n[3]);
    string s; cin >> s;
    REP(i, s.length()) dice.roll(s[i]);
    cout << dice.u << endl;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  for(int i=0;i<(int)str.size();i++){
    if('a'<=str[i]&&str[i]<='z'){
      str[i]=str[i]-'a'+'A';
    }else if('A'<=str[i]&&str[i]<='Z'){
    str[i]=str[i]-'A'+'a';
      }
    }
  cout<<str<<endl;
  return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		sc.close();
		if(b.equals("A")){
			System.out.println("T");
		} else if (b.equals("C")) {
			System.out.println("G");
		} else if (b.equals("G")) {
			System.out.println("C");
		} else if (b.equals("T")) {
			System.out.println("A");
		}
	}

}


Measured memory_bytes: 22356
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long unsigned long long

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) scanf("%d", &vec[i]);

  vector<long> prev(21, 0), nxt(21);
  prev[vec[0]]=1;
  repl(i,1,n-1){
    fill(all(nxt), 0);
    rep(j,21) if(prev[j]>0){
      if(j+vec[i] >= 0 && j+vec[i]<=20) nxt[j+vec[i]] += prev[j];
      if(j-vec[i] >= 0 && j-vec[i]<=20) nxt[j-vec[i]] += prev[j];
    }
    swap(nxt, prev);
  }

  cout << prev[vec[n-1]] << endl;

  return 0;
}

Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] nk = reader.readLine().split(" ");
        int N = Integer.parseInt(nk[0]);
        int K = Integer.parseInt(nk[1]);
        String[] lo = reader.readLine().split(" ");
        int[] list = new int[N];
        for (int i = 0; i <N ; i++) {
            list[i] = Integer.parseInt(lo[i]);
        }
        int[] dp = new int[K+1];
        dp[0] = 0;
        for (int i = 0; i <=K ; i++) {
            boolean possible = false;
            for (int j = 0; j<N && list[j] <= i ; j++) {
                if(dp[i-list[j]]==0){
                    possible=true;
                    dp[i] = 1;
                    break;
                }
            }
            if(!possible) dp[i]=0;
        }
        if(dp[K]==1) System.out.println("First");
        else System.out.println("Second");
    }
}


Measured memory_bytes: 22868
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(2e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

P v[100100];
ll ans[100100];

int main(void){
	int n,i,x;
	ll a;
	std::cin >> n; x = n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		v[i] = P(a,i);
	}
	v[n] = P(0ll,n);
	std::sort(v,v+n+1);
	for(i=n; i>0; --i){
		x = std::min(x,v[i].second);
		if(v[i].first != v[i-1].first){
			ans[x] += (v[i].first-v[i-1].first)*(n-i+1);
		}
	}
	for(i=0; i<n; ++i){
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(void) {
	// your code goes here
	int x,y,s,l;
	scanf("%d %d",&x,&y);
	
	s = x * y;
	l = (2 * x) + (2 * y);
	
	printf("%d %d\n",s,l);
	return 0;
}



Measured memory_bytes: 2048
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.root = [-1]*(n+1)
		self.rank = [0]*(n+1)

	def find(self, x):
		if self.root[x] < 0:
			return x
		else:
			self.root[x] = self.find(self.root[x])
			return self.root[x]
			
	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return 0
		elif self.rank[x] > self.rank[y]:
			self.root[x] += self.root[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.root[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

	def isSame(self, x, y):
		return self.find(x) == self.find(y)

	def size(self, x):
		return -self.root[self.find(x)]
		
n,m,*L=map(int,open(0).read().split())
L=L[:1:-1]
ans=[None]*m
ans[0]=n*(n-1)//2
uf=UnionFind(n)
for i,(a,b) in enumerate(zip(*[iter(L)]*2)):
	if not uf.isSame(a,b):
		ans[i+1]=ans[i]-uf.size(a)*uf.size(b)
		uf.unite(a,b)
	else:
		ans[i+1]=ans[i]
print(*ans[::-1])

Measured memory_bytes: 25260
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << string(b, a + '0') << endl;
  } else {
    cout << string(a, b + '0') << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
double x,y;
int32_t main(){
CODE_START;
cout<<fixed;
cin>>x;
y=double(x/3);
cout<<setprecision(6)<<y*y*y<<endl;
}


Measured memory_bytes: 256
//Atcoder Beginner 172
//Date: 27-06-2020
//------------------------------------------------------------------------------

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e6 + 5;
const double E= 1e-9;
 
//------------------------------------------------------------------------------

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE 
	    freopen("input.txt","r", stdin);
	    freopen("output.txt","w",stdout);
	#endif    
    /*ifstream cin("input.txt");
    ofstream cout("output.txt");*/
    ll a;
    cin>>a;
    cout<<(a+a*a+a*a*a);
    return 0;
}

//------------------------------------------------------------------------------

Measured memory_bytes: 3560
import math
a, b, h, m = map(int, input().split())

minute = h * 60 + m
short = minute * (1/2)
long = m * 6

degree = min(abs(short-long), abs(short-360-long))

c = (a**2 + b**2 - 2 * a * b * math.cos(degree/180 * math.pi)) ** (1/2)

print(c)

Measured memory_bytes: 9560
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    ans = 0
    for i in range(1,N + 1):
        for j in range(i,N + 1,i):
            ans += j
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 67776
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

max_m = 0
for i in range(N):
    m = gcd(L[i], R[i+1])
    if max_m < m:
        max_m = m
print(max_m)


Measured memory_bytes: 16152
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int lcss(string a, string b) {
  int res = 0;
  for(int i=-(int)a.size(); i<(int)a.size(); ++i) {
    int len = 0;
    for (int j=max(i,0); j<min(a.size()+i,b.size()); ++j) {
      if (a[j-i] == b[j]) res = max(res,++len);
      else len = 0;
    }
  }
  return res;
}

int main() {
  string a, b;
  while(cin >> a >> b) {
    cout << lcss(a,b) << endl;
  }
}

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

int main()
{
    long long n,a,b,x,y;
    cin>>n>>a>>b;

    if(n==1)
    {
        if(a==b)
            cout<<"1"<<endl;
        else
            cout<<"0"<<endl;
    }
    else
    {
        if(a>b)
            cout<<"0"<<endl;
        else
        {
            x=a*(n-2);
            y=b*(n-2);
            cout<<(y-x)+1<<endl;
        }

    }
}



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



int main(){
	int H,W;
	int i,j;
	
	cin >> H >> W;
	
	char S[H][W];
	int counter[H][W];
	
	for(i = 0; i < H; i++){
		cin >> S[i];
	}
	
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			counter[i][j] = 0;
			if(S[i][j] == '.'){
				if((i-1) >= 0){
					if(S[i-1][j] == '#'){
						counter[i][j]++;
					}
					if((j-1) >= 0){
						if(S[i-1][j-1] == '#'){
							counter[i][j]++;
						}
					}
					if((j+1) < W){
						if(S[i-1][j+1] == '#'){
							counter[i][j]++;
						}
					}
				}
				if((i+1) < H){
					if(S[i+1][j] == '#'){
						counter[i][j]++;
					}
					if((j-1) >= 0){
						if(S[i+1][j-1] == '#'){
							counter[i][j]++;
						}
					}
					if((j+1) < W){
						if(S[i+1][j+1] == '#'){
							counter[i][j]++;
						}
					}
				}
				
				if((j-1) >= 0){
						if(S[i][j-1] == '#'){
							counter[i][j]++;
						}
					}
					if((j+1) < W){
						if(S[i][j+1] == '#'){
							counter[i][j]++;
						}
					}
			}
		}
	}
	
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if( S[i][j] == '#'){
				cout << S[i][j];
			}else{
				cout << counter[i][j];
			}
		}
		cout << endl;
	}	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int a, b, k;

int main() {
    cin >> a >> b >> k;
    int n = 101;
    while (k) {
        n--;
        if (a%n == 0 && b %n == 0) k--;
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d %d", &a, &b);
  if ((a/10 > 0) || (b/10 > 0)) {
    printf("-1\n");
  } else {
    printf("%d\n", a*b);
  }
  
  return 0;
}

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

int main() {
    int M1, D1, M2, D2;
    int ans = 1;
    cin >> M1 >> D1 >> M2 >> D2;
    if(M1 == M2){
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

const int MAX_N = 15;
int n;
int a[MAX_N][MAX_N];
void input() {
    RI(n);
    memset(a, -1, sizeof(a));
    REP(i, n) {
        int t;
        RI(t);
        REP(j,t){
            int x,y;
            RI(x,y);
            a[i][x-1]=y;
        }
    }
    
}

void solve() {
    int ans = 0;
    REP(k,(1<<n)) {
        int cnt = 0;
        bool ok = true;
        REP(i, n) {
            if(((1<<i)&k)==0) continue;
            cnt++;
            REP(j, n) {
                // cout << i << ' ' << j << ' ' << k <<  ' ' << ((k >> j) & 1)  << endl;
                if (i != j && a[i][j] != -1 && ((k >> j) & 1) != a[i][j])
                {
                    ok = false;
                }
            }
            if(!ok) break;
        }
        if(ok) ans = max(ans, cnt);
    }
    printf("%d\n",ans);
}

int main( int argc, char *argv[] ) {
    input(); solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

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

template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}

//ifstream f(".in");
//ofstream g(".out");

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif

  int a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b << '\n';

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline int toLL(string s) {long long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<long,long> PLL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define PF push_front
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS=1e-8;

typedef complex<double> P;//座標(x,y)=(p.real,p.imag())


double cross(const P& a, const P& b) {
 	return imag(conj(a)*b);//正なら反時計回りの回転,負なら時計回り,0なら同一直線
}

int ccw(P a, P b, P c) {//点の進行方向a->b->c
	b -= a; c -= a;
  	if (cross(b, c) > 0)   return +1;       // counter clockwise
  	if (cross(b, c) < 0)   return -1;       // clockwise
  	return 0;
}

int len(P a,P b){
	return abs(a.real()-b.real())+abs(a.imag()-b.imag());
}

int main(){
    int N;
	while(cin>>N&&N){
		vector<P>G;
		VI ans[2];
		int m0;
		cin>>m0;
		
		REP(i,m0){
			int x,y;
			cin>>x>>y;
			G.PB(P(x,y));
		}
		
		FOR(i,1,m0-1){
			if(i==1)ans[0].PB(len(G[i-1],G[i]));
			ans[0].PB(ccw(G[i-1],G[i],G[i+1]));
			ans[0].PB(len(G[i],G[i+1]));
		}
		//REP(i,SZ(ans[0]))cout<<ans[0][i]<<" ";
		///cout<<endl;
		VI t=ans[0];
		reverse(ALL(t));
		REP(i,SZ(t)){
			if(i%2==1)ans[1].PB(-t[i]);
			else ans[1].PB(t[i]);
		}
		//REP(i,SZ(ans[1]))cout<<ans[1][i]<<" ";
		//cout<<endl;
		VI res;
		REP(i,N){
			int m,x,y;
			cin>>m;
			VI trace;
			G.clear();
			REP(j,m){
				cin>>x>>y;
				G.PB(P(x,y));
			}
			FOR(j,1,m-1){
				if(j==1)trace.PB(len(G[j-1],G[j]));
				trace.PB(ccw(G[j-1],G[j],G[j+1]));
				trace.PB(len(G[j],G[j+1]));
			}
			//REP(j,SZ(trace))cout<<trace[j]<<" ";
			//cout<<endl;
			if(trace==ans[0]||trace==ans[1])res.PB(i+1);
		}
		
		REP(i,SZ(res))cout<<res[i]<<endl;
		cout<<"+++++"<<endl;
	}
    return 0;
}

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

int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  int cnt=0;
  
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  
  sort(a, a+N);
  
  for(int i=0; i<N; i++){
    x -= a[i];
    cnt++;
    if(x > 0 && i == N-1 || x < 0){
      cnt--;
      break;
    }
  }
  
  cout << cnt << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << -1 << '\n';
  exit(0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  s = '$' + s;
  if (s[1] == '0' || s[n - 1] == '0' || s[n] == '1') {
    err();
  }
  for (int i = 1; i <= n / 2; i++) {
    if (s[i] != s[n - i]) {
      err();
    }
  }
  int par = 1;
  for (int i = 2; i <= n; i++) {
    cout << par << ' ' << i << '\n';
    if (s[i - 1] == '1') {
      par = i;
    }
  }
  return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int c = Integer.parseInt(scan.next());
		int ans = b + Math.min(a+b+1,c);
		System.out.println(ans);

	}

}
//end

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e8
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(ALL(v));
    int ans = 0;
    rep(i,n-2) {
        REP(j,i+1,n-1) {
            int num = v[i]+v[j];
            auto Iter = lower_bound(ALL(v),num);
            ans += max(0,(int)(Iter-v.begin())-(j+1));
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n),c;
  vector<bool>b(n,true);
  rep(i,n) {
    cin>>a[i];
  }
  bool ex=true;
  while(ex){
    int co=0;
    int now=-1;
    rep(i,n){
      if(b[i]){
        co++;
        if(co==a[i]){
          now=i;
        }
      }
    }
    if(now>=0){
      b[now]=false;
      c.push_back(a[now]);
    }
    else{
      ex=false;
    }
  }
  if(c.size()==n){
    rep(i,n){
      cout<<c[n-1-i]<<endl;
    }
  }
  else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;



int main() {  
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
piv = []
check = []
for i in range(n):
    a,b = map(int,input().split())
    piv.append([a,b])
for i in range(m):
    c,d = map(int,input().split())
    check.append([c,d])


for i in range(n):
    tmp = 1000000000
    ans = 0

    for j in range(m):
        x = abs(piv[i][0] - check[j][0]) + abs(piv[i][1] - check[j][1])
        if tmp > x:
            ans = j + 1
            tmp = x

    print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	static class Dp {
		int number;
		int height, width, slopeP, slopeN;

		Dp(int number) {
			this.number = number;
			this.height = 0;
			this.width  = 0;
			this.slopeP = 0;
			this.slopeN = 0;
		}
	}

	public static void main(String srgs[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		Dp a[][];
		int max;

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			a = new Dp[n][n];
			max = 0;
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < n; j++) {
					a[i][j] = new Dp(s.charAt(j) - '0');
					if (a[i][j].number == 1) {
						if (i == 0 && j == 0) {
							a[i][j].height = 1;
							a[i][j].width  = 1;
							a[i][j].slopeN = 1;
							a[i][j].slopeP = 1;
						} else if (i == 0) {
							a[i][j].height = 1;
							a[i][j].width  = a[i][j - 1].width + 1;
							a[i][j].slopeN = 1;
							a[i][j].slopeP = 1;
						} else if (j == 0) {
							a[i][j].height = a[i - 1][j].height + 1;
							a[i][j].width  = 1;
							a[i][j].slopeN = 1;
							a[i][j].slopeP = a[i - 1][j + 1].slopeP + 1;
						} else {
							a[i][j].height = a[i - 1][j].height + 1;
							a[i][j].width  = a[i][j - 1].width + 1;
							a[i][j].slopeN = a[i - 1][j - 1].slopeN + 1;
							if (j == n - 1) {
								a[i][j].slopeP = 1;
							} else {
								a[i][j].slopeP = a[i - 1][j + 1].slopeP + 1;
							}
						}
					}
					if (max < a[i][j].height) {
						max = a[i][j].height;
					}
					if (max < a[i][j].width) {
						max = a[i][j].width;
					}
					if (max < a[i][j].slopeP) {
						max = a[i][j].slopeP;
					}
					if (max < a[i][j].slopeN) {
						max = a[i][j].slopeN;
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 17000
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
 int n, m;
 cin >> n >> m;
 long long x[n], y[m], xi[n-1], yi[m-1];
 long long xsum=0, ysum=0;
 for(int i=0; i<n; i++) cin >> x[i];
 for(int i=0; i<m; i++) cin >> y[i];
 for(int i=0; i<n-1; i++) xi[i]=x[i+1]-x[i];
 for(int i=0; i<m-1; i++) yi[i]=y[i+1]-y[i];
 for(int i=0; i<n-1; i++){
   xsum=(xsum+xi[i]*(i+1)*(n-i-1))%1000000007;
 }
 for(int i=0; i<m-1; i++){
   ysum=(ysum+yi[i]*(i+1)*(m-i-1))%1000000007;
 }
 cout<< (xsum*ysum)%1000000007;
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define BUF_SIZE 20

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

#define DIVISOR 1000000007
#define WIDTH_MAX 1000000
#define HEIGHT_MAX WIDTH_MAX
// WIDTH_MAX*2/3 < 666667
#define COMBI_MAX 670000

struct pair {
    int x;
    int y;
};

// assume that a < b
struct pair gcdext(int a, int b) {
    // 0*x + 1*y = 1
    if(a==0) { return (struct pair){0, 1}; }
    struct pair p = gcdext(b%a, a);
    return (struct pair){p.y - (b/a)*p.x, p.x};
}

int main(void) {
    int width, height;
    int i;
    get_int2(&width, &height);

    // assume that p1: # of (+1, +2)
    //             p2: # of (+2, +1)
    // x = 2*p1 + p2
    // y = p1 + 2*p2
    // => x+y = 3(p1+p2) <= requires that x+y should be divided by 3
    if((width+height)%3) goto impossible;
    int p1_p2 = (width+height)/3;
    int p1 = width - p1_p2;
    int p2 = p1_p2 - p1;
    if(p1 < 0 || p2 < 0) goto impossible;

    // calc x! and inv(x!) in advance..
    static uint64_t factorial[COMBI_MAX];
    static uint64_t inv_factorial[COMBI_MAX];
    factorial[0] = factorial[1] = 1;
    inv_factorial[0] = inv_factorial[1] = 1;
    for(i = 2; i <= p1_p2; i++) {
        factorial[i] = (factorial[i-1]*i)%DIVISOR;

        struct pair p = gcdext(i, DIVISOR);
        // positive number
        uint64_t inv = (p.x + DIVISOR)%DIVISOR;
        inv_factorial[i] = (inv_factorial[i-1]*inv)%DIVISOR;
    }

    // calc (p1_p2)_C_p1
    uint64_t ans = 1;
    ans = (ans * factorial[p1_p2])%DIVISOR;
    ans = (ans * inv_factorial[p1])%DIVISOR;
    ans = (ans * inv_factorial[p2])%DIVISOR;
    // ans must be less than DIVISOR < MAX_INT
    printf("%d\n", (int)ans);
    return 0;
impossible:
    printf("0\n");
    return 0;
}

Measured memory_bytes: 10624
using System;

class aizu_judge
{
    static void Main()
    {
        int count = 1;
        while(true)
        {
            string x = Console.ReadLine();
            if(x.Equals("0") || x == null)
                break;
            Console.WriteLine("Case {0}: {1}", count, x);
            count++;
        }

    }
}

Measured memory_bytes: 9288
from heapq import heappush, heappop, heapify
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    ai, bi = map(lambda x: int(x) - 1, input().split())
    G[ai].append(bi)
    G[bi].append(ai)


# 大きい数字から順番に割り当てる
C = list(map(lambda x: -int(x), input().split()))
heapify(C)
score = -sum(C) + min(C)

# どこかの葉にmaxを置いて，そこから順番に置く
# => maxの値は葉のスコア計算で消えてOK
leaf = -1
for n in range(N):
    if len(G[n]) == 1:
        leaf = n
        break

# 深さ優先で全探索
queue = [leaf]
ans = [-1] * N
while queue:
    node = queue.pop()
    for neighbor in G[node]:
        if ans[neighbor] == -1:
            ans[neighbor] = -heappop(C)
            queue.append(neighbor)

print(score)
print(*ans)

Measured memory_bytes: 78180
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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



const long long INF = 1LL << 60;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        S.at(i) = 'x';
        cout << S.at(i);
    }
    cout << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	scanf("%d%d%d", &a, &b, &c);
	if((a < b) && (b < c)){
		printf("Yes\n");
	} else{	
		printf("No\n");
	}
	
	return(0);
}



Measured memory_bytes: 1732
#include <iostream>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    long N, M, K;
    cin >> N >> M >> K;

    long ans = 0;
    for(int i=1; i<=M-1; i++){
        ans += (i*(M-i)*N*N)%MOD;
        ans %= MOD;
    }
    for(int i=1; i<=N-1; i++){
        ans += (i*(N-i)*M*M)%MOD;
        ans %= MOD;
    }

    COMinit();

    ans *= COM(M*N-2, K-2)%MOD;

    cout << ans%MOD;

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n]={0};
    for(int i=0;i<n;i++)cin>>arr[i];
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-2]+ abs(arr[i-2]-arr[i]), dp[i-1]+ abs(arr[i-1]-arr[i]));
    }

    cout<<dp[n-1];

}



Measured memory_bytes: 1024
import sys
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
lrs = lambda: [_ for _ in rs().split()]
lri = lambda: [int(_) for _ in rs().split()]
lrf = lambda: [float(_) for _ in rs().split()]
import math
X = ri()
n = 100
for i in range(1, 10000):
    n = int(n * 1.01)
    if n >= X:
        print(i)
        exit()

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int d;cin >>d;
    vector<int>c(26);
    for (int i = 0; i < 26; ++i) {
        cin >>c[i];
    }
    int s[d][26];
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >>s[d][26];
        }
    }
    int ans=0;
    int res=0;
    for (int i = 0; i < 26; ++i) {
        int now=0;
        for (int j = 0; j < d; ++j) {
            now+=s[j][i];
        }
        if(now>ans){
            res=now;
            ans=i+1;
        }
    }
    for (int i = 0; i < d; ++i) {
        cout <<ans <<endl;
    }
    return 0;
}

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

int main ()
{
  int a, b, c, t;
  
  cin >> a;
  cin >> b;
  cin >> c;
  
  t = b;
  b = a;
  a = t;
  
  
  t = c;
  c = a;
  a = t;
  
  cout << a << " " << b << " " << c << endl;

  return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    string s;cin>>s;
    string t[] = {"KIH","B","R"};
    bool is_res = false;
    for(int i=0;i < (1<<4);i++){
        string res = "";
        if(i & 1)res="A";
        res+=t[0];
        if(i & (1<<1))res+="A";
        res+=t[1];
        if(i & (1<<2))res+="A";
        res+=t[2];
        if(i & (1<<3))res+="A";
        if(s == res)is_res = true;
    }
    cout << (is_res?"YES":"NO") << endl;
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 < i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<ll> llvv;

llv mul(llv lhs, llv rhs, ll mod)
{
    llv dst(9, 0);
    rep(i, 9)
        rep(j, 3)
    {
        dst[i] += (lhs[3 * (i / 3) + j] * rhs[j * 3 + (i % 3)]) % mod;
        dst[i] %= mod;
    }
    return dst;
}

llv mul_vec_mat(llv vec, llv mat, ll mod)
{
    llv dst(3);
    rep(i, 3)
        dst[i] = ((vec[0] * mat[i] % mod) + (vec[1] * mat[i + 3] % mod) + (vec[2] * mat[i + 6] % mod)) % mod;
    return dst;
}

llv powmod(llv m, ll n, ll mod)
{
    if (n == 0)
        return llv{1, 0, 0, 0, 1, 0, 0, 0, 1};
    if (n & 1)
    {
        llv tmp = powmod(m, n - 1, mod);
        return mul(tmp, m, mod);
    }
    else
    {
        llv tmp = powmod(m, n / 2, mod);
        return mul(tmp, tmp, mod);
    }
}

int main()
{
    ll L, A, B, M;
    cin >> L >> A >> B >> M;

    llv mat{1, 1, 0, 0, 0, 0, B % M, 0, 1};
    ll i = 0, d = 10;
    llv state{A % M, 0, 1};
    mat[4] = d;
    while (i <= L)
    {
        ll nexti = (d - A + B - 1) / B;
        if (nexti != 0 && i <= nexti && i <= L)
        {
            mat[4] = d % M;
            llv dst = powmod(mat, min(nexti, L) - i, M);
            i = nexti;
            state = mul_vec_mat(state, dst, M);

        }
        d *= 10;
    }
    cout << state[1] << endl;

    return 0;
}


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

int main() {
    int n, age;
    while (cin >> n, n) {
        int num[7] = {};
        for (int i=0; i<n; ++i) {
            cin >> age;
            if (age < 10) {
                ++ num[0];
            } else if (age < 20) {
                ++ num[1];
            } else if (age < 30) {
                ++ num[2];
            } else if (age < 40) {
                ++ num[3];
            } else if (age < 50) {
                ++ num[4];
            } else if (age < 60) {
                ++ num[5];
            } else {
                ++ num[6];
            }
        }
        for (int i=0; i<7; ++i) {
            cout << num[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

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

int main(){
  int n,y,
      i,j,
      ye,ne,
      flag=0;
  
  scanf("%d%d", &n, &y);
  y /= 1000;
  
  for(i = min(y/10, n); 0<=i; i--){
    ye = y-i*10 - (n-i);
    if((ye%4 == 0) && (0 <= ye/4) && (ye/4 <= min((y-10*i)/5, n-i))){
      printf("%d %d %d", i, ye/4, n-i-ye/4);
      flag = 1;
      break;
    }
/*    for(j = min((y-10*i)/5, n-i); 0<=j; j--){
      if(j*4 == ye){
        printf("%d %d %d", i, j, n-i-j);
        flag = 1;
        break;
      }
    }
    if(flag){
      break;
    }
*/  }
  
  if(flag==0){
    printf("-1 -1 -1");
  }
  return 0;
}

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


void solve() {
  int N,L;
  cin >> N >> L;
  int arr[N];
  rep(i, N) {
    arr[i] = L+i;
  }
  sort(arr, arr+N);
  int sum=0;
  if (arr[0]<=0 && arr[N-1]>=0) {
    for (size_t i = 0; i < N; i++) {
      sum += arr[i];
    }
  }else if (arr[N-1]<0) {
    for (size_t i = 0; i < N-1; i++) {
      sum += arr[i];
    }
  }else {
    for (size_t i = 1; i < N; i++) {
      sum += arr[i];
    }
  }

  cout << sum << "\n";
}

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


Measured memory_bytes: 256
#include<stdio.h>
int length;
void swap(int *a, int *b) {
	int temp = *a;
	*a = *b;
	*b = temp;
	return;
}
void max_heapify(int a[],int i) {
	int large = i,l = 2*i,r = 2*i+1;
	if (l <= length && a[l]>a[large]) {
		large = l;
	}
	if (r <= length &&  a[r] > a[large]) {
		large = r;
	}
	if (large != i) {
		swap(&a[i], &a[large]);
		max_heapify(a, large);
	}
}
void build_max_heap(int a[]) {
	for (int i = length/2; i >0 ; i--)
	{
		max_heapify(a, i);
	}
}
void heap_sort(int a[],int k) {
	build_max_heap(a);
	for (int i = k; i >= 1; i--)
	{
		swap(&a[1], &a[length]);
		length--;
		max_heapify(a,1);
	}
}
int main() {
	int n, k,a[51];
	scanf("%d %d", &n, &k);
	length = n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	int sum = 0;
	heap_sort(a, k);
	for (int j = 0; j < k; j++)
		sum += a[n - j];
	printf("%d\n", sum);
}

Measured memory_bytes: 128
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[1]*(10**7+1)
if n==1:
    print(1)
    exit()
ans=1
for i in range(2,n+1):
    k=0
    while i*k<10**7+1:
        l[i*k]+=1
        k+=1
    ans+=i*l[i]
print(ans)

Measured memory_bytes: 150956
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

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

    ll n, m;
    in >> n >> m;

    vector<ll> a(n), b(n);
    vector<ll> c(m), d(m);
    REP(i, n){
        in >> a[i] >> b[i];
    }

    REP(i, m){
        in >> c[i] >> d[i];
    }

    REP(i, n){
        ll min_score = 1e9;
        ll min_num, score;
        REP(j, m){
            score = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(score < min_score){
                min_score = score;
                min_num = j + 1;
            }
        }
        out << min_num << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main(void){
    int a[] = {1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    std::cin >> x >> y;
    std::cout << (a[x-1] == a[y-1] ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256