akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			if(m == 0 && n == 0) break;
			Data[] t = new Data[n];
			for(int i = 0; i < n; i++) {
				t[i] = new Data(i+1,sc.nextInt());
			}
			
			Data[] data1 = new Data[m];
			Data[] data2 = new Data[m];
			
			for(int i = 0; i < m; i++) {
				data1[i] = new Data(-1,0);
				data2[i] = new Data(-1,0);
			}
			
			Queue<Data> queue = new ArrayDeque<Data>();
			Queue<Data> out   = new ArrayDeque<Data>();
			int i = 0;
			while(out.size() != n) {
				if(i % 10 == 0 && i / 10 < n) {
					queue.add(t[i/10]);
				}
				
				for(int j = 0; j < m; j++) {
					if(data1[j].t != 0) {
						data1[j].t--;
					}
					if(data2[j].t != 0) {
						data2[j].t--;
					}
				}
				
				for(int j = 0; j < m; j++) {
					if(data1[j].t == 0 && data1[j].id != -1) {
						out.add(data1[j]);
						data1[j] = new Data(-1,0);
					}
					if(data2[j].t == 0 && data1[j].id == -1 && data2[j].id != -1) {
						out.add(data2[j]);
						data2[j] = new Data(-1,0);
					}
				}
				
				
				IN:while(!queue.isEmpty()) {
					for(int j = 0; j < m; j++) {
						if(data1[j].id == -1 && data2[j].id == -1) {
							data2[j] = queue.poll();
							continue IN;
						}
					}
					int id = -1;
					int ch = 10000000;
					for(int j = 0; j < m; j++) {
						if(data2[j].t >= queue.peek().t && data1[j].id == -1) {
							if(data2[j].t - queue.peek().t < ch) {
								ch = data2[j].t - queue.peek().t;
								id = j;
							}
						}
					}
					if(id != -1) {
						data1[id] = queue.poll();
						continue IN;
					}
					
					for(int j = 0; j < m; j++) {
							if(queue.peek().t - data2[j].t < ch && data1[j].id == -1) {
								ch = queue.peek().t - data2[j].t;
								id = j;
							}
					}
					if(id != -1) {
						data1[id] = queue.poll();
						continue IN;
					}
					break;					
				}
				
				i++;
			}
			
			System.out.print(out.poll().id);
			while(!out.isEmpty()) {
				System.out.print(" " + out.poll().id);
			}
			System.out.println();
			
		}
		
	}
	
	static class Data {
		int id;
		int t;
		Data(int a, int b) {
			id = a;
			t = b;
		}
	}
}

Measured memory_bytes: 17232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {


  int N, Q;

  cin >> N >> Q;
  string ss;
  cin >> ss;
  vector<int> l(Q), r(Q);
  REP(i, Q) cin >> l[i] >> r[i];
  vector<int> acc(N);

  acc[0] = 0;
  for(int i = 1; i < N; i++){
    if (ss[i] == 'C' && ss[i-1] == 'A'){
      acc[i] = acc[i-1] + 1;
    } else acc[i] = acc[i-1];
  }

  REP(i, Q){
    if (l[i] == 0 || l[i] == 1){
      cout << acc[r[i]-1] << endl;
    }else cout << acc[r[i]-1] - acc[l[i]-1] << endl;
  }
  //for(auto oo : acc) cout << oo << ",";

  return 0;
}


Measured memory_bytes: 2176
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

import bisect
count = 0
for i in b:
    a_count = bisect.bisect_left(a, i)
    c_count = n - bisect.bisect_right(c, i)
    count += a_count * c_count
    
print(count)

Measured memory_bytes: 23248
#include "bits/stdc++.h"
using namespace std;
 
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
 
int n;
vector<int> g[202020];
bool fav[202020];
int far[202020];
int second_farthest[202020];
int closest[202020];
bool in_fav[202020];
long long ans = 0;
 
static const int INF = 0x3f3f3f3f;
 
void dfs1(int v, int prev) {
        if (fav[v]) in_fav[v] = true;
        for (auto u : g[v]) if (u != prev) {
                dfs1(u, v);
                in_fav[v] |= in_fav[u];
                far[v] = max(far[v], far[u] + 1);
        }
}
 
