akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    char c;
    cin >> c;
    if(c <= 'Z')P('A');
    else P('a');
    
    return  0;
}


Measured memory_bytes: 3580
n = int(input())
A = list(map(int,input().split()))
balls = {}
for a in A:
  if a in balls:
    balls[a]+=1
  else:
    balls[a] = 1
ans = 0
for a in balls:
  ans += balls[a]*(balls[a]-1)//2

for i in range(n):
  ball = A[i]
  count = balls[ball]
  print(ans - count*(count-1)//2 + (count-1)*(count-2)//2)

Measured memory_bytes: 25716
import java.util.Scanner;
public class Main {
    public static void main(String[] $) {
       Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       int b = sc.nextInt();
       int C = sc.nextInt();
       double Cc = C * Math.PI /180;
       System.out.println(b * Math.sin(Cc) * a /2);
       System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Cc)) + a + b);
       System.out.println(b * Math.sin(Cc));
    }
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int h, a;
    scanf("%d %d", &h, &a);
    printf("%d", (h+a-1)/a);

    return 0;
}

Measured memory_bytes: 128
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  when (n /= (-1)) $ do
    print $ solve n
    main
    
solve :: Int -> Double
solve n = thirdroot (fromIntegral n) (fromIntegral n / 2.0)

recform :: Double -> Double -> Double
recform q x = x - (x * x * x - q) / (3 * x * x)

thirdroot :: Double -> Double -> Double
thirdroot q x
  | abs (nx ^ 3 - q) < 0.00001 * q = nx
  | otherwise = thirdroot q nx
  where
    nx = recform q x

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4208
while 1:
    n, m = map(int, input().split())
    if n == 0:
        break

    masu = []
    for _ in range(n):
        x = int(input())
        masu.append(x)

    dice = []
    for _ in range(m):
        x = int(input())
        dice.append(x)

    p = 0
    for i, d in enumerate(dice):
        p += d
        if p >= n:
            break
        p += masu[p]
        if p >= n:
            break

    print(i+1)



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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

//素数ならtrue
bool prime[10000010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  memset(prime, true, sizeof(prime));
  int cnt = 0;
  prime[0] = prime[1] = false;
  for (int i = 2; i <= 10000000; i++) {
    if (prime[i]) {
      cnt++;
      for (int j = 2 * i; j <= 10000000; j += i) {
        prime[j] = false;
      }
    }
  }

  int ret = 0;
  FOR(i, 3, n+1) {
    if(prime[i] && prime[i+2]) {
      // cout << i << " " << i+2 << endl;
      ret += 2;
    }
  }
  cout << ret << endl;

  return 0;
}



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

int main()
{
  string o,e;
  cin>>o>>e;
  register int ol,el;
  ol = o.length();
  el = e.length();
  if(ol>=el)
  {
    for(int i=0;i<ol;i++)
    {
      cout<<o[i];
      if(i<el)
        cout<<e[i];
    }
  }
  else
  for(int i=0;i<el;i++)
  {

    if(i<ol)
      cout<<o[i];
      cout<<e[i];
  }
  cout<<"\n";

  return 0;
}


Measured memory_bytes: 256
n = int(input())
ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
ci = list(map(int, input().split()))

#print(ai)
#print(bi)
#print(ci)

ans = 0
for i in range(n):
    t = ai[i]
    ans = ans+bi[t-1]
    if i >= 1 and ai[i-1]+1 == t:
        ans = ans + ci[ai[i-1]-1]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 300005
