akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define ilog2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}


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

	ll x;cin>>x;
	ll curr = 100;

	int ans = 0;
	while(curr < x){
		curr += (ll)((double)curr*1./100.);
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3656
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,W,w[110],v[110],dp[110][100010];

int main()
{
	cin>>n>>W;
	rep(i,n) cin>>w[i]>>v[i];
	for(int i=w[0];i<=W;i++) dp[0][i]=v[0];
	repn(i,n-1)
	{
		rep(j,W+1)
		{
			if(w[i]>j) dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			//cout<<i<<' '<<j<<' '<<dp[i][j]<<' '<<dp[i-1][j]<<' '<<w[i]<<endl;
		}
	}
	cout<<dp[n-1][W]<<endl;
	rt0;
}

Measured memory_bytes: 80128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import deque

n = int(readline())
graph = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, readline().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
c = list(map(int, readline().split()))
c.sort()
print(sum(c[:-1]))
q = deque([0])
d = [-1] * n

while q:
    x = q.popleft()
    d[x] = c.pop()
    for next in graph[x]:
        if d[next] < 0:
            q.appendleft(next)

print(*d)


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

int main() {
    string a, b;
    cin>>a>>b;
    ll x = stoll(a+b);
    for(int i=1;i*i<=x;i++) {
        if(i*i==x) {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    // if(sqrt(x)*sqrt(x) == x) cout<<"Yes\n";
    // else cout<<"No\n";

    return 0;
}

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define TL printf("Time elapsed: %gs.\n",1.0 * clock() / CLOCKS_PER_SEC)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);

inline string IntToString(LL a){
  	char x[100];
  	sprintf(x,"%lld",a); string s = x;
  	return s;
}

inline LL StringToInt(string a){
  	char x[100]; LL res;
  	strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  	return res;
}

inline string GetString(void){
  	char x[1000005];
  	scanf("%s",x); string s = x;
  	return s;
}

inline string uppercase(string s){
  	int n = SIZE(s); 
  	REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  	return s;
}

inline string lowercase(string s){
  	int n = SIZE(s); 
  	REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  	return s;
}

inline void OPEN (string s) {
  	#ifndef TESTING
  	freopen ((s + ".in").c_str (), "r", stdin);
  	freopen ((s + ".out").c_str (), "w", stdout);
  	#endif
}

int main() {
	// FASTIO;
 	// Start Program
    int a, b, c;
    scanf("%d %d %d", &a,&b,&c);
    printf("%s\n",(a+b+c >= 22) ? "bust" : "win");
  	// End of Program Jangan Lupa diComment TL
  	//TL;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

def insert(t, x):
    Llist[t].append(x)

def dump(t):
    print(*Llist[t])


def splice(s, t):
    if Llist[t]:
        if len(Llist[t]) ==1:
            Llist[s].appendleft(Llist[t][0])
            Llist[t] = Llist[s]
        elif len(Llist[s]) == 1:
            Llist[t].append(Llist[s][0])
        else:   
            Llist[t].extend(Llist[s])
    else:
        Llist[t] = Llist[s]

    Llist[s] = deque() 

n, q = map(int, input().split())

Llist = []

for i in range(n):
    Llist.append(deque())

for i in range(q):
    queryi = list(map(int, input().split()))

    if queryi[0] == 0:
        insert(queryi[1], queryi[2])
    
    elif queryi[0] == 1:
        dump(queryi[1])
    
    else:
        splice(queryi[1], queryi[2])


Measured memory_bytes: 30672
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int k;
    cin >> k;
    string s;
    cin >> s;

    if (s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) + "..." << endl;
    }
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N);
  for (auto &i : H) cin >> i;
  
  vector<int> bools(N, 1);
  int A, B;
  for (int i=0; i<M; i++) {
    cin >> A >> B;
    A--, B--;
    if (H[A] <= H[B]) bools[A] = 0;
    if (H[A] >= H[B]) bools[B] = 0;
  }
  cout << accumulate(bools.begin(), bools.end(), 0) << endl;
}


