akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  
  vector<int> a(5);
  rep(i,5) cin >> a[i];
  
  int k;
  cin >> k;
  
  sort(a.begin(), a.end());
  
  bool ans = true;
  
  rep(i,4) {
    if(a[4] - a[i] > k) ans = false;
  }
  
  cout << (ans ? "Yay!" : ":(") << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a;
  char s[8];
  
  fgets(s,8,stdin);
  sscanf(s,"%d",&a);
  
  if(a<= 999)
  {
    puts("ABC");
  }else
  {
    puts("ABD");
  }
  
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

const long long mod=1000000007;

int main(){
	long long n, m;
	cin >> n >> m;
	long long ans=1;
	if(n-m>=2 || m-n>=2) ans=0;
	else{
		for(long long i=1; i<=n; i++){
			ans*=i;
			ans%=mod;
		}
		for(long long i=1; i<=m; i++){
			ans*=i;
			ans%=mod;
		}
	}
	if(n==m){
		ans*=2;
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<pair<int, int>> x(m);
	for (int i = 0; i < m; i++) {
		cin >> x[i].first >> x[i].second;
	}
	sort(x.begin(), x.end(),
		 [](const pair<int, int> &p, const pair<int, int> &q) {
			 return p.second > q.second;
		 });
	vector<int> d;
	bool fill = false;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < x[i].first; j++) {
			d.push_back(x[i].second);
			if (d.size() == n) {
				fill = true;
				break;
			}
		}
		if (fill) {
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		if (d.size() > i && d[i] >= a[i]) {
			a[i] = d[i];
		}
	}
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


int main(){
    int n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    bool can = true;
    for(int i=0; i<=n-m; ++i){
        for(int j=0; j<=n-m; ++j){
            can = true;
            for(int k=0; k<m; ++k){
                string test = a[i+k].substr(j,m);
                string temp = b[k];
                if(test!=temp){
                    can = false;
                    break;
                }
            }
            if(can) break;
        }
        if(can) break;
    }

    if(can) cout("Yes");
    else cout("No");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{};
	cin>>n;
	vector<int>v(n);
	For(i,0,n)cin>>v[i];
	sort(all(v));
	if(n&1)cout<<"0\n";
	else cout<<v[n/2]-v[n/2-1]<<'\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 3724
# https://atcoder.jp/contests/abc122/tasks/abc122_c

import itertools
import collections
import bisect

def main():
    N, Q = map(int, input().split())
    S = list(input())

    counter = [0] * N
    for i in range(N-1):
        if "{}{}".format(S[i], S[i+1]) == 'AC':
            counter[i] = 1 + (counter[i - 1] if i > 0 else 0)
        else:
            counter[i] = counter[i - 1] if i > 0 else 0
    # print(counter)

    for _ in range(Q):
        l, r = map(int, input().split())
        l -= 1
        r -= 1
        print(counter[r - 1] - counter[l - 1])

if __name__ == '__main__':
    main()


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

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



int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
  int n;
  cin >> n;
  int i = 1;
  while (i <= n) i *= 2;
  cout << i/2 << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		long[] h = new long[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextLong();
		}
		Map<Integer,Integer> map = new HashMap<>();
		for(; m > 0; m--) {
			int a = sc.nextInt()-1, b = sc.nextInt()-1;
			if(h[a] == h[b]) {
				map.put(a, 1);
				map.put(b, 1);
			}else if(h[a] > h[b]) {
				map.put(b, 1);
			}else if(h[a] < h[b]) {
				map.put(a, 1);
			}
		}
		System.out.println(n-map.size());
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 59044
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        Console.WriteLine(
            s == "abc" ||
            s == "acb" ||
            s == "bac" ||
            s == "bca" ||
            s == "cab" ||
            s == "cba" ?
            "Yes" : "No");
    }
}


Measured memory_bytes: 11092
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
    real a = scan!real, b = scan!real, h = scan!real, m = scan!real;

    real x = (h / 12.0 + m / 720.0) * PI * 2;
    real y = (m / 60.0) * PI * 2;

    real ans = sqrt(a * a + b * b - 2 * a * b * cos(x - y));

    writefln("%10.10f", ans);
}