void dfs2(int v, int ma, bool par_fav, int prev) {
        vector<pair<pii, bool>> children;
        children.push_back(mp(mp(0, -1), false));
        for (auto u : g[v]) {
                if (u == prev) children.push_back(mp(mp(ma + 1, u), par_fav));
                else children.push_back(mp(mp(far[u] + 1, u), in_fav[u]));
        }
        vector<pii> fav_children;
        for (auto c : children) if (c.second) fav_children.push_back(mp(c.first.first, c.first.second));
        sort(all(fav_children));
        if (fav_children.empty()) closest[v] = INF;
        else closest[v] = fav_children[0].first;
        sort(all(children), greater<pair<pii, bool>>());
        second_farthest[v] = children[1].first.first;
        for (auto u : g[v]) if (u != prev) { 
                int maa = children[u == children[0].first.second ? 1 : 0].first.first;
                bool par_f = fav[v] || par_fav;
                if (!in_fav[u]) par_f |= !fav_children.empty();
                else par_f |= fav_children.size() > 1;
                ans += (maa < far[u] && par_f) || (maa > far[u] && in_fav[u]) || (maa == far[u] && (par_f || in_fav[u]));
                dfs2(u, maa, par_f, v);
        }
}
 
int main() {
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        string s;
        cin >> s;                                            
        for (int i = 0; i < n; i ++) fav[i] = s[i] == '1' ? true : false;
        dfs1(0, -1);
        dfs2(0, 0, fav[0], -1);
        for (int i = 0; i < n; i ++) {
                if (fav[i]) ans += 1 + second_farthest[i];
                else ans += max(0, 1 + (second_farthest[i] - closest[i]));
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 54660
from collections import Counter
N, K, L = map(int, input().split())
# Union-Find
def get_root(par, node):
  if par[node] == node:
    return node
  root = get_root(par, par[node])
  par[node] = root
  return root

def union(par, rank, a, b):
  root_a, root_b = get_root(par, a), get_root(par, b)
  if root_a == root_b:
    return
  rank_a, rank_b = rank[root_a], rank[root_b]
  if rank_a < rank_b:
    par[root_a] = root_b
  else:
    par[root_b] = root_a
    if rank_a == rank_b:
      rank[root_a] += 1

par1 = [i for i in range(N)]
rank1 = [1] * N
for _ in range(K):
    a, b = map(int, input().split())
    union(par1, rank1, a-1, b-1)

par2 = [i for i in range(N)]
rank2 = [1] * N
for _ in range(L):
    a, b = map(int, input().split())
    union(par2, rank2, a-1, b-1)

ct = Counter()
for i in range(N):
    a = get_root(par1, i)
    b = get_root(par2, i)
    ct[(a, b)] += 1

print(' '.join([str(ct[(par1[i], par2[i])]) for i in range(N)]))


Measured memory_bytes: 68808
#include <stdio.h>
#include <stdlib.h>
#define n 2000001
#define A 10000

int main(){
  int a;
 int *D,*B;
 int i,j;
  int C[A];
  scanf("%d", &a);
  
  D = malloc(sizeof(int)*a+1);
  B = malloc(sizeof(int)*a+1);
  
  for(i=0;i <= A ;i++)C[i]=0;
  
  for(i=0;i<a;i++){
    scanf("%d",&D[i+1]);
    C[D[i+1]]=C[D[i+1]]+1;
  }
  for(i=1;i<=A;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=a;j++){
    B[C[D[j]]]=D[j];
 C[D[j]]=C[D[j]]-1;
  }
  for(j=1;j<=a;j++){
    if(j>1)printf(" ");
    printf("%d",B[j]);	
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 17528
n = int(input())
A = []
f = 0
s = 0
for _ in range(n):
  a = int(input())
  A.append(a)
  if f <= a:
    s = f
    f = a
  elif s <= a:
    s = a
for a in A:
  if a == f:
    print(s)
  else:
    print(f)


Measured memory_bytes: 17024
#include<stdio.h>
#define N 45

int s[N];

void fib(int n){
  int i;
  s[0]=1;
  s[1]=1;
  for(i=2;i<=n;i++){
    s[i]=s[i-2]+s[i-1];
  }
}

int main(){
  int n;

  scanf("%d",&n);

  fib(n);

  printf("%d\n", s[n]);

  return 0;
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

bool sort_fn(Pll &a, Pll &b) {
  return a.first < b.first;
}

int main() {
  ll n, k;
  cin >> n >> k;

  map<ll, ll> m;
  for (ll i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    m[a] += b;
  }

  vector<Pll> ab;
  each (i, m) {
    ab.push_back(mkp(i.first, i.second));
  }
  sort(ab.begin(), ab.end(), sort_fn);

  ll x = 0;
  each (i, ab) {
    x += i.second;
    if (k <= x) {
      cout << i.first << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=200005;
int n,k,x,t,a,b,m;
string s;
vi v;
int dsu[N],cnt[N];
int find(int u){
	if(u==dsu[u])return u;
	return dsu[u] = find(dsu[u]);
}
void solve(){
	cin >> n >> k;
	for(int i =1;i<=n;i++){
		dsu[i]=i;
		cnt[i]=1;
	}
	int mx = 1;
	for(int i =0;i<k;i++){
		cin>> a>>b;
		int pa = find(a),pb=find(b);
		if(pa!=pb){
			cnt[pa]+=cnt[pb];
			dsu[pb] = pa;
			mx = max(cnt[pa],mx);
		}
	}
	cout << mx<<endl;

 
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n];
  for(int i=0; i<n; i++) {
    cin >> x[i];
  }
  int ans=1e9;
  int ans2;
  for(int i=0; i<100; i++) {
    ans2=0;
    for(int j=0; j<n; j++) {
      ans2+=pow(x[j]-i, 2);
      if(j==n-1&&ans2<ans) {
        ans=ans2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

void ans(int n)
{
    if(n==25)return;
    cout<<" Eve";
    ans(n+1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<"Christmas";
    ans(n);
}


Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc173/abc173_c
import sys
import itertools
import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W, K = i2nn()
    c = [None] * H
    for i in range(H):
        c[i] = [int(s == '#') for s in i2s()]
    ans = 0
    p1 = np.array(c)
    for h, w in itertools.product(range(H), range(W)):
        for row in itertools.combinations(range(H), h):
            p2 = p1.copy()
            for i in row:
                p2[i, :] = 0
            for col in itertools.combinations(range(W), w):
                p3 = p2.copy()
                for j in col:
                    p3[:, j] = 0
                if (p3.sum() == K):
                    ans += 1
    print(ans)
                
    return

main()


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

int main(){
    
    int n; double d;
    cin >> n >> d;
    int result = 0;
    while(n--){
        double x, y;
        cin >> x >> y;
        double distance = sqrt(x*x + y*y);
        if(distance <= d){
            result += 1;
        }
    }
    
    cout << result << endl;
    
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n;
typedef pair<int, int> P;
int main(){
  cin >> n;
  P pr[n], pb[n];
  for(int i=0 ; i<n ; i++){
    cin >> pr[i].fi >> pr[i].se;
  }
  for(int i=0 ; i<n ; i++){
    cin >> pb[i].fi >> pb[i].se;
  }
  sort(pr, pr+n); sort(pb, pb+n);
  priority_queue<P> que;
  int cnt = 0;
  bool used[200]={false};
  for(int i=0 ; i<n ; i++){
    int bx = pb[i].fi, by = pb[i].se;
    int k=-1;
    int hmi = -1;
    for(int j=0 ; j<n ; j++){
      int rx = pr[j].fi, ry = pr[j].se;
      if(rx<bx && ry<by && !used[j] && hmi<ry) {
        k = j;
        hmi = ry;
      }
    }
    if(k != -1){
        used[k] = true;
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
# class UnionFind():
#     def __init__(self, n):
#         self.n = n
#         self.parents = [-1] * n

#     def find(self, x):
#         if self.parents[x] < 0:
#             return x
#         else:
#             self.parents[x] = self.find(self.parents[x])
#             return self.parents[x]

#     def union(self, x, y):
#         x = self.find(x)
#         y = self.find(y)

#         if x == y:
#             return

#         if self.parents[x] > self.parents[y]:
#             x, y = y, x

#         self.parents[x] += self.parents[y]
#         self.parents[y] = x

#     def size(self, x):
#         return -self.parents[self.find(x)]

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

#     def members(self, x):
#         root = self.find(x)
#         return [i for i in range(self.n) if self.find(i) == root]

#     def roots(self):
#         return [i for i, x in enumerate(self.parents) if x < 0]

#     def group_count(self):
#         return len(self.roots())

#     def all_group_members(self):
#         return {r: self.members(r) for r in self.roots()}

#     def __str__(self):
#         return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

class UnionFind():
  par = []
  sizes = []

  def __init__(self, N):
    self.par = [i for i in range(N)]
    self.sizes = [1 for _ in range(N)]

  def root(self, x: int)-> int:
    if (self.par[x] == x):
      return x
    self.par[x] = self.root(self.par[x])
    return self.par[x]

  def unite(self, x: int, y: int):
    rootX = self.root(x)
    rootY = self.root(y)
    if rootX == rootY:
      return
    self.par[rootX] = rootY
    self.sizes[rootY] += self.sizes[rootX]

  def maxSize(self)-> int:
    return max(self.sizes)

def friends(N, As):
  uf = UnionFind(N)
  setAs = list(set(As))
  for val in setAs:
    uf.unite(val[0]-1, val[1]-1)
  # ans = 0
  ans = uf.maxSize()
  # for i in range(N):
  #   temp = uf.size(i)
  #   if ans < temp:
  #     ans = temp
  return ans

if __name__ == "__main__":
  nm = list(map(int, input().split()))
  As =[tuple(map(int, input().split())) for _ in range(nm[1])]
  print(friends(nm[0], As))

Measured memory_bytes: 57852
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int K = sc.nextInt();
		
		System.out.println((K / 2) * ((K + 1) / 2));
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
  int a, b, c, x, f=0;
  scanf("%d %d %d",&a,&b,&c);
  for(x=a; x<=b; x++) {
    if(c%x==0) f++;
  }
  printf("%d\n",f);
  return 0;
}


Measured memory_bytes: 2100
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

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

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

	sort(A, A+N);

	int prev = A[0];
	for(int i = 1; i < N; i++){
		if(A[i] == prev){
			cout << "NO" << endl;
			return 0;
		}
		prev = A[i];
	}
    cout <<"YES"<< endl;
    return 0;
}


Measured memory_bytes: 1024
def main ():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A: 
        print (0)
        return
    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod) 

main ()


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

typedef pair<int,int> P;
const int MAX_N = 20001;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

// input
int n, x[MAX_N], y[MAX_N];
char dir[MAX_N];

int futon[MAX_N];
bool used[MAX_N];
map<P,int> m;
bool ans;

void dfs(int pos, int k){
	if( !ans ) return ;
	
	int x1 = x[pos], y1 = y[pos], x2, y2;
	used[pos] = true;
	futon[pos] = k;
	int next = (k + 1) % 2;
	if( dir[pos] == 'x' ){
		x2 = x1 + 1, y2 = y1;
	}else{
		x2 = x1, y2 = y1 + 1;
	}
	
	for(int i=0 ; i < 4 ; i++ ){
		int mx = x1 + dx[i], my = y1 + dy[i];
		if( mx == x2 && my == y2 ) continue;
		
		if( m.count(P(mx, my)) ){
			int id = m[P(mx, my)];
			if( used[id] ){
				if( futon[id] == futon[pos] ){
					ans = false;
				}
			}else{
				dfs(id, next);
			}
		}
	}
	for(int i=0 ; i < 4 ; i++ ){
		int mx = x2 + dx[i], my = y2 + dy[i];
		if( mx == x1 && my == y1 ) continue;
		
		if( m.count(P(mx, my)) ){
			int id = m[P(mx, my)];
			if( used[id] ){
				if( futon[id] == futon[pos] ){
					ans = false;
				}
			}else{
				dfs(id, next);
			}
		}
	}
}

int main(){
	while( cin >> n , n ){
		// initialize 
		fill(used, used + MAX_N, false);
		fill(futon, futon + MAX_N, -1);
		m.clear();
		ans = true;
		
		for(int i=0 ; i < n ; i++ ){
			cin >> x[i] >> y[i] >> dir[i];
			m[P(x[i], y[i])] = i;
			if( dir[i] == 'x' ) m[P(x[i] + 1, y[i])] = i;
			if( dir[i] == 'y' ) m[P(x[i] , y[i] + 1)] = i;
		}
		
		for(int i=0 ; i < n ; i++ ){
			if( used[i] ) continue;
			dfs(i, 0);
		}
		cout << (ans? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(0)
#define ll 				long long int
#define ld 				long double
#define mk 				make_pair
#define pb 				push_back
#define f				first
#define s				second
#define fo(i,a,b) 		for(i=a;i<b;i++)
#define foe(i,a,b) 		for(i=a;i<=b;i++)
#define all(x)			x.begin(),x.end()
// #define vi 				vector<int>
#define vl 				vector <long long int>
// #define pii 			pair <int,int>
#define pll 			pair <long long int, long long int>
// #define vpii			vector< pair<int,int> >
#define vpll 			vector < pair <long long int,long long int> >
#define MOD				1000000007
using namespace std;
const int inf = INT_MAX;
const ll inf64 = LLONG_MAX;


int main()
{
	boost;
	ll n;
	cin >> n;
	vl a(n), b(n);
	ll i;
	fo(i, 0, n)cin >> a[i] >> b[i];
	sort(all(a));
	sort(all(b), greater<int>());
	if (n & 1)cout << b[n / 2] - a[n / 2] + 1;
	else
	{
		ll aa = b[n / 2 - 1] + b[n / 2];
		ll bb = a[n / 2 - 1] + a[n / 2];
		cout << aa - bb + 1;
	}




	return 0;
}

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

typedef long long ll;

int main(){
    ll N;
    vector<ll> num(5);
    cin >> N;
    for (int i=0;i<5;i++){
        cin >> num[i];
    }
  	ll mi = num[0];
    for (int i=0;i<4;i++){
        if (num[i+1] < num[i]){
            mi = min(mi, num[i+1]);
        }
    }
    // 1  2  3  4  5  6
    //   0  1  2  3  4
    //      1

    ll ans;
    ans = (ll)ceil((double)N / (double)mi) + 4;
  	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt(),c,a,n,count;
		
		for(int i = 0; i < x; i++){
			
			count = 0;
			c = sc.nextInt();
			a = sc.nextInt();
			n = sc.nextInt();
			
			while(c != 0 && a != 0 && n != 0){
				c--;
				a--;
				n--;
				count++;
			}
			while(c > 1 && a != 0){
				c -= 2;
				a--;
				count++;
			}
			while(c > 2){
				c -= 3;
				count++;
			}
			System.out.println(count);
		}
		sc.close();
	}
}

Measured memory_bytes: 21172
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <string>


using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() { int x; std::cin >> x; return x; }
template <typename T> inline void out(const T& x) { cout << x << endl; }
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; }return 0; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; }return 0; }
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 }, dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int gcd(int a, int b)
{
	if (a < b)
		gcd(b, a);
	int r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}
void eratos(bool * isPrime, int max) {
	fill(isPrime, isPrime + max, true);
	isPrime[0] = false;
	isPrime[1] = false;
	for (int i = 2; i <= max / i; ++i)
		if (isPrime[i])
			for (int j = 2; j <= max / i; ++j)
				isPrime[i*j] = false;
}
//

vector<int> divisor(int n) {
	vector<int> ret;
	for (int i = 0; i * i <= n; i++) {
		ret.push_back(i);
		if (i*i != n) ret.push_back(i);
	}
	sort(ALL(ret));
	return ret;
}

signed main()
{
	ios();
	int N;
	cin >> N;

	map<string, vector<pair<int, int>>> m;
	rep(i, N) {
		string s;
		int p;
		cin >> s >> p;

		m[s].push_back(make_pair(i, p));
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		sort(it->second.begin(),it->second.end(),[](auto a,auto b){return a.second > b.second;});
		for (auto it2 = it->second.begin();it2 != it->second.end();++it2) {
			cout << it2->first +1<< endl;
		}
	}
}



Measured memory_bytes: 256
def main():
    import fractions
    a,b = map(int,input().split())
    c = fractions.gcd(a,b)
    ans = [1]
    while c%2==0:
        c = c//2
        ans.append(2)
    f = 3
    while f*f<=c:
        if c%f==0:
            c = c//f
            ans.append(f) 
        else:
            f += 2
    if c!=1:
        ans.append(c)
    print(len(set(ans)))


if __name__ == "__main__":
    main()

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++)
        cin >> s[i];
    sort(all(s));
    for(int i = 0; i < n; i++)
        cout << s[i];
    return 0;
}


Measured memory_bytes: 256
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char buff[BUFF], *begin = buff, *end = buff;
char getc() {
    if (begin == end) {
        begin = buff;
        end = buff + fread(buff, 1, BUFF, stdin);
    }
    return begin == end ? -1 : *begin++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0; bool pos = true; char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 2500 + 5;

void fail() {
    puts("-1"); exit(0);
}

int n, k, a[N], ans[N];

int main() {
    n = read(); k = read() + 1;
    generate_n(a + 1, n, read);
    int lst = n + 1, cnt = 0;
    while (k--) {
        int idx = 1 + (lst == 1);
        for (int i = 1; i <= n; ++i) {
            if (i != lst && a[i] < a[idx]) idx = i;
        }
        for (int i = 1; i <= n; ++i) {
            if (i != lst && i != idx) {
                ans[cnt++] = i;
                if (--a[i] < 0) fail();
            }
        }
        ans[cnt++] = lst = idx;
        if (--a[idx] < 0) fail();
    }
    printf("%d\n", cnt);
    for (int i = 0; i < cnt; ++i) {
        printf("%d%c", ans[i], "\n "[i < cnt - 1]);
    }
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

vector<li> edge[100100];
li n, m;

int main() {
    cin >> n >> m;
    rep(i, m) {
        li a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    puts("Yes");
    queue<pair<li, PI>> q;
    vector<li> dist(n, INF);
    q.push({0, {0, -1}});
    vector<li> res(n);
    while (!q.empty()) {
        li now = q.front().S.F;
        li prev = q.front().S.S;
        li now_dist = q.front().F;
        q.pop();
        if (dist[now] != INF) {
            continue;
        }
        dist[now] = now_dist;
        res[now] = prev + 1;
        for (auto next : edge[now]) {
            q.push({now_dist + 1, {next, now}});
        }
    }
    repp(i, 1, n) {
        cout << res[i] << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b, k;
  cin >> a >> b >> k;
  set<int> s;
  for(int i=0; i<k; i++){
    if(a+i<=b) s.insert(a+i);
  }
  for(int i=0; i<k; i++){
    if(b-i>=a) s.insert(b-i);
  }
  vector<int> v(s.begin(), s.end());
  for(int i=0; i<int(v.size()); i++){
    cout << v[i] << endl;
  }
  return 0;
}


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

#define LL long long
#define pa pair<int,int>
using namespace std;
const int inf = 2147483647;

int _max(int x, int y) {return x > y ? x : y;}
LL _min(LL x, LL y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(LL x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int a[20];
LL f[21][21][21][21];

LL dfs(int l, int r, int ls, int rs) {
	if(l == r - 1) return 0;
	if(f[l][r][ls][rs] != -1) return f[l][r][ls][rs];
	LL ans = 999999999999LL;
	for(int i = l + 1; i < r; i++) {
		ans = _min(ans, dfs(l, i, ls, ls + rs) + dfs(i, r, ls + rs, rs) + (LL)a[i] * (ls + rs));
	} return ans;
}

int main() {
	int n = read();
	for(int i = 1; i <= n; i++) a[i] = read();
	memset(f, -1, sizeof(f));
	LL ans = a[1] + a[n] + dfs(1, n, 1, 1);
	put(ans);
	return 0;
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        char op = sc.next().charAt(0);
        int B = sc.nextInt();

        System.out.println(solve(A, op, B));

        sc.close();
    }

    static int solve(int A, char op, int B) {
        return (op == '+') ? (A + B) : (A - B);
    }
}

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

#define	LEN 100000

char t[LEN];
int a[256];

int main()
{
	int n,k,r,s,p;
	scanf("%d%d",&n,&k);
	scanf("%d%d%d",&r,&s,&p);
	scanf("%s",t);

	memset(a,0,256*sizeof(int));
	a['r'] = p;
	a['s'] = r;
	a['p'] = s;

	int x = 0;	//最大値のトータル
	for ( int i = 0 ; i < k ; i++ ) {
		x += a[t[i]];
	}
	for ( int i = k ; i < n ; i++ ) {
		if ( t[i-k] == t[i] ) {
			t[i] = 0;
	continue;
		}
		x += a[t[i]];
	}
	printf("%d",x);
}


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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
	t=1;
    while(t--)
    {
		string o,e,final="";
		cin>>o>>e;
		int i,j=0,k=0;
		for(i=1;i<=o.length()+e.length();i++)
			if(i&1)
				final+=o[j++];
			else 
				final+=e[k++];
		cout<<final;
	}
    return 0;
}

Measured memory_bytes: 256
import math
k = int(input())
# = map(int, input().split())
# = input()
# = list(map(int, input().split()))

g = [[0 for i in range(k)] for j in range(k)]

s = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        if g[i-1][j-1] == 0:
            x = math.gcd(i, j)
            g[i-1][j-1] = x
            g[j-1][i-1] = x
        a = g[i-1][j-1]
        for l in range(1, k+1):
            if g[a-1][l-1] == 0:
                y = math.gcd(a, l)
                g[a-1][l-1] = y
                g[l-1][a-1] = y
            s += g[a-1][l-1]

print(s)


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

int main() {
  string s; cin >> s;
  int n = s.size();
  vector<int> vec(n);

  int count = 0;
  rep(i,n-1){
    if(s[i] == s[i+1]){
      count++;
    }
    if(s[i] != s[i+1]){
      if(s[i] == 'L'){
        vec[i-count] = count+1;
      }
      else if(s[i] == 'R'){
        vec[i] = count+1;
      }
      count =0;
    }
    if(i == n-2){
      if(s[i] == 'L'){
        vec[i-count+1] = count+1;
      }
      else if(s[i] == 'R'){
        vec[i+1] = count+1;
      }
    }
  } // ここまで入力

  /*rep(i,n){
    cout << vec[i] <<" ";
  }*/

  rep(i,n-1){
    if(vec[i] != 0 && vec[i+1] != 0){
      int s=vec[i];
      int t=vec[i+1];
      if(vec[i] >= vec[i+1]){
        if(vec[i] % 2 == 1){
          vec[i+1] = (s+t) / 2;
          vec[i] = (s+t) - vec[i+1];
        }
        else{
          vec[i] = (s+t) / 2;
          vec[i+1] = (s+t) - vec[i];
        }
      }
      else{
        if(vec[i+1] % 2 == 0){
          vec[i+1] = (s+t) / 2;
          vec[i] = (s+t) - vec[i+1];
        }
        else{
          vec[i] = (s+t) / 2;
          vec[i+1] = (s+t) - vec[i];
        }
      }
      i++;
    }
  }

  rep(i,n){
    cout << vec[i] <<" ";
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind friends(n);
    vector<set<int>> fri_or_blo(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        fri_or_blo[a].insert(b);
        fri_or_blo[b].insert(a);
        friends.merge(a, b);
    }
    rep(i,k) {
        int c, d;
        cin >> c >> d;
        c--, d--;
        if(!friends.issame(c, d)) continue;
        fri_or_blo[c].insert(d);
        fri_or_blo[d].insert(c);
    }
    rep(i,n) {
        cout << friends.size(i) - fri_or_blo[i].size() - 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 25856
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int h;
    cin>>h;
    int ans=0;
    int f=1;
    while(h>=1)
    {
    	if(ans!=0)
    	{    
    	    f*=2;
    		ans+=f;
		}else{
			ans=1;
		}
		h/=2;
	}
	cout<<ans<<endl;
	return 0;
}













Measured memory_bytes: 256
N = input()
n = [v for v in N]

l = len(n)
C = []

for i in range(2**(l-1)):
    c = ''
    for j in range(l):
        c += n[j]
        if i >> j & 1:
            c += '+'
        else:
            c += '-'
    if eval(c[:-1]) == 7:
        print('{}=7'.format(c[:-1]))
        exit()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    cout << "square1001" << endl;

    return 0;
}



Measured memory_bytes: 3160
from itertools import accumulate
N = int(input())
A = list(accumulate(list(map(int,input().split()))))
B = list(accumulate(list(map(int,input().split()))))
res = A[0]+B[-1]
for i in range(1,N):
    res = max(res,A[i]+B[-1]-B[i-1])
print(res)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char const *argv[])
{
	int i;
	int num;
	char str[100];
	int blood_arr[4] = {0};
	while(scanf("%d,%s", &num, str) != EOF) {
		if(str[0] == 'A' && str[1] == '\0')
			blood_arr[0]++;
		else if(str[0] == 'B')
			blood_arr[1]++;
		else if(str[0] == 'A' && str[1] == 'B')
			blood_arr[2]++;
		else if(str[0] == 'O')
			blood_arr[3]++;		}
	for(i = 0; i < 4; i++) {
		printf("%d\n", blood_arr[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0



a, b, c = map(int, input().split())
for i in itertools.permutations([a, b, c], 3):
    if i[0] == sum(i[1:]) or sum(i[:2]) == i[2]:
        print("Yes")
        exit()

print("No")


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

int main(){
	
	int n; cin>>n;
	int cnt{};
	for(int i=0; i<n; i++){
		int a; cin>>a;
		if(cnt+1==a) ++cnt;
	}
	cout << (cnt>0?n-cnt:-1) << endl;
}

Measured memory_bytes: 256
/*
??°???????????¢
?????????????????°???????????????????????????????????°?????????????????????????????????

*/#include <iostream>

int main() {
	int num, tmp;
	std::cin >> num;

	// ????????????????????¢????¢????
	int *nums = new int[num];
	for (int i = 0; i < num; i++)
	{
		std::cin >> nums[i];
	}
	// ?????????
	/*
	for (int i = 0; i < num; i++)
	{
		for (int j = i; j < num; j++)
		{
			if (nums[i] < nums[j]) {
				tmp = nums[i];
				nums[i] = nums[j];
				nums[j] = tmp;
				std::cout << i << j << ":" << nums[i] << ">" << nums[j] << std::endl;
			}
		}
	}
	*/
	// ??????
	for (int i = num-1; i >= 0; --i)
	{

		std::cout << nums[i];
		if (i != 0) std::cout << " ";
	}
	std::cout << std::endl;
	// ?????¢?????????
	delete[] nums;
	return 0;
}

Measured memory_bytes: 3084
fun main(args: Array<String>) {
    val x = getInt()
    val l = lcm(x, 360)
    println(l / x)

}

fun gcd(a: Int, b: Int): Int {
    return if (a % b == 0) b else gcd(b, a % b)
}

fun lcm(a: Int, b: Int): Int {
    return a * b / gcd(a, b)
}

fun getInt() = readLine()!!.toInt()

Measured memory_bytes: 34508
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  else return 0;
}

long long getkey(char str[])
{
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++ )
  {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }

int h2(int key){ return 1 +(key % (M -1)); }

int find(char str[])
{
  long long key, i, h;
  key = getkey(str);
  for ( i = 0;; i++ )
  {
    h = (h1(key) + i * h2(key)) % M;
    if ( strcmp(H[h],str)== 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[])
{
  long long key, i, h;
  key = getkey(str);
  for (i = 0; ; i++ )
  {
    h = (h1(key) + i* h2(key)) % M;
    if ( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0)
    {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main()
{
  int i, n, h;
  char str[L], com[9];
  for ( i=0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
  {
    scanf("%s %s", com, str);

    if ( com[0]== 'i')
    {
      insert(str);
    }
    else
    {
      if ( find(str) )
      {
        printf("yes\n");
      }
      else
      {
        printf("no\n");
      }
    }
  }
  return 0;
}



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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif
using namespace std;

int n;
int a[200005], b[200005];

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
    cin >> a[i];
	}
	for (int i = 1; i <= n; ++i) {
    cin >> b[i];
	}
	int d = 0;
	int pa = 1, pb = 1;
	for (int i = 1; i <= n; ++i) {
		while (pa <= n && a[pa] == i) {
			++pa;
		}
		d = std::max(d, pa - pb);
		while (pb <= n && b[pb] == i) {
			++pb;
		}
	}
	std::rotate(b + 1, b + n - d + 1, b + 1 + n);
	for (int i = 1; i <= n; ++i) {
		if (a[i] == b[i]) {
      cout << "No\n";
			return 0;
		}
	}
  cout << "Yes\n";
	for (int i = 1; i <= n; ++i) {
    cout << b[i] << " ";
	}
  cout << "\n";
}



Measured memory_bytes: 5192
let ans n t =
  let rec f i p r =
    if i = n then r + t
    else
      let u = Scanf.scanf " %d" (fun u -> u) in
      f (i + 1) u (r + min (u - p) t)
  in f 0 0 0

let () =
  Scanf.scanf "%d %d" (fun n t -> print_int (ans n t))


Measured memory_bytes: 2688
#include <stdio.h>

int main(){
    int n, i;
    long int a = 100000;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        a = a + a / 20;
        if (a % 1000) a = a + 1000 - a % 1000;
    }
    printf("%d\n", a);
    
    return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

int main(){
    string S;cin>>S;
    if(S[S.size()-1]=='s'){
        cout<<S<<"es"<<endl;
    }
    else{
        cout<<S<<"s"<<endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

pii edge[100005];


struct UnionFind
{
    vector<int> uni;
    UnionFind(int n): uni(n+5, -1) {}
    int  root(int x)        { return (uni[x] < 0)? x : uni[x] = root(uni[x]); }
    bool same(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y){
        if ( (x=root(x)) == (y=root(y)) )return false;
        if ( uni[y] < uni[x] ) swap(x,y);
        uni[x] += uni[y],  uni[y] = x;
        return true;
    }
    int size(int i)     { return (-uni[root(i)]); }
};



signed main(){

  int n , m;

  int co[100005]={};
  int ans[100005]={};
  cin >> n >> m;
  FOR(i,m){
    int a, b;
    cin >> a>> b;
    edge[i]=pii(a,b);
  }
  int max = ans[m]= (n*(n-1))/2;
  UnionFind uf(n);
  for(int i=m-1;i>=0;i--){
    int a, b;
    a=edge[i].first;
    b=edge[i].second;
    if(!uf.same(a,b)){
        ans[i]=ans[i+1]-uf.size(a)*uf.size(b);
        uf.unite(a,b);
    }else
    ans[i]=ans[i+1];
  }
  FOR(i,m){
    cout << ans[i+1] fin;
  }
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;


Measured memory_bytes: 4480
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int n, m, ans;
struct edge {
	int a, b;
};

vector<edge> edges;

void DFS(int k, bool mat[55][55], bool visited[55]) {//今いる点、隣接行列、訪問済み点
	if (visited[k]) return;
	visited[k] = true;
	repi(i, 1, n + 1) {
		if (mat[k][i]) DFS(i, mat, visited);
	}
	return;
}

int main() {
	cin >> n >> m;
	repi(i, 0, m) {
		int tempA, tempB;
		cin >> tempA >> tempB;
		edge e;
		e.a = tempA, e.b = tempB;
		edges.push_back(e);
	}

	repi(i, 0, m) {
		bool mat[55][55] = {};
		bool visited[55] = {};
		repi(j, 0, m) {
			if (i == j)continue;//無視する辺をiで決めている
			mat[edges[j].a][edges[j].b] = true;
			mat[edges[j].b][edges[j].a] = true;
		}
		DFS(1, mat, visited);
		repi(i, 1, n + 1) {
			if (!visited[i]) {
				ans++;
				break;
			}
		}
	}

	wrln(ans);

	return 0;
}

Measured memory_bytes: 256