Measured memory_bytes: 3676
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int n=s.length();
    int flag=0;
    for(int i=0;i<n;++i){
      flag+=s.charAt(i)=='o'?1:0;
    }
    System.out.print(15+flag-n>=8?"YES":"NO");
  }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = int.Parse(Console.ReadLine());

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < q; i++)
            {
                double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);

                MyPoint a = new MyPoint(input[0] - input[2], input[1] - input[3]);
                MyPoint b = new MyPoint(input[4] - input[6], input[5] - input[7]);

                if (dot(a, b) == 0.0) sb.AppendLine("1");
                else if (cross(a, b) == 0.0) sb.AppendLine("2");
                else sb.AppendLine("0");
            }
            Console.Write(sb);
        }

        static double dot(MyPoint a, MyPoint b)
        {
            return a.x * b.x + a.y * b.y;
        }

        static double cross(MyPoint a, MyPoint b)
        {
            return a.x * b.y - a.y * b.x;
        }
    }

    class MyPoint : IComparable<MyPoint>
    {
        static readonly double EPS = 1E-10;

        internal double x, y;

        public MyPoint(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public double Abs() { return Math.Sqrt(Norm()); }
        public double Norm() { return x * x + y * y; }

        public static MyPoint operator +(MyPoint a, MyPoint b) { return new MyPoint(a.x + b.x, a.y + b.y); }
        public static MyPoint operator -(MyPoint a, MyPoint b) { return new MyPoint(a.x - b.x, a.y - b.y); }
        public static MyPoint operator *(MyPoint p, double d) { return new MyPoint(p.x * d, p.y * d); }
        public static MyPoint operator /(MyPoint p, double d) { return new MyPoint(p.x / d, p.y / d); }
        public static bool operator <(MyPoint a, MyPoint b) { return Math.Abs(a.x - b.x) > EPS ? a.x < b.x : a.y < b.y; }
        public static bool operator >(MyPoint a, MyPoint b) { return Math.Abs(a.x - b.x) > EPS ? a.x > b.x : a.y > b.y; }
        public static bool operator ==(MyPoint a, MyPoint b) { return Math.Abs(a.x - b.x) < EPS && Math.Abs(a.y - b.y) < EPS; }
        public static bool operator !=(MyPoint a, MyPoint b) { return Math.Abs(a.x - b.x) >= EPS || Math.Abs(a.y - b.y) >= EPS; }

        public int CompareTo(MyPoint other)
        {
            return x != other.x ? (int)(x - other.x) : (int)(y - other.y);
        }

        public override bool Equals(object obj)
        {
            MyPoint other = obj as MyPoint;
            return Math.Abs(x - other.x) < EPS && Math.Abs(y - other.y) < EPS;
        }

        public override int GetHashCode()
        {
            return x.GetHashCode() ^ y.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("{0:f10} {1:f10}", x, y);
        }
    }

    class MyVector : MyPoint
    {
        public MyVector(double x, double y) : base(x, y) { }
    }
}

Measured memory_bytes: 9504
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int count(string& str, string& sub) {
    int sz = sub.length();
    int cnt = 0;
    for(int i = 0; i < str.size()-(sz-1); i++) {
        if(str.substr(i, sz) == sub) cnt++;
    }
    return cnt;
}

int main(void) {
    int num;
    cin >> num;
    int sum = 0;
    int head_cnt = 0;
    int tail_cnt = 0;
    int cnt = 0;
    static string ab = "AB";
    for(int i = 0; i < num; i++) {
        string str;
        cin >> str;
        sum += count(str, ab);
        int flag = 0;
        if(str[0] == 'B') {
            flag = 1;
            head_cnt++;
        }
        if(*(str.end()-1) == 'A') {
            flag = 1;
            tail_cnt++;
        }
        cnt += flag;
    }
    debug("%d\n", sum);
    int bonus = max(cnt-1, 0);
    bonus = min(bonus, head_cnt);
    bonus = min(bonus, tail_cnt);
    cout << sum+bonus << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
  int input, output[3]={}, i;
  
  for( i=0; i<10; i++){
    scanf("%d", &input);
    if( input > output[0]){
      output[2] = output[1];
      output[1] = output[0];
      output[0] = input;
    }else if( input > output[1]){
      output[2] = output[1];
      output[1] = input;
    }else if( input > output[2]){
      output[2] = input;
    }
  }

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

Measured memory_bytes: 1028
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
const int Inf = 1e9 + 5;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000;
    return 0;
}

Measured memory_bytes: 3628
from math import sqrt

class Ufo:
	def __init__(self,px,py,d,vd,ui):
		self.pd=sqrt(px**2+py**2)
		self.px=float(px)
		self.py=float(py)
		self.ex=self.px/self.pd
		self.ey=self.py/self.pd
		self.d=float(d)
		self.vd=float(vd)
		self.vx=-self.vd*self.ex
		self.vy=-self.vd*self.ey
		self.i=ui
	def move(self):
		self.pd -= self.vd
		self.px += self.vx
		self.py += self.vy



