akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N,M;
vector<int> visited;
vector<vector<int>> G;
int num_visited = 0;
int ans = 0;


void dfs(int now){
    visited[now] = 1;
    num_visited++;
    if(num_visited == N){
        ans++;
    }
    for(int i = 0; i < G[now].size(); i++){
    int next = G[now][i];
    if(!visited[next]){dfs(next);}
    }
    visited[now] = 0;
    num_visited--;
}

int main(){
    cin >> N >> M;
    G = vector<vector<int>>(N);
    visited = vector<int>(N,0);
    for(int i=0; i < M; i++){
        int a,b; cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    string s;
    cin >> s;

    int cnt0 = 0, cnt1 = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '0')
            cnt0++;
        else
            cnt1++;
    }
    cout << 2 * min(cnt0, cnt1) << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	int k;
	cin >> k;
	cin >> s;
	
	for(int i = 0; i < k; i++)
	{
		cout << s[i];
		if(s[i+1] == '\0')
		return 0;
	}
	
	if(s[k] != '\0')
	{
		cout << "...";
	}

}
		
		


Measured memory_bytes: 3648
#include<iostream>
#include<set>
#include<string>
#include<algorithm>

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

using namespace std;

int main(void){

  int n;
  cin >> n;
  while(n--){
    set<string>st;

    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
      string l=s.substr(0,i),r=s.substr(i,s.size()-i);
      
      st.insert(l + r);
      st.insert(r + l);      
      reverse(all(l));
      st.insert(l + r);
      st.insert(r + l);            
      reverse(all(r));
      st.insert(l + r);
      st.insert(r + l);            
      reverse(all(l));
      st.insert(l + r);      
      st.insert(r + l);      
    }
    cout << st.size() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>

using namespace std;

int a[110];

int main()
{
//	freopen("input.txt","r",stdin);
	
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]==a[j]) continue;
			for(int k=j+1;k<n;k++)
			{
				if(a[j]==a[k]) continue;
				if(a[i]+a[j]>a[k]) ans++;
//				cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
			}
		}
	}
	cout<<ans;
	
	return 0;
} 

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
//nもrも10^5くらいのときにはこれ使うと良き
//二項係数の計算
const int MAX = 510000;
ll fac[MAX],finv[MAX],inv[MAX];

//テーブルの初期化
void COMinit(){
	fac[0] = fac[1] = 1;//階乗
	finv[0] = finv[1] = 1;//階乗の逆元
	inv[1] = 1;//逆元(1の逆元は1)
	for(int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;//累積積的な感じ
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;//inv[i] = iの逆元(mod mod)
		finv[i] = finv[i - 1] * inv[i] % mod;//階乗の逆元の計算
	}
}