Measured memory_bytes: 3400
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k;
    cin >> n >> k;
    akari<int> hs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> hs[i];
    }
    hs.push_back(0);
    yukari<i64> dp(n + 2, akari<i64>(k + 1, 1e15));
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= k; j++)
        {
            if (dp[i][j] == 1e15)
            {
                continue;
            }
            for (int x = 0; j + x <= k && i + x + 1 <= n + 1; x++)
            {
                int ni = i + x + 1;
                dp[ni][j + x] = min(dp[ni][j + x], dp[i][j] + max(0, hs[ni - 1] - (i ? hs[i - 1] : 0)));
            }
        }
    cout << *min_element(dp.back().begin(), dp.back().end()) << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int cntR = 0, cntB = 0;
    rep(i, n) {
        if(s[i] == 'R') {
            cntR++;
        }
        else {
            cntB++;
        }
    }

    if(cntR > cntB) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

while True:
    H, W = [int(x) for x in stdin.readline().rstrip().split()]
    if H == 0 and W == 0:
        break
    else:
        print("#"*W)
        for i in range(H-2):
            print("#"+"."*(W-2)+"#")
        else:
            print("#"*W + "\n")



Measured memory_bytes: 5636
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n;
    while(cin>>n,n){
        vi v(n+1,0);
        rep(i,n)cin>>v[i];
        ll ans=-INF, temp;
        for(int i=0;i<n;i++){
            temp=0;
            for(int j=i;j<n;j++){
                temp+=v[j];
                ans=max(ans,temp);
            }
        }
        if(n==1)cout<<v[0]<<endl;
        else cout<<ans<<endl;
    }
}

Measured memory_bytes: 2972
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int a,b,c;
   int count=0;
   cin>>a>>b>>c;
   for(int i=a;i<=b;i++) if(c%i==0) count++;
   cout<<count<<endl;
   //while(1);
   return 0;
 }
 

Measured memory_bytes: 3088
while 1:
    n=int(input())
    if n==0:break
    treat_list=[]
    treat_limit=[]
    count=0
    for i in range(n):
        treat_list.append(list(map(int,input().split())))
    treat_limit=list(map(int,input().split()))
    for i in treat_list:
        if i[1]<=treat_limit[0] and i[2]<=treat_limit[1] and i[3]<=treat_limit[2] and (i[1]+i[3])*4+i[2]*9<=treat_limit[3]:
            print(i[0])
            count+=1
    if count==0:print("NA")


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

const ll MOD=924844033;

ll modpow(ll n, ll k) {
    ll r=1;
    for(;k;k/=2){
        if(k%2)r*=n,r%=MOD;
        n*=n,n%=MOD;
    }
    return r;
}

int main() {
    ll N,K;
    cin>>N>>K;

    vector<ll>fact(N+1,1);
    vector<ll>invfact(N+1,1);
    for(ll i=1;i<=N;++i)fact[i]=fact[i-1]*i%MOD;
    for(ll i=0;i<=N;++i)invfact[i]=modpow(fact[i],MOD-2);
    for(ll i=0;i<=N;++i)assert(fact[i]*invfact[i]%MOD==1);

    auto binom=[&](ll n,ll k)->ll{
        if(k>n)return 0;
        return fact[n]*invfact[k]%MOD*invfact[n-k]%MOD;
    };

    vector<ll> dp[2];
    dp[0].resize(N+1);
    dp[1].resize(N+1);
    ll D=0;
    dp[D][0]=1;
    for(ll i=0;i<2*K;++i,D=1-D){
        fill(dp[1-D].begin(),dp[1-D].end(),0);
        ll len=(N-1-i/2)/K;
        if(len<1)break;
        for(ll a=0;a<=N;++a){
            for(ll b=a;b<=N&&b-a<=len;++b){
                dp[1-D][b]=(dp[1-D][b]+dp[D][a]*binom(len-(b-a)+1,b-a))%MOD;
            }
        }
    }
    ll res=0;
    for(ll i=0;i<=N;++i){
        ll tmp=dp[D][i]*fact[N-i]%MOD;
        res=(res+(i%2?-tmp:tmp)+MOD)%MOD;
    }
    cout<<res<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
pll find(ll n)
{
	ll b=n%10;
	ll a=n;
	while(n!=0)
	{
		a=n;
		n=n/10;
	}
	return {a,b};
}
void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	pll p;
	map<pll,ll> m;
	for(ll i=1;i<=n;i++)
	{
		p=find(i);
		m[p]++;
	}
	for(ll i=1;i<=n;i++)
	{
		p=find(i);
		pll q=mp(p.sec,p.fir);
		ans=ans+m[q];
	}
	cout<<ans;
}	