while True:
	R,ul=tuple(map(int,raw_input().split()))
	if(R==0 and ul==0): break
	us=[]
	for ui in xrange(ul):
		px,py,d,vd = tuple(map(int,raw_input().split()))
		u = Ufo(px,py,d,vd,ui)
		us.append(u)

	re=0
	while True:
		for u in us: u.move()
		us.sort(key=lambda u: u.pd)

		for u in us[:]:
			if u.pd<=R:
				re+=1
				us.remove(u)
				#print u.i, "due to invade"
				continue
			else:
				break
		if len(us)==0: break

		neu=us.pop(0)
		#print "focus",neu.i
		#print neu.i,"due to hit"

		for u in us[:]:
			d = u.pd*abs(neu.ex*u.ey-neu.ey*u.ex)	#u kara laser ni orosita suisen no nagasa
			if d<u.d:
				if u.pd*(neu.ex*u.ex+neu.ey*u.ey)+sqrt(u.d**2-d**2) > R:
					us.remove(u)
					#print u.i, "due to hit"
		if len(us)==0: break

	print re

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

template<typename T>
map<T,ll> factorize(T x){
	map<T,ll> res;
	for(ll i=2;i*i<=x;i++){
		while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	cout << n << ":";
	auto m=factorize(n);
	for(auto p:m){
		for(int i=0;i<p.second;i++){
			cout << " " << p.first;
		}
	}
	cout << endl;
}


Measured memory_bytes: 3212
#include <stdio.h>
#include <algorithm>

using namespace std;

int GCD(int x, int y){
    if(y==0) return x;
    int r = max(x, y) % min(x, y);
    return GCD(min(x, y), r);
}

int main(void){
    int x=0, y=0;
    scanf("%d %d", &x, &y);
    printf("%d\n", GCD(x, y));
    return 0;
}


Measured memory_bytes: 2752
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=1
data=[0,0,0]
for u in a:
    cnt=0
    k=-1
    for i in range(3):
        if u==data[i]:
            k=i
            cnt+=1
    ans=ans*cnt%mod
    if k!=-1:
        data[k]+=1
print(ans)

Measured memory_bytes: 52952
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    ll n;
    cin>>n;
    ll a[n];
    inp_arr(a,n);

    ll x = 1;
    ll c = 0;
    for(int i=0;i<n;++i) {
        if(a[i] == x) {
            ++x;
            ++c;
        }
    }

    ll ans = n-c;
    if(ans == n) ans = -1;
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    n, k = LI()
    g = [[] for i in range(n+1)]
    for i in range(n-1):
        a, b = LI()
        g[a].append(b)
        g[b].append(a)

    s = 1
    Q = [s]
    ans = k
    Qappend = Q.append
    searched = [0] * (n+1)
    searched[s] = 1
    while len(Q) != 0:
        temp = 1
        v = Q.pop()
        if v == s:
            cand = k - 1
        else:
            cand = k - 2
        for i in g[v]:
            if searched[i] == 1:
                continue
            searched[i] = 1
            temp = temp * cand % MOD
            cand -= 1
            Qappend(i)
        ans = ans * temp % MOD
    print(ans % MOD)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

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

struct FastNumberTheoreticTransform {

  ll size = 1, size_x12, root;
  vector<ll> x1, x2, theta;

  FastNumberTheoreticTransform(ll s=10) { 
    while(size<s) size*=2;
    root = modpow(3,MOD/size);
    x1.resize(size); x2.resize(size); theta.resize(size);
    rep(i,size) theta[i] = i==0 ? 1 : theta[i-1]*root % MOD;
  }

  void set(vector<ll> &v1, vector<ll> &v2) { 
    size_x12 = v1.size() + v2.size() - 1;
    x1 = v1; x2 = v2;
  }

  vector<ll> convolution(vector<ll> &x, bool rev, ll s, ll pos=0) {
    if (s==1) return {x[pos]};
    vector<ll> ex = convolution(x,rev,s/2,pos), ox = convolution(x,rev,s/2,pos+size/s);
    vector<ll> result(s);
    rep(i,s) result[i] = (ex[i%(s/2)] + theta[size/s*i] * ox[i%(s/2)]) % MOD;
    if (rev && s==size) {
      reverse(result.begin()+1, result.end());
      ll invs = inv(size);
      for (auto &x: result) x = x * invs % MOD;
    }
    return result;
  };

  vector<ll> calc(vector<ll> &v1, vector<ll> &v2) {
    set(v1,v2);
    vector<ll> cx1 = convolution(x1, false, size), cx2 = convolution(x2, false, size);
    vector<ll> cx12(size); rep(i,size) cx12[i] = cx1[i] * cx2[i] % MOD;
    vector<ll> x12 = convolution(cx12, true, size);
    vector<ll> result(size_x12); copy(x12.begin(), x12.begin()+size_x12, result.begin());
    return result;
  }

};

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

int main() {
  ll N, M; cin >> N >> M;
  vector<ll> v1(N), v2(M);
  rep(i,N) cin >> v1[i];
  rep(i,M) cin >> v2[i];

  FastNumberTheoreticTransform FNTT(N+M);
  vector<ll> result = FNTT.calc(v1, v2);
  debug(result.begin(), result.begin()+(N+M-1));
  return 0;
}

Measured memory_bytes: 85144
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	string T, H;
	char t[1001], h[1001];
	int score_t, score_h;
	score_t = 0;
	score_h = 0;
	scanf("%d", &n);
	int i;
	for(i = 0; i < n; i++) {
		scanf("%s %s", t, h);
		T = string(t);
		H = string(h);
		if(T < H) {
			score_h += 3;
		} else if(H < T) {
			score_t += 3;
		} else if(T == H) {
			score_t++;
			score_h++;
		}
	}
	printf("%d %d\n", score_t, score_h);
	return 0;
}