ll COM(int n,int k){//二項係数の計算
	if(n < k){
		return 0;
	}
	if (n < 0 || k < 0){
		return 0;
	} 
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
	COMinit();
	ll ans = 0;
	ll h,w,a,b;cin>>h>>w>>a>>b;
	for(ll i = b + 1; i <= w; i++) {
		ans += ((COM(i - 1 + (h - a - 1),i - 1)) * (COM(w - i + a - 1,a - 1)));
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int n;

int main(void){
	cin >> n;
	vector<int> t(n+1), x(n+1), y(n+1);
	t[0] = x[0] = y[0] = 0;
	for(int i = 1; i <= n; i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	bool f = true;
	for(int i = 0; i < n; i++){
		int dt = t[i+1]-t[i];
		int dist = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1]);
		if(dist > dt) f = false;
		if(dist%2 != dt%2) f = false;
	}
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 4576
key = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "None"]
judge = dict()
for value in key:
  judge[value] = False
s = input()
n = len(s)
for i in range(n):
  judge[s[i]] = True

for i in range(27):
  if judge[key[i]] == False:
    print(key[i])
    break

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359

int main()
{
  int a;int b;double h;double m;cin>>a>>b>>h>>m;
  h=h*5+ (m*1.0/12);
  double diff=abs(h-m);
  diff=min(diff,60-diff);
   double angle=6*diff;
  double theta=(angle*pi)/180;
  double ans=(a*a*1.00)+(b*b*1.000)-(2*a*b*cos(theta));
  cout<<fixed<<setprecision(50)<<sqrt(ans)<<endl;
  
  return 0;
}
  
  

Measured memory_bytes: 4128
import sys
# input = sys.stdin.readline

A, B, C, D = map(int, input().split())

def div(a, b):
    return a // b

def gcd(a, b):
    if b > a: return gcd(b, a)
    elif b == 0: return a
    else: return gcd(b, a % b)

ans = 0
ans += div(B, C)
ans -= div(A - 1, C)
# print("#", ans)
ans += div(B, D)
ans -= div(A - 1, D)
# print("#", ans)
#
E = (C * D) // gcd(C, D)
ans -= div(B, E)
ans += div(A - 1, E)
# print("#", ans)

ans = (B - A + 1) - ans
print(ans)


Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    N = int(input())
    if N == 0:
        break
    crops = {}
    for i in range(N):
        L,P,A,B,C,D,E,F,S,M = map(lambda x: int(x) if x.isnumeric() else x,input().split())
        time = A+B+C
        for _ in range(M):
            time += D + E
        crops[L] = (M*F*S - P) / time

    for key,value in sorted(crops.items(), key = lambda c: (-c[1],c[0])):
        print(key)
    print('#')

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

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


class UnionFindLabel(UnionFind):
    def __init__(self, labels):
        assert len(labels) == len(set(labels))

        self.n = len(labels)
        self.parents = [-1] * self.n
        self.d = {x: i for i, x in enumerate(labels)}
        self.d_inv = {i: x for i, x in enumerate(labels)}

    def find_label(self, x):
        return self.d_inv[super().find(self.d[x])]

    def union(self, x, y):
        super().union(self.d[x], self.d[y])

    def size(self, x):
        return super().size(self.d[x])

    def same(self, x, y):
        return super().same(self.d[x], self.d[y])

    def members(self, x):
        root = self.find(self.d[x])
        return [self.d_inv[i] for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [self.d_inv[i] for i, x in enumerate(self.parents) if x < 0]

def MAP(): return map(int, input().split())
def ZIP(n): return zip(*(MAP() for _ in range(n)))

N, M, K = list(map(int, input().split()))
ans = [-1] * N
uf = UnionFindLabel(range(1, N + 1))
for i in range(M):
    node1, node2 = list(map(int, input().split()))
    ans[node1 - 1] -= 1
    ans[node2 - 1] -= 1
    if not uf.same(node1, node2):
        uf.union(node1, node2)
for i in range(N):
    ans[i] += uf.size(i + 1)
for i in range(K):
    node1, node2 = list(map(int, input().split()))
    if uf.same(node1, node2):
        ans[node1 - 1] -= 1
        ans[node2 - 1] -= 1
print(*ans)


Measured memory_bytes: 120160
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[sys.maxsize]*n
dp[0]=0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]))
print(dp[n-1])


Measured memory_bytes: 52448
sx,sy,tx,ty = map(int,input().split())

ans = ''

# 1周目
ans += 'D'
for _ in range(tx-sx+1):
    ans += 'R'
for _ in range(ty-sy+1):
    ans += 'U'
for _ in range(tx-sx+1):
    ans += 'L'
for _ in range(ty-sy):
    ans += 'D'

# 2周目
for _ in range(tx-sx):
    ans += 'R'
for _ in range(ty-sy+1):
    ans += 'U'
for _ in range(tx-sx+1):
    ans += 'L'
for _ in range(ty-sy+1):
    ans += 'D'
ans += 'R'

print(ans)


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n-1);
    for(auto& e: b) cin >> e;
    a[0] = b[0];
    a[n-1] = b[n-2];
    for(int i = 1;i < n - 1;i++){
        a[i] = min(b[i], b[i-1]);
    }
    cout << accumulate(begin(a), end(a), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = a*b;
		int d = 2*a + 2*b;
		System.out.println(c+" "+d);
	}
}

