akhauriyash/Code-Regression huggingface dataset:
// AOZ 2084: Hit and Blow
// 2017.10.2 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 5050
 
int all[MAX]; int sz;
char enable[MAX];

int nhit(int a, int b) 
{  
    int i, k = 0;

	for (i = 0; i < 4; i++) {
		if (a%10 == b%10) k++;
		a /= 10, b /= 10;
	}
	return k; 
}  
  
int nblow(int a, int b)  
{  
    int i, j, k = 0;
	int aa, bb;

    for (i = 0; i < 4; i++) {
		aa = a % 10, a /= 10, bb = b;
		for (j = 0; j < 4; j++) {
			if (i != j && bb%10 == aa) k++;
			bb /= 10;
		}
	}
    return k;  
}  
  
int diff(int a)
{
	int i;
	static int c = 0;
	int f[10];
  
	c++;
	for (i = 0; i < 4; i++) {  
        if (f[a % 10] == c) return 0;
		f[a % 10] = c;
        a /= 10;
    }
    return 1;  
}  
  
int main()  
{  
    int n, i, j, num, hit, blow, ans;
	int hb[5][5], h, b, c;

	for (sz = 0, i = 123; i <= 9876; i++) if (diff(i)) all[sz++] = i;
	while (scanf("%d", &n) && n > 0) {
		memset(enable, 0, sizeof(enable));
		for (ans = sz, j = 0; j < n; j++) {
			scanf("%d%d%d", &num, &hit, &blow);
			for (i = 0; i < sz; i++) if (!enable[i]) {
				if (nhit(all[i], num) != hit || nblow(all[i], num) != blow)
					enable[i] = 1, ans--;
			}
        }

		if (ans == 1) {
			for (i = 0; i < sz; i++) if (!enable[i]) break;
			printf("%04d\n",all[i]); goto Done;
		}
		if (ans > 1 && ans <= 24) {
			memset(hb, 0, sizeof(hb));
			for (c = 1, j = 0; j < sz; j++, c++) {
				for (i = 0; ; i++) {
					if (i == sz) { printf("%04d\n", all[j]); goto Done; }
					if (enable[i]) continue;
					h = nhit(all[i], all[j]), b = nblow(all[i], all[j]);
					if (hb[h][b] == c) break;
					hb[h][b] = c;
				}
			}
        }
		puts("????");
Done:;
    }  
    return 0;  
}  

Measured memory_bytes: 1796
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='S')
        cout<<"Cloudy";
    else if(s[0]=='C')
        cout<<"Rainy";
    else if(s[0]=='R')
    cout<<"Sunny";


    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100002

int main() {
	int imos[MAX] = {};
	int N; cin >> N;

	for (int i = 0; i < N; i++) {
		int a, b; scanf("%d%d", &a, &b);
		imos[a]++; imos[b + 1]--;
	}
	imos[0] = 1;
	for (int i = 1; i < MAX; i++) {
		imos[i] += imos[i - 1];
	}
	int ans = 0;
	for (int i = 0; i < MAX; i++) {
		if (imos[i] >= i)ans = max(ans, i - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1640
import sys
l = sys.stdin.read().split('\n')[:-1]
p = [list(map(int, i.split())) for i in l[1:3]]
ans = (p[0][d[0] - 1] + p[1][d[1] - 1] - d[2] for d in (list(map(int, i.split())) for i in l[3:]))
print(min(min(ans), min(p[0]) + min(p[1])))

Measured memory_bytes: 26244
#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;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	double n;
	cin>>n;
	double a,b,h;
	a=n/(double)3;
	b=n/(double)3;
	h=n-a-b;
	double ans;
	ans=a*b*h;
//	cout<<ans<<endl;
	printf("%0.12f\n",ans);
	return 0;
}

Measured memory_bytes: 256
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var map = {};
  var max = 0;
  for(var i=1;i<=N;i++){
    map[input[i]] = (map[input[i]]||0)+1;
    max = Math.max(max, map[input[i]]);
  }
  Object.keys(map).filter(v=>map[v]==max).sort().forEach(v=>console.log(v));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 90584
#include <stdio.h>
#include <stdlib.h>
#define Mod 1000000007
typedef long long ll;

ll P(ll a, ll b){
  if(a < b) return 0;
  ll r = 1;
  for(int i = 0; (ll)i < b; i++){
    r = r * a % Mod;
    a--;
  }
  return r;
}

void dfs(int u, int **g, int *in, int *used, ll *ans, int k){
  used[u] = 1; int cnt = 0;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0) cnt++;
  }
  *ans = (*ans) * P((ll)k - 2, (ll)cnt) % Mod;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0){
      used[g[u][i]] = 1;
      dfs(g[u][i], g, in, used, ans, k);
    }
  }
  return;
}