Measured memory_bytes: 3276
#include <stdio.h>
int main(void)
{
    int a,b,add,cnt;
    
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        add=a+b;
        cnt=0;
        while(1)
        {
            cnt++;
            if(add/10==0) break;
            else add/=10;
        }
        printf("%d\n",cnt);
    }
    return 0;
}



Measured memory_bytes: 2028
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int sum = 0;
	ll n, temp;
	cin >> n;
	temp = n;
	while(temp > 0){
		sum += temp % 10;
		temp /= 10;
	}
	if(n % sum == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <map>
#define fr first
#define sc second
#define pii pair<int,bool>
#define mp make_pair
using namespace std;
const int maxn=1e6+10;
int n,a[maxn];
map<pii,long long>dp[maxn];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	dp[0][mp(0,0)]=0;
	for (int i=1;i<=n;i++)
	 for (auto j:dp[i-1])
	 {
	 	if (!j.fr.sc) 
	 	{
	 		if (dp[i].count(mp(j.fr.fr+1,1))) dp[i][mp(j.fr.fr+1,1)]=max(dp[i][mp(j.fr.fr+1,1)],j.sc+a[i]);
	 		else dp[i][mp(j.fr.fr+1,1)]=j.sc+a[i];
	 	}
	 	if ((n-i+1)/2+j.fr.fr>=(n/2)) 
	 	{
	 		if (dp[i].count(mp(j.fr.fr,0))) dp[i][mp(j.fr.fr,0)]=max(dp[i][mp(j.fr.fr,0)],j.sc);
	 		else dp[i][mp(j.fr.fr,0)]=j.sc;
	 	}
	 }
	printf("%lld\n",max(dp[n][mp(n/2,0)],dp[n][mp(n/2,1)]));
return 0;
}

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

const int N = 10;
vector<int> L(N);

int n, a, b, c;

vector<char> C = {'0', 'A', 'B', 'C'};
vector<string> S;

void dfs(int now, string str){
    for(int i = 0; i < 4; i++){
        if(now == n){
            vector<bool> F(3, false);
            for(int j = 0; j < n; j++){
                if(str[j] == 'A') F[0] = true;
                else if(str[j] == 'B') F[1] = true;
                else if(str[j] == 'C') F[2] = true;
            }
            int cnt = count(F.begin(), F.end(), true);
            if(cnt == 3){
                S.push_back(str + C[i]);
            }
        }
        else dfs(now + 1, str + C[i]);
    }
}

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

    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++){
        cin >> L[i];
    }

    dfs(0, "");

    int ans = 1e9;
    int ss = S.size();
    for(int i = 0; i < ss; i++){
        int mp = 0;
        int a_total = 0, b_total = 0, c_total = 0;
        int a_cnt = 0, b_cnt = 0, c_cnt = 0;
        for(int j = 0; j < n; j++){
            if(S[i][j] == '0');
            else if(S[i][j] == 'A'){
                a_total += L[j];
                a_cnt++;
            }else if(S[i][j] == 'B'){
                b_total += L[j];
                b_cnt++;
            }else if(S[i][j] == 'C'){
                c_total += L[j];
                c_cnt++;
            }
        }
        mp += max(0, a_cnt - 1) * 10 + max(0, b_cnt - 1) * 10 + max(0, c_cnt - 1) * 10;
        mp += abs(a - a_total);
        mp += abs(b - b_total);
        mp += abs(c - c_total);

        ans = min(ans, mp);
    }

    cout << ans << endl;

    return 0;
}

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