int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
ans = False
for i in range(n):
    a, b = map(int,input().split())
    if a==b:
        if cnt == 2:
            ans = True
            break
        cnt += 1
    else:
        cnt = 0
    
    
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62196
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True

 

 
#main
P=[]
for a in get_primes(55555):
    if a%5==1:P.append(a)
N=int(input())
print(" ".join(list(map(str,P[0:N]))))


Measured memory_bytes: 6636
#print([chr(ord('a') + i) for i in range(26)])
#print([chr(i) for i in range(97, 97+26)])
import sys
import bisect
li = [chr(i) for i in range(97, 97+26)]
s = input()
if len(s)<26:
    for l in li:
        if l not in s:
            print(s+l)
            sys.exit()
elif s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
else:
    r = s[::-1]
    tmp = ''
    kabe = ''
    for i,rr in enumerate(r):
        if i == 0:
            continue
        if rr < r[i-1]:
            tmp = r[:i+1][::-1]
            kabe = rr
            break
    #print(tmp) #wzyx

    tmp_li = list(tmp)
    tmp_li.sort()
    ind = bisect.bisect_left(tmp_li, kabe)
    s0 = tmp_li[ind+1]
    #s0 = tmp_li[1]
    print(s.replace(tmp, s0))

    #print(tmp_li)
    #print(s - tmp + tmp[-1])
    #xx = list(tmp[1:])
    #xx.sort()
    #print(s[:26-len(tmp)] + xx[0])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    set<string> s;
    rep(i,n){
        string l;
        cin>>l;
        s.insert(l);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  for(int i=0;i<w+2;i++) cout<<"#";
  cout<<endl;
  for(int i=0;i<h;i++){
    cout<<"#";
    vector<char> vec(w);
    for(int j=0;j<w;j++){ 
      cin>>vec.at(j);
      cout<<vec.at(j);
    }
    cout<<"#"<<endl;
  }
  for(int i=0;i<w+2;i++) cout<<"#";
  cout<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
width,height = 0,0
a = -n-1
for k in range(1,n+1):
  width += x[k-1] * (2*k+a)
a = -m-1
for k in range(1,m+1):
  height += y[k-1] * (2*k+a)
width %= 1000000007
height %= 1000000007
print(width * height % 1000000007)

Measured memory_bytes: 18576
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int count = 0;
    string S;
    string T;
    cin >> S >> T;

    for (int i = 0; i < 3; i++){
        if (S[i] == T[i]) count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	K--;
	string S;
	cin >> S;
	S[K] += 'a' - 'A';
	cout << S << endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;
	vector<ll> v(3);
	cin >> n >> v[0] >> v[1] >> v[2];
	vector<string> str(n+1);
	REP(i, n)cin >> str[i];
	str[n] = "ABC";

	map<char, ll> mp;
	mp['A'] = 0;
	mp['B'] = 1;
	mp['C'] = 2;
	vector<char> ans;
	REP(i, n){
		ll a = mp[str[i][0]];
		ll b = mp[str[i][1]];

		ll na = mp[str[i+1][0]];
		ll nb = mp[str[i+1][1]];
		bool flag = true;
		v[a]++;
		v[b]--;
		if(v[a] < 0 || v[b] < 0)flag = false;
		if(i != n-1 && v[na] <= 0 && v[nb] <= 0)flag = false;
		if(flag){
			ans.EB(str[i][0]);
			continue;
		}
		v[a]--;
		v[b]++;

		flag = true;
		v[a]--;
		v[b]++;
		if(v[a] < 0 || v[b] < 0)flag = false;
		if(i != n-1 && v[na] <= 0 && v[nb] <= 0)flag = false;
		if(flag){
			ans.EB(str[i][1]);
			continue;
		}

		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	REP(i, n)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 6704
loop do
    t, sheet = gets.chomp.split
    target = t.to_i
    break if target == 0

    hash = {}
    (0 .. 2 ** (sheet.size - 1) - 1).each do |x| 
        arr = [-1] + (0..sheet.size-1).select {|i| x[i] == 1} + [sheet.size-1]

        part = arr.each_cons(2).map {|i, j| sheet[i+1..j]}
        # next if part.any?{|s| s =~ /^0./}
        sum = part.map(&:to_i).inject(:+)
        (hash[sum] ||= []) << part
    end 

    hash.delete_if {|s, _| s > target}

    if hash.empty?
        puts 'error'
    else
        max = hash.keys.max

        if hash[max].size > 1 
            puts 'rejected'
        else
            puts ([max] + hash[max][0]) * ' ' 
        end 
    end 
end

Measured memory_bytes: 8768
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    fastio;
    string s;
    cin >> s;
    if (s[2] == s[3] and s[4] == s[5]) cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        Calc c = new Calc();
        int x = int.Parse(Console.ReadLine());
        Console.WriteLine(c.Multiple(x));

    }
}

class Calc
{
    public int Multiple(int x)
    {
        if (x >= 1 && x <= 100)
            return x * x * x;
        else
            return 0;
    }
}

Measured memory_bytes: 9136
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { Item(it.toInt(), 2) }.sortedByDescending { it.f }

    var max = aa[0].f.toLong()
    var maxIdx = 1

    for (i in 2 until n) {
        if (aa[maxIdx].cnt == 0) {
            maxIdx += 1
        }
        max += aa[maxIdx].f
        aa[maxIdx].cnt--
    }

    println(max)
}

