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

const int N = 200005;

vector<int> g1[N], g2[N], a1[N], a2[N];

int n, x, y, c1[N], c2[N], was1[N], was2[N];
int n1, n2;

void dfs(int v, int was[], int c[], vector<int> a[], vector<int> g[], int num) {
    c[v] = num;
    a[num].push_back(v);
    was[v] = true;
    for (auto& to : g[v]) {
        if (!was[to]) dfs(to, was, c, a, g, num);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> x >> y;
    while (x--) {
        int a, b;
        cin >> a >> b;
        g1[a].push_back(b);
        g1[b].push_back(a);
    }
    while (y--) {
        int a, b;
        cin >> a >> b;
        g2[a].push_back(b);
        g2[b].push_back(a);
    }
    for (int i = 1; i <= n; ++i) {
        if (!was1[i]) dfs(i, was1, c1, a1, g1, ++n1);
        if (!was2[i]) dfs(i, was2, c2, a2, g2, ++n2);
    }
    for (int i = 1; i <= n1; ++i) sort(a1[i].begin(), a1[i].end());
    for (int i = 1; i <= n2; ++i) sort(a2[i].begin(), a2[i].end());
    map<pair<int,int>,int> mp;
    for (int i = 1; i <= n; ++i) {
        int x = c1[i], y = c2[i];
        pair<int, int> cur = {x, y};
        if (!mp.count(cur)) {
            int cnt = 0;
            if (a1[x].size() < a2[y].size()) {
                for (auto& el : a1[x]) if (binary_search(a2[y].begin(), a2[y].end(), el)) ++cnt;
            } else {
                for (auto& el : a2[y]) if (binary_search(a1[x].begin(), a1[x].end(), el)) ++cnt;
            }
            mp[cur] = cnt;
        }
        cout << mp[cur] << ' ';
    } 
    cout << endl;
    return 0;
}


Measured memory_bytes: 48128
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll N, Z, W;
vector<ll> A(2001, 0); 

int main(void){
    
    scanf("%lld %lld %lld", &N, &Z, &W);
    for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);
    
    ll ans = 0;
    if(N == 1) ans = abs(A[0] - W);
    else ans = max(abs(A[N - 2] - A[N - 1]), abs(A[N - 1] - W));
    printf("%lld\n", ans);
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a, b, c;

    cin >> a >> b >> c;

    c-=a-b;

    cout << max(c, 0);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int N, K;
  cin >> N >> K;
  if(0 == (N % K)) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1 << endl;
  return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];

            var cnt = 0;
            while (true)
            {
                if ((A - 1) * cnt + 1 >= B)
                {
                    Console.WriteLine(cnt);
                    return;
                }
                cnt++;
            }
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <string.h>
  int main(){
    char str[80];
    int strstr[80];
	while(gets(str) != NULL){
    int b = strlen(str);
    int i,j,k;
    for(i=0;i<b;i++){
        strstr[i]=str[i]-'a';
	}
 for(j=0;j<b;j++){
    for(i=0;i<26;i++){
       if((strstr[j]+i)%26==19){
		   if((strstr[j+1]+i)%26==7){
		   for(k=0;k<b;k++){
			  if(strstr[k]>=0){
			  if(strstr[k]<=25){
              str[k]=(strstr[k]+i)%26+'a';
              }
			  }
			  }
		   }
	   }    
	}

}
	puts(str);
	}
return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

const int MAXN = 200000+10;
int N;
int nums[MAXN];
int num[MAXN];

int main() {
	scanf("%d",&N);
	for(int i = 1;i <= N; i++) { scanf("%d",&nums[i]); num[i] = nums[i]; }
	sort(nums+1,nums+N+1);
	int a1 = nums[(N)/2],a2 = nums[N/2+1];
	for(int i = 1,j; i <= N; i++) {
//		j = lower_bound(nums+1,nums+N+1,num[i]);
		if(num[i] <= a1) cout << a2 << endl;
		else cout << a1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if((a+b)>(c+d))
    {
        printf("Left");
    }
    else if((a+b)<(c+d))
    {
        printf("Right");
    }
    else
    {
        printf("Balanced");
    }
        return 0;
}


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

int main() {
    long long N, M;
    cin >> N >> M;
    if (N > M) {
        swap(N, M);
    }

    if (N == 1 && M == 1) {
        cout << 1 << endl;
        return 0;
    }

    if (N == 1) {
        cout << max(M - 2, 0LL) << endl;
    } else {
        cout << (N - 2) * (M - 2) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std; 

string normalize(string s)
{
    int n = s.size();
    char c = 'A';
    vector<char> to(256, ' ');
    for(int i=0; i<n; ++i){
        if(s[i] != '.'){
            if(to[s[i]] == ' '){
                to[s[i]] = c;
                ++ c;
            }
            s[i] = to[s[i]];
        }
    }
    return s;
}

int main()
{
    int h, w;
    cin >> h >> w;
    if(w == 1)
        swap(h, w);

    vector<string> grid(h, string(w, ' '));
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            cin >> grid[i][j];
        }
    }

    map<string, int> dp;
    dp.insert(make_pair(string(w, '.'), 0));

    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            map<string, int> nextDp;
            map<string, int>::iterator it;
            for(it=dp.begin(); it!=dp.end(); ++it){
                string s = it->first;
                int numA = count(s.begin(), s.end(), 'A');
                // ツ板陳つュツ塗ツづゥ
                if(grid[y][x] != '#'
                        && (x == 0 || s[w-1] != '.')    // ツ債カツ右ツづ可板陳づーツ堕アツつッツづ按つ「
                        && (y == 0 || s[0] != '.')      // ツ湘」ツ可コツづ可板陳づーツ堕アツつッツづ按つ「
                        && (s[0] != 'A' || numA != 1)){ // ツ債閉づーツ静伉づィツ猟」ツつウツづ按つ「
                    string t = string(s.begin()+1, s.end()) + '.';
                    t = normalize(t);
                    nextDp[t] = max(nextDp[t], it->second);
                }

                // ツ債閉つュツ塗ツづゥ
                if(grid[y][x] != '.'
                        && (x == 0 || s[0] == '.' || s[0] != s[w-1])){ // ツ債閉づ個陛つ路ツづーツ催ャツづァツづ按つ「
                    string t = string(s.begin()+1, s.end()) + '.';
                    if(x != 0)
                        t[w-1] = s[w-1];

                    if(t[w-1] == '.'){
                        if(s[0] == '.'){
                            t[w-1] = 'Z';
                        }else{
                            t[w-1] = s[0];
                        }
                    }else{
                        if(s[0] == 'A')
                            replace(t.begin(), t.end(), 'A', s[w-1]);
                    }
                    t = normalize(t);
                    nextDp[t] = max(nextDp[t], it->second + 1);
                }
            }
            dp.swap(nextDp);
        }
    }

    int ret = -1;
    map<string, int>::iterator it;
    for(it=dp.begin(); it!=dp.end(); ++it){
        if(it->first.find_first_not_of("A.") == -1)
            ret = max(ret, it->second);
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
    ll k; cin >> k;
    ll x = 7;
    int ans = 1;
    set<ll> s;
    s.insert(x);

    if(x % k == 0) {
        cout << ans << endl;
        return 0;
    }

    while(true){
        x = x * 10 + 7;
        x %= k;
        ans++;
        if(x % k == 0){
            cout << ans << endl;
            return 0;
        }
        s.insert(x);
        if(s.size() != ans){
            cout << -1 << endl;
            return 0;
        } 
    }
}

/*
g++ c.cpp
./a.out

oj d https://atcoder.jp/contests/abc172/tasks/abc172_c
g++ c.cpp
oj t
*/


Measured memory_bytes: 50508
//
// Created by 13783 on 2020/3/28.
//
#include<iostream>
#include<set>
#include<queue>
using namespace std;
int x,y;
int a,b,c;
const int N=1e5;
int p[N],q[N],r[N];

priority_queue<pair<int,int> > sp;
void solve(){
    int n=x+y;
    long long ans=0;
    while(n){
        if(sp.top().second==1&&x>0){
            ans+=sp.top().first;
            x--;
            n--;
        }
        else if(sp.top().second==2&&y>0){
            ans+=sp.top().first;
            y--;
            n--;
        }
        else if(sp.top().second==0){
            ans+=sp.top().first;
            n--;
        }
        sp.pop();
    }
    cout<<ans;
}
int main(){
    cin>>x>>y;
    cin>>a>>b>>c;
    for (int i = 0; i < a; ++i) {
        cin>>p[i];
        sp.push(make_pair(p[i],1));
    }
    for (int j = 0; j < b; ++j) {
        cin>>q[j];
        sp.push(make_pair(q[j],2));
    }
    for (int k = 0; k < c; ++k) {
        cin>>r[k];
        sp.push(make_pair(r[k],0));
    }
    solve();
    return 0;
}


Measured memory_bytes: 7536
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    Cout(max(0LL,a-b));
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
s = []

for i in range(H):
    tmp = list(input())
    s.append(tmp)

for y in range(H):
    for x in range(W):
        if s[y][x] == '#':

            if x >= 1:
                if s[y][x-1] == '#':
                    continue

            if x <= W-2:
                if s[y][x+1] == '#':
                    continue

            if y >= 1:
                if s[y-1][x] == '#':
                    continue     

            if y <= H-2:
                if s[y+1][x] == '#':
                    continue

                print("No")
                exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{

    ll N;
    cin >> N;
    vector<ll> Ap;
    vector<ll> Am;
    ll min_p = 10000000000;
    ll min_m = 10000000000;
    rep(i,N) {
        ll a = 0;
        cin >> a;
        if (a >= 0) {
            Ap.push_back(a);
            if (a < min_p) min_p = a;
        } else {
            Am.push_back(a);
            if (abs(a) < min_m) min_m = abs(a);
        }
    }

    ll ret = 0;
    if (Am.size() % 2 == 0) {
        rep(i, Ap.size()) ret += Ap.at(i);
        rep(i, Am.size()) ret += abs(Am.at(i));
    } else {
        sort(Ap.begin(), Ap.end());
        sort(Am.begin(), Am.end());

        ll t = 0;
        if (min_p < min_m) {
            t = min_p;
        } else {
            t = min_m;
        }
        rep(i, Ap.size()) ret += Ap.at(i);
        rep(i, Am.size()) ret += abs(Am.at(i));
        ret -= (2*t);
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1656
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    N = len(S)
    w = "keyence"
    for i in range(7):
        if S[:i] == w[:i] and S[N-7+i:] == w[i:]:
            print("YES")
            break
    else: print("NO")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;

int n, a[100010];
ll calc(ll cur) {
	for(int i = 0; i < n; ++i) {
		cur = cur / a[i] * 1LL* a[i];
	}
	return cur;
}
ll ter1() {
	ll l = 0, r = 1e17 + 10, l1, r1, l2, r2, ans = -1;
	while(l <= r) {
		l1 = (2 * l + r) / 3;
		l2 = (l + 2 * r) / 3;
		r1 = calc(l1);
		r2 = calc(l2);
		if(r2 == 2)
			ans = l2;
		if(r1 == 2)
			ans = l1;
		if(r1 < 2)
			l = l1 + 1;
		else
			r = l2 - 1;
	}
	return ans;
}

ll ter2() {
	ll l = 0, r = 1e17 + 10, l1, r1, l2, r2, ans = -1;
	while(l <= r) {
		l1 = (2 * l + r) / 3;
		l2 = (l + 2 * r) / 3;
		r1 = calc(l1);
		r2 = calc(l2);
		if(r1 == 2)
			ans = l1;
		if(r2 == 2)
			ans = l2;
		if(r1 > 2)
			r = l2 - 1;
		else
			l = l1 + 1;
	}
	return ans;
}

int main() {

	//freopen("a.txt", "r", stdin);
	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", a + i);
	ll ans1 = ter1();
	ll ans2 = ter2();
	if(ans1 == -1 && ans2 == -1)
		puts("-1");
	else if(ans1 == -1)
		printf("%lld %lld\n", ans2, ans2);
	else if(ans2 == -1)
		printf("%lld %lld\n", ans1, ans1);
	else
		printf("%lld %lld\n", ans1, ans2);

	return 0;
}

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

#define MAX_N 100000

ll x[MAX_N+2];

int main(){
	int n;
	scanf("%d",&n);
	++n;
	x[0]=0;
	for(int i=1;i<n;++i) scanf("%lld",&x[i]);
	x[n]=0;
	ll ans=0;
	for(int i=1;i<=n;++i) ans+=abs(x[i]-x[i-1]);
	for(int i=1;i<n;++i) printf("%lld\n",ans-abs(x[i]-x[i-1])-abs(x[i+1]-x[i])+abs(x[i+1]-x[i-1]));
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long int power (long long int a, long long int b) {
    long long int ans=1ll;
    while(b) {
        if(b&1)ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b=b/2;
    }
    return ans;
    }
int main()
{
        long long n;
        cin>>n;
         long long a=power(n,3);
        cout<<a<<"\n";
}


Measured memory_bytes: 256
# coding: utf-8

nums = [int(x) for x in input().split()]
H,W = nums[0],nums[1]

field = []
for i in range(H):
    line = [x for x in input()]
    field.append(line)


for i in range(H):
    for j in range(W):
        if field[i][j] == "#":
            continue
        else:
            # 探索処理
            cnt = 0
            for dy in [-1,0,1]:
                for dx in [-1,0,1]:
                    ny, nx = i + dy, j + dx 
                    if 0 <= ny < H and 0 <= nx < W:
                        
                        if field[ny][nx] == "#": cnt += 1

            # finally
            field[i][j] = str(cnt)


for line in field:
    print("".join(line))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];

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

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

int main()
{
	int N, X[100], Y[100], H[100], x = 0, y = 0, h = 0, k = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
	}

	while (H[k] == 0) ++k;

	for (x = 0; x <= 100; x++) {
		for (y = 0; y <= 100; y++) {
			h = abs(X[k] - x) + abs(Y[k] - y) + H[k];
			bool ok = true;

			for (int i = 0; i < N; i++) {
				if (H[i] != max(h - abs(X[i] - x) - abs(Y[i] - y), 0)) {
					ok = false;
					break;
				}
			}
			if (ok) {
				cout << x << " " << y << " " << h << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */
#include <vector>
#include <algorithm>

void print_array(std::vector<int> list)
{
  for(int i = 0; i < list.size(); ++i){
    if(i>0) std::cout << " ";
    std::cout << list[i];
  }
  std::cout << std::endl;
}

void SelectionSort(std::vector<int> &listToSort, int &swapCounter){
    int mini;
    for (int i=0; i<listToSort.size(); i++) {
        mini = i;
        for (int j=i; j<listToSort.size(); j++) {
            if(listToSort[j]<listToSort[mini]) {
                mini = j;
            }
        }

        std::swap(listToSort[i],listToSort[mini]);
        if (i!=mini) swapCounter++;
    }
}

int main(void){

    int num;
    std::cin >> num;
    if (num>100) {
        std::cout << "list too big" << std::endl;
        return 1;
    }
    std::vector<int> list;
    for(int i = 0; i < num; i++){
    int value;
    std::cin >> value;
    list.push_back(value);
    }

    int swapNumber=0;
    
    SelectionSort(list, swapNumber);

    print_array(list);
    std::cout << swapNumber << std::endl;

    return 0;
}

Measured memory_bytes: 1220
from collections import deque
n,m = map(int,input().split())

adj = [[] for i in range(n)]
dist = [-1]*n
for i in range(m):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
q = deque()
dist[0] = 0
q.append(0)

while len(q) > 0:
    x = q.popleft()
    
    for f in adj[x]:
        if dist[f] != -1:
            continue
        
        dist[f] = dist[x] + 1
        q.append(f)
     
if dist[n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 40472
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"strconv"
)

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

// An IntHeap is a heap of ints.
type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

//Push is push
func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

// Pop is pop
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func solve() {
	n, m := nextInt(), nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	q := &IntHeap{}
	heap.Init(q)
	for _, a := range a {
		heap.Push(q, a)
	}
	for i := 0; i < m; i++ {
		tmp := heap.Pop(q).(int)
		tmp = tmp / 2
		heap.Push(q, tmp)
	}
	res := 0
	for q.Len() > 0 {
		res += heap.Pop(q).(int)
	}
	fmt.Fprint(writer, res)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 8704
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m,x = inpm()
    c = [list(map(int,input().split())) for _ in range(n)]
    ans = float('inf')
    for num in range(1,n+1):
        for e in combinations(range(n),num):
            cost = 0
            under = [0 for _ in range(m)]
            for f in e:
                cost += c[f][0]
                for i in range(m):
                    under[i] += c[f][i+1]
            if min(under) >= x:
                ans = min(ans,cost)
    if ans == float('inf'):
        print(-1)
    else:
        print(ans)

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 10896
n,k = gets.chomp.split(" ").map{|i|i.to_i}
d = []
a = [[]]
snk = (1..n).to_a
k.times do |i|
  d[i] = gets.chomp.to_i
  a[i] = gets.chomp.split(" ").map{|i|i.to_i}
end

a.each do |di|
  if snk.empty?
    break
  end
  di.each do |sunuke|
    snk.delete(sunuke)
  end
end

puts snk.size
  

Measured memory_bytes: 14284
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        Arrays.sort(l);
        int sum = 0;
        for (int i = 0; i < k; i++) {
            sum += l[l.length - 1 - i];
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef  unsigned long long uLL;
typedef pair<LL, LL> P;

int main(){
    uLL a, b;
    cin >> a >> b;
    a--;
    LL f0b = 0, f0a = 0;
    if(a%4 == 2 || a%4 == 1) f0a += 1;
    if(b%4 == 2 || b%4 == 1) f0b += 1;
    for(uLL i = 50;;i--){
        if(i <= 0)  break;
        if(1ull<<i > b) continue;
        if((b>>i & 1ull) == 1 && (b%(1ull<<i) & 1ull) == 0){
            f0b += 1ull<<i;
        }
    }
    for(uLL i = 50;;i--){
        if(i <= 0)  break;
        if(1ull<<i > a) continue;
        if((a>>i & 1ull) == 1 && (a%(1ull<<i) & 1ull) == 0){
            f0a += 1ull<<i;
        }
    }
    LL ans = f0a xor f0b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{int n,a,b,c,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)
      puts("YES");
    else
      puts("NO");
  }

  return(0);

}

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

int main(void){
	char s[101][11], f, e = 'j', c, *j, *k, *l;
	int i, n, flag;
	strcpy(s[0],"abcj");
	for(i = 0;i < 100;i+=2){
		printf("?%s\n",s[i]);
		fflush(stdout);
		scanf("%s",&s[i + 1]);
		if(e != s[i + 1][0]){
			printf("!OUT\n");
			fflush(stdout);
			return 0;
		}
		for(n = 0;n < i + 1;n++){
			if(!strcmp(s[i + 1],s[n])){
				printf("!OUT\n");
				fflush(stdout);
				return 0;
			}
		}
		f = s[i + 1][strlen(s[i + 1]) - 1];
		flag = 0;
		s[i + 2][0] = f;
		j = &s[i + 2][1], k = &s[i + 2][2], l = &s[i + 2][3];
		s[i + 2][4] = e, s[i + 2][5] = '\0';
		for(*j = 'a';*j <= 'z';(*j)++){
			for(*k = 'a';*k <= 'z';(*k)++){
				for(*l = 'a';*l <= 'z';(*l)++){
					for(n = 0;n < i + 2;n++)
						if(!strcmp(s[i + 2],s[n])) break;
					if(n == i + 2)
						flag = 1;
					if(flag)
						break;
				}
				if(flag) break;
			}
			if(flag) break;
		}

	}
	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
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 rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int main() {
  string T; cin >> T;
  int AddTopping;
  if (T[0] == 'o') ++AddTopping;
  if (T[1] == 'o') ++AddTopping;
  if (T[2] == 'o') ++AddTopping;
  cout << 700 + (100 * AddTopping) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cassert>
using namespace std;

typedef long long ll;
ll dp[2100][2100];
ll sum[1000100];
int N, M, L;
vector<ll> K;
vector<ll> S;
const ll INF = 1e15;

ll gauss(ll a, ll l) {
	return a/l;
}

ll solve(int a, int b) {
	// a, b ???????????§?????°
	if(dp[a][b]+1)
		return dp[a][b];
	if(a == b)
		return dp[a][b] = INF;

	ll res = INF;
	if(abs(a-b) == 1) {
		for(int i = 1; i < min(a,b); i++) {
			if(a > b)
				res = min(res, solve(i,b) + gauss(sum[K[a-1]] - sum[K[i-1]-1], L));
			else
				res = min(res, solve(a,i) + gauss(sum[K[b-1]] - sum[K[i-1]-1], L));
		}
	}
	else {
		if(a > b)
			res = min(res, solve(a-1,b) + gauss(sum[K[a-1]]-sum[K[a-2]-1], L));
		else
			res = min(res, solve(a,b-1) + gauss(sum[K[b-1]]-sum[K[b-2]-1], L));
//		cout << a << "," << b << " "<< K[max(a,b)-1] << "," << K[max(a,b)-2] << " " << res << endl;
	}
	return dp[a][b] = res;
}

int main() {
	cin >> N >> M >> L;
	K.resize(N); S.resize(M);
	for(int i = 0; i < N; i++)
		cin >> K[i];
	for(int i = 0; i < M; i++)
		cin >> S[i];

	for(int i = 0; i < 2100; i++)
		for(int j = 0; j < 2100; j++)
			dp[i][j] = -1;
	for(int i = 0; i < S.size(); i++)
		sum[i+1] = S[i]+sum[i];

	ll res = INF;
	sort(K.begin(), K.end());
	dp[1][1] = 0;
	dp[1][2] = dp[2][1] = gauss(sum[K[1]]-sum[K[0]-1],L);
	for(int i = 1; i < N; i++) {
		res = min(res, solve(i,N) + gauss(sum[K[N-1]]-sum[K[i-1]-1],L));
	}
	cout << res << endl;
}

Measured memory_bytes: 38924
/* Author: topcoderme123
   Date: 22nd june 2020 
*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define np next_permutation
using namespace std;
using vi=vector<int>;
#define lp(i,n) for(int i=0;i<n;i++)
#define reps(i,j,n) for(int i=j;i<=n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>> 
#define eb emplace_back
#define prl pair<ll,ll>
#define vp vector<pr>
#define N 10000008
//const int N=(int)1e7+1;

ll n;
/*static int mindiv[N];

void seive(){
    int s[N];
    for(int i=2;i<N;i++)
       s[i]=1;
    s[0]=s[1]=0;
    for(int i=2;i*i<N;i++){
        if(!s[i]) continue;
        for(int j=i*i;j<N;j+=i){
          s[j]=0;
          mindiv[j]=(!mindiv[j])?i:min(mindiv[j],i);
        }
    }
    for(int i=2;i<N;i++) if(s[i]) mindiv[i]=i;
}
int slv(int x){
   int d=mindiv[x];
   int ans=1;
   while(x>1){
      int d=mindiv[x],cnt=0;
      while(x%d == 0){
         x/=d;
         cnt++;
      }
      ans*=(cnt+1);
   }
}*/
void solve(){
   ll ans=0;
   cin>>n;
   for(int i=1;i<=n;i++){
      ll x=floor(n/i),val=(x*1LL*(x+1))/2;
      ans+=i*1LL*val;
   }
   cout<<ans<<"\n";
}
int main(int argc,char *argv[]){
   ios_base::sync_with_stdio(0);
   cin.tie(nullptr);
   //assert(freopen("input.txt", "r", stdin));
   //assert(freopen("output.txt", "w", stdout));
   //seive();
   solve();

   return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int sx[1001],sy[1001],gx[1001],gy[1001],s[1511][1511];
int dx[]={0,0,1,-1},w,h,n;
int dy[]={1,-1,0,0};
vector<int>v1,v2;
map<int,int>m1,m2;
set<int>s1,s2;
void zaatsu(){
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  v1.erase(unique(v1.begin(),v1.end()),v1.end());
  v2.erase(unique(v2.begin(),v2.end()),v2.end());
  int a=0,b=0;
  r(i,v1.size())m1[v1[i]]=a,a+=2;
  r(i,v2.size())m2[v2[i]]=b,b+=2;
}
void init(){
  s1.clear();
  s2.clear();
  v1.clear();
  v2.clear();
  m1.clear();
  m2.clear();
}
void make_map(){
  r(i,n){
    for(int j=m2[sy[i]];j<=m2[gy[i]];j++)
      for(int k=m1[sx[i]];k<=m1[gx[i]];k++)
        s[j][k]=1;
  }
}
void dfs(int y,int x){
  s[y][x]=2;
  r(i,4){
    int xx=x+dx[i];
    int yy=y+dy[i];
    if(xx<0||yy<0||xx>=m1[v1[v1.size()-1]]||yy>=m2[v2[v2.size()-1]])continue;
    if(!s[yy][xx])dfs(yy,xx);
  }
}
int main(){
  while(cin>>w>>h,w){
    int ans=0;
    memset(s,0,sizeof(s));
    init();
    cin>>n;
    r(i,n){
      cin>>sx[i]>>sy[i]>>gx[i]>>gy[i];
      if(!s1.count(sx[i]))v1.push_back(sx[i]),s1.insert(sx[i]);
      if(!s2.count(sy[i]))v2.push_back(sy[i]),s2.insert(sy[i]);
      if(!s1.count(gx[i]))v1.push_back(gx[i]),s1.insert(gx[i]);
      if(!s2.count(gy[i]))v2.push_back(gy[i]),s2.insert(gy[i]);
    }
    v1.push_back(0);
    v2.push_back(0);
    v1.push_back(w);
    v2.push_back(h);
    zaatsu();
    make_map();
    r(i,m2[v2[v2.size()-1]]){
      r(j,m1[v1[v1.size()-1]]){
        if(!s[i][j])ans++,dfs(i,j);
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 35556
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}   

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

unsigned char calculate_num_monitor (unsigned char num_tree_all, unsigned char num_range)
{
	// variable for this function
	register unsigned char num_tree_monitored;
	register unsigned char num_monitor;

	num_tree_monitored = (unsigned char)(2) * num_range + (unsigned char)(1);
	num_monitor        = num_tree_all / num_tree_monitored;

	if ( num_tree_all % num_tree_monitored != (unsigned char)(0) ) { num_monitor += (unsigned char)(1); }

	return num_monitor;
}

int main (void)
{
	// variables for main process
	register unsigned short N;
	register unsigned short D;

	// STEP.01
	// read out the given data
	std::cin >> N >> D;

	// STEP.02
	// output the answer of this task
	std::cout << std::to_string(calculate_num_monitor (N, D)) << std::endl;

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256
N = int(input())

result = {}
for _ in range(N):
  s = input()
  result[s] = result.get(s, 0) + 1

print(f"AC x {result.get('AC', 0)}")
print(f"WA x {result.get('WA', 0)}")
print(f"TLE x {result.get('TLE', 0)}")
print(f"RE x {result.get('RE', 0)}")


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

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

    int maxv = max({a, b, c});
    int ans = a + b + c;
    ans += maxv * pow(2, k) - maxv;

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


Measured memory_bytes: 256
n = gets.to_i
minus_numbers = []
plus_numbers = []
numbers = gets.split(" ").map(&:to_i)

if n == 2
  if numbers[0] > numbers[1]
    puts numbers[0] - numbers[1]
    puts "#{numbers[0]} #{numbers[1]}"
    exit
  else
    puts numbers[1] - numbers[0]
    puts "#{numbers[1]} #{numbers[0]}"
    exit
  end
end

numbers.each do |n|
  if n >= 0
    plus_numbers << n
  else
    minus_numbers << n
  end
end

plus_numbers.sort!.reverse!
minus_numbers.sort!

flag = false

if minus_numbers.length == 0
  tmp_a = plus_numbers.pop
  tmp_b = plus_numbers.pop
  minus_numbers << tmp_a - tmp_b
  flag = true
end

if plus_numbers.length == 0
  tmp_a = minus_numbers.pop
  tmp_b = minus_numbers.pop
  plus_numbers << tmp_a - tmp_b
  flag = true
end

answers = []

if flag == true
  answers << [tmp_a, tmp_b]
end

calc_number = minus_numbers.pop

plus_numbers.each_with_index do |plus_number, index|
  if index != plus_numbers.length - 1
    answers << [calc_number, plus_number]
    calc_number = calc_number - plus_number
  else
    answers << [plus_number, calc_number]
    calc_number = plus_number - calc_number
  end
end

minus_numbers.each do |minus_number|
  answers << [calc_number, minus_number]
  calc_number = calc_number - minus_number
end

puts calc_number

answers.each do |answer|
  puts "#{answer[0]} #{answer[1]}"
end

Measured memory_bytes: 19976
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

const ll INF=1e15;

template <typename X>
struct SegTree{
  using FX=function<X(X,X)>;
  int n;
  FX fx;
  const X ex;
  vector<X> dat;
  SegTree(int n_,FX fx_,X ex_) : n(),fx(fx_),ex(ex_),dat(n_*4,ex_){
    int x=1;
    while (n_>x){
      x *= 2;
    }
    n=x;
  }
  void set(int i,X x){ dat[i+n - 1]=x;}
  void build(){
    for (int k=n - 2;k>=0;k--) dat[k]=fx(dat[2*k+1],dat[2*k+2]);
  }
  void update(int i,X x){
    i += n - 1;
    dat[i]=x;
    while(i>0){
      i=(i - 1)/2;
      dat[i]=fx(dat[i*2+1],dat[i*2+2]);
    }
  }
  X get(int i){return dat[i+n-1];}
  X all(){return dat[0];}
  X query(int a,int b){ return query_sub(a,b,0,0,n);}
  X query_sub(int a,int b,int k,int l,int r){
    if(r<=a || b<=l){
      return ex;
    }else if(a<=l && r<=b){
      return dat[k];
    }else{
      X vl=query_sub(a,b,k*2+1,l,(l+r)/2);
      X vr=query_sub(a,b,k*2+2,(l+r)/2,r);
      return fx(vl,vr);
    }
  }
  int find_rightest(int a,int b,X x){ return find_rightest_sub(a,b,x,0,0,n);}
  int find_leftest(int a,int b,X x){ return find_leftest_sub(a,b,x,0,0,n);}
  int find_rightest_sub(int a,int b,X x,int k,int l,int r){
    if(dat[k]>x || r<=a || b<=l){
      return a - 1;
    }else if (k>=n - 1){
      return (k - (n - 1));
    }else{
      int vr=find_rightest_sub(a,b,x,2*k+2,(l+r)/2,r);
      if(vr!=a-1){
        return vr;
      }else{
        return find_rightest_sub(a,b,x,2*k+1,l,(l+r)/2);
      }
    }
  }
  int find_leftest_sub(int a,int b,X x,int k,int l,int r){
    if(dat[k]>x || r<=a || b<=l){
      return b;
    }else if (k>=n - 1){ 
      return (k - (n - 1));
    }else{
      int vl=find_leftest_sub(a,b,x,2*k+1,l,(l+r)/2);
      if(vl != b){
         return vl;
      }else{
         return find_leftest_sub(a,b,x,2*k+2,(l+r)/2,r);
      }
    }
  }
};

int main(){
  ll n,x;
  cin>>n>>x;
    
  using X=ll;
  auto fx=[](X x1,X x2)->X{ return min(x1,x2);};
  X ex=INF;
  SegTree<X> seg(n,fx,ex);
  
  rep(i,n){
    int y;
    cin>>y;
    seg.set(i,y);
  }
  seg.build();
  
  ll mi=INF;
  rep(i,n){
    ll sum=0;
    rep(j,n){
      if(j-i>=0) sum+=seg.query(j-i,j+1);
      else{
        int l=n+j-i;
        sum+=min(seg.query(0,j+1),seg.query(l,n-1));
      }
    }
    mi=min(mi,sum+x*i);
  }
  cout<<mi<<endl;
      
  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char c[MAXN];

void solve(){
	scanf("%s", &c[0]);
	int n = strlen(c);
	ll ans = 0ll, cur = 0ll;
	REP(i, 0, n) {
		if (c[i] == 'B') {
			cur++;
		} else {
			ans += cur;
		}
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main(void)
{
  int x,y,z;
  int t=0;
  
  cin >> x >> y >> z;
  
  t = x;
  x = y;
  y = t;
  t = x;
  x = z;
  z = t;
  
  cout << x << " " << y << " " << z <<endl;
  
  return 0;
}

Measured memory_bytes: 3608
import scala.io.StdIn.readInt

object Main{
  def main(args: Array[String]): Unit = {
    var c = 0
    var ok = true
    do {
      val i = readInt
      ok = i != 0
      if(ok) {
        c = c + 1
        printf("Case %d: %d\n", c, i)
      }
    } while(ok)
  }
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i, m)
        cin >> a.at(i);

    int minv = 0, maxv = 0;
     rep(i, m) {
        if (a.at(i) < x)
            minv++;
        else
            maxv++;
    }

    cout << (min(minv, maxv)) << endl;
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
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;}
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
// clang-format on

void solve(std::vector<long long> M, std::vector<long long> D){
  cout << (D[1] == 1 ? 1 : 0) << endl;
}

int main() {
  std::vector<long long> M(2);
  std::vector<long long> D(2);
  for(int i = 0 ; i < 2 ; i++){
    scanf("%lld",&M[i]);
    scanf("%lld",&D[i]);
  }
  solve(std::move(M), std::move(D));
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
     int a, b, c;
     scanf ("%d %d", &a, &b);
     if (a > b) {
          do {
               c = b;
               b = a % c;
               a = c;
          } while (b != 0);
     }
     else {
          do {
               c = a;
               a = b % c;
               b = c;
          } while (a != 0);
     }

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

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

#define IN inline
#define CO const
typedef long long int64;

template<typename type>
IN type read(){
	type x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<typename type>
IN type&read(type&x){
	return x=read<type>();
}
template<typename type,typename...others>
IN void read(type&x,others&...y){
	x=read<type>(),read(y...);
}
template<typename type>
IN void write(type x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
template<>
IN void write<char>(char x){
	putchar(x);
}
template<typename type,typename...others>
IN void write(type x,others...y){
	write(x),write(y...);
}
#define popcnt __builtin_popcount

CO int mod=1e9+7;
IN int add(int a,int b){
	return (a+=b)>=mod?a-mod:a;
}
IN int mul(int a,int b){
	return (int64)a*b%mod;
}
IN int fpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}
IN void inc(int&a,int b){
	if((a+=b)>=mod) a-=mod;
}

CO int N=15;
int bas[N*N],e[N],f[1<<N];

int main(){
	int n=read<int>(),m=read<int>();
	bas[0]=1;
	for(int i=1;i<=m;++i) bas[i]=add(bas[i-1],bas[i-1]);
	for(int i=1;i<=m;++i){
		int x=read<int>()-1;
		e[x]|=1<<(read<int>()-1);
	}
	f[0]=1;
	for(int S=1;S<1<<n;++S)if((S&1)==(S>>1&1))
		for(int T=S;T;T=(T-1)&S)if((T&1)==(T>>1&1)){
			int ways=1;
			for(int i=0;i<n;++i)if(S>>i&1){
				if(T>>i&1) ways=mul(ways,bas[popcnt(e[i]&(S^T))]);
				else ways=mul(ways,bas[popcnt(e[i]&T)]-1);
			}
			inc(f[S],mul(f[S^T],ways));
		}
	write(add(bas[m],mod-f[(1<<n)-1]),'\n');
	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	int n;
	cin >> n;
	
	double s = 0;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
		s = s + (1.0/a[i]);
	
	cout << fixed << setprecision(10) << 1/s << endl;
}


Measured memory_bytes: 256
import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


cnt = 0
A, B = map(int, input().split())

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

yaku = sorted(divisor(A) + divisor(B))
y_list = [x for x in set(yaku) if yaku.count(x) > 1]


for r in y_list:

    if is_prime(r):
        cnt += 1

print(cnt + 1)


Measured memory_bytes: 4236
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A1 = sc.nextInt();
    int A2 = sc.nextInt();
    int A3 = sc.nextInt();
    int ans = A1 + A2 + A3;
    if (ans < 22){
      System.out.println("win");
    } else {
      System.out.println("bust");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;


int main(){
    int N,X;
    cin >>N>>X;
    int ruiseki=0;
    int cnt=0;
    while(1){
        if(ruiseki<=X)cnt++;
        else break;
        if(cnt>=N+1)break;
        int l;
        cin >>l;
        ruiseki+=l;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int pm,pe,pj;
        while(n--){
            cin>>pm>>pe>>pj;
            char res;
            double ave=(pm+pe+pj)/3.0;
            bool upFlag=false;
            if(pm==100||pe==100||pj==100)res='A';
            else if((pm+pe)/2.0>=90)res='A';
            else if(ave>=80)res='A';
            else if(ave>=70){
                res='B';
                upFlag=true;
            }
            else if(ave>=50&&(pm>=80||pe>=80)){
                res='B';
                if(upFlag)res='A';
            }
            else res='C';
            cout<<res<<endl;
        }
    }
}

Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    ll ans1 = 0, ans2 = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (S[i] == ('0' + i % 2)) {
            ans1++;
        }
        if (S[i] == ('0' + (i + 1) % 2)) {
            ans2++;
        }
    }

    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int	ans[10000];

int main()
{
	int		a,b,i=0,j;
	char	op = 0;

	while(op!='?') {
		scanf("%d %c %d", &a, &op, &b);
		switch (op) {
			case '+':
				ans[i++] = a + b;
				break;
			case '-':
				ans[i++] = a - b;
				break;
			case '*':
				ans[i++] = a * b;
				break;
			case '/':
				ans[i++] = a / b;
				break;
		}
	}

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



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code
LL gcd(LL a,LL b) {
	LL bigger = max(a,b);
	LL smaller = min(a,b);
	if (smaller == 0) return bigger;
	if (smaller < 0) {
		cerr << "smaller is negative number" << endl;
		return 1;
	}
	if (bigger % smaller != 0) {
		return gcd(smaller,(bigger % smaller));
	}
	return smaller;
}

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	VL g_f(n+1);
	VL g_b(n+1);
	g_f[0] = 0;
	g_b[0] = 0;
	for (int i = 0; i < n; i++) {
		g_f[i+1] = gcd(g_f[i],a[i]);
		g_b[i+1] = gcd(g_b[i],a[n-i-1]);
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(gcd(g_f[i], g_b[n-i-1]),ans);
	}

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


Measured memory_bytes: 2560