Measured memory_bytes: 26172
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define maxe              *max_element
#define mine              *min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x;
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl;
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    ll n; cin>>n; ll a[n]; get(a);
    ll s=0;
    for(ll i=0;i<n;i++)
    {
        s+=a[i];
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        s=s-a[i];
        ans+=(s%mod*a[i]%mod)%mod;
    }
    cout<<ans%mod;
}







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

int main(){
    int n;
    cin >> n;
    vector <int> d(n);
    ll ans;
    ans=0;
    rep(i,n){
        cin >> d[i];
    }
    rep(i,n-1){
        rep(j,n-1-i){
            ans+=d[i]*d[j+i+1];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int m = cin.Int();
			if (n == m) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long  x1,x2,x3,x4;
  x1=a*c;
  x2=a*d;
  x3=b*c;
  x4=b*d;
 // cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<" ";
  cout<<max(max(max(x1,x2),x3),x4);
  
}

Measured memory_bytes: 3548
NTEST = 26

D=int(input())

C=list(map(int,input().split()))

SL=list()
SL.append([0 for i in range(NTEST)])
for d in range(D):
    S=list(map(int,input().split()))
    SL.append(S)

def calcSat(test_applied):
    lastDay = [0 for i in range(NTEST)]

    sat = 0
    for d in range(1,D+1):
        tst = test_applied[d] - 1
        lastDay[tst] = d
        sat += SL[d][tst]
        for itst in range(NTEST):
            sat -= C[itst] * (d-lastDay[itst])
    return sat

satList = list()
satList.append(0)
lastDay = [[0 for i in range(NTEST)]]

def calcSat_with_memo(test_applied):

    total_sat = 0
    for d in range(1,D+1):
        lastDay.append(list(lastDay[d-1]))
        sat = 0
        tst = test_applied[d] - 1
        lastDay[d][tst] = d
        sat += SL[d][tst]
        for itst in range(NTEST):
            sat -= C[itst] * (d-lastDay[d][itst])
        satList.append(sat)
        total_sat += sat

    return total_sat

def recalcSat_with_memo(total_sat_before, tday, t_from, t_to, test_applied):

    d_total_sat = 0

    lastDay[tday][t_from -1]=lastDay[tday-1][t_from -1]
    d_sat=0
    d_sat += (SL[tday][t_to -1]-SL[tday][t_from -1])
    d_sat += C[t_to -1]*(tday - lastDay[tday][t_to -1])
    d_sat -= C[t_from -1]*(tday - lastDay[tday][t_from -1])

    lastDay[tday][t_to -1]=tday

    satList[tday]+= d_sat
    d_total_sat  += d_sat

    old_last = tday
    new_last = lastDay[tday][t_from -1]
    for d in range(tday+1,D+1):
        if test_applied[d] == t_from :
            break
        d_sat = C[t_from -1]*(- old_last + new_last)
        lastDay[d][t_from -1] = new_last
        satList[d]+= d_sat
        d_total_sat += d_sat

    old_last = lastDay[tday-1][t_to -1]
    new_last = tday
    for d in range(tday+1,D+1):
        if test_applied[d] == t_to :
            break
        d_sat = C[t_to -1]*(- old_last + new_last)
        lastDay[d][t_to -1] = new_last
        satList[d]+= d_sat
        d_total_sat += d_sat
            
    return d_total_sat


# sat = calcSat(tests)
# print(sat)


tests=list()
tests.append(0)
for d in range(D):
    tests.append((d % 26) +1)
    print((d%26)+1)



Measured memory_bytes: 9504
using System;
using System.Collections.Generic;
					
public class Program
{
	
	public static void Main()
	{
		var a =int.Parse(Console.ReadLine());
		List<Restrant> b = new List<Restrant>();
		List<Restrant> c = new List<Restrant>();
		for(int i = 0; a > i; i++){
			var x = new Restrant(Console.ReadLine());
			b.Add(x);
			c.Add(x);
		}
		b.Sort();
		
		foreach(var t in b){
			Console.WriteLine(c.IndexOf(t) + 1);
		}
		
	}
	
	
	class Restrant : IComparable{

		public String Place{get;set;}
		public int Score{get;set;}

		public Restrant(String input){
			var a = input.Split(' ');
			Place = a[0];
			Score = int.Parse(a[1]);
		}

		public int CompareTo(object O){
			Restrant tgt= (Restrant)O;
			int r = this.Place.CompareTo(tgt.Place);
			return r != 0 ? r : tgt.Score - this.Score;
		}
	
	}
}


Measured memory_bytes: 13524
#AGC A
h,w,a,b=map(int,input().split())
data=["" for i in range(h)]
for i in range(b):
    data[i]+="0"*(w-a)+"1"*a
for i in range(b,h):
    data[i]+="1"*(w-a)+"0"*a
for i in range(h):
    print(data[i])

Measured memory_bytes: 43632
#include<iostream>
#include<map>

std::map<char, int> mp;
int H, W;

bool ans = true;

void solve1(int a, int b){
	bool check;
	for(int i = 0; i < a; i += 2){
		check = false;
		if(a - i >= 2){
			if(b >= 2){
				for(char i = 'a'; i <= 'z'; i++){
					if(mp[i] >= 4) {
						mp[i] -= 4;	
						check = true;
						break;
					}
				}
			}else{
				for(char i = 'a'; i <= 'z'; i++){
					if(mp[i] >= 2) {
						mp[i] -= 2;	
						check = true;
						break;
					}
				}
			}
		}else{
			if(b >= 2){
				for(char i = 'a'; i <= 'z'; i++){
					if(mp[i] >= 2) {
						mp[i] -= 2;	
						check = true;
						break;
					}
				}
			}else{
				for(char i = 'a'; i <= 'z'; i++){
					if(mp[i] >= 1) {
						mp[i] -= 1;	
						check = true;
						break;
					}
				}
			}

		}
		if(!check)ans = false;
	}

}
void solve(int H, int W){
	if(H <= 0 || W <= 0)return;

	solve1(H, W);

	if(W >= 2)W -= 2;
	else W = 0;

	solve1(W, H);

	if(H >= 2)H -= 2;
	else H = 0;

	solve(H, W);
}

int main(){
	std::cin >> H >> W;
	char a;

	for(char i = 'a'; i <= 'z'; i++){
		mp[i] = 0;
	}

	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			std::cin >> a;
			mp[a]++;
		}
	}

	solve(H, W);

	std::cout << (ans ? "Yes" : "No") << std::endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n;
    cin >> n;
    vector<int> data(n+1);
    data[0]=0;
    rep(i,1,n+1){
        int a;
        cin >> a;
        data[i]=a;
    }
    int check = 0;
    int now = 1;
    int count = 0;
    rep(i,0,n){
        now = data[now];
        count ++;
        if(now==2){
            check=1;
            break;
        }
    }
    if(check==1){
        cout<<count<<endl;
    }else{
        cout<<-1<<endl;
    }
  return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}