const int B=11;
int v[N],w[N],n,tot;
int dep[N];
map<int,int> f[2048];
map<int,int> tmp;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++) v[i]=read(),w[i]=read();
	dep[1]=1; for(int i=2;i<=n;i++) dep[i]=dep[i/2]+1;
	for(int i=1;i<=n;i++)
	{
		if(dep[i]<=B)
		{
			f[i]=f[i/2];
			for(auto [x,y]:f[i/2])
			{
				if(x+w[i]<=100000) f[i][x+w[i]]=max(f[i][x+w[i]],y+v[i]);
			}
			f[i][w[i]]=max(f[i][w[i]],v[i]);
			int cur=0; vector<map<int,int>::iterator> v;
			for(auto j=f[i].begin();j!=f[i].end();++j)
			{
				cur=max(cur,(*j).sec);
				if((*j).sec!=cur) v.pb(j);
			}
			for(auto j:v) f[i].erase(j);
		}
	}
	// for(int i=1;i<=n;i++)
	// {
		// if(dep[i]>B) break;
		// cout<<i<<" :\n";
		// for(auto [x,y]:f[i]) printf("%d %d\n",x,y);
	// }
	int Q=read();
	while(Q--)
	{
		int u=read(),L=read();
		int r=dep[u];
		if(r<B)
		{
			auto x=f[u].upper_bound(L);
			if(x==f[u].begin()) printf("0\n");	
			else x--,printf("%d\n",(*x).sec);
		}
		else
		{
			// map<int,int> res; res.clear();
			int fa=u;
			while(dep[fa]>B) fa/=2;
			vector<pii> t;
			int tmp=u;
			while(tmp!=fa)
			{
				t.eb(v[tmp],w[tmp]);
				// map<int,int> qaq=res;
				// for(auto [x,y]:res)
				// {
					// if(x+w[tmp]<=100000) qaq[x+w[tmp]]=max(qaq[x+w[tmp]],y+v[tmp]);
				// }
				// qaq[w[tmp]]=max(qaq[w[tmp]],v[tmp]);
				// res=qaq;
				// int cur=0; vector<map<int,int>::iterator> v;
				// for(auto j=res.begin();j!=res.end();++j)
				// {
					// cur=max(cur,(*j).sec);
					// if((*j).sec!=cur) v.pb(j);
				// }
				// for(auto j:v) res.erase(j);
				tmp/=2;
			}
			// for(auto [x,y]:f[fa]) printf("%d %d\n",x,y); cout<<"\n";
			// for(auto [x,y]:res) printf("%d %d\n",x,y); cout<<"\n";
			int ans=0;
			auto x=f[fa].upper_bound(L);
			if(x==f[fa].begin()) ans=0;
			else x--,ans=(*x).sec;
			for(int i=0;i<(1<<(int)t.size());i++)
			{
				int x=0,y=0;
				for(int j=0;j<(int)t.size();j++)
				{
					if(i&(1<<j)) x+=t[j].sec,y+=t[j].fir;
				}
				int ned=L-x;
				if(ned<0) continue;
				auto rr=f[fa].upper_bound(ned);
				if(rr==f[fa].begin()) ans=max(ans,y);
				else rr--,ans=max(ans,y+(*rr).sec);
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}




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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  if (n%2) printf("%d", n/2);
  else printf("%d", n/2-1);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

using namespace std;

int main() {
  int64_t H, N;
  cin >> H >> N;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    H -= A;
  }

  if (H <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,a,b,c=0,f=0,i; 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    if(a==b){
      c++;
    }
    else{
      c=0;
    }
    if(c>=3){
      f=1;
    }
  }
  if(f==1){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1660
import sys
import numpy as np

input = sys.stdin.readline
n = int(input())
h_arr = np.array(list(map(int, input().split())))
ans = 0
h_min = min(h_arr)
if h_min > 0:
    h_arr -= h_min
    ans += h_min
while True:
    s = 0
    tmp = 0
    for i in range(n):
        if i == n-1:
            if h_arr[i] > 0:
                h_min = min(h_arr[s:])
                tmp += h_min
                h_arr[s:] = h_arr[s:] - h_min
            elif s < i:
                h_min = min(h_arr[s:i])
                tmp += h_min
                h_arr[s:i] = h_arr[s:i] - h_min
        elif h_arr[i] == 0:
            if s == i:
                s += 1
            else:
                h_min = min(h_arr[s:i])
                tmp += h_min
                h_arr[s:i] = h_arr[s:i] - h_min
                s = i + 1
    if tmp == 0:
        break
    else:
        ans += tmp
print(ans)


Measured memory_bytes: 21408
import collections
s = input()
s = collections.Counter(s).most_common()
t = input()
t = collections.Counter(t).most_common()
if len(s) == len(t):
    for i in range(len(s)):
        if s[i][1] != t[i][1]:
            print("No")
            exit()
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3880
#define _CRT_SECURE_NO_DEPRECATE

#include<iostream>
#include<cstdio>
#include<string>
//#include<vector>
//#include<stack>

using namespace std;

int main() {
	string str; cin >> str;
	//stack<int, vector<int>> S;
	int sz = str.size(); int len = 0, p = 0;
	for (int i = 0; i < sz; i++) {
		if (str[i] == 'S') len++;
		else if (len > 0) { len--; p++; }
	}
	printf("%d\n", sz - 2 * p);
}

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

int main(){
	string s;cin>>s;
	string u=s;reverse(u.begin(),u.end());
	for(char&c:u){
		if(c=='(')c=')';
		else if(c==')')c='(';
	}
	int cnt=0;
	rep(i,(int)s.size()/2+(int)s.size()%2){
		if(s[i]!=u[i])cnt++;
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 3312
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}
signed main(){
  vi a(5);
  rep(i,5)cin >> a[i];
  sort(all(a));
  int k;
  cin >> k;
  if(a.back()-a.front() > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, a[22], x[22][22], y[22][22];
int main(){
    cin>>n;
    for(int i = 1;i <= n; i++){
        cin>>a[i];
        for(int j = 1;j <= a[i]; j++){
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans = 0;
    for(int i = 0;i < 1 << n; i++){
        int sum = 0, fl = 1;
        for(int j = 0;j < n; j++){
            if(i >> j & 1){
                sum++;
                for(int k = 1;k <= a[j+1]; k++){
                    int ck = i >> (x[j+1][k] - 1) & 1;
                    if(ck != y[j+1][k]){
                        fl = 0;
                        break;
                    }
                }
                if(!fl)break;
            }
        }
        if(fl)ans = max(ans, sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
S = N.times.map { gets.chomp }

ans = 0

S.each do |s|
  l = s.size

  0.upto(l - 2) do |i|
    ans += 1 if s[i..(i + 1)] == 'AB'
  end
end

acnt = S.count { |s| s[-1] == 'A' && s[0] != 'B' }
bcnt = S.count { |s| s[0] == 'B' && s[-1] != 'A' }
ccnt = S.count { |s| s[0] == 'B' && s[-1] == 'A' }

cnt = [0, ccnt - 1].max
ans += cnt
ccnt -= cnt

if ccnt > 0
  if acnt > 0
    ans += 1
    acnt -= 1
  end

  if bcnt > 0
    ans += 1
    bcnt -= 1
  end

  ans += [acnt, bcnt].min
else
  ans += [acnt, bcnt].min
end

puts ans


Measured memory_bytes: 2812
n = int(input())
a = []
max1 = 0
max2 = 0
for i in range(n):
    j = int(input())
    a.append(j)
    if j > max1:
        max2 = max1
        max1 = j
    elif j > max2:
        max2 = j
for i in a:
    print(max1 if i != max1 else max2)


Measured memory_bytes: 12532
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)


int main(){
	int N,a,b;
	long long K;
	long long num[100011] = {0};

	scanf("%d",&N);
	scanf("%lld",&K);

	REP(N){
		scanf("%d",&a);
		scanf("%d",&b);
		num[a] += b;
	}

	REP(100011){
		K -= num[i];
		if(K<=0){
			printf("%d\n",i);
			return 0;
		}

	}
	return 0;
	
}

Measured memory_bytes: 896
#include <stdio.h>
int main(void){
	long long q,p,n,l,r;
	char c;
	scanf("%d",&q);
	l=r=0;
	while(q--){
		scanf("%lld %c %lld",&p,&c,&n);
		if(c=='('){
			l+=n;
		}
		else{
			r+=n;
		}
		printf("%s\n",l==r?"Yes":"No");
	}
	return 0;
}

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

int main()
{
    string s;
    ll k;
    cin >> s;
    cin >> k;

    char ans = 'A';
    for(int i = 0; i < min((ll)s.size(), k); i++)
    {
        if (s[i] != '1')
        {
            ans = s[i];
            break;
        }
    }

    if (ans == 'A')
        cout <<  (s.size() < k ? ' ' : '1') << endl;
    else
        cout << ans << endl;
    // cout << s << endl;

    return 0;
}

Measured memory_bytes: 384
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n");
var yx=Arr.shift();
var ans=[];
Arr.forEach(function(v,index){
   ans[index]=[];
   var arr=v.split("");
   var t=-1;
   for(var i=0;i<arr.length;i++){
      if(arr[i]=="c"){ans[index].push(0);t=1;}
      else if(arr[i]=="." && t==-1)ans[index].push(t);
      else if(arr[i]=="." && t!=-1){ans[index].push(t);t++;}
   }
});
console.log(ans.join("\n").replace(/\,/g," "));

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

vector<vector<long long> > ans;
long long eraseOverlapIntervals(vector<vector<long long>>& intervals) {
        long long ret = 0;
        std::sort(intervals.begin(), intervals.end(),
                  [](vector<long long> a, vector<long long> b) {
                      return a[0] < b[0];
                  });

        for (int i = 0; i < intervals.size(); i++) {
            if (ans.empty() || ans[ans.size()-1][1] <= intervals[i][0]) {
                ans.push_back(intervals[i]);
            } else { //overlap
			    // Greedy: make sure the last node of ans has the samllest left value
                if (ans[ans.size()-1][1] > intervals[i][1]) {
                    ans.pop_back();
                    ans.push_back(intervals[i]);
                }
                ret++;
            }
        }
        return ret;
    }

int main()
{
    long long n;
    cin>>n;
    long long a[n],b[n],ans=0;
    vector<vector<long long> > v;
    for(int i=0; i<n; i++)
    {
        cin>>a[i]>>b[i]; 
        vector<long long> z;
        z.push_back(a[i]-b[i]);
        z.push_back(a[i]+b[i]);
        v.push_back(z);
    }
    cout<<n-eraseOverlapIntervals(v)<<endl;
    return 0;
}


Measured memory_bytes: 13616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
typedef long long LL;

int main()
{
	LL n, A, B;
	while (~scanf("%lld%lld%lld", &n, &A, &B)) {
		if (B < A) printf("0\n");
			else if (n == 1 && A != B) printf("0\n");
				else printf("%lld\n", B * (n - 1) + A - (A * (n - 1) + B) + 1);
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	vector<long long> a, b;
	int n;
	int i, j;
	long long input;
	long long cnt = 0;

	scanf("%d", &n);

	for (i = 0; i < n + 1; i++)
	{
		scanf("%lld", &input);

		a.push_back(input);
	}

	for (i = 0; i < n; i++)
	{
		scanf("%lld", &input);

		b.push_back(input);
	}

	for (i = 0; i < n; i++)
	{
		if (a[i] >= b[i])
		{
			cnt += b[i];

			a[i] -= b[i];
		}

		else
		{
			cnt += a[i];

			b[i] -= a[i];

			cnt += b[i] < a[i + 1] ? b[i] : a[i + 1];

			a[i + 1] = b[i] > a[i + 1] ? 0 : a[i + 1] - b[i];
		}
	}

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


Measured memory_bytes: 2548
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var s string
	fmt.Scanf("%s", &s)

	rot := []rune{}
	for _, b := range s {
		c := (b-65+rune(n))%26 + 65
		rot = append(rot, c)
	}
	fmt.Println(string(rot))
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


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

long long dp[52][2600];
int main() {
    string s;
    cin >> s;
    int n = s.size();
    long long ans = 0;
    for (int i = 0; i < (1 << (n - 1)); ++i) {
        long long sum = 0, a = s[0] - '0';
        for (int j = 0; j < n - 1; ++j) {
            if ((i >> j) & 1) {
                sum += a;
                a = s[j + 1] - '0';
            }
            else {
                a = a * 10 + s[j + 1] - '0';
            }
        }
        sum += a;
        ans += sum;
    }
    cout << ans << "\n";
    return 0;
}


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

int main()
{
  ll x, n; cin >> x >> n;
  ll bucket[101] = {0};

  rep(i, n) {
    ll tmp;cin>>tmp;
    bucket[tmp] = 1;
  }

  if (bucket[x] == 0) {
    cout << x << endl;
    return 0;
  }

  int left = x;
  int right = x;
  while (true) {
    left ++;
    right --;
    if(bucket[right] != 1 && bucket[left] != 1) {
      cout << right << endl;
      return 0;
    } else if(bucket[right] != 1) {
      cout << right << endl;
      return 0;
    } else if(bucket[left] != 1) {
      cout << left << endl;
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

int dp[101][100001];
int sum[100001];

const int mod = 1e9 + 7;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	dp[0][k] = 1;
	for (int i = 0; i < n; i++)
	{
		memset(sum, 0, sizeof(sum));
		sum[0] = dp[i][0];
		for (int j = 1; j <= 100000; j++)
			sum[j] = (sum[j - 1] + dp[i][j]) % mod;
		for (int j = 0; j <= k; j++)
			dp[i + 1][j] = (sum[min(k, j + a[i])] - (j == 0 ? 0 : sum[j - 1]) + mod) % mod;
	}
	cout << dp[n][0] % mod << endl;

	return 0;
}


Measured memory_bytes: 39680
def ketanowa(p):
    ans = 0
    p = str(p)
    for i in p:
        ans += int(i)
    return ans


def main():
    s = input()
    temp1 = input()
    temp1=int(temp1)
    ans=""
    # print(len(s))
    for i in range(0,len(s),temp1):
        # print(s[i])
        ans+=s[i] 
    print(ans)   

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
template <typename Domain, typename Range, typename Function>
Domain tsearch(Domain L, Domain R, const Function& f, bool concave_up = true) {
#ifdef DEBUG
    using actual_type = typename callable_traits<Function>::function_type;
    using expected_type = typename callable_traits<Range(Domain)>::function_type;
    static_assert(is_same<actual_type, expected_type>::value, "tsearch 'f' must be Range(Domain)");
#endif
    while(R - L > 1) {
        Domain M = (L + R) / 2;
        ((concave_up ? f(M) < f(M + 1) : f(M) > f(M + 1)) ? R : L) = M;
    }
    return (concave_up ? f(L) < f(R) : f(L) > f(R)) ? L : R;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= (i + 1);
    }
    auto foo = [&](int x) {
        ll val = 0;
        for(int i = 0; i < n; i++) {
            val += abs(a[i] - x);
        }
        return val;
    };
    int x = tsearch<int, ll>(-1'000'000'000, 1'000'000'000, foo);
    cout << foo(x) << endl;
    return 0;
}


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

vector<int> adata(4000);
int N;
vector<int> tmpg(4000);

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

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

	cout << ans << endl;

	return 0;
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int a,b;

int main(){
  cin >> a>>b;
  int c = b-a-1;
  cout << c*(c+1)/2-a<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >> N >> M;
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  stack<int> st;
  int pos = 0;
  while(1){
    if(pos == N) break;
    bool did = false;
    for(int i=min(N,pos+M); i>pos; i--){
      if(S[i] == '0'){
        st.push(i-pos);
        did = true;
        pos = i;
        break;
      }
    }
    if(!did){
      cout << -1 << endl;
      return 0;
    }
  }
  while(st.size()){
    cout << st.top() << " ";
    st.pop();
  }
  cout << endl;
  return 0;
}


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


int main(){

  ll N;
  cin>>N;
  
  int count=0;
  rep(i,N+1){
    if(i==0)continue;

    string s=to_string(i);
    
    if(s.length()%2==1)count++;
    
  }
  
  cout<<count<<endl;
}


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

int main(){
    string str;
    cin >> str;
    
    ll top = 1;
    ll tail = str.size();

    bool flag = true;
    while(top<=tail){
        if(str[top-1]!=str[tail-1]){
                flag = false;
                break;
        }
        top++;
        tail--;
    }
    top = 1;
    tail = (str.size()-1)/2;
    while(top<=tail){
        if(str[top-1]!=str[tail-1]){
            flag = false;
            break;
        }
        top++;
        tail--;
    }
    top = (str.size()+3)/2;
    tail = str.size();
    while(top<=tail){
        if(str[top-1]!=str[tail-1]){
            flag = false;
            break;
        }
        top++;
        tail--;
    }
    if(flag)    cout << "Yes";
    else    cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
bool p[10000];
int main(){
	int n,c;
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];
	r(i,n)p[a[i]]=true;
	if(n>1)r(i,n-1){
		int s=a[i]*10+a[i+1];
		p[s]=true;
	}
	if(n>2)r(i,n-2){
		int s=a[i]*100+a[i+1]*10+a[i+2];
		p[s]=true;
	}
	if(n>3)r(i,n-3){
		int s=a[i]*1000+a[i+1]*100+a[i+2]*10+a[i+3];
		p[s]=true;
	}c=0;
	while(p[c])c++;
	cout<<c<<endl;
}

Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] n = String.valueOf(N).toCharArray();
        boolean flag = false;
        for(int i=0;i<n.length;i++){
            if(n[i] == '7'){
                flag = true;
                break;
            }
        }
        System.out.println(flag ? "Yes" : "No");
    }
}


Measured memory_bytes: 27088
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const ll INF = 1e13;
int N;
ll a[410];
ll dp[410][410];
ll asum[410];
 
ll Sum(int l, int r)
{
    return asum[r] - asum[l - 1];
}
 
ll cost(int l, int r)
{
    if(dp[l][r] != -1) return dp[l][r];
    ll res = 0;
    if(l == r) return dp[l][r] = 0;
    res += Sum(l, r);
   //cout<<res<<" "<<l<<" "<<r<<endl; 
    ll cmin = INF;
    for(int m = l; m < r; m++)
    {
        cmin = min(cmin, cost(l, m) + cost(m + 1, r));
    }
    res += cmin;
    //cout<<res<<" "<<cmin<<endl;
    return dp[l][r] = res;
}
 
int main()
{
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    asum[0] = 0;
    for(int i = 1; i <= N; i++) asum[i] = asum[i - 1] + a[i - 1];
    memset(dp, -1, sizeof(dp));
    cout << cost(1,N) << endl;
}

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

#define int long long
signed main(){
    int n;
    cin >>n;
    int p[n];
    for(int i=0;i<n;i++)cin>> p[i];
    sort(p,p+n);
    int ans=p[n-1]/2;
    for(int i=0;i<n-1;i++ )ans+=p[i];
    cout <<ans;
    return 0;

  
    
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EFriendships solver = new EFriendships();
        solver.solve(1, in, out);
        out.close();
    }

    static class EFriendships {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            if (k > (n * (n - 1)) / 2 - (n - 1)) {
                out.println(-1);
                return;
            }
            out.println(((n * (n - 1)) / 2 - k));
            for (int i = 0; i < n - 1; i++) {
                out.println("1 " + (i + 2));
            }
            int x = 2;
            int y = x + 1;
            for (int i = (n * (n - 1)) / 2 - (n - 1) - k; i > 0; i--) {
                out.println(x + " " + y);
                y++;
                if (y == n + 1) {
                    x++;
                    y = x + 1;
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
import sys

S = input()
if int(S[2:]) in range(1, 13):
    if int(S[:2]) in range(1, 13):
        print('AMBIGUOUS')
        sys.exit()
    else:
        print('YYMM')
        sys.exit()
elif int(S[:2]) in range(1, 13):
    print('MMYY')
    sys.exit()
else:
    print('NA')


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){

  int d;
  scanf("%d", &d);
  if (d == 25) {
    printf("Christmas\n");
  }
  if (d == 24) {
    printf("Christmas Eve\n");
  }
  if (d == 23) {
    printf("Christmas Eve Eve\n");
  }
  if (d == 22) {
    printf("Christmas Eve Eve Eve\n");
  }

  return 0;
}

Measured memory_bytes: 128
// SeeAlso: https://atcoder.jp/contests/arc061/tasks/arc061_a

#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;

#define MAX 100000
#define NIL -1

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string S;

int main() {
    cin >> S;

    int n = S.size();
    ll ans = 0;

    for (int bit = 0; bit < (1<<(n-1)); ++bit) {
        ll sum = S[0] - '0';
        for (int i = 0; i<(n-1); ++i) {
            if (bit & (1<<i)) { 
                ans += sum;
                sum = 0;
            }         
            sum *= 10;
            sum += S[i+1] - '0';
        }
        ans += sum;
    }

    print(ans);
    return 0;
}


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

struct cake {
    int w, d;
    int area() const {return w * d;}
};
bool operator<(const cake &c1, const cake &c2) {
    return c1.area() < c2.area();
}

void cake_cut(int N, int W, int D) {
    vector<cake> C;
    C.push_back({W, D});

    int p, s;
    rep(i, N) {
        cin >> p >> s;
        p--;
        cake c0 = C[p];

        s %= (c0.w + c0.d);
        cake c1, c2;
        if (s <= c0.w) {
            c1 = {s, c0.d};
            c2 = {c0.w - s, c0.d};
        } else {
            s-= c0.w;
            c1 = {c0.w, s};
            c2 = {c0.w, c0.d - s};
        }
        if (c1.area() > c2.area()) swap(c1, c2);
        C.push_back(c1);
        C.push_back(c2);
        C.erase(C.begin() + p);
    }

    sort(C.begin(), C.end());
    rep(i, C.size()) {
        cout << C[i].area();
        if (i < C.size()-1) cout << " ";
    }
    cout << endl;

}

int main() {
    int N, W, D;
    while (cin >> N >> W >> D, N || W || D) {
        cake_cut(N, W, D);
    }

    return 0;
}




Measured memory_bytes: 3048
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---

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

signed main(void) {
	SETUP;
	solve();
	return 0;
}

void solve() {
	int H, W; cin >> H >> W;
	bool A[10][10] = {};
	REP(i, H) {
		string s;
		cin >> s;
		REP(j, W) {
			A[i][j] = (s[j] == '#');
		}
	}

	int x, y;
	x = y = 0;
	while (1) {
		A[y][x] = false;
		if (y == H - 1 and x == W - 1) break;

		if (A[y + 1][x] and A[y][x + 1]) {
			cout << "Impossible" << endl;
			return;
		}
		else if (A[y + 1][x]) {
			++y;
		}
		else if (A[y][x + 1]) {
			++x;
		}
		else {
			cout << "Impossible" << endl;
			return;
		}
	}
	REP(i, H) REP(j, W) if (A[i][j]) {
			cout << "Impossible" << endl;
			return;
	}
	cout << "Possible" << endl;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

const int MAX = 2e5 + 5;
int n, m;
struct dsu {
    vector<int> par, sz;
    int size;

    dsu(int n) {
        size = n;
        par = sz = vector<int>(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            sz[i] = 1;
        }
    }
    int find(int u) {
        return par[u] == u ? u : (par[u] = find(par[u]));
    }
    void unite(int u, int v) {
        if ((u = find(u)) == (v = find(v))) return;
        if (sz[u] > sz[v]) swap(u, v);
        par[u] = v;
        sz[v] += sz[u];
        size--;
    }
    int count(int u) {
        return sz[find(u)];
    }
};
int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    cin >> n >> m;
    dsu ds(n);
    forn(i, m) {
        int x, y;
        cin>>x>>y;
        x--, y--;
        ds.unite(x, y);
    }
    int ans = 0;
    forn(i, n) {
        ans = max(ans, ds.count(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4788
#include <stdio.h>
int main(void)
{
	int i, f, r;
	while (1)
	{
		scanf("%d %d %d", &i, &f, &r);
		if (i==-1 && f==-1 && r==-1)
		{
			break;
		}
	
		if (i==-1 || f==-1)
		{
			printf("F\n");
		}
		else if (i+f>=80)
		{
			printf("A\n");
		}
		else if (65<=i+f && i+f<80)
		{
			printf("B\n");
		}
		else if (50<=i+f && i+f<65)
		{
			printf("C\n");
		}
		else if (30<=i+f && i+f<50 && r<50)
		{
			printf("D\n");
		}
		else if (30<=i+f && i+f<50 && 50<=r)
		{
			printf("C\n");
		}
		else if (i+f<30)
		{
			printf("F\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll dp[40][1<<18];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,X,Y,Z;
    cin>>N>>X>>Y>>Z;
    rep(j,1,11){
        dp[0][1<<j]=1;
    }
    rep(i,1,N){
        rep(j,0,1<<18){
            rep(k,1,11){
                bitset<18> bit=j;
                bit=bit<<k;
                bit[k]=1;
                dp[i][bit.to_ulong()]+=dp[i-1][j];
                if(bit[X]==1&&bit[X+Y]==1&&bit[X+Y+Z]==1) dp[i][bit.to_ulong()]-=dp[i-1][j];
                dp[i][j]%=MOD;
            }
        }
    }
    ll ans=1;
    rep(i,0,N){
        ans*=10;
        ans%=MOD;
    }
    rep(i,0,1<<18){
        ans-=dp[N-1][i];
        ans%=MOD;
    }
    cout << (ans+MOD)%MOD<<"\n";
}

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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999

using namespace std;

int32_t main(){
    int n;
    cin >> n;
    int cnt=0, m;
    REP(i, n){
        cin >> m;
        while(!(m%2)){
            cnt++;
            m/=2;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n;
int fr[150];
int main()
{
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; ++i)
    {
        char c;
        cin >> c;
        if(!fr[c])fr[c]++, cnt++;
        else fr[c]++;
    }
    if(cnt == 3)
        cout <<"Three";
    else cout << "Four";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    for(int i=0;i<n;i++){
        cout << s[i] << t[i] ;
    }
    return 0;
}
    



Measured memory_bytes: 256
<?php

//標準入力
class Scanner {
  private $arr = [];
  private $count = 0;
  private $pointer = 0;
  public function next() {
      if($this->pointer >= $this->count) {
          $str = trim(fgets(STDIN));
          $this->arr = explode(' ', $str);
          $this->count = count($this->arr);
          $this->pointer = 0;
      }
      $result = $this->arr[$this->pointer];
      $this->pointer++;
      return $result;
  }
  public function hasNext() {
      return $this->pointer < $this->count;
  }
  public function nextInt() {
      return (int)$this->next();
  }
  public function nextDouble() {
      return (double)$this->next();
  }
}

//標準出力
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

/* 標準入力からの受取
$sc = new Scanner();

#数値(スペース区切り対応)
$n = $sc->nextInt();

#文字(スペース区切り対応)
$str = $sc->next();

#改行込みの文字列を配列に格納
$str=[];
$str[] = $sc->next();
$str[] = $sc->next();
var_dump($str);

*/



$sc = new Scanner();
$n = $sc->nextInt();
$k = $sc->nextInt();
$s = $sc->next();

//$len = strlen($s);

$tmp =$s[$k-1];

if($tmp === "A"){
    $rep = "a";
}elseif ($tmp === "B") {
    $rep = "b";
}else{
    $rep = "c";
}
$s[$k-1] = $rep;

//substr_replace($s,$rep,);

//echo ($a + $b + $c). " ". $s.PHP_EOL;
echo $s.PHP_EOL;

?>


Measured memory_bytes: 4604
A = [0 for _ in range(20)]
x = [[0 for _ in range(20)] for _ in range(20)]
y = [[0 for _ in range(20)] for _ in range(20)]
N = int(input())
for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        temp_x, temp_y = map(int, input().split(' '))
        x[i][j] = temp_x
        y[i][j] = temp_y
res = 0
for i in range(2 ** N):
    flg = True
    for j in range(N):        
        if(not ((i >> j) & 1)): continue
        for a in range(A[j]):
            if(((i >> (x[j][a] - 1)) & 1) ^ y[j][a]):
                flg = False        
    if(flg):
        res = max(res, str(bin(i)).count('1'))
            
print(res)


Measured memory_bytes: 3064
#include <cctype>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
 
int get()
{
    char c;
    while (!isdigit(c=getchar()));
    int k=c-'0';
    for (; isdigit(c=getchar()); k=k*10+c-'0');
    return k;
}
 
using namespace std;
const int N=1e5+10,mod=1e9+7;
char s[N];
int n,m,ans,fac[N],ifac[N],l[N],r[N],lb[N],rb[N],f[2][N],a[N];

int inv(int x)
{
    return x>1? 1ll*(mod-mod/x)*inv(mod%x)%mod:1;
}

int c(int n,int m)
{
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
 
int main()
{
    n=get(),m=get();
    fac[0]=1;
    rep(i,1,n)
        fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=inv(fac[n]);
    repd(i,n,1)
        ifac[i-1]=1ll*ifac[i]*i%mod;
    scanf("%s",s+1);
    rep(i,1,n)
        a[i]=a[i-1]+s[i]-48;
    int t=0;
    rep(i,1,m)
    {
        int x=get(),y=get();
        if (x==l[t])
            r[t]=max(r[t],y);
        else if (y>r[t])
            ++t,l[t]=x,r[t]=y;
    }
    m=t,l[m+1]=n+1,f[0][0]=1;
    rep(i,1,m)
    {
        static int *f=::f[0],*g=::f[1];
        swap(f,g);
        int w=a[r[i]]-a[max(l[i]-1,r[i-1])];
        int s=min(r[i],l[i+1]-1)-l[i]+1;
        int mx=r[i]-l[i]+1-s;
        lb[i]=max(0,lb[i-1]+w-s),rb[i]=min(mx,rb[i-1]+w);
        rep(j,lb[i],rb[i])
            rep(k,max(j-w,lb[i-1]),min(s+j-w,rb[i-1]))
                f[j]=(f[j]+1ll*g[k]*c(s,k+w-j))%mod;
        memset(g+lb[i-1],0,sizeof(int)*(rb[i-1]-lb[i-1]+1));
    }
    rep(i,0,n)
        ans=(ans+f[m&1][i])%mod;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def dfs(balls,B=-1,C=-1,cp=0):
	if cp==len(balls): 	return True
	ball = balls[cp]
	if B<ball:
		is_find = dfs(balls,ball,C,cp+1)
		if is_find: return True
	if C<ball:
		is_find = dfs(balls,B,ball,cp+1)
		if is_find: return True
	return False

def main():
	N = int(input().strip())
	for _ in range(N):
		balls = list(map(int,input().split(' ')))
		is_find = dfs(balls)
		if is_find:		print('YES')
		else:			print('NO')

if __name__=='__main__':
	main()

"""
2
3 1 4 2 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
"""

Measured memory_bytes: 7616
#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++)
 
int main() {
  int A, B, sum = 0,j = 0, l = 0, k= 0, f = 0;
  cin >> A ;
  
  int n1 = 0, n2 = 0, n4= 0, n5 = 0;
 
  // ここにプログラムを追記
    rep(i , A) {
      cin >> B;
      j = 0;
      l = 0;
      
      while (1 == 1) {
        j = B % 2;
    	
        if (j != 0) {
           break;
        }
        B = B / 2;
        l = l + 1;

      }
      
      if (l == 0) {
        k = 0;
        break;
      }
      else{
        if (k == 0){
          k = l;          
        }
        else if (l < k){
          k = l;
        }
        else{
          k = k;
        }
      }
        
  	}
    	cout << k;
}

Measured memory_bytes: 256