akhauriyash/Code-Regression huggingface dataset:
import sys
from io import StringIO
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import unittest

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

def resolve():
    n,m,k=map(int, readline().split())
    #list(map(int,input().strip().split()))

    uf = UnionFind(n)

    res=[[] for i in range(n)]
    frd=[0 for i in range(n)]
    blk=[0 for i in range(n)]

    for i in range(m):
        #a,b=list(map(int,input().strip().split()))
        a,b=map(int, readline().split())
        a-=1
        b-=1
        uf.Unite(a,b)
        frd[a]+=1
        frd[b]+=1
    
    for i in range(k):
        #a,b=list(map(int,input().strip().split()))
        a,b=map(int, readline().split())
        a-=1
        b-=1
        if uf.isSameGroup(a,b):
            blk[a]+=1
            blk[b]+=1
    
    rescnt=[]

    for i in range(n):
        ri=uf.Count(i)-1-blk[i]-frd[i]
        rescnt.append(str(ri))
        ##rescnt.append(str(n-uf.size(i)-len(blk[i])))
    
    print(" ".join(rescnt))

resolve()

Measured memory_bytes: 25064
import math

#素数か(x>=2)
def prime_check(x): #x>=2
    if x==2:
        return True,2
    elif x%2==0:
        return False,2
    else:
        limit=int(math.sqrt(x))
        for factor in range(3,limit+1,2):
            if x%factor==0:
                return False,factor
        return True,x

#素因数分解(x>=2)
def prime_factorization(x): #x>=2
    factor_list=[]
    factor_dictionary={}
    factor_set=set()
    judge,factor=prime_check(x)
    while True:
        factor_list.append(factor)
        if factor in factor_set:
            factor_dictionary[factor]+=1
        else:
            factor_dictionary[factor]=1
            factor_set.add(factor)

        if judge:
            return factor_list,factor_dictionary,factor_set
            break
        else:
            x//=factor
            judge,factor=prime_check(x)

#素因数の個数(x>=2)
def total_number_of_factors(x):
    List,Dict,Set=prime_factorization(x)
    Total=1
    while Set:
        factor=Set.pop()
        Total*=Dict[factor]+1
    return Total


N=int(input())
ans=0
for i in range(1,N+1,2):
    if total_number_of_factors(i)==8:
        ans+=1
        
print(ans)