data class Item(val f: Int, var cnt: Int)

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var H = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(Count(H));
        }

        static int Count(int[] H)
        {
            var max = H[0];
            var cnt = 1;
            for (int i = 1; i < H.Length; i++)
            {
                if (max <= H[i])
                {
                    cnt++;
                    max = H[i];
                }
            }
            return cnt;
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    string S;
    cin>>S;
    
    ll addleft=0;
    ll stoch=0;//(
    for(ll i=0;i<N;i++){
        if(S[i]=='('){
            stoch++;
        }else{
            if(stoch>0)stoch--;
            else addleft++;
        }
    }
    
    for(ll i=0;i<addleft;i++)printf("(");
    printf("%s",S.c_str());
    for(ll i=0;i<stoch;i++)printf(")");
    printf("\n");
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    double anw = 0;
    if(n % 2 == 0){
        anw = ((double)(n / 2)) / n;
    }
    else{
        anw = ((double)((n + 1) / 2)) / n;
    }
    printf("%.10lf", anw);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

const int nax = 3e5+5;
const int inf = 1e18+7;
const int mod = 1e9+7;

int n,m;
int a[nax], cost[nax];
vector<int>adj[nax];

/*
 * DO SOMETHING RATHER THAN DOING NOTHING
 * */

signed main(){
    fast;
     cin>>n;
     for(int i=0;i<n;i++){
          cin>>a[i];
     }
     cost[0] = 0;
     for(int i=1;i<n;i++){
          if(i==1){
               cost[i] = abs(a[i]-a[i-1]);
          }
          else{
               cost[i] = min(abs(a[i-1]-a[i])+cost[i-1], abs(a[i-2]-a[i])+cost[i-2]);
          }
     }
     cout<<cost[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 12124
#include <iostream>
#include <vector>

using namespace std;

void solve() {
  int H, W;
  cin >> H >> W;

  string line(W+2, '#');
  cout << line << endl;
  while(H--) {
    string s; cin >> s;
    cout << '#' << s << '#' << endl;
  }
  cout << line << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
#define mkp make_pair
#define pb push_back
#define pf push_front
#include <string>
ll mod=1000000007;
ll mod2=998244353;
ll OO=1e18;
using namespace std;

ll dp[500][500];
ll pre[500],suf[500];
ll a[500];
ll david_villa(ll st,ll en)
{
    if (st==en)
        return 0;
    if (dp[st][en]+1)
        return dp[st][en];
    ll res1=OO;
    for (ll i=st;i<en;i++)
        res1=min(res1,david_villa(st,i)+pre[i]-pre[st-1]+david_villa(i+1,en)+suf[i+1]-suf[en+1]);
    return dp[st][en]=res1;
}

int main()
{
    ll n,i;
    cin >>n;
    for (i=1;i<=n;i++)
        cin >>a[i];
    pre[1]=a[1];
    suf[n]=a[n];
    for (i=2;i<=n;i++)
        pre[i]=pre[i-1]+a[i];
    for (i=n-1;i>=1;i--)
        suf[i]=suf[i+1]+a[i];
    memset(dp,-1,sizeof dp);
    cout <<david_villa(1,n);
    return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var HW = ReadLine().Split().Select(int.Parse).ToArray();
        int H = HW[0], W = HW[1];
        var c = new int[10, 10];
        for (int i = 0; i < 10; i++)
        {
            var line = ReadLine().Split().Select(int.Parse).ToArray();
            for (int j = 0; j < 10; j++)
            {
                c[i, j] = line[j];
            }
        }
        var A = new int[H, W];
        for (int i = 0; i < H; i++)
        {
            var line = ReadLine().Split().Select(int.Parse).ToArray();
            for (int j = 0; j < W; j++)
            {
                A[i, j] = line[j];
            }
        }

        for (int k = 0; k < 10; k++)
        {
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    c[i, j] = Min(c[i, j], c[i, k] + c[k, j]);
                }
            }
        }

        int cost = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (A[i, j] == -1) continue;
                cost += c[A[i, j], 1];
            }
        }
        WriteLine(cost);
    }
}


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

