akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

int main() 
{

	int N;
	int A;
	char S[10010];
	int Len;

	scanf("%d", &N);
	scanf("%s", S);
	Len = strlen(S);

	for (int i = 0; i != Len; i++) {
		if (S[i] + N <= 90) {
			putchar(S[i] + N);
		}
		else {
			A = S[i] + N - 90;
			putchar(64 + A);
		}
	}


	return 0;
}

Measured memory_bytes: 128
using System;
class MainClass
{
    public static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int wk1 = 0;
        int wk2 = 0;
        int wk3 = 0;
        int ans = 0;

        if (a >= b) {
            if(a <=c){
                wk1 = c;
                wk2 = a;
                wk3 = b;
            }
            else{
                if(b >= c){
                    wk1 = a;
                    wk2 = b;
                    wk3 = c;
                }
                else{
                    wk1 = a;
                    wk2 = c;
                    wk3 = b;
                }

            }
        }
        else{
            if(a <= c)
            {
                wk1 = b;
                wk2 = c;
                wk3 = a;
            }
            else{
                if(b <= c){
                    wk1 = c;
                    wk2 = b;
                    wk3 = a;
                }
                else{
                    wk1 = b;
                    wk2 = a;
                    wk3 = c;
                }
            }

        }


        ans = wk1 * 10 + wk2 + wk3;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    while(true){
        int N,M;
        cin>>N>>M;
        if(N==0)break;
        int r;
        cin>>r;
        vector<int> t(r),n(r),m(r),s(r);
        for(int i=0;i<r;i++){
            cin>>t[i]>>n[i]>>m[i]>>s[i];
        }
        int q;
        cin>>q;
        vector<int> ts(q),te(q),qm(q);
        for(int i=0;i<q;i++){
            cin>>ts[i]>>te[i]>>qm[i];
        }
        for(int i=0;i<q;i++){
            int sum=0;
            int start=0;
            int PCnum=0;
            for(int j=0;j<r;j++){
                if(m[j]==qm[i]){
                    if(s[j]==1){
                        PCnum++;
                        if(PCnum==1)
                            start=t[j];
                    }else{
                        PCnum--;
                        if(PCnum==0)
                            sum+=max(0,min(t[j],te[i])-max(ts[i],start));
                    }
                }
            }
            cout<<sum<<endl;
        }
    }
}

Measured memory_bytes: 1208
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<complex>
#include<tuple>
using namespace std;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template<typename T>bool chmin(T& l, T r) {bool res = l > r;if (res)l = r;return res;}

#define IL inline
typedef double D;
typedef bool B;
typedef complex<D> P;
typedef pair<P, P> L;
typedef L LS;