int
main(int argc, char *argv[])
{
  int n, k;
  scanf("%d %d", &n, &k);
  int **g;
  g = malloc(sizeof(int *) * n);
  for(int i = 0; i < n; i++) g[i] = malloc(sizeof(int) * n);

  int a, b; int in[100000] = {};
  for(int i = 0; i < n - 1; i++){
    scanf("%d %d", &a, &b);
    a--; b--;
    g[a][in[a]] = b; in[a]++;
    g[b][in[b]] = a; in[b]++;
  }

  int used[100000] = {};

  ll ans = k * P((ll)k - 1, (ll)in[0]) % Mod;
  used[0] = 1;
  for(int i = 0; i < in[0]; i++){
    dfs(g[0][i], g, in, used, &ans, k);
  }

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

  return 0;
}


Measured memory_bytes: 408064
#include<stdio.h>
int main(void){
int k[4][13];
int i,n,r,l;
for(i=0;i<4;i++){
for(n=0;n<13;n++){
k[i][n]=0;
}
}
char c;
scanf("%d",&l);
for(i=0;i<2*l;i++){
scanf("%c %d",&c,&r);
if(c=='S'){k[0][r-1]=1;}
else if(c=='H'){k[1][r-1]=1;}
else if(c=='C'){k[2][r-1]=1;}
else if(c=='D'){k[3][r-1]=1;}
}
for(i=0;i<4;i++){
for(n=0;n<13;n++){
if(k[i][n]!=1){
if(i==0){printf("S %d\n",n+1);}
else if(i==1){printf("H %d\n",n+1);}
else if(i==2){printf("C %d\n",n+1);}
else if(i==3){printf("D %d\n",n+1);}
}
}
}
return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    int n;
    string s;

    cin >> n >> s;

    int result = 0;

    for(auto x = s.begin(); x != s.end(); ++x){
        if (s.end() - x < 3) { break; }
        if (*x == 'A' && *(x + 1) == 'B' && *(x + 2) == 'C') {
            ++result;
        }
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 256
/*
 *  Created on: 24-October-2019
 *      Author: ankur314
 */
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define ldb long double
#define vr vector
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb(n) push_back(n)
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007
#define INF 1000000005
 
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int n; cin>>n;
    int a[n+1], b[n+1], c[n+1];
    fi(i,1,n+1) cin>>a[i]>>b[i]>>c[i];
    int dp[3][n+1];
    dp[0][1] = a[1];
    dp[1][1] = b[1];
    dp[2][1] = c[1];
    fi(i,2,n+1)
    {
    	dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
    	dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
    	dp[2][i] = c[i] + max(dp[1][i-1], dp[0][i-1]);
    }
    int ans = max(dp[0][n], max(dp[1][n], dp[2][n]));
    cout<<ans;
    return 0;
}

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

int main() {
    int K;
    int S;

    cin >> K >> S;

    int ans = 0;
    for (int X = 0; X <= K; X++) {
        for (int Y = 0; Y <=K; Y++) {
            int Z = S-X-Y;
            if (Z <= K && Z >= 0) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
void main() {
	auto t = rs.to!(dchar[]);
	t.map!(v => v == '?' ? 'D' : v).array.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4588
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    int parent;
    int l;
    int r;
    int d;
}Node;

Node Tree[100001];

int dep;
int getDep(int ppp){
    if(Tree[ppp].parent == -1) return 0;
    dep = getDep(Tree[ppp].parent) + 1;
    return dep;
}

void scan(int n){
    int id, number;
    int p1, p2;
    for(int i=0; i<n; i++){
        scanf("%d %d", &id, &number);
        for(int j=0; j<number; j++){
            scanf("%d", &p1);
            if(j==0){
                Tree[id].l = p1;
                Tree[p1].parent = id;
                p2 = p1;
            }
            else{
                Tree[p2].r = p1;
                Tree[p1].parent = id;
                p2 = p1;
            }
        }
    }
}

void depppp(int n){
    for(int i =0; i<n; i++){
        Tree[i].d = getDep(i);
    }
}
int main(){
    int n;
    scanf("%d", &n);

    for(int i=0;i<n;i++){
        Tree[i].parent = Tree[i].l = Tree[i].r=-1;
    }
    scan(n);

    depppp(n);

    int ppp;
    for(int i=0; i<n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, Tree[i].parent, Tree[i].d);
        if(Tree[i].parent == -1){
            printf("root, [");
        }
        else if(Tree[i].l == -1){
            printf("leaf, [");
        }
        else{
            printf("internal node, [");
        }
        if(Tree[i].l != -1){
            printf("%d", Tree[i].l);
            ppp = Tree[i].l;
            for(int k=0; k<n; k++){
                if(Tree[ppp].r == -1) break;
                printf(", %d", Tree[ppp].r);
                ppp = Tree[ppp].r;
            }
        }
        printf("]\n");
    }
    return 0;
}


Measured memory_bytes: 3340
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Main m = new Main();
    }
    
    public Main(){
        Scanner s = new Scanner(System.in);
        char[] N = s.next().toCharArray();
        int zero = 0;
        for(int i = N.length - 1; i > 0; i--){
            if(N[i-1] == '0'){
            zero = 1;
            }
            if(zero == 1){
                N[i] = '9';
                zero = 0;
            }else if(N[i] < '9'){
                N[i] = '9';
                N[i-1] -= 1;
            }
        }
        
        int max = 0;
        for(int i = 0; i < N.length; i++){
            max += N[i] - '0';
        }
        System.out.println(max);
    }
    
}


Measured memory_bytes: 21844
// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int64 x, y, z, K; cin >> x >> y >> z >> K;
  vector<int64> a(x), b(y), c(z);
  rep(i, x) cin >> a[i]; rep(i, y) cin >> b[i]; rep(i, z) cin >> c[i];
  sort(rall(a)); sort(rall(b)); sort(rall(c));
  vector<int64> ans;
 
  rep(i, x){
    rep(j, y){
      if ((i + 1) * (j + 1) > K) break;
      rep(k, z){
        if ((i + 1) * (j + 1) * (k + 1) > K) break;
        ans.push_back(a[i] + b[j] + c[k]);
      }
    }
  }
  sort(rall(ans));
  rep(i, K) print(ans[i]);
 
  return 0;
}