void Main(){
    int n;cin>>n;
    vector<int> v(n);
    long long  sum=0;
    rep(i,n) {
        cin>>v[i];
        sum+=v[i];
    }
    int avg=sum/v.size();

    int minn = *min_element(v.begin(), v.end());
    int max = *max_element(v.begin(), v.end());
    // int avg=ceil((min+max)/2);
    // long long sum=0;
    sum=0;
    long long   sum2=0;
    //cout<<avg<<endl;
    rep(i,n){
        sum+=pow((v[i]-avg-1),2);
        sum2+=pow((v[i]-avg),2);

        //cout<<sum<<endl;
    }
    long long  ans=min(sum,sum2);
    cout<<ans;

}
int main(void)
{
 
  Main();
    return 0;
}



Measured memory_bytes: 256
//abc076_d.cpp
//Sun Jul 29 10:19:29 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 100000000
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	double st[n+2],et[n+2];
	double v[n+2];
	st[0] = 0;
	et[0] = 0;
	v[0] = 0;

	double totaltime = 0;
	for (int i=1;i<=n;i++){
		st[i] = et[i-1];
		double tempt;
		cin >> tempt;
		et[i] = et[i-1]+tempt;
		totaltime += tempt;
	}
	
	for (int i=1;i<=n;i++){
		cin >> v[i];
	}

	st[n+1] = totaltime;
	et[n+1] = totaltime;
	v[n+1] = 0;

	double curtime = 0.5;
	double curv = 0;
	double ans = 0;
	while (curtime <= totaltime){
		double minv = INF;
		for (int i=0;i<n+2;i++){
			double tempv = 0;
			if (curtime <= st[i]){
				tempv = v[i]+st[i]-curtime;
			}else if (curtime <= et[i]){
				tempv = v[i];
			}else {
				tempv = v[i]+curtime-et[i];
			}
			if (tempv < minv){
				minv = tempv;
			}
		}
		ans += 0.25*(curv+minv);
		curv = minv;
		curtime += 0.5;
	}

	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * l.cc: L - Deque
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 3000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N];
ll dp[MAX_N][MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", as + i), dp[i][i] = as[i];

  for (int l = 1; l < n; l++)
    for (int i = 0, j = l; j < n; i++, j++)
      dp[i][j] = max(as[i] - dp[i + 1][j], as[j] - dp[i][j - 1]);

  printf("%lld\n", dp[0][n - 1]);
  return 0;
}


Measured memory_bytes: 70016
from itertools import combinations
from collections import Counter

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

cXY = combinations(XY, 2)

edge = []
for a, b in cXY:
  edge.append((a[0]-b[0], a[1]-b[1]))
  edge.append((-a[0]+b[0], -a[1]+b[1]))

ce = Counter(edge)

if N == 1:
  ans = 1
else:
  dup = max(ce.values())
  ans = N - dup
print(ans)

Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>A(3);
  for(int i=0;i<3;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int ans=(A[0]+A[1]);
  cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,a,s,i,mn;
int main ()
{
	cin>>n;
	cin>>a;
	mn=a; s++;
	for(i=2;i<=n;i++)
	{
		cin>>a;
		mn=min(a,mn);
		if(a==mn) s++;
	}
	cout<<s;
	
	

}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string S, T;
int A, B;
string U;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> S >> T >> A >> B >> U;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  if (S == U) {
    A--;
  } else {
    B--;
  }

  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  map<int, int> mochi;
  rep(i, N) { int tmp; cin >> tmp; mochi[tmp]++; }
  cout << mochi.size() << endl;
  return 0;
}

Measured memory_bytes: 256
def pri(k):
    if k==1:return False
    elif k==2: return True
    for i in range(2,int(k**0.5)+1):
        if k%i==0:
            return False
    return True