#define X real()
#define Y imag()
const D EPS = 1e-10;
IL D dot(P a, P b) {
	return a.X*b.X + a.Y*b.Y;
}
IL D cross(P a, P b) {
	return a.X*b.Y - a.Y*b.X;
}
IL D signed_distance_P_L(P p,L l) {
	P a, b, c = p;
	tie(a, b) = l;
	return cross(b - a, c - a) / abs(b - a);
}
IL B isintersected_L_L(L p, L q) {
	P a, b, c, d;
	tie(a, b) = p;
	tie(c, d) = q;
	return abs(cross(a - b, c - d)) > EPS;
}
IL B isintersected_LS_LS(LS p, LS q) {
	P a, b, c, d;
	tie(a, b) = p;
	tie(c, d) = q;
	return cross(b - a, c - a)*cross(b - a, d - a) < EPS&&
		cross(d - c, a - c)*cross(d - c, b - c) < EPS;
}
IL P cross_point_L_L(L p, L q) {
	P a, b;
	tie(a, b) = p;
	D d1 = signed_distance_P_L(a, q);
	D d2 = signed_distance_P_L(b, q);
	return (a*d2 - b*d1) / (d2 - d1);
}
B check(P p, P q) {
	return (abs(p.X - q.X) > EPS&&abs(p.Y - q.Y) > EPS);
}
int main() {
	int n;
	while (cin >> n, n) {
		vector<LS> ls(n);
		REP(i, n) {
			int x, y, v, w;
			cin >> x >> y >> v >> w;
			ls[i] = LS(P(x, y), P(v, w));
		}
		int res = n + 1;
		vector<P> p;
		REP(i, n) REP(j,i){
			//if (isintersected_L_L(ls[i], ls[j]))cout << 114 ;
			//if (isintersected_LS_LS(ls[i], ls[j]))cout << 514 << endl;

			if (isintersected_L_L(ls[i], ls[j]) && isintersected_LS_LS(ls[i], ls[j]))
				p.push_back(cross_point_L_L(ls[i], ls[j]));
		}
		n = p.size();
		vector<int> cnt(n, 1);
		REP(i, n) {
			REP(j, i)if (abs(p[i] - p[j]) < EPS) {
				cnt[j] += cnt[i];
				cnt[i] = 0;
			}
		}
		REP(i, n) {
			int ans = 0;
			while (ans*(ans - 1) / 2 < cnt[i])ans++;
			if(ans&&check(p[i],P(100,100))&&check(p[i],P(-100,-100)))res += ans-1;
			//cout << p[i] << " " << ans << endl;
		}

		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define maxn 350
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
ll a[maxn],n,k,ans,r;
char s[maxn][maxn];
bool f;

int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%s",&s[i]);
    for (int i=0;i<n;i++)
    {
        f=true;
        for (int j=0;j<n;j++)
            for (int k=0;k<n;k++)
                if (s[(i+j)%n][k]!=s[(i+k)%n][j]) f=false;
        ans+=f;
    }
    cout << ans*n << endl;
    return 0;
}



Measured memory_bytes: 384
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		BigDecimal r = new BigDecimal(scan.nextDouble());
		scan.close();
		BigDecimal pi = new BigDecimal(Math.PI);
		BigDecimal area = r.multiply(r).multiply(pi);
		BigDecimal length = r.multiply(new BigDecimal(2)).multiply(pi);
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 19080
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


s = gc
mn = s.size
rep s.size-1 do |i|
  if s[i] != s[i+1]
    mn = min(mn, max(i+1, s.size-i-1))
  end
end

puts mn


Measured memory_bytes: 7676
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

//UnionFind
class UnionFind {
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<ll> Parent;
    
    UnionFind(ll N) {
        Parent = vector<ll>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    ll root(ll A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    ll size(ll A) {
        return -Parent[root(A)];
    }
    
    //AとBをくっ付ける
    void connect(ll A, ll B) {
        
        A = root(A);
        B = root(B);
        if (A == B) {
            
            return;
        }
        if (size(A) < size(B)) swap(A, B);
        
        Parent[A] += Parent[B];
        Parent[B] = A;
        
        return;
    }
};

int main(){
    
    ll m,n;
    vector<ll> ans;
    vector<pair<ll,ll>> p;
    
    cin >>n >> m;
    rep(i,m){
        ll a,b;
        cin >> a>>b;
        p.push_back(pair<ll,ll>(--a,--b));
    }
    
    reverse(all(p));
    
    UnionFind uni(n);
    ans.push_back(n*(n-1)/2);
    
    
    for(int i=0;i<m;i++){
        //cout << i<<' '<<p[i].first<<' '<<p[i].second<<endl;
        
        if(uni.root(p[i].first)!=uni.root(p[i].second)){
            ll asize = uni.size(p[i].first),bsize = uni.size(p[i].second);
            ans.push_back(ans[ans.size()-1]-asize*bsize);
        }else{
            ans.push_back(ans[ans.size()-1]);
        }
        uni.connect(p[i].first,p[i].second);
    }
    
    reverse(all(ans));
    
    rep(i,m){
        cout << ans[i+1]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 5488
import bisect

n, q = list(map(int, input().split()))
rws = [list(map(int, input().split())) for _ in range(n)]
ds = [int(input()) for _ in range(q)]

rws.sort(key = lambda x: x[2])

ans = [-1 for _ in range(q)]
nxt = [-1 for _ in range(q)]
for rw in rws:
	st = bisect.bisect_left(ds, rw[0] - rw[2])
	en = bisect.bisect_left(ds, rw[1] - rw[2])
	while st < en:
		if nxt[st] == -1:
			ans[st] = rw[2]
			nxt[st] = en
			st += 1
		else:
			st = nxt[st]

for a in ans:
	print(a)

Measured memory_bytes: 74232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

struct edge{
    int to;
    int d;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vvec<edge> g(N);
    for(int i=0;i<N-1;i++){
        int a,b,w;
        cin >> a >> b >> w;
        a--; b--;
        g[a].push_back({b,w});
        g[b].push_back({a,w});
    }
    vec<int> ans(N);
    auto dfs = [&](auto&& self,int cur,int par,int col)->void{
        ans[cur] = col;
        for(auto& e:g[cur]) if(e.to!=par){
            self(self,e.to,cur,e.d%2==0? col:1-col);
        }
    };
    dfs(dfs,0,-1,0);
    for(int i=0;i<N;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 7552
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
string s[105];
int main(){
		int n,m;
		cin >> n >> m;
		for(int i = 1;i <= n;i++){
			cin >> s[i];
			}
		sort(s+1,s+1+n);
		for(int i  = 1;i <= n;i++) cout << s[i];
		return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

int main(void) {
	int paperNum;
	cin >> paperNum;
	int maxCharNum = 50;
	vector<int> minChars('z' - 'a' + 1, maxCharNum);
	for (int _numOfPaper = 0; _numOfPaper < paperNum; _numOfPaper++) {
		vector<int> chars('z' - 'a' + 1, 0);
		string paper;
		cin >> paper;
		for (auto chr : paper) chars[chr - 'a']++;
		for (int numOfAlphabet = 0; numOfAlphabet < minChars.size(); numOfAlphabet++)
			minChars[numOfAlphabet] = min(chars[numOfAlphabet], minChars[numOfAlphabet]);
	}
	for (int numOfAlphabet = 0; numOfAlphabet < minChars.size(); numOfAlphabet++) {
		for (int count = 0; count < minChars[numOfAlphabet]; count++)
			cout << (char)(numOfAlphabet + 'a');
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll cnt[30];
int main(){
	string s;
	cin>>s;
	ll n=s.size();
	for(int i=0;i<n;i++){
		cnt[s[i]-'a']++;
	}
	ll ans=n*(n-1)/2+1;
	for(int i=0;i<26;i++)ans-=cnt[i]*(cnt[i]-1)/2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3728
//#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;



int main(){
    ll n,m;
    cin>>n>>m;
    //kado 4 hen 6 hoka 9
    if(n>m)swap(n,m);
    if(n>1 && m>1)cout<<(n-2)*(m-2);
    else if(n==1&&m==1)cout<<1;
    else cout<<(m-2);
    

    return 0;
}

Measured memory_bytes: 256
////////////////////////    W H I T E C L O U D    ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main()
{
    FAST();
    ll n,i,x,mod,ans,sum,cum[100004],rpt_elmnt,e,s,rpt_sum,baki,q,rem;
    map<ll,ll>mp;
    cin>>n>>x>>mod;
    cum[1]=sum=x;
    cum[0]=0;
    mp.insert({x,1});
    bool test=false;
    for(i=2; i<=1e5+4; i++)
    {
        if(i>n)break;
        x=(x*x)%mod;
        if(mp.count(x)==1)
        {
            test=true;
            s=mp[x];e=i-1;break;
        }
        mp.insert({x,i});
        sum+=x;
        cum[i]=sum;
    }
    rpt_sum=cum[e]-cum[s-1];
    rpt_elmnt=e-s+1;
    baki=n-e;
    q=baki/rpt_elmnt;
    rem=baki%rpt_elmnt;
    ans=sum;
    if(test)
    ans+=(q*rpt_sum)+cum[s+rem-1]-cum[s-1];
    cout<<ans<<endl;



    return 0;
}







Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
    set<int> s;
    int t;
    rep(i, 3) {
        cin >> t;
        s.insert(t);
    }
    bool f = s.size() == 2;
    Yn(f);
}


Measured memory_bytes: 256
import math
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)


S = readChar()

res = [0]*len(S)
res[-1]=int(S[-1])

d = defaultdict(int)

for i in range(2,len(S)+1):
	re = int(S[i*-1])*pow(10,i-1,2019)
	res[i*-1] = (res[i*-1+1]+re)%2019
	


for i in res:
	d[i]+=1

ans = d[0]
for key in d:
	if d[key]>1:
		ans+=comb(d[key],2)

print(ans)

Measured memory_bytes: 16684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 string s;
 cin >> s;
 if(s=="Sunny"){
     cout << "Cloudy" << endl;
 }else if(s=="Cloudy"){
     cout << "Rainy" << endl;
 }else{
     cout << "Sunny" << endl;
 }
return 0;
}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
p inp[0,2].inject(:*)/2

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string s;
    cin>>s;
    if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    if (a+b > c+d) {
        cout << "Left" << endl;
    } else if (a+b < c+d) {
        cout << "Right" << endl;
    } else if (a+b == c+d) {
        cout << "Balanced" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  if (a1+a2+a3 > 21) {
	    cout << "bust" << endl;
    } else {
    	cout << "win" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typpo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){//k!を求める関数
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所,分けてた方がデバッグしやすい気がする---------------------
intl n,m;
intl a,b,c,d;
string s,t;

void input_var(){
    cin >> s;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    if((s[s.length()-1] == '1')) t = "pon";
    if((s[s.length()-1] == '2'))t = "hon";
    if((s[s.length()-1] == '3'))t = "bon";
    if((s[s.length()-1] == '4'))t = "hon";
    if((s[s.length()-1] == '5'))t = "hon";
    if((s[s.length()-1] == '6'))t = "pon";
    if((s[s.length()-1] == '7'))t = "hon";
    if((s[s.length()-1] == '8'))t = "pon";
    if((s[s.length()-1] == '9'))t = "hon";
    if((s[s.length()-1] == '0'))t = "pon";
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << "ABC" << n <<  endl;
    
    return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n,k;
  cin >> n;
  int a[n] = {};
  int maxA = 0;
  priority_queue<int, vector<int>, greater<int> > queue;
  for(int i=0;i<n;i++){
    cin >> a[i];
    queue.push(a[i]);
    if(maxA<a[i]) maxA=a[i];
  }
  bool isMultiple[maxA+1] = {};
  int count = 0;
  int prevX = 0;
  bool isCounted = false;

  while(!queue.empty()){
    int x = queue.top();
    queue.pop();
    if(prevX == x && isCounted){
      count--;
    }
    prevX = x;
    int y = x;
    isCounted = false;
    while(y<=maxA){
      if(x==y&&!isMultiple[y]){
        count++;
        isCounted = true;
      }
      else if(x==y&&isMultiple[y]){
        break;
      }
   	  isMultiple[y] = true;
      y += x;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 5772
#include<iostream>
#include<string>
using namespace std;
int main() {
	int d;
	cin >> d;
	if (d == 25) {
		cout << "Christmas" << endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll a[555][555], dp[555][555];

void dfs(ll le, ll ri) {
  if (le > ri) {
	dp[le][ri] = 0;
	return;
  }
  ll num = a[le][ri];
  if (dp[le][ri - 1] == -1) dfs(le, ri - 1);
  num += dp[le][ri - 1];
  if (dp[le + 1][ri] == -1) dfs(le + 1, ri);
  num += dp[le + 1][ri];
  if (dp[le + 1][ri - 1] == -1) dfs(le + 1, ri - 1);
  num -= dp[le + 1][ri - 1];
  dp[le][ri] = num;
}

int main(void) {
  ll q;
  cin >> n >> m >> q;
  FOR(i, 1, n + 1) FOR(j, 1, n + 1) dp[i][j] = -1;
  rep(i, m) {
	ll le, ri;
	cin >> le >> ri;
	a[le][ri]++;
  }

  dfs(1, n);
  
  rep(i, q) {
	ll p, q;
	cin >> p >> q;
	cout << dp[p][q] << endl;
  }

  return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

int main()
{
    vector<int> ans = {1, 2, 3};
    int A, B;
    cin >> A;
    cin >> B;

    for (int i = 0; i < ans.size(); i++)
    {
        if (ans[i] == A || ans[i] == B)
            continue;
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
  	//"math"
    //"sort"
	//"strconv"
)
 
func main() {
  var N int
  fmt.Scanf("%d",&N)
  sli := make([]int,N)
  for i:=0;i<N;i++{
    	fmt.Scanf("%d",&sli[i])
   }
  
  sum:=0
  ans:=10000000000
    for P:=0;P<100;P++{
      for i:=0;i<N;i++{
        sum+=(P-sli[i])*(P-sli[i])
      }
      if ans>sum {
        ans=sum
      }
      sum=0
    }
  
  
  fmt.Print(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(k<=a)
    {
        cout<<k<<endl;
    }
    else
    {
        sum+=a;
        k=k-a;
        k=k-b;
        if(k>0)
        {
            sum=sum-k;
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline void read(int &x)
{
	x=0;int p=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')p=-p;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch-'0'),ch=getchar();
	x=x*p;
}
int n,a[100005],b[100005],cnt,head[100005],ans[100005];
bool cmp(const int &x,const int &y)
{
	return a[x]<a[y];
}
struct edge{int to,next;
}e[200005];
void add(int x,int y)
{
	e[cnt].to=y;
	e[cnt].next=head[x];
	head[x]=cnt++;
}
int main()
{
	read(n);cnt=1;
	for(int i=1;i<=n;++i)read(a[i]),b[i]=i;
	for(int i=1;i<n;++i)
	{
		int x,y;read(x);read(y);add(x,y);add(y,x);
	}
	sort(b+1,b+n+1,cmp);memset(ans,-1,sizeof(ans));
	for(int x=1;x<=n;++x)
	{
		int u=b[x];
		for(int i=head[u];i;i=e[i].next)
		{
			if(ans[e[i].to]==0&&a[e[i].to]<a[u])ans[u]=1;
		}
		if(ans[u]!=1)ans[u]=0;
	}
	for(int i=1;i<=n;++i)if(ans[i])printf("%d ",i);
}

Measured memory_bytes: 768
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    def find(self, x):
        """
        親が同じか判別する
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        yをxの根に繋ぐ
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """
        xとyが同じ連結成分か判別する
        """
        return self.find(x) == self.find(y)

    def size(self, x):
        """
        xの連結成分の大きさを返す
        """
        return -self.parents[self.find(x)]

    def kruskal(self, edge):
        """
        :param edge: edge = [(コスト, 頂点1, 頂点2),...]の形で重み付き隣接リストを渡して下さい
        :return: 最小全域木のコストの和
        """
        edge.sort()
        cost_sum = 0
        for cost, node1, node2 in edge:
            if not self.same(node1, node2):
                cost_sum += cost
                self.union(node1, node2)
        return cost_sum


def resolve():
    n, q = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(q):
        com, x, y = map(int, input().split())
        if com == 0:
            uf.union(x, y)
        else:
            print(1 if uf.same(x, y) else 0)


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6440
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    priority_queue<int> que[n];
    for(int i = 0; i < q; i++)
    {
        int v, t, x;
        cin >> v >> t;
        if(v == 0)
        {
            cin >> x;
            que[t].push(x);
        }
        else if(v == 1)
        {
            if(que[t].size() != 0) cout << que[t].top() << endl;
        }
        else if(v == 2)
        {
            if(que[t].size() != 0) que[t].pop();
        }
    }
    return 0;
}




Measured memory_bytes: 4088
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
      	int cnt = 0;
      	for(int i=0; i<S.length(); i++){
          	int num = S.charAt(i) - '0' ;
        	if (i%2 == num) cnt++;
        }
      	System.out.println(Math.min(cnt,S.length()-cnt));
    }
}

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

int main(){
  long long N,ans,c,d;
  cin>>N;
  if(N%2==1){
    cout<<0<<endl;
  }
  else{
    ans=0;
    for(c=5;c*2<=N;c*=5){
      ans+=N/(c*2);
    }

    cout<<ans<<endl;
    }
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int x,y;
  cin >> x >> y;
  vector<int> aaa = {1,2,1,3,1,3,1,1,3,1,3,1};
  if(aaa.at(x-1) == aaa.at(y-1)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	long long s[111] = { 0 }, a[111][111], b[111];
	int i, k, n, m;
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		for (k = 0; k < m; k++) {
			scanf("%lld", &a[i][k]);
		}
	}
	for (k = 0; k < m; k++) {
		scanf("%lld", &b[k]);
	}
	for (i = 0; i < n; i++) {
		for (k = 0; k < m; k++) {
			s[i] += a[i][k] * b[k];
		}
	}
	for (i = 0; i < n; i++) {
		printf("%lld\n", s[i]);
	}
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const ll INF = 0x3f3f3f3f3f3f3f3f;

int main() {
    int n, k; cin >> n >> k;
    vi p(n + 1), c(n + 1);
    FOR(i, 1, n) cin >> p[i];
    FOR(i, 1, n) cin >> c[i];
    ll ans = -INF;
    FOR(i, 1, n) {
        vll cyc(1);
        ll sum = 0, mx = -INF;
        int cur = i;
        do {
            cur = p[cur];
            sum += c[cur], mx = max(sum, mx);
            if (sz(cyc) == 1) cyc.pb(sum);
            else cyc.pb(max(cyc[sz(cyc) - 1], sum));
        } while (cur != i);
        int len = sz(cyc) - 1;
        // cerr << len << ' ' << sum << endl;
        if (k >= 2 * len) ans = max(ans, sum * (k / len - 1) + cyc[len]);
        if (k >= len) ans = max(ans, sum * (k / len) + cyc[k % len]);
        ans = max(ans, cyc[min(len, k)]);
    }
    cout << ans << endl;
}

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

#define jaldi ios_base::sync_with_stdio(false)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define mod 1000000007

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}

ll root(ll a,vll &head)
{
    while(a!=head[a])
    {
        head[a]=head[head[a]];
        a=head[a];
    }
    return a;
}

void merge(ll a,ll b,vll &head, vll &size)
{
    ll p_a = root(a,head);
    ll p_b = root(b,head);
    if(p_a==p_b)
        return;
    
    if(size[p_a]>size[p_b])
    {
        size[p_a]+=size[p_b];
        head[p_b]=head[p_a];
    }
    else
    {
        size[p_b]+=size[p_a];
        head[p_a]=head[p_b];
    }
    
}

int main()
{
    jaldi;
    precision(20);
    ll i,j;

    string s,t;
    cin>>s>>t;
    ll f=0;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            f=1;
    }
    if(f==1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 3608
s = input()
array = []

for char in s:
    if char == "S":
        array.append(char)
    elif char == "T":
        if len(array) == 0:
            array.append(char)
        elif array[-1] == "S":
            array.pop()
        else:
            array.append(char)
print(len(array))

Measured memory_bytes: 5096
#include<bits/stdc++.h>
#include<thread>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define show(x, y); cout << x << " " << y << endl;
using namespace std;

int n;
vector<int> g[100001];

pair<ll,ll> dfs(int u, int p){
    ll x = 1, y = 1;
    for(auto v : g[u]){
        if(v != p){
            pair<ll,ll> smallAns = dfs(v, u);
            x = (x * (smallAns.first + smallAns.second)) % mod;
            y = (y * smallAns.first) % mod;
        }
    }
    return {x, y};
}

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

    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    pair<ll,ll> p = dfs(1,1);
    cout << (p.first + p.second) % mod;
    return 0;
}


Measured memory_bytes: 12672
n, m = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
a.sort()
a.reverse()
for i in a:
    if i >= sum(a) / (4 * m):
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")
    exit()

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
    char a[11],b[11],c[11];
    scanf("%s %s %s",a,b,c);
    char init[4]={a[0],b[0],c[0]};
    char ans[4];
    for(int i=0;i<=strlen(init);i++){
        ans[i]=toupper(init[i]);
//      printf("%s\n",init[i]);
    }
    printf("%s\n",ans);
    return 0;

}

Measured memory_bytes: 128
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    k, s = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    for x in range(k+1):
        if x == s:
            cnt += 1
            break
        for y in range(k+1):
            c = s - (x + y)
            if c <= k and c >= 0:
                cnt += 1

#            for z in range(k+1):
 #               if x + y + z == s:
  #                  cnt += 1
   #                 break
    print(cnt)

resolve()

Measured memory_bytes: 43868
import java.util.*;
 
public class Main{
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
    	int num = sc.nextInt();
        long number[] = new long[num];
        long mul = 1;
        for(int i = 0; i < num; i++){
        	number[i] = sc.nextLong();
            if(number[i] == 0){
            	mul = 0;
            }
        }
        if(mul != 0){
        	for(int i = 0; i < num; i++){
          		if(number[i] <= (long)Math.pow(10,18)/mul){
        			mul = mul * number[i];
          		}else{
          			mul = -1;
                    break;
                }
          	}
        }
        System.out.println(mul);
	}
}

Measured memory_bytes: 62160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = (sc.nextInt()*100 + sc.nextInt()*10 + sc.nextInt());
		if(n % 4 == 0 ) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int mvx[] = {1, 0, 0, -1};
int mvy[] = {0, 1, -1, 0};

//union find
struct UnionFind {
    vector<ll> parent;
    vector<ll> usize;
 
    UnionFind(int n) : parent(n), usize(n, 1LL){
        rep(i, n)parent[i]=i;
    }
    
    int root(int x){
        if(parent[x] == x) return x;
        else return parent[x] = root(parent[x]);
    }
    
    bool issame(int x, int y){
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
 
        if(x == y)return false;
 
        if(parent[x] > parent[y]) swap(x, y);

        usize[x] += usize[y];
        parent[y] = x;
 
        return true;
    }
    
    int size(int x) {
        return usize[root(x)];
    }
};

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

    UnionFind uf(n);

    rep(i, m){
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;

        uf.merge(x, y);
    }

    set<ll> ans;
    rep(i, n){
        ans.insert(uf.root(i));
    }

    cout << ans.size() << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
	ll n, m;
	cin >> n >> m;
	ll scc = 0;
	ll sm = m / 2;
	ll s = min(sm, n);
	scc += s;
	m -= s * 2;
	scc += m / 4;
	cout << scc << endl;
	return 0;
}


Measured memory_bytes: 3612
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()

cnter=Counter(s)

ans=float('inf')
for a in al:
    if cnter[a]==0:
        continue
    tmp=s[:]
    cnt=0
    while 1:
        flag=1
        for i in range(len(tmp)):
            if a!=tmp[i]:
                flag=0
        if flag==1:
            break
        tmp1=""
        for i in range(len(tmp)-1):
            if tmp[i]==a or tmp[i+1]==a:
                tmp1+=a
            else:
                tmp1+=tmp[i]
        cnt+=1
        tmp=tmp1[:]
    ans=min(ans,cnt)
print(ans)

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  int d, t, s;
  cin >> d >> t >> s;
  if ((d + s - 1) / s <= t) 
    cout << "Yes";
  else 
    cout << "No";
}

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

int main(){
	string S;
	cin>>S;
  int N=S.size();
  vector<int> str(0);
  
  for(int i=0;i<N;i++){
  	if(S.at(i)=='0')
      str.push_back(0);
    else if(S.at(i)=='1')
      str.push_back(1);
    else{
    	if(str.size()>0)
          str.pop_back();
    }
  }
  for(int i=0;i<str.size();i++)
    cout<<str.at(i);
  cout<<endl;
}

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

class E
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1];
		Console.WriteLine(Totients(k).Select((x, i) => i == 0 ? 0 : x * ((MInt)(k / i)).Pow(n)).Aggregate((x, y) => x + y));
	}

	static int[] Totients(int n)
	{
		var r = new int[n + 1];
		for (int x = 1; x <= n; ++x) r[x] = x;
		var b = new bool[n + 1];
		for (int p = 2; p <= n; ++p)
			if (!b[p])
				for (int x = p; x <= n; x += p)
				{
					r[x] = r[x] / p * (p - 1);
					b[x] = true;
				}
		return r;
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;

	public MInt Pow(int i) => MPow(V, i);
	public override string ToString() => $"{V}";

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 19060
/*
 * itp08_c.cpp
 *
 *  Created on: 2013/06/09
 *      Author: nakataninaoki
 */
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {

	string line;
	int count[26];
	char c;

	for (int i = 0; i < 26; ++i) {
		count[i] = 0;
	}

	while (cin >> line) {
		for (int i = 0; (int) i < line.size(); ++i) {
			c = line.at(i);
			if (c >= 'A' && c <= 'Z') {
				count[c - 'A']++;
			} else if (c >= 'a' && c <= 'z') {
				count[c - 'a']++;
			}
		}
	}

	for (int i = 0; i < 26; ++i) {
		printf("%c : %d\n", i + 'a', count[i]);
	}

	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>
 
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
 
ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222
 
 
struct BinaryIndexed {
	ll num;
	vll bit;
 
	BinaryIndexed(ll x = MAX) {
		num = x;
		bit.resize(x + 1, 0);
	}
 
	ll sum(ll i) {
		ll ret = 0;
		while (i > 0) {
			ret += bit[i];
			i -= i & -i;
		}
		return ret;
	}
 
	void add(ll i, ll x) {
		if (i == 0) cout << "access 0 index" << endl;
		while (i <= num) {
			bit[i] += x;
			i += i & -i;
		}
	}
};
 
ll a[MAX], b[MAX];
 
int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
 
	cin >> n >> m;
	FOR(i, 1, n + 1) {
		cin >> a[i];
	}
	FOR(i, 1, n + 1) b[i] = b[i - 1] + a[i];
	FOR(i, 1, n + 1) b[i] = i * m - b[i];
	vll v;
	FOR(i, 1, n + 1) v.pb(b[i]);
	sort(all(v));
	MAP comp;
	rep(i, n) comp[v[i]] = i + 1;
	BinaryIndexed bit;
	FOR(i, 1, n + 1) {
		if (comp[b[i]] > 1) ans += (i - 1) - bit.sum(comp[b[i]] - 1);
		else ans += i - 1;
		if (b[i] <= 0) ans++;
		bit.add(comp[b[i]], 1);
	}
	cout << ans << endl;
 
 
	return 0;
}

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

int main(){
	int N;
	string s, t;
	cin >> N >> s >> t;
	int count = 0;
	rep(i, N) {
		if (s.substr(0 + i, N - i) == t.substr(0, N - i)) {
			count = N - i;
			break;
		}
	}
	cout << 2 * N - count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string s;
	cin>>s;
	int ans = 0;
	int n = s.size();
	set<char> g = {'A','C','G','T'};
	for (int i = 0; i < n; i++){
		for (int j = i; j < n; j++){
			for (int k = i; k <= j; k++){
				if(g.find(s[k])==g.end()) break;
				if(k==j) ans = max(ans,j-i+1);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
ans = Array.new(10**4+1, 0)
(1..100).each{|i|
  (1..100).each{|j|
    (1..100).each{|k|
      sum = i**2 + j**2 + k**2 + i*j + j*k + k*i
      ans[sum] += 1 if sum <= 10**4
    }
  }
}

puts ans[1, gets.to_i]


Measured memory_bytes: 14236