const int MAXN = 410;
const int mod = 998244353;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int UP = 1, DU;
class poly {
	int A[MAXN];
public:
	int & operator [] (int x) { return A[x]; }
	int operator [] (int x) const { return A[x]; }
	int gethi() const {
		int hi = UP;
		while (hi && !A[hi - 1]) --hi;
		return hi;
	}
	poly & operator () (const poly & a, const poly & b) {
		int ha = a.gethi(), hb = b.gethi();
		for (int i = 0; i != ha; ++i) if (a[i])
			for (int j = 0; j != hb; ++j)
				reduce(A[i + j] += (LL) a[i] * b[j] % mod - mod);
		return *this;
	}
} A, B, f[MAXN], g[MAXN];
int fac[MAXN], inv[MAXN];
int xs[MAXN], ys[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i != MAXN; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = mul(inv[mod % i], mod - mod / i);
	}
	for (int i = 2; i != MAXN; ++i) inv[i] = mul(inv[i - 1], inv[i]);
	f[0][0] = 1;
	int n; std::cin >> n;
	for (int i = 1; i <= n; ++i)
		std::cin >> xs[i] >> ys[i], UP += ys[i] - 1, DU += xs[i];
	for (int i = 1; i <= n; ++i) {
		memset(&A, 0, sizeof A); memset(&B, 0, sizeof B);
		A[ys[i] - 1] = pow(xs[i], ys[i], inv[ys[i] - 1]);
		for (int j = 0; j < ys[i]; ++j)
			B[j] = pow(xs[i], j, (mod - inv[j]) % mod);
		for (int j = DU - xs[i]; j >= 0; --j)
			if (f[j].gethi() || g[j].gethi()) {
				f[j + xs[i]](f[j], B);
				g[j + xs[i]](f[j], A);
				g[j + xs[i]](g[j], B);
			}
	}
	int ans = 0;
	for (int i = 1; i <= DU; ++i)
		for (int j = 0; j < UP; ++j) {
			int t = pow(pow(i, j + 2), mod - 2, fac[j + 1]);
			reduce(ans += (LL) t * g[i][j] % mod - mod);
		}
	ans = mul(ans, DU);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=2e5+100;