while True:
    n,p=map(int,input().split())
    if n==-1:
        exit()
    lprime=[]
    while len(lprime)!=p:
        n+=1
        if pri(n):
            lprime.append(n)
    lans=[]
    le=len(lprime)
    for k1 in range(le):
        for k2 in range(k1,le):
            lans.append(lprime[k1]+lprime[k2])
    lans.sort()
    print(lans[p-1])

    




Measured memory_bytes: 5744
#include<bits/stdc++.h>
#define ll unsigned long long
#define vi vector<int>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[n]={0};
int t,te;
for(int i=0;i<n;i++)
{a[i]=1001;
cin>>t>>te;
if(te<=m)
a[i]=t;
}
te=*min_element(a,a+n);
if(te==1001)
cout<<"TLE";
else cout<<te;

}


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

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double theta;
    if(abs((h/12*2*M_PI+m*M_PI/360)-m/60*2*M_PI)>M_PI){
        theta = 2*M_PI-abs((h/12*2*M_PI+m*M_PI/360)-m/60*2*M_PI);
        //cout << 1 << endl;
    }
    else{
        theta = abs((h/12*2*M_PI+m*M_PI/360)-m/60*2*M_PI);
    }
    //cout << theta << endl;
    double ans;
    ans = sqrt(a*a+b*b-2*a*b*cos(theta));
    cout << setprecision(10) << ans << endl;

}

Measured memory_bytes: 4152
import math
from functools import reduce
n = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

allsum = 0
for i in  range(1,n+1):
  for j  in range(1,n+1):
    for k in  range(1,n+1):
      allsum += gcd(i,j,k)
print(allsum)

Measured memory_bytes: 69892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

class UnionFind {
public:
    vector<int> par;
    int N;
    UnionFind(int n) {
        par.resize(n, -1);
        N = n;
    }
    int Find(int n) {
        return par[n] < 0 ? n : par[n] = Find(par[n]);
    }
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        if (x == y) return false;
        if (-par[x] > -par[y]) swap(x, y);
        par[y] += par[x];
        par[x] = y;
        N--;
        return true;
    }
    bool Same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -par[Find(x)];
    }
    int size() {
        return N;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    int sz = 100010;
    vector<int> m(sz, 0);
    REP(i, 0, n) {
        cin >> a[i];
        m[a[i]]++;
    }
    vector<bool> used(sz, false);
    UnionFind uf(sz);
    REP(i, 2, sz) {
        int prev = -1;
        if (used[i]) continue;
        used[i] = true;
        for (int j = i; j < sz; j += i) {
            used[j] = true;
            if (m[j]) {
                if (prev != -1) {
                    uf.Union(prev, j);
                }
                prev = j;
            }
        }
    }
    auto cp = a;
    sort(cp.begin(), cp.end());
    REP(i, 0, n) {
        dump(cp[i], a[i], uf.Same(cp[i], a[i]));
        if (!uf.Same(cp[i], a[i])) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;

    return 0;
}



Measured memory_bytes: 4432
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
import math
ll=[]
lll=[]
for i in range(n):
    ll.append([l[i][0]+l[i][1],i])
    lll.append([l[i][0]-l[i][1],i])
ll.sort()
lll.sort()

a=int(math.fabs(l[ll[0][1]][0]-l[ll[-1][1]][0])+math.fabs(l[ll[0][1]][1]-l[ll[-1][1]][1]))
b=int(math.fabs(l[lll[0][1]][0]-l[lll[-1][1]][0])+math.fabs(l[lll[0][1]][1]-l[lll[-1][1]][1]))

print(max(a,b))


Measured memory_bytes: 100636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <stdlib.h>
using namespace std;
typedef long long int lld;
typedef long double ld;
pair<lld,lld> arr[222222];
bool tmr(pair<lld,lld> a,pair<lld,lld> b){
   return ((a.second*b.first) + b.first) < ((b.second*a.first) + a.first);
}
bool tmr2(pair<lld,lld> a,pair<lld,lld> b){
   return a.second < b.second;
}
lld dp[33];
vector<pair<lld,lld> > v1,v2;
int main(void){
   for(int e=0;e<33;e++) dp[e] = 2e9;
   int n,t;
   scanf("%d%d",&n,&t);
   for(int e=0;e<n;e++) scanf("%lld%lld",&arr[e].first,&arr[e].second);
   sort(arr,arr+n,tmr);
   for(int e=0;e<n;e++){
      if(arr[e].first!=0) v1.push_back(make_pair(arr[e].first,arr[e].second));
      else v2.push_back(make_pair(arr[e].first,arr[e].second));
   }
   sort(v2.begin(),v2.end(),tmr2);
   lld tot = 0,ans = 0;
   dp[0] = 0;
   for(int e=0;e<v1.size();e++){
      lld dp2[33];
      for(int q=0;q<33;q++) dp2[q] = dp[q];
      for(int q=1;q<33;q++){
         if(dp[q-1]>1e9) break;
         lld tot = dp[q-1];
         tot++;
         if(arr[e].first*tot>2e9) break;
         tot += (arr[e].first*tot+arr[e].second);
         dp2[q] = min(dp2[q],tot);
      }
      for(int q=0;q<33;q++) dp[q] = dp2[q];
   }
   for(int e=0;e<33;e++){
      if(dp[e]>(lld)t) break;
      lld tot = dp[e],val = e;
      for(int p=0;p<v2.size();p++){
         tot++;
         tot += (v2[p].first*tot+v2[p].second);
         if(tot>t) break;
         val++;
      }
      ans = max(ans,val);
   }
   printf("%lld",ans);
   return 0;
}

Measured memory_bytes: 9584
N = int(input())



# 数値→アルファベット
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)