Measured memory_bytes: 1404
/*
// A - Traveling Budget
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
  return 0;
}

// B - Chocolate
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int N,D,X;
  cin>>N>>D>>X;
  int A[N];
  for (int i=0; i<N; i++) {
    cin>>A[i];
  }
  int ans=X;
  for (int i=0; i<N; i++) {
    int k=0;
    while (k*A[i]+1<=D) {
      ans++;
      k++;
    }
  }
  cout<<ans<<endl;
  return 0;
}
 
// C - Traveling Plan
#include <iostream>
#include <cstring>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int N;
  cin>>N;
  int A[N+2];
  memset(A,0,sizeof(A));
  for (int i=1; i<=N; i++) {
    cin>>A[i];
  }
  int total=0;
  for (int i=1; i<N+2; i++) {
    total+=abs(A[i]-A[i-1]);
  }
  for (int i=1; i<=N; i++) {
    cout<<total-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])<<endl;
  }
  return 0;
}
*/
// D - Grid Components
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int A,B;
  cin>>A>>B;
  char grid[100][100];
  for (int i=0; i<100; i++) {
    for (int j=0; j<100; j++) {
      grid[i][j]=(i<50?'.':'#');
    }
  }
  A--; B--;
  for (int i=51; i<100 && A; i+=2) {
    for (int j=0; j<100 && A; j+=2) {
      grid[i][j]='.';
      A--;
    }
  }
  for (int i=0; i<50 && B; i+=2) {
    for (int j=0; j<100 && B; j+=2) {
      grid[i][j]='#';
      B--;
    }
  }
  cout<<100<<" "<<100<<endl;
  for (int i=0; i<100; i++) {
    for (int j=0; j<100; j++) {
      cout<<grid[i][j]<<flush;
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
dp=[0,0,0]
for i in range(n):
	ndp=[0,0,0]
	l=[int(x) for x in input().split()]
	for j in range(3):
		for k in range(3):
			if j!=k:
				ndp[k]=max(ndp[k],dp[j]+l[k])
	#print(ndp)
	dp=ndp
print(max(dp))

Measured memory_bytes: 46680
#import sys
#input = sys.stdin.readline
Q = 10**9+7
def cmb(n,r):
    if n-r < r: r = n-r
    if r == 0: return 1
    denominator = 1                       #分母
    numerator = 1                         #分子
    for i in range(r):
        numerator *= n-i
        numerator %= Q
        denominator *= i+1
        denominator %= Q
    return numerator*pow(denominator, Q-2, Q)%Q

def main():
    S = int( input())
    ans = 0
    for i in range(1, S//3+1):
        t = S - i*3
        ans += cmb(t+i-1,i-1)
        ans %= Q
    print(ans)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 8840
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

import numpy as np

def binarySearch(lis,key):
    ng = -1
    ok = len(lis)
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if isOk(lis,mid,key): ok = mid
        else: ng = mid
    return ok

def isOk(lis,index,key):
    if lis[index] > key: return True
    else: return False

n,m,k = iim()
a = iil()
cuma = np.cumsum(a)
b = iil()
cumb = np.cumsum(b)

ans = binarySearch(cumb,k)
for i,item in enumerate(cuma):
    if item > k:
        break

    res = k-item
    plus = binarySearch(cumb,res)
    ans = max(ans,i+1+plus)

print(ans)


Measured memory_bytes: 61920
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long a,b,c;
long long count=0;
string s;
cin>>s;

for (int i = 0; i < s.length(); ++i)
{
	/* code */
	if (s[i]=='+')
	{
		/* code */
		count++;
	}
	else
		count--;
}

cout<<count<<endl;
return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;


const i64 MAXN = 300005;

i64 n;
i64 a[MAXN];

i64 gcdex(i64 a, i64 b, i64 & x, i64 & y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    i64 x1, y1;
    i64 d = gcdex(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

i64 rev(i64 a) {
    i64 x, y;
    i64 g = gcdex(a, mod, x, y);
    if (g != 1) {
        throw g;
    }
    return (x % mod + mod) % mod;
}

i64 nok(i64 a, i64 b) {
    i64 x, y;
    i64 g = gcdex(a, b, x, y);
    g %= mod;
    //return (a / g * b) % mod;
    return a / g * b;
}

map<i64, i64> np;

void up(i64 v) {
    map<i64, i64> q;
    for (i64 i = 2; i <= sqrt(v) + 2; i++) {
        while (v % i == 0) {
            v /= i;
            q[i] += 1;
            np[i] = max(np[i], q[i]);
        }
    }

    if (v > 1) {
        q[v] += 1;
        np[v] = max(np[v], q[v]);
    }
}

i64 binpow(i64 a, i64 n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        i64 b = binpow(a, n / 2);
        b %= mod;
        return (b * b) % mod;
    }
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    for (i64 i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (i64 i = 1; i <= n; i++) {
        up(a[i]);
    }

    i64 v = 1;
    for (auto t : np) {
        v *= binpow(t.first, t.second);
        v %= mod;
    }

    i64 R = 0;
    for (i64 i = 1; i <= n; i++) {
        R += (v * rev(a[i])) % mod;
        //R += v / a[i];
        R %= mod;
    }

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
const long double PI=acos(-1);
using namespace std;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
bool prime(ll x)
{
    if(x==2)
    {
        return true;
    }
    else if(x<2||x%2==0)
    {
        return false;
    }
    else
    {
        for(int i=3;i*i<=x;i+=2) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}
int main()
{
  ll z;
  cin>>z;
  ll c=0,r=0,i=0;
  bool b=false;
  while(i<=1000000)
  {
      i++;
      c=(c*10+7)%z;
      if(c==0)
      {
          cout<<i;
          return 0;
      }

  }
      cout<<-1<<endl;

}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P, int> PI;

struct edge {
	int from,to;
	int cost, res;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int t,int c,int r) : to(t), cost(c), res(r) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

vector<edge> G[105];
int d[105][105];

void dijkstra(int s, int l) {
	rep(i, 105) rep(j, 105) d[i][j] = INF;
	d[s][l] = 0;

	priority_queue<PI, vector<PI>, greater<PI> > que;
	que.push(mp(mp(0, -l), s));

	while(que.size()) {
		PI p = que.top(); que.pop();
		int cost = p.first.first;
		int coin = p.first.second;
		int v = p.second;
		coin *= -1;

		if(d[v][coin] < cost) continue;
		
		rep(i, G[v].size()) {
			edge e = G[v][i];

			if(d[e.to][coin] > d[v][coin] + e.res) {
				d[e.to][coin] = d[v][coin] + e.res;
				que.push(mp(mp(d[e.to][coin], -coin), e.to));
			}

			int nc = coin - e.cost;
			if(nc >= 0 && d[e.to][nc] > d[v][coin]) {
				d[e.to][nc] = d[v][coin];
				que.push(mp(mp(d[e.to][nc], -nc), e.to));
			}
		}

	}
}

int main() {
	int n, m, l;
	while(cin >> n >> m >> l)  {
		if(n == 0 && m == 0 && l == 0) break;

		rep(i, 105) G[i].clear();

		rep(i, m) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;

			a--; b--;

			G[a].push_back(edge(b, c, d));
			G[b].push_back(edge(a, c, d));
		}

		dijkstra(0, l);

		int ans = INF;
		rep(i, l+1) {
			ans = min(ans, d[n-1][i]);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1784
n = int(input())

def f(x):
    res = x * (x - 1) // 2

    return max(0, res)


a = list(map(int, input().split()))

if n == 1:
    print(0)
    exit()

counts = [0] * (n + 1)

for x in a:
    counts[x] += 1

s = sorted(counts)
m1 = s[-1]
m2 = s[-2]


max_result = 0
for k in range(1, n + 1):
    max_result += f(counts[k])

for k in range(1, n + 1):
    kk = a[k - 1]
    print(max_result - f(counts[kk]) + f(counts[kk] - 1))

Measured memory_bytes: 26140
#include<stdio.h>

#define MAX 25
struct node{
	int parent, left, right;
};

node T[MAX];
int D[MAX], H[MAX];

void setDepth(const int t, const int d){
	if (t == -1) return;
	D[t] = d;
	setDepth(T[t].right, d + 1);
	setDepth(T[t].left, d + 1);
}

int setHeight(const int t){
	int h1 = 0, h2 = 0;
	if (T[t].right != -1){
		h1 = setHeight(T[t].right) + 1;
	}
	if (T[t].left != -1){
		h2 = setHeight(T[t].left) + 1;
	}
	return H[t] = (h1 > h2 ? h1 : h2);
}

void output(const int t){
	int deg = 0;
	if (T[t].right != -1) deg++;
	if (T[t].left != -1) deg++;
	int sib = -1;
	int p = T[t].parent;
	if (p != -1){
		if (T[p].right != t) sib = T[p].right;
		else sib = T[p].left;
	}
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
				t, p, sib, deg, D[t], H[t]);
	if (p == -1) printf("root\n");
	else if (H[t] == 0) printf("leaf\n");
	else printf("internal node\n");
}

void PrePrint(int t){
    if (t == -1) return;
	printf(" %d", t);
	PrePrint(T[t].left);
	PrePrint(T[t].right);
}
void InPrint(int t){
	if (t == -1) return;
	InPrint(T[t].left);
	printf(" %d", t);
	InPrint(T[t].right);
}
void PosPrint(int t){
	if (t == -1) return;
	PosPrint(T[t].left);
	PosPrint(T[t].right);
	printf(" %d", t);
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i< n; i++) {
		T[i].left = -1;
		T[i].right = -1;
		T[i].parent = -1;
	}
	for (int i = 0; i < n; i++){
		int t, l, r;
		scanf("%d %d %d", &t, &l, &r);
		T[t].left = l;
		T[t].right = r;
		if (l != -1) T[l].parent = t;
		if (r != -1) T[r].parent = t;
	}
	int root;
	for (int i = 0; i < n; i++){
		if (T[i].parent == -1) {
			root = i;
			break;
		}
	}
	setDepth(root, 0);
	setHeight(root);

	printf("Preorder\n");
	PrePrint(root);
	printf("\n");
	printf("Inorder\n");
	InPrint(root);
	printf("\n");
	printf("Postorder\n");
	PosPrint(root);
	printf("\n");
}



Measured memory_bytes: 2692
from collections import Counter
N = int(input())
dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10,"k":11,"l":12,"m":13,"n":14,"o":15,"p":16,"q":17,"r":18,"s":19,"t":20,"u":21,"v":22,"w":23,"x":24,"y":25,"z":26}

ans = []
for i in range(N):
    si = input()
    a = [0]*26
    s = ""
    for j in range(10):
        a[dic[si[j]]-1] += 1
    for k in range(26):
        s = s + "a"
        s = s + str(a[k])
    ans.append(s)
c = Counter(ans)
b = 0
for v in c.values():
    if v > 1:
        b += v*(v-1)//2
    else:
        pass
print(b)
    

Measured memory_bytes: 23916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  using P = pair<int, int>;
  int n;
  vector<int> f, primes; //f.at(x)はxの最小素因数
  Sieve(int n=1):n(n), f(n+1) {
  f[0] = f[1] = -1;
  for (ll i = 2; i <= n; ++i) {
    if (f[i]) continue; //ここでf[i]==0なら素数
    primes.push_back(i);
    f[i] = i;
    for (ll j = i*i; j <= n; j += i) {
  if (!f[j]) f[j] = i;
    }
  }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) { //xの素因数を小さい順に列挙
  vector<int> res;
  while (x != 1) {
    res.push_back(f[x]);
    x /= f[x];
  }
  return res;
  }
  vector<P> factor(int x) {
  vector<int> fl = factorList(x);
  if (fl.size() == 0) return {};
  vector<P> res(1, P(fl[0], 0));
  for (int p : fl) { //ここでランレングス圧縮
    if (res.back().first == p) {
  res.back().second++;
    } else {
  res.emplace_back(p, 1);
    }
  }
  return res;
  }
};
// Sieve sieve(N);でN以下の各自然数の最小素因数を調べ上げる
// sieve.factor(M)でMの素因数分解

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数
    // 割れる限り割り続ける
    while (N % a == 0) {
     ++ex;
      N /= a;
    }
    // その結果を push
    res.push_back({a, ex});
  }
  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main()
{
    ll N;
    cin >> N;
    Sieve sieve(277775);
    vector<ll> a(N);
    a.at(0) = 2;
    a.at(1) = 3;
    rep2(i, 2, N){
        int p = a.at(i-1) + 10;
        while(true){
            if(sieve.f.at(p) == p){
                a.at(i) = p;
                break;
            }
            p += 10;
        }
    }
    rep(i, N-1){
        cout << a.at(i) << " ";
    }
    cout << a.at(N-1) << endl;
}

Measured memory_bytes: 4640
import bisect
def judge(k, N, A):
    t = 0
    for i in A:
        j = bisect.bisect_left(A, k - i)
        t += N - j
    return t
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    t = A[-1] * 2
    b = 0
    X = None
    while t - b > 1:
        m = (t + b)//2
        i = judge(m, N, A)
        if i == M:
            X = m
            break
        if i > M:
            ip = judge(m + 1, N, A)
            if ip == M:
                X = m + 1
                break
            if ip < M:
                X = m
                break
            b = m + 1
        if i < M:
            im = judge(m - 1, N, A)
            if im >= M:
                X = m - 1
                break
            t = m - 1
    if X is None:
        X = b
    B = []
    tmp = 0
    for i in reversed(range(N)):
        tmp += A[i]
        B.append(tmp)
    B.reverse()
    r = 0
    tot = 0
    for i in reversed(range(N)):
        j = bisect.bisect_left(A, X - A[i])
        tot += N - j
        if j == N:
            break
        r += A[i] * (N - j) + B[j]
    return r - (tot - M) * X
print(main())


Measured memory_bytes: 58224
N = int(input())
H = list(map(int, input().split()))

sum=0
for i in range(1,N-1):
    if(min(H[i-1],H[i],H[i+1])!=H[i]):
        if(max(H[i-1],H[i],H[i+1])!=H[i]):
            sum+=1
print(sum)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>//sort,二分探査など
//#include<bitset>
//#include<cmath>//pow,logなど
//#include<deque>
//#include<functional>
//#include<iterator>
//#include<map>
#include<numeric>//gcd,lcm
//#include<queue>
//#include<set>
//#include<stack>
//#include<string>
//#include<utility>//pair

//QCFium法
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//浮動小数点処理高速化
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;

constexpr i64 INF = 1010000000000000017LL;
constexpr u64 MOD = 1000000007LL;
constexpr f80 PI = 3.14159265358979323846;

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(int)(start);i<(int)(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(int)(start);i>(int)(end);--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >

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

template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int N;
  cin >> N;
  bool flagP = true;
  bool flagS = false;

  vector<int> A(N);
  cin >> A;

  int gcdx = A[0];
  rep(i, 1, N) {
    gcdx = __gcd(gcdx, A[i]);
    if(gcdx==1) {
      flagS = true;
      break;
    }
  }

  vector<int> prime(1000001);
  rep(i,1000001) {
    prime[i] = i;
  }
  rep(i,2,1000) {
    if(prime[i] != i) {
      continue;
    }
    for(int j = i; j <= 1000000; j += i) {
      prime[j] = i;
    }
  }

  vector<bool> counter(1000001, false);

  rep(i,N){
    int x = A[i];
    while(x > 1){
      int p = prime[x];
      if(counter[p]) {
        flagP = false;
        break;
      }
      counter[p] = true;
      while(x % p == 0){
        x /= p;
      }
    }
  }

  if(flagP) {
    cout << "pairwise coprime\n";
    return;
  }

  if(flagS) {
    cout << "setwise coprime\n";
    return;
  }

  cout << "not coprime\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
//  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 11368
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 


int main() {
    int n, k; cin >> n >> k;
    vector<int> chs(n, 1); 
    rep(i, k) {
        int d; cin >> d;
        rep(j, d) {
            int a; cin >> a;
            chs[--a] = 0; 
        }
    }
    int ret = accumulate(all(chs), 0);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main (void){
  long long n,i; 
  long long num;
  long long max;
  long long min;
  long long sum;
  
  scanf("%lld",&n);

  scanf("%lld",&num);

  max=num;
  min=num;
  sum=num;
  

  for(i=2;i<=n;++i){
    scanf("%lld",&num);

    if(num>max)
      max=num;
    
    if(num<min)
      min=num;

    sum+=num;
  }
  printf("%lld %lld %lld\n",min,max,sum);

  return 0;
}
  

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (YES) << endl;}else{cout << NO << endl;}
#define YES "Yes"
#define NO "No"

bool dp[101];

int main()
{
	int n;
	cin >> n;
	dp[0] = true;
	dp[4] = true;
	reps(i, 7, n+1) {
		dp[i] = dp[i-4] || dp[i-7];
	}
	PRINT(dp[n]);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace A {
    class Program {
        static void Main (string[] args) {
            var HW = Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
            var hw = Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
            var H = HW[0];
            var W = HW[1];
            var h = hw[0];
            var w = hw[1];

            Console.WriteLine ((H - h) * (W - w));
        }
    }
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> data(m);
  for(int i=0;i<m;i++) cin >> data[i];
  
  int d=0;
  for(int i:data) d+=i;
  
  if(n<d){
    cout << -1 <<endl;
  }
  else{
    cout << n-d <<endl;
  }
}

Measured memory_bytes: 3636
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll a[4];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    memset(a,-1,sizeof a);
    cin>>n>>m;
    bool f = 0;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        if(n!=1 && x==1 && y==0)
            f = 1;
        if(a[x]==-1)
            a[x] = y;
        else
        {
            if(a[x]!=y)
                f = 1;
        }
    }
    if(f)
    {
        cout<<-1<<endl;
        return 0;
    }
    if(n==1)
    {
        if(a[1]==-1)
            cout<<0<<endl;
        else cout<<a[1]<<endl;
    }
    else
    {
        for(i=1;i<=n;i++)
        {
            if(a[i]==-1)
            {
                if(i==1)
                    cout<<1;
                else
                cout<<0;
            }
            else cout<<a[i];

        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
/*
TASFIA TASNEEM ANNESHA

IUT CSE-19
*/
#define lld long long
#define pb push_back
#define mp make_pair
#define LCM(a,b)    (a/__gcd(a,b))*b
#define GCD(a,b) __gcd(a,b);
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define bismillah                ios_base::sync_with_stdio(0);cin.tie(NULL);
#include<bits/stdc++.h>
#include<string>
using namespace std;

int main()
{
    bismillah;
  lld x,b,t;
  cin>>x>>b>>t;
  lld p=t/x;
  lld ans=p*b;
  cout<<ans<<endl;



}


Measured memory_bytes: 3620
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  int red = 0;
  int blue = 0;
  FOR(c,s) {
    if (c == 'R') {
      red++;
    } else {
      blue++;
    }
  }
  cout << (red > blue ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	int team[10][3],n,i,j,k,c;
	
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		
		memset(team,0,sizeof(team));
		
		for(i=0;i<n;i++){
			scanf(" %c ",&team[i][0]);
			for(j=0;j<n-1;j++){
				scanf("%d",&c);
				if(c==0)++team[i][1];
				if(c==1)++team[i][2];
			}
		}
		
		for(i=0;i<n;i++){
			for(j=0;j<n-1;j++){
				if(team[j][2]>team[j+1][2]){
					for(k=0;k<3;k++){
						c=team[j][k];
						team[j][k]=team[j+1][k];
						team[j+1][k]=c;
					}
				}
			}
		}
		
		for(i=0;i<n;i++){
			for(j=0;j<n-1;j++){
				if(team[j][1]<team[j+1][1]){
					for(k=0;k<3;k++){
						c=team[j][k];
						team[j][k]=team[j+1][k];
						team[j+1][k]=c;
					}
				}
			}
		}

		for(i=0;i<n;i++){
			printf("%c\n",team[i][0]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	vector<int> ans(10004, 0);
	cin >> n;
	for (int i = 1; i * i <= n; ++i)
	{
		for (int j = 1; j * j <= n; ++j)
		{
			for (int k = 1; k * k <= n; ++k)
			{
				int sum = i * i + j * j + k * k + i * j + j * k + k * i;
				if (sum <= 10000)
					ans[sum] ++;
			}
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		cout << ans[i] << '\n';
	}
	
	return 0;
}

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

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

    int n, a, b;
    cin >> n >> a >> b;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        int num = i, cost = 0;
        do{
            cost += num % 10;
            num /= 10;
        }while(num >= 1);

        if(a <= cost && cost <= b){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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



int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h + w == 0) break;
		int ans_h = 10000;
		int ans_w = 10000;
		for(int i = 1;i < 150;i++){
			for(int j = i+1;j < 150;j++){
				if(h*h + w*w < i*i + j*j ){
					if(i*i + j*j < ans_h*ans_h + ans_w*ans_w){
						ans_h = i;
						ans_w = j;
					}else if(i*i + j*j == ans_h*ans_h + ans_w*ans_w && i < ans_h){
						ans_h = i;
						ans_w = j;
					}
				}else if(h*h + w*w == i*i + j*j && i > h){
					if(i*i + j*j < ans_h*ans_h + ans_w*ans_w){
						ans_h = i;
						ans_w = j;
					}else if(i*i + j*j == ans_h*ans_h + ans_w*ans_w && i < ans_h){
						ans_h = i;
						ans_w = j;
					}
				}
			}
		}
		cout << ans_h << " " << ans_w << endl;
	}

}


Measured memory_bytes: 3092
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

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

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> fib(100);
	fib[0] = 2;
	fib[1] = 1;
	for(int i = 2;i <= n;++i){
		fib[i] = fib[i-1] + fib[i-2];
	}
	cout << fib[n] << '\n';
	return 0;	
}


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

int main() {int n,s=0;cin>>n;vector<int> v;
  for(int i=0;i<n;i++){int d;cin>>d;v.push_back(d);}
  for(int i=0;i<n;i++){for(int j=0;j<n;j++){
  if(i<j){s+=v[i]*v[j];}}}cout<<s<<endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

const int maxn = 1e3 + 3;

struct box{
	int w, s, val;
};

bool cmp(box a, box b){
	return a.w + a.s < b.w + b.s;
}

ll dp[20010]; //dp[i] menyatakan jumlah value maksimal apabila total weight adalah i

int main(){
	int n,i,j;
	box a[maxn];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i].w, &a[i].s, &a[i].val);
	}

	sort(a,a+n, cmp);

	for(i=0;i<n;i++){
		int maksBerat = a[i].s;
		for(j=maksBerat;j>=0;j--){
			dp[j+a[i].w] = max(dp[j+a[i].w], dp[j] + a[i].val);
		}
	}
	ll maks = 0;
	for(i=0;i<20001;i++){
		maks = max(maks, dp[i]);
	}
	printf("%lld\n",maks);

	return 0;
};

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		Grid[][] grid = new Grid[6][6];
		for(int i = 0; i < 36; i++){
			grid[i/6][i%6] = new Grid();
		}
		
		for(int i = 0; i < 9; i++){
			String tmp = br.readLine();
			
			if(i%2 == 0){
				for(int j = 0; j < 4; j++){
					if(tmp.charAt(j) == '1'){
						grid[i/2 + 1][j + 1].top = true;
						//System.out.println("top");
					}
				}
			}
			else{
				for(int j = 0; j < 5; j++){
					if(tmp.charAt(j) == '1'){
						grid[i/2 + 1][j + 1].left = true;
						//System.out.println("left");
					}
				}
			}
		}
		
		int currentX = 1;
		int currentY = 0;
		final int R = 0;
		final int D = 1;
		final int U = 2;
		final int L = 3;
		
		int mode = R;
		
		StringBuffer sb = new StringBuffer();
		while(true){
			//System.out.println("mode "+ mode +"(x,y)"+currentX + " " + currentY);
			if(mode == R){
				//??´?????????
				if(grid[currentY][currentX + 1].left){
					mode = U;
				}
				//??´??????
				else if(grid[currentY + 1][currentX + 1].top){
					currentX++;
				}
				//?????????
				else if(grid[currentY + 1][currentX + 1].left){
					mode = D;
					currentX++;
					currentY++;
				}
				else {
					mode = L;
					currentY++;
				}
				sb.append("R");
			}
			else if(mode == D){
				//??´?????????
				if(grid[currentY+1][currentX].top){
					mode = R;
				}
				//??´??????
				else if(grid[currentY + 1][currentX].left){
					currentY++;
				}
				//??????
				else if(grid[currentY + 1][currentX - 1].top){
					mode = L;
					currentX--;
					currentY++;
				}
				else{
					mode = U;
					currentX--;
				}
				sb.append("D");
			}
			else if(mode == U){
				//??´?????????
				if(grid[currentY][currentX].top){
					mode = L;
				}
				//??´??????
				else if(grid[currentY - 1][currentX + 1].left){
					currentY--;
				}
				//??????
				else if(grid[currentY][currentX + 1].top){
					mode = R;
					currentX++;
					currentY--;
				}
				else {
					mode = D;
					currentX++;
				}
				sb.append("U");
			}
			else {
				//??´?????????
				if(grid[currentY][currentX].left){
					mode = D;
				}
				//??´??????
				else if(grid[currentY][currentX - 1].top){
					currentX--;
				}
				//??????
				else if(grid[currentY - 1][currentX].left){
					mode = U;
					currentX--;
					currentY--;
				}
				else {
					mode = R;
					currentY--;
				}
				sb.append("L");
			}
			
			if(currentX == 1 && currentY == 1 && mode == L){
				//if(sb.charAt(sb.length() - 1) != 'L'){
				sb.append("L");
				//}
				break;
			}
			else if(currentX == 0 && currentY == 1 && mode == U){
				//if(sb.charAt(sb.length() - 1) != 'U'){
				sb.append("U");
				//}
				break;
			}
		}
		
		System.out.println(sb);
	}

}

class Grid {
	boolean top = false;
	boolean left = false;
}

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

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 2e5;
struct Point
{
	int x,y;
	bool operator <(const Point &arg) const {return y<arg.y||(y==arg.y&&x<arg.x);}
} a[N+3];
int n,m,p;

int main()
{
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1; i<=p; i++)
	{
		scanf("%d%d",&a[i].x,&a[i].y);
		if(a[i].x<a[i].y) {p--,i--;}
		else {a[i].x -= a[i].y-1;}
	}
	sort(a+1,a+p+1);
	int lim = 0,ans = n;
	for(int i=1; i<=p; i++)
	{
		int j = i,k;
		while(j<p && a[j+1].y==a[i].y) {j++;}
		for(k=i; k<=j&&a[k].x<=lim; k++);
		for(; k<=j&&a[k].x==lim+1; k++,lim++);
		for(; k<=j; k++)
		{
			ans = min(ans,a[k].x+a[k].y-2);
		}
		i = j;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long h = scan.nextLong();

    int[] a = new int[n];
    int[] b = new int[n];

    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
      b[i] = scan.nextInt();
    }

    Arrays.sort(a);
    Arrays.sort(b);

    int maxa = a[n-1];
    ArrayList<Integer> c = new ArrayList<Integer>();
    for (int j=n-1;j>=0;j--){
      if(b[j] <= maxa){
        break;
      }
      c.add(b[j]);
    }
    int count = 0;
    for (int k=0;k<c.size();k++){
      h -= c.get(k);
      count += 1;
      if (h <= 0){
        System.out.println(count);
        return;
      }
    }

    if (h % maxa == 0){
      count += (int) h/maxa;
    }
    else{
      count += 1;
      count += (int) h/maxa;
    }
    System.out.println(count);
  }

}


Measured memory_bytes: 61096