const double eps=1e-10;
int main()
{
    LL k,n=50;
    while(scanf("%lld",&k)!=EOF)
    {
        printf("50\n");
        LL cnt=k/50,res=k%50;
        for(int i=0;i<50;i++)
        {
            if(i<res)
            printf("%lld",i+cnt+n-res+1);
            else printf("%lld",i+cnt-res);
            if(i!=49) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
int main(){
  unsigned n,m;
  std::cin >> n >> m;
  
  unsigned sum[m]={};
  
  for(int i=0;i<n;i++){
    unsigned tmp; std::cin >> tmp;
    for(int j=0; j<tmp;j++){
      unsigned now;
      std::cin >> now; now--;
      sum[now]++;
    }
  }
  
  unsigned count = 0;
  for(auto x: sum)
    if(n==x) count++;
  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
S = input()

ans = []
i = N
while i > 0:
    for m in range(M,0,-1):
        if i-m <= 0:
            ans.append(i)
            i = 0
            break
        if S[i-m]=='0':
            ans.append(m)
            i -= m
            break
    else:
        print(-1)
        exit()
print(*ans[::-1])

Measured memory_bytes: 50416
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T>
vector<T> Gauss_Jordan(const vector<T> &v, const int &MAX){ //v[i]<2^MAX
    int n=v.size();
    vector<T> ret=v;
    int d=0;
    for(int k=MAX-1; k>=0; k--){
        int p=-1;
        for(int i=d; i<n; i++){
            if((ret[i]>>k)&1){
                p=i;
                break;
            }
        }
        if(p==-1) continue;
        swap(ret[d], ret[p]);
        for(int i=0; i<n; i++){
            if(i==d) continue;
            if((ret[i]>>k)&1) ret[i]^=ret[d];
        }
        d++;
    }
    return ret;
}
int main()
{
    int n;
    scanf("%d", &n);
    using ull=unsigned long long;
    const int MAX=60;
    ull s=0;
    vector<ull> a(n);
    for(int i=0; i<n; i++){
        scanf("%llu", &a[i]);
        s^=a[i];
    }
    for(int i=0; i<n; i++) a[i]&=(~s);
    vector<ull> b=Gauss_Jordan(a, MAX);
    ull t=0;
    for(int i=0; i<n; i++) t^=b[i];
    ull ans=s+(t<<1);
    printf("%llu\n", ans);
    return 0;
}

Measured memory_bytes: 1920
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#ifdef LOCAL
#include "prettyprint.hpp"
#else
#define debug(...)
#define debuga(arr, n)
#define debugg(grid, n) 
#endif
typedef long long int ll;
#define int ll
#define F first
#define S second
#define float double
const int inf = LLONG_MAX;
int get() { int x; cin >> x; return x; }
void getl(int* ar, int sz){ for(int i=0; i<sz; i++) cin >> ar[i];}
template <typename T> void print(T x) { cout << x << "\n";}
template <typename T> void prints(T x) { cout << x << " ";}
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
const int mod = 1e9+7;
const int N = 1e6+1;
 
int32_t main(){
	fast_io();
	int a = get();
	string s; cin >> s;
	if(!(a<3200)){
		print(s);
	} else {
		print("red");
	}
	return 0;
}

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

std::string str;
bool flag = true;

void dfs (int i, int sum, std::string str_) {
  if ( !flag ) return;
  if ( i == 4 ) {
      if (sum == 7) {
        std::cout << str_+"=7" << std::endl;
        flag = false;
      }
      return;
  }

  dfs(i+1, sum+std::atoi(str.substr(i,1).c_str()), str_+"+"+str[i]);
  dfs(i+1, sum-std::atoi(str.substr(i,1).c_str()), str_+"-"+str[i]);
  return;
}

int main (void){
  std::cin >> str;

  std::string s = ""; s+=str[0];
  dfs(1, std::atoi(str.substr(0, 1).c_str()), s);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int ar[n+3];
  for(int i=0;i<n;i++)cin>>ar[i];
  sort(ar,ar+n);
  int sum=0;
  for(int i=0;i<m;i++)sum+=ar[i];
  cout<<sum<<endl;
  return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

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;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int n,m,x;
    cin>>n>>m>>x;

    vec c(n);
    vvec a(n,vec(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }
    int ans=INF;
    int Digit=n; // 2進数の桁数を入力
        rep(_,(1<<Digit)){
            vec ski(m);
            int cost=0;
            rep(each,Digit){
                if ((_>>(Digit-1-each))&(1)){ // 左からeach番目のbitが立っているとき
                    cost+=c[each];
                    rep(kk,m){
                        ski[kk]+=a[each][kk];
                    }
                }
            }
            int ng=0;
            rep(kk,m) if(ski[kk]<x) ng++;
            if(ng==0){
                chmin(ans,cost);
            }
        }
    
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7796
#include <iostream>
#include <stack>
#include <string>
#include <numeric>
#include <vector>

std::vector<int> countPuddle(std::string str) {
  std::stack<int> s;
  std::vector<int> puddles(20000, 0);
  for (int i = 0; i < (int)str.size(); ++i) {
    char c = str[i];    
    switch (c) {
    case '\\':
      s.push(i);
      break;
    case '/':
      if (s.empty())
        break;
      int j = s.top(); s.pop();
      for (int k = j; k <= i; ++k) {
        puddles[k] += (k == i || k == j) ? 1 : 2;
      }
      break;
    }
  }
  return puddles;
}

int main() {
  std::string str;
  std::cin >> str;
  std::vector<int> ans = countPuddle(str);
  std::cout << std::accumulate(ans.begin(), ans.end(), 0) / 2 << std::endl;
  int sum = 0;
  std::vector<int> fin;
  for (int i = 0; i < (int)ans.size(); ++i) {
    if (ans[i] <= 1 && sum != 0) {
      sum += ans[i];
      fin.push_back(sum / 2);
      sum = 0;
    }
    else
      sum += ans[i];
  }
  std::cout << fin.size();
  for (auto a : fin) {
    std::cout << " " << a;
  }
  std::cout << std::endl;
}

Measured memory_bytes: 3312
from collections import defaultdict
a,b,c,k = map(int, input().split()) 
# b = list(map(int, input().split()))
# n = int(input())
# a = [int(input()) for _ in range(n)]

if k<=a:
    print(min(k,a))
elif a < k and k <= a+b:
    print(a)
else:
    print(a - (k-a-b))



Measured memory_bytes: 9460
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int count = 0;
	if(N < 105){
	    count = 0;
	}else if(N ==105){
	    count = 1;
	}else if(N > 105){
	    count = 1;
	    for(int j=107;j<=N;j+=2){
		int cc = 0;
		for(int i=1;i<=j;i+=2){
		    if(j%i==0) cc++;
		}
		if(cc==8) count++;
	    }
	}
	System.out.print(count);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(n);
    VEC(int, a, n);
    REP(i, n) if(a[i] % 2){
        cout <<"first\n";
        return 0;
    }
    cout <<"second\n";
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans=0,x=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		{
			x++;
		}
		ans=max(x,ans);
		if(s[i]=='D')
		{
			x--;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
	N, Y = map(int, input().split())

	c = 0
	for x in range(N+1):
		if c == 0:
			if 10000 * x <= Y:
				NN = N-x
				YY = Y-10000*x
				for y in range(NN+1):
					if 5000 * y <= YY:
						NNN = NN - y
						YYY = YY - 5000*y
						if 1000 * NNN == YYY:
							ans = [x,y,NNN]
							c = 1

	if c == 1:
		print('{} {} {}'.format(ans[0],ans[1],ans[2]))
	else:
		print('{} {} {}'.format(-1,-1,-1))

Measured memory_bytes: 67392
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		double max;
		double min;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
				double first = stdIn.nextDouble();
				max = first;
				min = first;
			while( stdIn.hasNext() ){
				double x = stdIn.nextDouble();
				if( x > max ){
					max = x;
				}
				if( x < min ){
					min = x;
				}
			}
			System.out.println(max-min);
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

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

int main(void){
  int n,m;
  cin>>n>>m;
  
  vector<int>a(m);
  vector<int>b(m);
  for(int i=0;i<m;i++){
   cin>>a.at(i)>>b.at(i); 
  }
  
  vector<int>count(n);
  for(int i=0;i<m;i++){
    count.at(a.at(i)-1)++;
    count.at(b.at(i)-1)++;
  }
  
  for(int i=0;i<n;i++){
    cout<<count.at(i)<<endl; 
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

struct disj{
	int pa[MAXN];
	void init(int n){
		iota(pa, pa + n + 1, 0);
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q){
		pa[find(p)] = find(q);
		return 0;
	}
}disj;

int n, m, a[MAXN];

int solve(vector<int> v){
	vector<int> w;
	for(auto &i : v) w.push_back(a[i]);
	sort(w.begin(), w.end());
	int ret = 0;
	for(auto &i : v) ret += binary_search(w.begin(), w.end(), i);
	return ret;
}

vector<int> v[MAXN];

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	disj.init(n);
	while(m--){
		int s, e; scanf("%d %d",&s,&e);
		disj.uni(s, e);
	}
	for(int i=1; i<=n; i++) v[disj.find(i)].push_back(i);
	int ret = 0;
	for(int i=1; i<=n; i++) ret += solve(v[i]);
	cout << ret << endl;
}



Measured memory_bytes: 9472
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 5e5 + 5;
int n, k;
int q[maxn];

bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  k--;
  for (int i = 0; i < n; i++) {
    scanf("%d", &q[i]);
    q[i]--;
  }
  return true;
}

int fen[maxn];

void add(int i, int val) {
  for (; i < n; i |= i + 1) {
    fen[i] += val;
  }
}

int get(int i) {
  int res = 0;
  for (; i >= 0; i = (i & (i + 1)) - 1) {
    res += fen[i];
  }
  return res;
}

void addSeg(int l, int r, int val) {
  l = max(l, 0);
  r = min(r, n);
  add(l, val);
  add(r, -val);
}

void qsort(vector<int> &p) {
  int n = sz(p);
  if (n <= 1) {
    return;
  }
  int x = rnd(n);
  vector<int> todel;
  addSeg(p[x] - k, p[x] + k + 1, 1);
  todel.push_back(p[x]);
  vector<int> l, r;
  for (int i = x - 1; i >= 0; i--) {
    if (p[i] > p[x] && !get(p[i])) {
      r.push_back(p[i]);
    } else {
      l.push_back(p[i]);
      addSeg(p[i] - k, p[i] + k + 1, 1);
      todel.push_back(p[i]);
    }
  }
  reverse(l.begin(), l.end());
  reverse(r.begin(), r.end());
  for (int i = 0; i < sz(todel); i++) {
    addSeg(todel[i] - k, todel[i] + k + 1, -1);
  }
  todel.clear();
  addSeg(p[x] - k, p[x] + k + 1, 1);
  todel.push_back(p[x]);
  for (int i = x + 1; i < n; i++) {
    if (p[i] < p[x] && !get(p[i])) {
      l.push_back(p[i]);
    } else {
      r.push_back(p[i]);
      addSeg(p[i] - k, p[i] + k + 1, 1);
      todel.push_back(p[i]);
    }
  }
  for (int i = 0; i < sz(todel); i++) {
    addSeg(todel[i] - k, todel[i] + k + 1, -1);
  }
  todel.clear();
  qsort(l);
  qsort(r);
  int val = p[x];
  for (int i = 0; i < sz(l); i++) {
    p[i] = l[i];
  }
  p[sz(l)] = val;
  for (int i = 0; i < sz(r); i++) {
    p[sz(l) + 1 + i] = r[i];
  }
}

void solve() {
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[q[i]] = i;
  }
  memset(fen, 0, sizeof(fen));
  qsort(p);
  for (int i = 0; i < n; i++) {
    q[p[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", q[i] + 1);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 31072
#include <stdio.h>
#include <string.h>
int main()
{   char s[500001];
    scanf("%s",s);
    long long l=strlen(s);
    long long left=0,right=0;
    long long a[l+2];
    for(int i=0;i<l+2;i++){a[i]=0;}
    for(int i=0;i<l;i++){
        if(s[i]=='<'){
            a[i]=left;
            left++;
        }else{
            a[i]=left;
            a[i+1]=0;
            left=0;
        }
        if(i==l-1&&s[i]=='<'){
            a[i+1]=left;
        }
    }
    for(int i=l-1;i>=0;i--){
        if(s[i]=='>'){
            a[i+1]=right;
            right++;
        }else{
            a[i+1]=right>a[i+1]?right:a[i+1];
            right=0;
        }
        if(i==0&&s[i]=='>'){
            a[i]=right;
        }
    }
    long long ans=0;
    for(int i=0;i<=l;i++){
        ans+=a[i];
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 4608
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
	double n;
	while(cin >> n){
		if(n > 91.0){
			cout << "heavy" << endl;
		}else if(n > 81.0){
			cout << "light heavy" << endl;
		}else if(n > 75.0){
			cout << "middle" << endl;
		}else if(n > 69.0){
			cout << "light middle" << endl;
		}else if(n > 64.0){
			cout << "welter" << endl;
		}else if(n > 60.0){
			cout << "light welter" << endl;
		}else if(n > 57.0){
			cout << "light" << endl;
		}else if(n > 54.0){
			cout << "feather" << endl;
		}else if(n > 51.0){
			cout << "bantam" << endl;
		}else if(n > 48.0){
			cout << "fly" << endl;
		}else{
			cout << "light fly" << endl;
		}
	}
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		vvi d(n,vi(n,0));
		int x=n/2,y=n/2+1;
		rer(i,1,n*n){
			while(1){
				if(x<n && x>=0 && y<n && y>=0 && d[y][x]==0){
					d[y][x]=i; 
					break;
				}else if(x<n && x>=0 && y<n && y>=0 && d[y][x]){
					y++; x--;
				}
				if(x>=n) x-=n;
				if(x<0) x+=n;
				if(y>=n) y-=n;
			}
			x++; y++;
		}
		rep(i,0,n){
			rep(j,0,n){
				printf("%4d",d[i][j]);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans=0;
  
  for (int i=0;i<N;i++){
    int R,L;
    cin >> R>>L;
    ans +=L-R+1;
  }
  
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;

    int a[n];

    for (int i = 1; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (int i = n; i > 0; i--)
    {
        cout << a[i];
        if (i != 1)
        {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];


signed main(){
	IOS;
	string s;
	cin >> s;
	ll cnt = 0;
	REP(i,4)if(s[i] == '2')cnt++;
	dump(cnt);
}


Measured memory_bytes: 768
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

        int i = 1;
        while (true) {
            int x = scanner.nextInt();

            if (x == 0) break;

            System.out.println("Case " + i + ": " + x);
            ++i;
        }
    }
}


Measured memory_bytes: 40976