print(num2alpha(N).lower())

Measured memory_bytes: 9184
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int a, b;
  cin >> a >> b;
  int d = a - 1;
  REP(i, 30) {
    if (b == 1) {
      cout << 0 << endl;
      break;
    }
    if (a >= b) {
      cout << i + 1 << endl;
      break;
    }
    a += d;
  }
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n;
vector<ll> V, W;
int main(void){
    // Your code here!
    cin >> n;
    if (n == 3){
        cout << 2 << ' ' << 5 << ' ' << 63 << endl;
        return 0;
    } if (n == 4){
        cout << 2 << ' ' << 5 << ' ' << 20 << ' ' << 63 << endl;
        return 0;
    }
    V.push_back(0), W.push_back(0);
    for (ll i = 1; i <= 15000; i++){
        if (i % 3 == 0) continue;
        V.push_back(2 * i);
    }
    for (ll i = 1; i <= 10000; i++){
        W.push_back(i * 3);
    }
    ll k = n / 4, l = k / 2;
    if (n % 4 == 0){
        for (ll i = 1; i <= 4 * l; i++) cout << V[i] << ' ';
        for (ll i = 1; i <= 4 * (k - l); i++){
            cout << W[i];
            if (i < 4 * (k - l)) cout << ' ';
            else cout << endl;
        }
    } else if (n % 4 == 1){
        for (ll i = 1; i <= 4 * l + 2; i++) cout << V[i] << ' ';
        for (ll i = 1; i <= 4 * (k - l - 1) + 3; i++){
            cout << W[i];
            if (i < 4 * (k - l - 1) + 3) cout << ' ';
            else cout << endl;
        }
    } else if (n % 4 == 2){
        for (ll i = 1; i <= 4 * l + 2; i++) cout << V[i] << ' ';
        for (ll i = 1; i <= 4 * (k - l); i++){
            cout << W[i];
            if (i < 4 * (k - l)) cout << ' ';
            else cout << endl;
        }
    } else {
        for (ll i = 1; i <= 4 * (l + 1); i++) cout << V[i] << ' ';
        for (ll i = 1; i <= 4 * (k - l - 1) + 3; i++){
            cout << W[i];
            if (i < 4 * (k - l) + 3) cout << ' ';
            else cout << endl;
        }
    }
}


Measured memory_bytes: 640
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
size_t partition(T)(T A, size_t p, size_t r)
{
    auto x = A[r];
    auto i = p - 1;
    for (auto j = p; j < r; j++)
    {
        if (A[j] <= x)
        {
            i++;
            A[i].swap(A[j]);
        }
    }
    A[i + 1].swap(A[r]);
    return i + 1;
}
void main()
{
    readln();
    int[] a = readln().strip.split(' ').map!(x => x.to!int).array;
    auto ad = partition(a, 0, a.length - 1);
    foreach (i, j; a)
    {
        if (i)
            write(" ");
        if (i == ad)
            write("[");
        write(j);
        if (i == ad)
            write("]");
    }
    writeln();
}



Measured memory_bytes: 4828