Measured memory_bytes: 3064
//
//  main.cpp
//  ABC152C
#include <iostream>
#include<vector>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    vector<int>P(N+1);
    int low=2*100000+1;
    int ans=0;
    for (int i=1; i<=N; i++) {
        cin>>P.at(i);
        if (P.at(i)<low) {
            low=P.at(i);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

signed main() {
	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> prs;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		prs.push_back(mp(b, a));
	}

	sort(all(prs));

	int ret = 0;
	int pt = 0;
	for (auto &pr : prs) {
		if (pr.second < pt) continue;
		ret++;
		pt = pr.first;
	}

	cout << ret << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main (){
int A,B;
  cin >> A;
  cin >> B;
  if(A == 1 && B == 3 || A == 3 && B == 1)
    cout << "2" << endl;
if(A == 1 && B == 2 || A == 2 && B == 1)
    cout << "3" << endl;
  if(A == 2 && B == 3 || A == 3 && B == 2)
    cout << "1" << endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  int a=0;
  int B=0;
  for(int i=1;i<=N;i++){
    a=a+i-1;
  }
  for(int j=1;j<=M;j++){
    B=B+j-1;
  }
  cout<<a+B<<endl;
}

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

int main() {
	int n, a, d = 1000000000, c;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a;
		if (a % d == 0 and i != 0) {
			continue;
		}
		c = 0;
		d = 1;
		while(a % 2 == 0) {
			a /= 2;
			c++;
			d *= 2;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL A,B,K;
	cin>>A>>B>>K;
	set<LL> mySet;
	LL i;
	for (i=A;i<A+K;i++){
		if (i>B){
			break;
		}
		mySet.insert(i);
	}
	for (i=B;i>B-K;i--){
		if (i<A){
			break;
		}
		mySet.insert(i);
	}
	set<LL>::iterator sit;
	for (sit=mySet.begin();sit!=mySet.end();sit++){
		cout<<(*sit)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define mp make_pair
#define pb push_back
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;


int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int in,lo,hi;
	cin>>in;
	lo=int(floor((double)in/100.0));
	hi=int(ceil((double)in/105.0));
	if(lo>=hi)cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

int main() {
	int l,r,d;
	cin >> l >> r >> d;
	cout << r/d - (l-1)/d << endl;
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    double x,r;
    cin >> x;
    x=x/3;
    r=x*x*x;
    cout << fixed << showpoint << setprecision(7) << r;
}


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

int main()
{
	int A,B,C,D,E,F;
	cin >> A >> B >> C >> D >> E >> F;
	double ansc = 0;
	int answ = 100*A, anss = 0;
	int imax = F/(100*A), jmax = F/(100*B);
	for (int i = 0; i <= imax; ++i)
	{
		//if (A * i * 100 > F) break;
		for (int j = 0; j <= jmax; ++j)
		{
			//if ((A*i + B*j) * 100 > F) break;
			int w = (A*i + B*j) * 100;
			int kmax = min(w/100*E / C, (F-w) / C);
			for (int k = 0; k <= kmax; ++k)
			{
				int l = min((w/100*E - k*C) / D, (F-w-k*C) / D);
				//cout << i << " " << j << " " << k << " " << l;
				if (i == 0 && j == 0 && k == 0 && l == 0) continue;
				int s = C*k + D*l;
				if (w+s<= F && s <= w/100*E)
				{
					double c = double(s) / double(s+w) * 100;
					//cout << " " << c;
					if (c > ansc)
					{
						ansc = c;
						answ = w;
						anss = s;
					}
				}
				//cout << endl;
			}
		}
	}
	cout << answ + anss << " " << anss << endl;
	return 0;
}

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

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

using namespace std;

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}


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

    string S; cin >> S;
    stack<int> slopes;
    stack<pair<int, int> > locAreas; // (leftPosition, localArea)
    int area = 0;
    vector<int> areas;
    const int nStr = S.size();
    rep(i, nStr) {
        if (S[i] == '\\') {
            slopes.push(i);
        }
        else if (S[i] == '/') {
            if (slopes.size() == 0) continue;
            const int leftPos = slopes.top(); slopes.pop();
            const int dArea = i - leftPos;
            area += dArea;
            int locArea = dArea;
            while (locAreas.size() > 0 && locAreas.top().first > leftPos) {
                locArea += locAreas.top().second; locAreas.pop();
            }
            locAreas.push(make_pair(leftPos, locArea));
        }
    }

    // sort out the local areas; it's reverse order
    const int n = locAreas.size();
    vector<int> vecLocAreas(n + 1);
    for (int i = 0; i < n; ++i) {
        vecLocAreas[i] = locAreas.top().second; locAreas.pop();
    }
    vecLocAreas[n] = n; // nb of the local areas
    reverse(vecLocAreas.begin(), vecLocAreas.end());

    // input: \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\
    // out:
    // 35
    // 5 4 2 1 19 9
    
    cout << area << endl;
    output(vecLocAreas);

    return 0;
}



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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const int mod = 1e9 + 7;


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

	int n;
	cin >> n;

	for(int i = 9; i > 0; i--){
		if(n % i == 0){
			if(n / i < 10){
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
			break;
		}
	}

    return 0;
}



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

int main(){
  int n,p;
  int player[50] = {0};
  int step, stone;

  cin >> n >> p;
  while(n!=0 && p != 0){
    for(int i=0; i<n; i++)
      player[i] = 0;
    step = 0;
    stone = p;

    while(1){
      if(stone == 0){
	stone = player[step];
	player[step] = 0;
      }else{
	if(stone == 1 && player[step] == p-1){
	  break;
	}
	stone--;
	player[step]++;
      }

      if(step < n-1)
	step++;
      else
	step=0;
    }

    cout << step << "\n";
    cin >> n >> p;
  } 

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
/*ll get(ll *arr,ll low,ll high,ll n){
	int mid=low+(high-low)/2;
	if((mid==0 or arr[mid-1]<=arr[mid]) and (mid==(n-1) or arr[mid+1]<=arr[mid])){
		return arr[mid];
	}
	else if(mid>0 and arr[mid-1]>arr[mid]){
		return get(arr,low,mid-1,n);
	}
	else{
		return get(arr,mid+1,high,n);
	}
}*/
/*ll get(int *arr,int n,int left,int i){
	if(i==n){return 1;}
	int curr=arr[i];
	int right=get(arr,n,arr[i]*left,i+1);
	arr[i]=left*right;
	return curr*right;
}*/
/*ll get(int *arr,int n){
	int low=0,high=n-1;
	while(low<=high){
		int mid=low+(high-low)/2;
		int prev=(mid-1+n)%n;
		int next=(mid+1)%n;
		if(arr[mid]<=arr[prev] and arr[mid]<=arr[next]){
			return mid;
		}
		else if(arr[low]<=arr[mid]){
			low=mid+1;
		}
		else if(arr[high]>=arr[mid]){
			high=mid-1;
		}
	}
}*/
/*void get(map<str,int>&m,str s,str ans=""){
	if(s.size()==0){cout<<ans;e;return;}
	for(int i=1;i<=(int)s.size();i++){
		str x=s.substr(0,i);
		if(m[x]){
			get(m,s.substr(i),ans+" "+x);
		}
	}
}*/
ll get(str s,str t,int n){
	ll ans=0;
	for(int i=0;i<n;i++){
		if(s[i]!=t[i]){ans+=1;}
	}
	return ans;
}
void solve(){
	str s,t;cin>>s>>t;
	int n=s.length();
	int m=t.length();
	ll ans=inf;
	for(int i=0;i<n-m+1;i++){
		str x=s.substr(i,m);
		ans=min(ans,get(t,x,m));
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case #"<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int N, M;
	scanf("%d%d",&N, &M);
	int num[30];
	int K[30][30];
	int i = 0;
	int j,k;
	while (i < N)
	{
		if (scanf("%d", &num[i]) == 1)
		{
			j = 0;
			while (j < num[i])
			{
				if (scanf("%d", &K[i][j]) == 1)
				{
				}
				else
					break;
				j++;
			}
		}
		else
			break;
		i++;
	}
	// i = 0;
	// while (i < N)
	// {
	// 	j = 0;
	// 	while (j < num[i])
	// 	{
	// 		printf("%d ", K[i][j]);
	// 		j++;
	// 	}
	// 	printf("\n");
	// 	i++;
	// }
	i = 1;
	int count;
	int ans = 0;
	while (i <= M)
	{
		j = 0;
		count = 0;
		while (j < N)
		{
			k = 0;
			while (k < num[j])
			{
				if (i == K[j][k])
				{
					count++;
					break;
				}
				k++;
			}
			j++;
		}
		if (count == N)
			ans++;
		i++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
X = int(input())

tmp = X
ans = 0
for i in range(min(A+1, X//500+1)):
    X -= 500*i
    if X == 0:
        ans += 1
        break
    for j in range(min(B+1, X//100+1)):
        tmp_2 = X
        X -= 100*j
        if X == 0:
            ans += 1
            break
        else:
            if 50*C >= X:
                ans += 1
        X = tmp_2
    X = tmp

print(ans)


Measured memory_bytes: 3064
import java.util.*;

class Main {
	public static void main(String[] args) {
		Comparator<Integer> comparator = new Comparator<Integer>() {
	        @Override
	        public int compare(Integer o1, Integer o2) {
	            return Integer.valueOf(o2).compareTo(Integer.valueOf(o1));
	        }
    	};
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		long ans=0;
		Queue<Integer> pq1 = new PriorityQueue<Integer>(comparator);
		Queue<Integer> pq2 = new PriorityQueue<Integer>();

		for (int i=0;i<Q;i++) {
			int x=sc.nextInt();
			if (x==1) {
				int a=sc.nextInt();
				int b=sc.nextInt();
				if (!pq1.isEmpty() && (a<pq1.peek() || pq2.peek()<a)) {
					ans+=Math.min(Math.abs(pq1.peek()-a),Math.abs((pq2.peek()-a)));
				}
				pq1.add(a);
				pq2.add(a);
				ans+=b;
				if (pq1.peek()>pq2.peek()) {
					int tmp_1=pq1.peek();
					int tmp_2=pq2.peek();
					pq1.remove();
					pq2.remove();
					pq1.add(tmp_2);
					pq2.add(tmp_1);
				}
			} else if (x==2) {
				System.out.print(pq1.peek()+" ");
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 159872
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int oddnize(int n){
    return n-(n%2==0);
}

int main(){
    int N;
    cin >> N;
    if(N == 3){
        cout << "2 5 63" << endl;
        return 0;
    }
    vector<int> S;
    S.push_back(2);
    S.push_back(3);
    S.push_back(4);
    N -= 3;

    vector<int> A0, A2, A3, A4;
    for(int i=6; i<=30000; i+=6) A0.push_back(i);
    for(int i=8; i<=30000; i+=6) A2.push_back(i);
    for(int i=9; i<=30000; i+=6) A3.push_back(i);
    for(int i=10; i<=30000; i+=6) A4.push_back(i);

    //int a = A0.size();
    int b = A2.size();
    int c = A3.size();
    int d = A4.size();

    int z = min(oddnize(N), oddnize(c));
    N -= z;
    int yw = min(min(b, d), N/2);
    N -= 2*yw;
    int x = N;

    REP(i, x) S.push_back(A0[i]);
    REP(i, yw){
        S.push_back(A2[i]);
        S.push_back(A4[i]);
    }
    REP(i, z) S.push_back(A3[i]);

    for(auto x : S)
        cout << x << " ";
    cout << endl;

//    int sm = 0;
//    for(int x : S) sm += x;
//    for(int x : S)
//        assert(__gcd(sm, x) > 1);
//
//    int g0 = __gcd(S[0], S[1]);
//    for(int i=2; i<N; i++)
//        g0 = __gcd(g0, S[i]);
//    assert(g0 == 1);


    return 0;
}


Measured memory_bytes: 640
program max_min_sums
    implicit none
    integer(8):: n, k, i, smax, smin
    integer(8), parameter:: mod_ = 1000000007
    integer(8), allocatable:: a(:), fac(:), finv(:), inv(:)

    ! import --------------------------
    read*, n, k
    allocate(a(n), fac(0:n), finv(0:n), inv(0:n))
    read*, a(:)
    ! init_combination table
    call com_init(fac(:), finv(:), inv(:), mod_)

    ! sort a --------------------------
    call marge_sort(a(:), 1_8, n)
    smax = 0; smin = 0
    do i=1,n; block; integer(8):: mi, cof
        mi = n-i+1
        cof = comb(i-1, k-1)
        smax = mod(smax + cof*a(i), mod_)
        smin = mod(smin + cof*a(mi), mod_)
    end block; end do

    print*, mod(smax - smin, mod_)

contains
recursive subroutine marge_sort(arr, first, last)
    integer(8):: arr(:), first, last
    integer(8):: mean, tmp

    if (last - first <= 1) then
        ! sort
        if (arr(last) < arr(first)) then
            tmp = arr(last)
            arr(last) = arr(first)
            arr(first) = tmp
        end if
        return
    end if

    !  only : (last - first) > 1
    mean = (first + last) / 2
    call marge_sort(arr, first, mean)
    call marge_sort(arr, mean+1, last)
    call marge(arr, first, last, mean)
end subroutine


subroutine marge(arr, first, last, mean)
    integer(8):: arr(:), first, last, mean
    integer(8):: il, ir, i
    integer(8), allocatable:: tmp(:)

    allocate(tmp(last-first+1))
    il = first
    ir = mean+1
    i = 1

    do while (il <= mean .and. ir <= last)
        if (arr(il) <= arr(ir)) then
            tmp(i) = arr(il)
            i = i+1
            il = il+1
        else
            tmp(i) = arr(ir)
            i = i+1
            ir = ir+1
        end if        
    end do

    if (il > mean)then
        tmp(i:) = arr(ir:last)
    else
        tmp(i:) = arr(il:mean)
    end if
    arr(first:last) = tmp(:)
    end subroutine


    subroutine com_init(fac, finv, inv, mod_)
        integer(8):: fac(0:), finv(0:), inv(0:), mod_
        integer(8):: i

        fac(0:1) = 1
        finv(0:1) = 1
        inv(1) = 1

        do i=2, size(fac(1:))
            fac(i) = mod(fac(i-1)*i, mod_)
            inv(i) = calc_inv(i,mod_)
            finv(i) = mod(finv(i-1) * inv(i), mod_)             
        end do
    end subroutine


    function comb(n, k) result(ret)
        integer(8):: ret, n, k
        if(n<k) then
            ret = 0
        else if(n < 0 .or. k < 0) then
            ret = 0
        else
            ret = mod(fac(n)*mod(finv(k)*finv(n-k), mod_), mod_)
        end if        
    end function

    
    function calc_inv(i,mod_) result(inv)
        integer(8):: i, mod_, inv
        integer(8):: lev, a
        lev = mod_ - 2
        inv = 1
        a = i

        do while(lev /= 0)
            if(mod(lev, 2)/=0) inv = mod(inv*a, mod_)
            lev = lev/2
            a = mod(a*a, mod_)
        end do
    end function


end program max_min_sums

Measured memory_bytes: 5044
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (i >= k) {
			if (t > v[i - k]) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		}
		v.push_back(t);
	}
}


Measured memory_bytes: 4320
# coding: utf-8

def getint():
    return int(input().rstrip())

def main():
    ls = []
    num_of_mount = 10
    num_of_top = 3
    
    for i in range(num_of_mount):
        ls.append(getint())

    ls.sort(reverse=True)

    for i in range(num_of_top):
        print(ls[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 7640
// https://atcoder.jp/contests/abc128/tasks/abc128_f
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, s: [i64; n]
    };

    let mut best = s[n-1];
    let mut visited = vec![0; n];
    for d in 1..n {
        let mut total = s[n-1];
        let mut low = 0;
        let mut high = n-1;
        while true {
            if high <= d*2 || low+d*2 >= n-1 {
                break;
            }
            high -= d;
            low += d;
            if high == low {
                break;
            }
            if visited[high] != d {
                visited[high] = d;
            } else {
                break;
            }
            if visited[low] != d {
                visited[low] = d;
            } else {
                break;
            }

            total += s[high];
            total += s[low];
            best = max(best, total);
            // debug!(d, high, low, best);
        }
    }

    println!("{}", best);
}


Measured memory_bytes: 6396
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	ll N,A,B,C,D;
	cin>>N>>A>>B>>C>>D;
	//増加させる回数を0からN-1まで調べて、可能な範囲を全部調べる
	for(int i=0;i<N;i++){
		ll UP=A+i*D-(N-1-i)*C;
		ll DOWN=A+i*C-(N-1-i)*D;
		//cout<<UP<<" "<<DOWN<<endl;
		if(DOWN<=B && B<=UP){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

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

using namespace std;

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

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> A(n);
    for(i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    ll leftOK = 0, leftNG = A[0] * 2 + 1;
    while(abs(leftOK - leftNG) > 1) {
        ll leftmid = (leftNG+leftOK)/2;
        ll cnt = 0;
        for(i=0;i<n;i++){
            ll ok=-1,ng=A.size();
            while(abs(ok-ng)>1){
                ll mid = (ok+ng)/2;
                if(A[i]+A[mid]>=leftmid){
                    ok = mid;
                }else {
                    ng = mid;
                }
            }
            cnt += ok+1;
        }
        if(cnt>=m){
            leftOK = leftmid;
        }else {
            leftNG = leftmid;
        }
    }
    vector<ll> sum(n+1,0);
    for(i=0;i<n;i++){
        sum[i+1]=sum[i]+A[i];
    }
    ll cnt = 0;
    ll ret = 0;
    for(i = 0; i < n; i++) {
        ll ok = -1, ng = A.size();
        while(abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if(A[i] + A[mid] >= leftOK) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cnt += ok + 1;
        ret += (ok+1)*A[i]+sum[ok+1];
    }
    if(cnt>m){
        ret-= leftOK*(cnt-m);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1792
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, great_W = getNM()
query = [getList() for i in range(N)]
wei = []
val = []
for i in range(N):
    w, v = query[i]
    wei.append(w)
    val.append(v)

# 下限の数字て引く（あとで足し合わせた数 * wei_minを使う）
wei_min = min(wei)
for i in range(N):
    wei[i] -= wei_min

def part_sum_5(n, k, limit, wei, val):
    dp = [[[0] * (limit + 1) for i in range(k + 1)] for i in range(n + 1)]

    # 足し合わせN個でvalができる
    for i in range(1, n + 1):
        for j in range(1, k + 1):
            for l in range(limit + 1):
                dp[i][j][l] = dp[i - 1][j][l]
                if l - wei[i - 1] >= 0:
                    dp[i][j][l] = max(dp[i - 1][j][l], dp[i - 1][j - 1][l - wei[i - 1]] + val[i - 1])

    res = 0
    for i in range(n + 1):
        for j in range(limit + 1):
            if i * wei_min <= (great_W - j):
                res = max(res, dp[N][i][j])

    return res

print(part_sum_5(N, N, 301, wei, val))

Measured memory_bytes: 109520
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		int a[n+1][n+1];
		rep(i,1,n+1){
			rep(j,1,n+1) cin >> a[i][j];
		}
		int val[1<<n]={};
		rep(mask,0,1<<n){
			rep(i,0,n){
				rep(j,i+1,n){
					if(mask&(1<<i) && mask&(1<<j)){
						val[mask] += a[i+1][j+1];
					}
				}
			}
		}
		int dp[1<<n];
		rep(i,0,1<<n) dp[i] = -INF;
		dp[0] = 0;
		rep(mask,1,1<<n){
			for(int submask = mask; submask!=0; submask = (submask-1)&mask){
				// trace(mask, submask);
				dp[mask] = max(dp[mask], val[submask]+dp[mask^submask]);
			}
		}
		// trace(dp[5]);
		cout<<dp[(1<<n)-1];
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n) ans += a[i] - 1;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let n = read();
    for _ in 0..n {
        let s: Vec<char> = read::<String>().chars().collect();
        let t: Vec<char> = read::<String>().chars().collect();
        // [sの文字目][tの文字目]
        let mut memo = vec![vec![(0, (0, 0)); t.len() + 1]; s.len() + 1];

        for i in 0..s.len() {
            for j in 0..t.len() {
                if s[i] == t[j] {
                    if memo[i][j].0 + 1 > memo[i + 1][j + 1].0 {
                        memo[i + 1][j + 1] = (memo[i][j].0 + 1, (i, j));
                    }
                } else {
                    if memo[i][j + 1].0 < memo[i + 1][j].0 {
                        memo[i + 1][j + 1] = (memo[i + 1][j].0, (i + 1, j))
                    } else {
                        memo[i + 1][j + 1] = (memo[i][j + 1].0, (i, j + 1))
                    }
                }
            }
        }
        println!("{}", memo[s.len()][t.len()].0);
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 33596
D , G = map(int,input().split())
questions = []
for i in range(D):
    p , c = map(int,input().split())
    questions.append([p,c])

ans = float("inf")
for bit in range(2 ** D):
    tmp_ans = 0
    tmp_sum = 0
    for j in range(D):
        if bit >> j & 1:
            tmp_sum += questions[j][0] * 100 * (j + 1) + questions[j][1]
            tmp_ans += questions[j][0]
    if tmp_sum < G:
        for j in range(D - 1 , -1 , -1):
            if bit >> j & 1:
                continue
            else:
                for k in range(questions[j][0]):
                    tmp_ans += 1
                    tmp_sum += 100 * (j + 1)
                    if tmp_sum >= G:
                        break
                if tmp_sum >= G:
                    break
    if tmp_ans < ans and tmp_sum >= G:
        ans = tmp_ans
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
 
  ll N, W; cin >> N >> W;
  vector<ll> dp(W + 5, -1);

  dp[0] = 0;

  rep(i, N){
    ll w, v; cin >> w >> v;
    for(int j = W; j >= 0; j--){
      if(dp[j] != -1 and j + w <= W){
        chmax(dp[j + w], dp[j] + v);
      }
    }
  }

  rep(i, W){
    chmax(dp[i + 1], dp[i]);
  }

  pr(dp[W]);

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {

	int A,B,C,X;

	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&X);

	int i,j,k;

	int ans=0;

	for(i=0;i<=A;i++){
		for(j=0;j<=B;j++){
			for(k=0;k<=C;k++){
				if((500*i)+(100*j)+(50*k)==X){ans++;}
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>

using namespace std;

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if (a*b>c*d) cout<<a*b<<endl;
	else cout<<c*d<<endl;
	return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let v = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

    let k = read_as_vec::<usize>()[0]-1;

    println!("{}", v[k]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int r,g,b;
	cin>>r>>g>>b;
	int k;
	cin>>k;
	int a[3];
	a[0]=b;
	a[1]=g;
	a[2]=r;
	while(k>0)
	{
		if(a[0]>a[1] && a[1]>a[2])
		{
			break;
		}

		int x = min(a[0],a[1]);

		int y = min(a[1],a[2]);

		if(x==a[0])
		{
			a[0]=a[0]*2;
			k--;
		}	
		else if(y==a[1])
		{
			a[1]=a[1]*2;
			k--;
		}
	}

	if(a[0]>a[1] && a[1]>a[2])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		// cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var keyWord = Console.ReadLine();

            var count = 0;
            var max = 0;

            foreach (var k in keyWord)
            {
                if (k == 'A' || k == 'C' || k == 'G' || k == 'T')
                {
                    count++;
                    if (max < count) max = count;
                }
                else
                    count = 0;
            }

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i,cnt=0,c=0;
    for(i=0; i<3; i++)
    {
        if(s[i]=='A')
        {
            cnt++;
        }
        if(s[i]=='B') c++;
    }
    if(cnt==0 || c==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
ans = 0
i = 0
while R*i <=  N:
    j = 0
    while R*i + G*j <=  N:
        if (N - R*i - G*j) % B ==  0:
            ans += 1
        j += 1
    i += 1
print(ans)


Measured memory_bytes: 66956
#include <stdio.h>
#include <iostream>
using namespace std;

int a[200001];
int box[200001];

int main()
{
	int ret;
	int N;

	ret = scanf("%d", &N);

	int l, i = 1;
	while (cin >> l) {
		a[i] = l;
		i++;
	}

	for (int i = 1; i <= N; i++) {
		box[i] = 0;
	}

	for (int i = N; i >= 1; i--) {
		//自分(i)の2倍以降最後までの箱を見て、入っている値の和を得る
		int sum = 0;
		for (int j = 2; i*j <= N ; j++) {
			int boxIdx = i*j;
			sum += box[boxIdx];
		}
		int partSum = sum; //出力

		//箱iに入れるか入れないか決める
		if (partSum % 2 != a[i]) {
			box[i] = 1;
		}
	}
	//ボールを入れる箱の個数を得る
	int count = 0;
	for (int i = 1; i <= N; i++) {
		count += box[i];
	}
	int ballNum = count;


	//出力
	printf("%d\n", ballNum);
	int first = 1;
	for (int i = 1; i <= N; i++) {
		if (box[i] == 1) {
			if (first == 1) {
				first = 0;
			}
			else {
				printf(" ");
			}

			printf("%d", i);
		}
	}

	return 0;
}



Measured memory_bytes: 2432
#include <iostream>
#include <complex>
//#include <fstream>

using namespace std;

typedef complex <double> P;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

// OÏ (cross product) : a~b = |a||b|sinÆ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.pt", "r", stdin);
	double x1, y1, x2, y2, x3, y3, xp, yp;

	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp ){
		P a(x1, y1), b(x2, y2), c(x3, y3 ), p(xp, yp);
		
		if ( (cross (p - a, p - b ) > 0. && cross (p - b, p - c ) > 0. && cross (p - c , p - a ) > 0.)
		||   (cross (p - a, p - b ) < 0. && cross (p - b, p - c ) < 0. && cross (p - c , p - a ) < 0.) ) {
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} // end loop

	return 0;
}

Measured memory_bytes: 0
# ContestName
# URL
import sys
#import numpy as np

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

def main():
    N, C = i2nn()
    D = ii2nnn(C)
    c = ii2nnn(N)
    E = [[0] * C for _ in range(3)]
    for i in range(N):
        for j in range(N):
            before = c[i][j]
            e = (i+j) % 3
            for after in range(1, C+1):
                E[e][after-1] += D[before-1][after-1]
    iwakan = N * N * 1000
    for c1 in range(C):
        for c2 in range(C):
            for c3 in range(C):
                if c1 == c2 or c2 == c3 or c3 == c1:
                    continue
                n = E[0][c1] + E[1][c2] + E[2][c3]
                if n < iwakan:
                    iwakan = n
    print(iwakan)

main()


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

int main() {
  int P,Q,R;
  cin >> P >> Q >> R;
  vector<int> vec(3);
  vec = { P, Q, R};
  sort(vec.begin(), vec.end());
  cout << vec.at(0) + vec.at(1) <<endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, L; cin >> N >> L;
	vector<int>as;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a; as.push_back(a);
	}
	vector<vector<pair<int,int>>>edges(N);
	vector<long long int>nums(N);
	for (int i = 0; i < N-1; ++i) {
		if (as[i] < as[i + 1]) {
			edges[i + 1].push_back(make_pair(i,L-as[i+1]));
			nums[i]++;
		}
		else {
			edges[i].push_back(make_pair(i + 1,L-as[i]));
			nums[i + 1]++;
		}
	}
	queue<pair<int, long long int>>que;
	vector<long long int>times(N);
	for (int i = 0; i < N; ++i) {
		if (!nums[i]) {
			que.push(make_pair(i, 0));
		}
	}
	while (!que.empty()) {
		auto p(que.front());
		que.pop();
		times[p.first] = p.second + (L - as[p.first]);
		for (auto e : edges[p.first]) {
			nums[e.first]--;
			if (!nums[e.first])que.push(make_pair(e.first, p.second + (L - as[p.first])));
		}
	}
	int ans = *max_element(times.begin(), times.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int d,l;
	scanf("%d %d",&d,&l);
	int k,ka;
	k=d/l;
	ka=d%l;
	if(ka!=0){
		k=k+ka;
	}
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 2144
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

struct lst
{
    long long int i;
    long long int num;
};

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    long long int N, K;
    gc(N);
    gc(K);

    vector<lst> vl;

    for (long long int i = 0LL; i < N; i++)
    {
        long long int a, b;
        gc(a);
        gc(b);

        lst l = {a, b};

        vl.push_back(l);
    }

    // i をキーに昇順でソート
    sort(vl.begin(), vl.end(),
        [](const lst &x, const lst &y) { return x.i < y.i; });

    long long int sum = 0LL;
    long long int ans;
    for (long long int i = 0LL; i < N; i++)
    {
        sum += vl[i].num;
        ans = vl[i].i;

        if (K <= sum) break;
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2420
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day3/problems/A>
問題文============================================================
 
 林檎農家で働くMonの仕事は「林檎の収穫」と「林檎の出荷」の二つである。
 育てている林檎の種類は N 種あり、収穫した林檎はそれぞれ区別された N 個の箱に保管される。
 出荷は箱に保管されている林檎から行われ、指定された種類の林檎を出荷する。
 林檎は (1≤i≤N) の番号付けによって種類が区別されており、 i 番目の種類の林檎は 箱 i に保管されるものとする。
 各箱 i (1≤i≤N) には最大 ci 個の林檎をいれることができ、初め各箱に入っている林檎の個数は 0 個である。
 
 Monはこれらの仕事を上司であるKukuiの指示に完全に従う。
 指示は全部で Q 回あり、各指示は以下の 2 つのうちのどちらかである。
 
 林檎の収穫 ：箱 x に、収穫した d 個の林檎 x を入れる
 林檎の出荷 ：箱 x から、 d 個の林檎 x を取り出す
 ただし、kukuiの指示は必ずしも理にかなっているとは言えず、理不尽なものが含まれている可能性がある。
 それを判定するプログラムを作ってほしい。 ここで理不尽な指示とは以下の 2 つのことを指す。
 
 林檎の収穫をする際に箱の最大容量を超える
 林檎の出荷をする際に箱の中の林檎が足りなくなる

=================================================================

解説=============================================================

================================================================
*/

int solve(){
    int N; cin >> N;
    vector<int> c(N);
    for(auto& in:c) cin >> in;
    int Q; cin >> Q;
    vector<int> t(Q),x(Q),d(Q);
    vector<int> hako(N,0);
    for(int i = 0; i < Q;i++){
        int t,x,d; cin >> t >> x >> d;
        x--;
        if(t==1){
            hako[x] += d;
            if(hako[x] > c[x]) return x+1;
        }else{
            hako[x] -= d;
            if(hako[x] < 0) return x+1;
        }
    }
    return 0;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}



Measured memory_bytes: 4160