int main() {

	string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int n;
	cin >> n;
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		int siz = s[i] - 'A';
		s[i] = alpha[(siz + n) % 26];
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::BufRead;

const MOD: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n: usize = sc.next().unwrap();
    let mut cs: Vec<usize> = vec![0; n];
    let mut prev = vec![-1i32; 200_001];
    let mut nxt = vec![-1i32; n];
    for i in 0..n {
        cs[i] = sc.next().unwrap();
        if prev[cs[i]] >= 0 {
            nxt[prev[cs[i]] as usize] = i as i32;
        }
        prev[cs[i]] = i as i32;
    }
    
    let mut dp = vec![0i64; n+1];
    dp[n] = 1i64;
    for i in (0..n).rev() {
        dp[i] += dp[i + 1];
        if i + 1 < n && cs[i] != cs[i+1] && nxt[i] >= 0 {
            dp[i] += dp[nxt[i] as usize];
        }
        dp[i] %= MOD;
    }
    // let res = recur(0, &mut memo, &nxt, &cs);
    println!("{}", dp[0]);
}


/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next());
/// assert_eq!(3.5, sc.next());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 10492
A, B, C = map(int,input().split())

if B %2 != 0:
    print(0)
    exit()
if A == B == C:
    print(-1)
    exit()

x = B/2
cnt = 0
while A % 2 == 0 and C % 2 == 0:
    tmp_a = A
    tmp_c = C
    A = tmp_c/2 + x
    C = tmp_a/2 + x
    cnt += 1
print(cnt)

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

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

int main()
{
    long long N;
    cin >> N;
    set<string> S;
    rep(i, N){
        string tmp;
        cin >> tmp;
        S.insert(tmp);
    }
    cout << S.size() << endl;
}



Measured memory_bytes: 19064
import numpy as np

def distance(x1, x2):
    return np.sqrt((x1[0] - x2[0])**2 + (x1[1] - x2[1])**2)

N = int(input())
X = []

N_exs = [0, 1, 2, 6, 24, 120, 720, 5040, 40320]

for _ in range(N):
    A, B = map(int, input().split())
    X.append([A, B])

total = 0
for i in range(N):
    for j in range(N-1, i, -1):
        if i == j:
            continue
        total += distance(X[i], X[j])

num = int((N * N - N) / 2)

# 1パターンあたりにN-1個ルートがあり、どのルートも均等に存在する
ans = total * (N-1) / num

print(ans)


Measured memory_bytes: 27068
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  ll n;
  cin>>n;
  vec h(n);
  loop(i,n){
    cin>>h[i];
  }
  ll count=0;
  bool endcheck=true;
  ll start=MAX;
  ll end=MIN;
  loop(j,5600){
    endcheck=true;
    start=MAX;
    end=MIN;
    loop(i,n){
      
      if(h[i]>0&&start==MAX){
        start=i;
      }
      
      if(h[i]!=0){
        endcheck=false;
      }
       if(h[i]==0&&start!=MAX){
          end=i;
          count++;
          Loop(k,start,end){
            h[k]--;
          }
          end=MIN;
          start=MAX;
        }
      
      
      
      
      
      
      }
    if(start!=MAX&&end==MIN){
        Loop(k,start,n){
          h[k]--;
        }
        count++;
    }
    if(endcheck)break;
  }
  putout(count);
}

Measured memory_bytes: 764
import sys
import numpy as np

s=sys.stdin.readline().strip()
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

if s=='ABC':
    print('ARC')
else:
    print('ABC')


Measured memory_bytes: 27084
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second

long long a, b, ans;

int main (){
    
    scanf("%lld%lld",&a,&b);
    ans = min(a, b / 2);
    a -= ans;
    b -= 2 * ans;
    //printf("%lld %lld %lld\n", ans, a, b);
    if(!a){
        ans += b / 4;
    }
    printf("%lld\n", ans);
        
    
    return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N, M, X;
    cin >> N >> M >> X;
    vector<vector<ll>> books(N, vector<ll>(M + 1));
    rep(i, N) {
        rep(j, M + 1) { cin >> books[i][j]; }
    }

    ll ans = INF;
    int mask = 1;

    for (int i = pow(2, N); i > 0; --i) {
        int cnt = i;
        vector<ll> table(M + 1, 0);
        for (int j = 0; j < N; ++j) {
            if ((cnt & mask) == 0) {
                cnt = cnt >> 1;
                continue;
            }
            cnt = cnt >> 1;
            for (int k = 0; k < M + 1; ++k) {
                table[k] += books[j][k];
            }
        }

        bool is_ok = true;
        for (int l = 1; l < M + 1; ++l) {
            if (table[l] < X) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) {
            chmin(ans, table[0]);
        }
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 4100
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll          long long
#define int         long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi         pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)

using namespace std;
using namespace __gnu_pbds;

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int> > minHeap;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cout << name << " : " << arg1 << endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif


istream &operator>>(istream &in, vector<int> &arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cin >> arr[i];
    return in;
}

ostream &operator<<(ostream &os, vector<int> arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cout << arr[i] << " ";
    cout << endl;
    return os;
}

void solution()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    cin >> arr;
    int maxx = arr[0];
    int ans = 0;
    loop(i,1,n)
    {
        if (arr[i] >= maxx)
            maxx = arr[i];
        else
            ans += abs(maxx - arr[i]);
    }
    cout << ans << endl;
}

signed main()
{
    fastio

    ll t = 1;
    // cin >> t;
    loop(i, 1, t + 1)
    {
        //cout<<"Case #"<<i<<": ";
        solution();
    }
}


    

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

const int max_n = 1e3 + 5;

char s[max_n];

int main() {
	scanf("%s", s);
	int m = strlen(s);
	if (m != 26) {
		set<char> secik;
		FOR(i,0,m) secik.insert(s[i]);
		FOR(i,'a','z'+1) {
			if (secik.find(i) == secik.end()) {
				printf("%s%c\n",s,i);
				return 0;
			}
		}
	} else {
		int x = 24;
		while (s[x] > s[x+1]) {
			x--;
			if (x==-1) {
				printf("-1\n");
				return 0;
			}
		}
		char bnd = s[x];
		set<char> secik;
		char mini = s[x+1];
		FOR(i,x,m) {
			secik.insert(s[i]);
			if (s[i] > bnd) {
				mini = min(mini, s[i]);
			}
		}
		s[x] = mini;
		s[x+1] = '\0';
		printf("%s\n", s);
	}
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

constexpr ll M = 998244353;

#define endl '\n'

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    cout << b + min(c, a + b + 1) << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()
    val hs = ArrayList<Int>()
    for (i in 1..n) {
        hs.add(scanner.nextInt())
    }
    hs.sort()
    var min = Int.MAX_VALUE
    for (i in 0..(hs.size - k)) {
        val it = hs[i + k - 1] - hs[i]
        if (it < min) min = it
    }
    print(min)
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n;
    cin>>n;
    vector<int> c(n-1),s(n-1),f(n-1);
    
    for(int i = 0; i < n-1; i++)
    {
        cin>>c[i]>>s[i]>>f[i];
    }
    
    for(int bgnstn = 0; bgnstn < n-1; bgnstn++)
    {
        int nowstn=bgnstn;
        int tim =0;
        
        while(nowstn<n-1){
            if(tim<=s[nowstn])
            {
                tim=s[nowstn];
            }
            else if(tim%f[nowstn]!=0)
            {
                tim=(tim/f[nowstn]+1)*f[nowstn];
            }
            tim+=c[nowstn];
            nowstn++;
        }
        cout<<tim<<endl;
    }

    cout<<0<<endl;//n
    return 0;
}

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

int main() {
    long N;
    cin >> N;
    map<long, long> m;
    for(long i=0; i<N; ++i) {
        long a;
        cin >> a;
        if(m.find(a) == m.end()) {
            m[a] = 1;
        }
        else m[a] += 1;
    }

    long cnt = 0;
    for(auto it=m.begin(); it!=m.end(); ++it) {
        if(it->first < m[it->first]) {
            cnt += m[it->first] - it->first;
        }
        else if(it->first > m[it->first]) {
            cnt += m[it->first];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 6272
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int a, b;
	cin >> a >> b;
	int ret = 0;
	if (a == b)ret = 2 * a;
	else ret = 2 * max(a, b) - 1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

ll count (ll x)
{
    if (x==0)
        return 1;
    ll cnt=0;
    while (x)
    {
        cnt++;
        x/=10;
    }
    return cnt;
}

ll f (ll a, ll b)
{
    return max(count(a),count(b));
}

main()
{
    fast;
    ll n,i,ans=INT_MAX;
    cin>>n;
    for (i=1;i<=sqrt(n);i++)
    {
        if (n%i==0)
            ans=min(ans,f(i,n/i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main()
{
	int n;
	
	while (1) {
		cin >> n;
		if (n == 0) break;
		vector<pair<int, int>> v;

		
		for (int i = 0; i < n; i++) {
			int a, b;
			cin >> a >> b;
			v.push_back(make_pair(b, a));
		}
		sort(begin(v), end(v));

		int w = 0;
		for (int i = 0; i < n; i++) {
			w += v[i].second;
			if (w > v[i].first) {
				cout << "No" << endl;
				goto next;
			}
		}
		cout << "Yes" << endl;
	next:;
	}
	return (0);
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
int upcmpii(const void *a, const void *b){
    return (*(int*)a == *(int*)b ? 0 : (*(int*)a > *(int*)b ? 1 : -1));
}
void sort_ui(int *a, int n){ qsort(a, n, sizeof(int), upcmpii); }

int main(){
    int n, t; scanf("%d%d",&n,&t);
    int a[202020];
    rep(i,n) scanf("%d",a+i);
    sort_ui(a,n);
    ll ans = t, tmp = a[0]+t;
    rep(i,n-1){
        if(tmp >= a[i+1]){
            ans += a[i+1] - a[i];
        }else{
            ans += t;
        }
        tmp = a[i+1] + t;
    }
    
    printf("%lld\n",ans);
}

Measured memory_bytes: 2516
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int gcd(int a, int b) {
    return b? gcd(b,a%b):a;
}

int main(){
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

vector<vector<int> > V;
int N, M;
int W[11][11];
int p[11];


int main() {

    cin >> N >> M;
    int k;
    for (int i = 0; i < M; i++) {
        cin >> k;
        int s;
        for (int j = 0; j < k; j++) {
            cin >> s;
            s--;
            W[i][s] = 1;
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }


    int ans = 0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<N); ++bit)
    {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }
        // bit の表す集合の出力
        int a[M + 1];
        for (int i = 0; i < M+1; i++) a[i] = 0;

        for (int i = 0; i < (int)S.size(); ++i) {
            for (int j = 0; j < M; j++) {
                if (W[j][S[i]] == 1) a[j]++;
            }
        }

        /*
        for (int i = 0; i < M; i++) {
            cout << a[i] << ' ';
        }
        cout << '\n';
        */

        int sum = 0;
        for (int i = 0; i < M; i++) {
            if ((a[i] % 2) == p[i]) sum++;
        }
        if (sum == M) ans++;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l.at(i);
    }
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=l.at(i);
    }
    cout<<ans<<endl;
}

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
//   cout<<std::setprecision(12)<<

int main()
{
    ll i,j,k,l,m,n,u,v;

    cin >> n >> m;

    ll ar[n+10],lc = 1;

    for(i=0;i<n;i++)
    {
        cin >> ar[i];
        lc = lcm(lc,ar[i]/2);
    }
    mapll mpp;
    for(i=0;i<n;i++)
    {
        mpp[lcm(ar[i],lc)]++;
    }
    //cout << lc <<endl;
    ll fin = 1e9;
    for(auto x : mpp)
    {
        u = m/lc;
        v = m/x.F;
        l = u-v;
        fin = min(fin,l);
    }

    cout<<fin<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int h, w;
    cin >> h >> w;
    
    string S[100];
    for(int i = 0; i < h; i ++){
        cin >> S[i];
    }
    for(int i = 0; i < w + 2; i ++){
        cout << "#";
    } cout << endl;
    
    for(int i = 0; i < h; i ++){
        cout << "#" << S[i] << "#" << endl;
    }
    
    for(int i = 0; i < w + 2; i ++){
        cout << "#";
    } cout << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  char S[100];
  cin >> N;
  for (int i=0;i<N;i++) cin >> S[i];
  bool flag = false;
  for (int i=0;i<N;i++){
    if(S[i]=='Y') flag = true;
  }    
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;
int main(){
int temp;
priority_queue<int> q;
char a[1000];
while(1){
scanf("%s",a);
if(a[2]=='d')return 0;
scanf("%d",&temp);
if(a[2]=='s'){
q.push(temp);
}
if(a[2]=='t'){
printf("%d\n",q.top());
q.pop();
}
}
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    repp(i, 5) {
        int a;
        cin >> a;
        if (a == 0) {
            prt(i);
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 3628