akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n;
    map<string, int> dict;
    REP(i, n){
        string tmp;
        cin >> tmp;
        if(dict.count(tmp))dict[tmp]+=1;
        else dict[tmp]=1;
    }
    cin >> m;
    REP(i, m){
        string tmp;
        cin >> tmp;
        if(dict.count(tmp)) dict[tmp] +=-1;
        else dict[tmp]=-1;
    }

    int ans = 0;
    for(auto iter = dict.begin(); iter!=dict.end(); iter++)
        ans = max(ans, iter->second);
    
    // for(auto iter = dict.begin(); iter!=dict.end(); iter++)
    //     cout << "key: " << iter->first << " value: " << iter->second << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    ans := "AC"
    if s[0]!='A'{
        ans = "WA"
    }
    for i:=0; i<len(s); i++{
        if s[i]!='A' && s[i]!='C' && (s[i]>='A' && s[i]<='Z'){
            ans = "WA"
        }
    }
    cnt := 0
    for i:=2; i<len(s)-1; i++{
        if s[i]=='C'{
            cnt++
        }
    }
    if cnt!=1{
        ans = "WA"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  vector<int> S;
  loop(i,0,3) {
    int a;
    cin >> a;
    S.push_back(a);
  }
  if (abs(S[0]-S[1]) < abs(S[0]-S[2])) cout << "A" << endl;
  else cout << "B" << endl;
}


Measured memory_bytes: 3612
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = map(int, (input().split()))
dic = defaultdict(list)
seen = [-1] * (n+1)

for _ in range(m):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)


def dfs(v, todo, color):
    if seen[v] == color:  # 同じ色で戻ってくる = 偶サイクル
        return
    elif seen[v] == 1-color:  # 異なる色で戻ってくる = 奇サイクル
        ans = 0.5 * n * (n-1) - m
        print(int(ans))
        sys.exit()

    seen[v] = color
    for new_v in todo:
        new_todo = dic[new_v]
        dfs(new_v, new_todo, 1-color)


dfs(1, dic[1], 0)
black = seen.count(0)
white = seen.count(1)
ans = black * white - m

print(int(ans))

Measured memory_bytes: 34236
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	deque<char>q;
	cin >> S;

	REP(i, S.size())q.push_back(S[i]);

	int Q; cin >> Q;

	int pat = 1;

	REP(i, Q) {
		int a; cin >> a;
		if (a == 1)pat ^= 1;
		else {
			int b; cin >> b;
			char c; cin >> c;
			if (b == 1) {
				if(pat==1)q.push_front(c);
				else q.push_back(c);
			}
			else {
				if (pat == 1)q.push_back(c);
				else q.push_front(c);
			}
		}
		//cout << S << endl;
	}
	if (pat == 1) {
		REP(i, q.size())cout << q[i];
		cout << endl;
	}
	else {
		for (int i = q.size() - 1; i >= 0; i--) {
			cout << q[i];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 976
using System;

class Program
{
  static void Main(string[] args)
  {
    string str = Console.ReadLine();
    
    char a = str[0];
    char b = str[1];
    char c = str[2];
    
    bool AorB = false;
    
    if(a != b)
    {
      AorB = true;
    }else if(b != c){
      AorB = true;
    }
    
    if(AorB)
    {
      Console.WriteLine("Yes");
    }else{
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 13140
N = int(input())
A,B,C = [],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
dp = [[0,0,0] for i in range(N+1)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1,N):
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + A[i]
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + B[i]
    dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + C[i]
print(max(dp[N-1][0],dp[N-1][1],dp[N-1][2]))


Measured memory_bytes: 82520
/***************************************************************
	File name: B.cpp
	Author: huhao
	Create time: Sun 04 Aug 2019 08:02:10 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
int n,ans;
int main()
{
	n=read();
	fr(i,1,n)
	{
		if(int(log10(i))%2==0)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int r = in.nextInt();
        int s = in.nextInt();
        if (r >= 1 && r <= 20 && s >= 1 && s <= 20) {
            if (r >= 1 && r <= 9 && s >= 1 && s <= 9) {
                System.out.println(r * s);
            } else {
                System.out.println(-1);
            }

        }
    }
}


Measured memory_bytes: 25044
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::set;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

ull A, B, C, D, E, F;
ull i, j, k, l, m, n;
ull H, W, Q,S;
ull a, b, c, x, y;
ull K, L, N, M;
string str;

int main()
{
	cin >> A >> B >> C >> D >> E >> F;
	ull MAX_W=100*A, MAX_S=0;
	for (i = 0; i * 100 * A < F; ++i)
	{
		for (j = 0; i * 100 * A + j * 100 * B < F; ++j)
		{
			W = i * 100 * A + j * 100 * B;
			if (W == 0)continue;
			for (k = 0;; ++k)
			{
				for (l = 0;; ++l)
				{
					S = C*k + D*l;
					if(W+S<=F)
					{
						if (S * (100 + E) > E * (W + S))break;
						if (S * (MAX_W + MAX_S) > MAX_S * (W + S))
						{
							MAX_W = W;
							MAX_S = S;
						}
					}
					else break;
				}
				if (W + C*k > F)break;
			}
		}
	}
	cout << MAX_W + MAX_S << ' ' << MAX_S << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
using namespace std;
int main()
{
  int kosu;
  cin >> kosu;
  int heikin,riso;
  cin >> heikin >> riso;
  double hyoko[kosu];
  for(int i=0;i<kosu;i++){
    cin >> hyoko[i];
    hyoko[i]=heikin-hyoko[i]*0.006;
  }
  double min=INT_MAX,tmp;
  int minnum;
  for(int i=0;i<kosu;i++){
    if(riso-hyoko[i]<0)
      tmp=hyoko[i]-riso;
    else 
      tmp=riso-hyoko[i];
    if(tmp<min){
      min=tmp;
      minnum=i;
    }
  }
  cout << minnum+1 << endl;
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(long long a, long long b){

    if(a*b%2==0)
        printf("Even\n");
    else
        printf("Odd\n");

}

int main(){
    // cout << fixed << setprecision(5);

    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    func(a, b);
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] b = new boolean[n+1];
        long[] a = new long[n+1];
        long mod = 1_000_000_007;

        for(int i=0; i<m; i++) {
            b[sc.nextInt()] = true;
        }

        a[0] = 1;
        if(!b[1]) a[1] = 1;


        for(int i=2; i<=n; i++) {
            if(b[i]) continue;
            a[i] = a[i-2] + a[i-1];
            a[i] %= mod;
        }

        System.out.println(a[n]);

    }

}


Measured memory_bytes: 61336
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
  print(0)
  exit()
else:
  flag = True
  prd = 1
  A.sort(reverse=True)
  for i in range(N):
    prd *= A[i]
    if prd > 10**18:
      flag = False
      break
if flag:
  print(prd)
else:
  print(-1)

Measured memory_bytes: 21444
n = int(input())
li = list(map(int,input().split()))
total = 0
for i in range(max(li)):
    a = 0
    b = 0
    for j in range(n):
        if li[j] != 0 and a == 0:
            b += 1
            a = 1
        if li[j] == 0:
            a = 0
        else:
            a = 1
    for j in range(n):
        li[j] -= 1
        if li[j] < 0:
            li[j] = 0
    total += b
print(total)

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

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define SUMV(v)		(accumulate(v.begin(),v.end(),0.0))

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

//uint dp[MAX];


int main(){
	int D,N;cin>>D>>N;
	if(N==100)N++;
	if(D==0)
		cout << N << endl;
	else if(D==1)
		cout << (100*N) << endl;
	else
		cout << (10000*N) << endl;
 
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int h = in.nextInt(), w = in.nextInt();
        while (h != 0) {
            int[][] b = new int[h][w];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    b[i][j] = in.nextInt();
                }
            }

            int ans = 0;
            for (int i = 0; i < h - 2; i++) {
                for (int j = 0; j < w - 2; j++) {

                    for (int k = i + 2; k < h; k++) {
                        inner: for (int l = j + 2; l < w; l++) {
                            int min = Integer.MAX_VALUE;
                            for (int m = i; m <= k; m++) {
                                min = Math.min(min, b[m][j]);
                                min = Math.min(min, b[m][l]);
                            }
                            for (int n = j; n <= l; n++) {
                                min = Math.min(min, b[i][n]);
                                min = Math.min(min, b[k][n]);
                            }
                            //System.out.println("MIH" + min);

                            int v = 0;
                            for (int m = i + 1; m <= k - 1; m++) {
                                for (int n = j + 1; n <= l - 1; n++) {
                                    if (b[m][n] >= min) continue inner;
                                    v += min - b[m][n];
                                }
                            }
                            ans = Math.max(ans, v);
                        }
                    }
                }
            }
            out.println(ans);

            h = in.nextInt();
            w = in.nextInt();
        }
        out.flush();
    }

    private static List<String> parse(String s, boolean init) {
        List<String> res = new ArrayList<>();
        boolean q = init;
        StringBuilder sb = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (c == '"') {
                if (q) {
                    res.add(sb.toString());
                    q = false;
                } else {
                    sb.setLength(0);
                    q = true;
                }
            } else if (q) {
                sb.append(c);
            }
        }
        if (q) {
            res.add(sb.toString());
        }
        return res;
    }

}



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

void solve(int n){
    int ans=0;
    bool l=false,r=false,state=false;
    string str;
    for(int i=0;i<n;i++){
        cin>>str;
        if(str[0]=='l'){
            if(str[1]=='u')l=true;
            else l=false;
        }
        else{
            if(str[1]=='u')r=true;
            else r=false;
        }
        if(l&&r&&!state){
            state=true;
            ans++;
        }
        else if(!l&&!r&&state){
            state=false;
            ans++;
        }
    }
    cout<<ans<<endl;
    
}

int main(void){
    int a;
    while(cin>>a,a){
        solve(a);
    }
    
    
    
}

Measured memory_bytes: 3080
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

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

using namespace std;

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


ll N, K;
vl A(MAX-1), B(MAX-1);
vvl T(MAX);
vector<bool> TF(MAX, false);
vector<pair<ll,ll> > L(MAX, mp(0,0));
ll DP = 1;
queue<ll> NEXT;

void search(ll t) {
	if (TF[t])return;
	ll count = 0;
	ll s = 0;

	rep(i, T[t].size()) {
		ll dst = T[t][i];
		if (TF[dst] == true) {
			count++;
			s += L[dst].first;
			L[dst].first++;
			//rep(k, T[dst].size()) {
			//	if (TF[T[dst][k]] == true) {
			//		count++;
			//	}
			//}
		}
		else {
			NEXT.push(dst);
		}
	}
	L[t] = mp(count, s);

	TF[t] = true;
	DP = (DP * (K - (count+s))) % MOD;
}

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

	cin >> N >> K;
	rep(i, N - 1) {
		cin >> A[i] >> B[i];
		T[A[i] - 1].push_back(B[i] - 1);
		T[B[i] - 1].push_back(A[i] - 1);
	}

	search(0);
	while (!NEXT.empty()) {
		search(NEXT.front());
		NEXT.pop();
	}


	cout << DP << endl;


	return 0;
}



Measured memory_bytes: 10484
def main():
     def root(x):
          path=[]
          while x!=P[x]:
               path.append(x)
               x=P[x]
          for i in path:
               P[i]=x
          return x
     
     def is_same_set(x,y):
          return root(x)==root(y)
     
     def unite(x,y):
          P[root(x)]=root(y)
     
     n=int(input())
     P=[i for i in range(n)]
     edge_CostAndVertex=[]
     for i in range(n):
          cost=list(map(int,input().split()))
          for j in range(i):
               if cost[j]!=-1:
                    edge_CostAndVertex.append([cost[j],[i,j]])
                    
     edge_CostAndVertex.sort(key=lambda x:x[0])
     ans=0
     check=[]#連結されている頂点
     main_edge=edge_CostAndVertex[0][1][0]
     for i in edge_CostAndVertex:
          cost_i,a,b=i[0],i[1][0],i[1][1]
          if is_same_set(a,b):
               continue
          else:

               unite(a,b)
               ans+=cost_i
               if a not in check:
                    check.append(a)
               if b not in check:
                    check.append(b)
               if len(check)==n:
                    flag=1
                    for i in range(n):
                         for j in range(i):
                              if is_same_set(i,j):
                                   continue
                              else:
                                   flag=0
                                   break
                    if flag==1:
                         break
                    
     print(ans)
                    
if __name__=='__main__':
     main()


Measured memory_bytes: 6376
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    VL cnt(26, 1);
    for (char c : s){
        cnt[c - 'a']++;
    }
    ll ans = 1;
    REP(i,26) ans = (ans * cnt[i]) % mod;
    ans = (ans - 1 + mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import bisect
import copy

ans = 0
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    a = l[i]
    b = l[j]
    m = bisect.bisect_left(l, a + b)
    ans += (m - j - 1)
print(ans)

Measured memory_bytes: 3700
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

res = 0

from bisect import bisect_left, bisect_right

for b in B:
    idx_a = bisect_left(A, b)
    idx_c = bisect_right(C, b)
    res += idx_a * (n - idx_c)

print(res)

Measured memory_bytes: 107108
import java.util.Scanner;

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

		int x = sc.nextInt();
		int y = sc.nextInt();
		
		while (x!=y) {
			if(x>y) {
				x-=y;
			} else {
				y-=x;
			}
		}
		
		System.out.println(y);

	}
}


Measured memory_bytes: 26360
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=0;
  for(int i=0;i<s.length();i++){
    n+=s[i]-'0';
  }
  if(n%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            long N = long.Parse(input.Split(' ')[0]);
            long K = long.Parse(input.Split(' ')[1]);
            long[] h = new long[N];
            string[] h_in = Console.ReadLine().Split(' ');
            long count = 0;
            for (int i = 0; i < N; i++)
            {
                h[i] = long.Parse(h_in[i]);
                if (h[i] >= K) count++;
            }

            Console.WriteLine(count.ToString());
//            Console.Read();
        }
    }
}

Measured memory_bytes: 16480
mod = 10 ** 9 + 7
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
numl = Array.new(n)
numr = Array.new(n)

n.times do |i|
    c = 0
    d = 0
    (i + 1).upto(n - 1) do |j|
        c += 1 if a[i] > a[j]
    end

    (i - 1).downto(0) do |j|
        d += 1 if a[i] > a[j]
    end

    numl[i] = c
    numr[i] = d
end

ans = 0
n.times do |i|
    ans += numl[i] * k * (k + 1) / 2
    ans += numr[i] * k * (k - 1) / 2
    ans %= mod
end

puts ans

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

int main() {
  string s;
  
  for (int i = 0; i < 3; i++) {
    cin >> s;
  
    if(s.size() < 1 || s.size() > 100) {
      break;
    }
    else {
	  cout << s.at(0);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
#define pss pair<string,string>
using namespace std;
map<pss,int>Map;
int n;
char p[40];
void Go1(int pv, int e, string &a, string &b) {
	if (pv == e) {
		Map[pss(a, b)]++;
		return;
	}
	a += p[pv];
	Go1(pv + 1, e, a, b);
	a.pop_back();
	b += p[pv];
	Go1(pv + 1, e, a, b);
	b.pop_back();
}
long long res = 0;
void Go2(int pv, int e, string &a, string &b) {
	if (pv == e) {
		res += Map[pss(b, a)];
		return;
	}
	a += p[pv];
	Go2(pv - 1, e, a, b);
	a.pop_back();
	b += p[pv];
	Go2(pv - 1, e, a, b);
	b.pop_back();
}
int main() {
	int i;
	scanf("%d", &n);
	scanf("%s", p);
	string t1="", t2="";
	Go1(0, n, t1, t2);
	Go2(2 * n - 1, n - 1, t1, t2);
	printf("%lld\n", res);
}

Measured memory_bytes: 86272
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    ll x,a;
    cin>>x>>a;
    if(x<a) cout<<"0"<<endl;
    else cout<<"10"<<endl;
}


Measured memory_bytes: 256
main = do
  x <- read . concat . words <$> getLine :: IO Int
  let rx = floor . sqrt . realToFrac $ x
  if judge x [1..rx]
    then putStrLn "Yes"
    else putStrLn "No"

judge :: Int -> [Int] -> Bool
judge _ []     = False
judge x (y:ys) = if x == y^2
                   then True
                   else judge x ys


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin  >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int tmp = 0, prev = -1;
    int ans = 0;
    repe(i, a){
        if(prev == i) tmp++;
        else{
            ans += tmp / 2;
            tmp = 1;
            prev = i;
        }
    }
    ans += tmp / 2;
    cout << ans << endl;


}

Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)
S=input()
S=S[::-1]
i=0
x=0
MOD=2019
for s in S:
  x+=(int(s)*pow(10,i,MOD))%MOD
  x%=MOD
  d[x]+=1
  i+=1
ans=0
for k in d.values():
  ans=ans+k*(k-1)//2
print(ans+d[0])


Measured memory_bytes: 9788
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ll n;
    l sum=0.0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    sum=(l)((a[0]+a[1])/2.0);
    //cout<<sum<<endl;
    for(int i=2;i<=n-1;i+=1)
    {
        sum=(l)((sum+a[i])/2.0);
    }
    cout<<fixed<<setprecision(7)<<(l)sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
 
using namespace std;
 
long long a, b, c;
vector< long long > tab;
 
int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>a>>b>>c;
	if( a%2 == 0 )
	{
		cout<<0;
		return 0;	
	}
	if( b%2 == 0 )
	{
		cout<<0;
		return 0;	
	}
	if( c%2 == 0 )
	{
		cout<<0;
		return 0;	
	}
	
	tab.push_back( a );
	tab.push_back( b );
	tab.push_back( c );
	sort( tab.begin(), tab.end() );
	cout<<tab[0]*tab[1]<<endl;
	return 0;	
}

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

int main() {
	long long N, M;
	cin >> N >> M;
	long long S = N;
	long long c = M;
	if (S >= c / 2) {
		cout << c / 2 << endl;
	}
	else {
		long long piece = S;
		cout << piece + (c - piece * 2) / 4 << endl;
	}
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m,x = readInts()
    ans = float('inf')
    money = []
    rikai = []
    for i in range(n):
        LIST = readInts()
        money.append(LIST[0])
        rikai.append(LIST[1:])
    #print(money,rikai)
    # bit 全探索
    for bit in range(1 << n):
        mo = 0
        ansrikai = [0] * m
        for i in range(n):
            if bit & (1 << i):
                mo += money[i]
                for j in range(m):
                    ansrikai[j] += rikai[i][j]
        ok = True
        #print(ansrikai)
        for j in range(m):
            if ansrikai[j] >= x:
                ok = True
            else:
                ok = False
                break
        if ok:
            #print(ansrikai)
            ans = min(ans,mo)
    print(ans if ans != float('inf') else -1)
if __name__ == '__main__':
  main()


Measured memory_bytes: 73728
import java.util.Scanner;

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

        while(true){
            int num = scanner.nextInt();
            if (num == 0){
                break;
            }

            int[] score = new int[num];

            for(int i = 0; i < num; i++){
                score[i] = scanner.nextInt();
            }

            double ave;
            double sum = 0;
            for(int s : score){
                sum += s;
            }
            ave = sum / num;
            sum = 0;

            for(int s : score){
                sum += Math.pow(s-ave, 2);
            }

            System.out.println(Math.sqrt( sum / num));
        }

        scanner.close();
    }
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

const int INFTY = pow(10, 8);

int main()
{
    int n; cin >> n;
    int p[n+1];
    int m[n+1][n+1];
    rep(i,n){
        m[i][i] = 0;
        int p1, p2; cin >> p1 >> p2;
        p[i] = p1;
        if(i == n-1){
            m[i+1][i+1] = 0;
            p[i+1] = p2;
        }
    }

    for(int l=2; l<=n; l++){
        for(int i=1; i<=n-l+1; i++){
            int j = i+l-1;
            m[i][j] = INFTY;
            for(int k=i; k<j; k++){
                m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
}


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

using namespace std;
typedef long long ll;

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

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

  if(a==b && a!=c)
    cout << "Yes" << endl;
  else if(b==c && a!=c)
    cout << "Yes" << endl;
  else if(c==a && b!=c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


//cout << setprecision(13);
//next_permutation(v.begin(), v.end());



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,m,ans=0;
    cin >> n >> m;
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }//到達目標が置ける駒の数以下のとき

//以下 n<m    

    vector<int> v(m);
    for(int i=0;i < m;i++)
    {
        cin >> v.at(i);
    }//input
    sort(v.begin(),v.end());

    if(n==1){
        cout << v.at(m-1)-v.at(0) << endl;
        return 0;
    }//n==1でgapが発生しない場合

    vector<int> gap(m-1,0);//gap
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>> > q;

    for(int i=0;i < n-1;i++)
    {
        q.push({0,0});
    }//queueの初期化
    
    for(int i=0;i < m-1;i++)
    {
        gap.at(i)=v.at(i+1)-v.at(i);

        if(gap.at(i)>q.top().fi){
            q.pop();
            q.push({gap.at(i),i});
        }
    }//queueにはgapの大きい上位３の、左端の添え字が入っている
    //gapの大きさでソートしたいのでpair

    vector<int> u;
    while(q.size()!=0)
    {
        u.push_back(q.top().se);
        q.pop();
    }//添え字を再格納してソート
    sort(u.begin(),u.end());//添え字をソート

    int x=0;
    while(u.size()!=0){
        ans += v.at(u.at(0))-v.at(x);
        x=u.at(0)+1;
        u.erase(u.begin());
    }

    ans += v.at(v.size()-1)-v.at(x);

    cout << ans << endl;
}

Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <map>
#include <utility>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    map<string, int> memo;
    string S;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        memo[S]++;
    }

    int max = 0;
    int v;
    for (const auto& x : memo)
    {
        v = x.second;
        if (v > max) max = v;
    }
    
    for (auto itr = memo.begin(); itr != memo.end(); itr++)
    {
        if (itr->second == max)
        {
            cout << itr->first << endl;
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 25216
a,b,c=map(int,input().split())
n=0
if a==b:
    if c%a==0:
        n+=1
        print(n)
    else:
        print(n)

else:
    for i in range(a,b+1):
        if c%i==0:
            n+=1
        else:
            pass
    print(n)


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

long long n;
long long cnt[105] = {0};
long long data[10] = {0};

long long solve();

int main() {
  cin >> n;
  for(long long i = 2; i <= n; ++i) {
    long long x = i;
    for(long long j = 2; j * j <= x; ++j)
      while(x % j == 0) {
        ++cnt[j];
        x /= j;
      }
    if(x > 1) ++cnt[x];
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 2; i <= n; ++i) {
    if(cnt[i] + 1 >= 75)
      ++data[0];
    else if(cnt[i] + 1 >= 25)
      ++data[1];
    else if(cnt[i] + 1 >= 15)
      ++data[2];
    else if(cnt[i] + 1 >= 5)
      ++data[3];
    else if(cnt[i] + 1 >= 3)
      ++data[4];
  }
  // 75
  ans += data[0];
  // 3 25
  for(int i = 0; i < 2; ++i) {
    ans += data[i] * (data[i] - 1);
    for(int j = 0; j < 5; ++j)
      if(i != j) ans += data[i] * data[j];
  }
  // 5 15
  for(int i = 0; i < 3; ++i) {
    ans += data[i] * (data[i] - 1);
    for(int j = 0; j < 4; ++j)
      if(i != j) ans += data[i] * data[j];
  }
  // 3 5 5
  for(int i = 0; i < 4; ++i)
    ans += data[i] * (data[i] - 1) * (data[i] - 2) / 2;
  for(int i = 0; i < 5; ++i) {
    for(int j = 0; j < 4; ++j)
      for(int k = j; k < 4; ++k) {
        if(i == j && j == k) continue;
        if(i == j)
          ans += data[i] * (data[j] - 1) * data[k];
        else if(i == k)
          ans += data[i] * data[j] * (data[k] - 1);
        else if(j == k)
          ans += data[i] * data[j] * (data[k] - 1) / 2;
        else
          ans += data[i] * data[j] * data[k];
      }
  }
  return ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	double x[101],y[101],s[101];
	double n,d1,d22,d2,d33,d3,d8,max;
	int i;
	
	scanf("%lf",&n);
	
	rep(i,0,n) scanf("%lf",&x[i]);
	rep(i,0,n) scanf("%lf",&y[i]);
	
	max=0;
	rep(i,0,n){
		s[i]=fabs(x[i]-y[i]);
		d1+=s[i];
		d22+=pow(s[i],2);
		d33+=pow(s[i],3);
		if(s[i]>max) max=s[i];
	}
	
	d2=pow(d22,0.5);
	d3=pow(d33,1.0/3);
	d8=max;
	
	printf("%lf\n%lf\n%lf\n%lf\n",d1,d2,d3,d8);
	
	return 0;
}



Measured memory_bytes: 2108
h, w = gets.split(" ").map(&:to_i)
map = []
for i in 1..h
  line = gets.chomp.split("")
  map << line
end

map.each_with_index do |a, i|
  a.each_with_index do |b, j|
    # p map[i][j]
    if map[i][j] == "."
      map[i][j] = 0

      if i != 0
        if j != 0
          if map[i-1][j-1] == "#"
            map[i][j] += 1
          end
        end
        if map[i-1][j] == "#"
          map[i][j] += 1
        end
        if map[i-1][j+1] == "#"
          map[i][j] += 1
        end
      end

      if j != 0
        if map[i][j-1] == "#"
          map[i][j] += 1
        end
      end
      if map[i][j+1] == "#"
        map[i][j] += 1
      end

      if i != h-1
        if j != 0
          if map[i+1][j-1] == "#"
            map[i][j] += 1
          end
        end
        if map[i+1][j] == "#"
          map[i][j] += 1
        end
        if map[i+1][j+1] == "#"
          map[i][j] += 1
        end
      end
    end
  end
end

map.each do |m|
  puts m.join
end

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=0;
    bool f=0;
    while(1){
        if(!f){
            c-=b;
            if(c<=0){
                cout<<"Yes\n";
                break;
            }
            f=1;
        }
        else{
            a-=d;
            if(a<=0){
                cout<<"No\n";
                break;
            }
            f=0;
        }
    }

    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key,vi a) {
    int left = -1;
    int right = (int)a.size();
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        
        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }
    return right;
}

int modpow(int a,int b,int p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    S s;
    cin >> s;
    bool d[4]={false,false,false,false};
    rp(i,s.size()){
        if(s.at(i)=='N'){
            d[0]=true;
        }elif(s.at(i)=='S'){
            d[1]=true;
        }elif(s.at(i)=='E'){
            d[2]=true;
        }elif(s.at(i)=='W'){
            d[3]=true;
        }
    }
    if(d[0]==d[1]&&d[2]==d[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int a, b;
	cin >> a >> b;
	int cnt = 1;
	int ans = 0;
	while (cnt < b) {
		--cnt;
		cnt += a;
		++ans;
	}
	cout << ans << "\n";

	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;

  double ans = 0;
  for (int64_t i = 1; i <= n; i++) {
    auto j = i;
    double tmp = static_cast<double>(1) / n;
    while (j < k) {
      tmp /= 2;
      j *= 2;
    }
    ans += tmp;
  }

  std::cout << std::fixed << std::setprecision(12) << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
sc = [tuple(map(int,input().split())) for i in range(M)]

if N==1:
    r = range(0,10)
elif N==2:
    r = range(10,100)
else:
    r = range(100,1000)

for n in r:
    n = str(n)
    for s,c in sc:
        s -= 1
        if n[s] != str(c):
            break
    else:
        print(n)
        exit()
print(-1)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>
#include <iomanip>

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

using namespace std;
using p = pair<int, int>;
using ll = long long;



int main() {
	const double PI = acos(-1);
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double m_angle = 6 * m / 180 * PI;
	double h_angle = ((double)30 * h + (double)m / 2) / 180 * PI;
	double t = abs(m_angle - h_angle);
	if (t > PI) t = 2*PI - t;
	double ans = pow(a,2) + pow(b,2);
	ans -= 2 * a * b * cos(t);
	cout << setprecision(19) << sqrt(ans) << endl;
}

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

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> s(n);

    rep(i, n){
        cin >> s[i];
    }

    rep(i, n){
        for(int j = n-1; j > i; j--){
            if(s[j] < s[j-1]){
                swap(s[j], s[j-1]);
            }
        }
    }

  	string str = "";
  	rep(i, n) str += s[i];
  	cout << str;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 3e3 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n;
ld dp[maxn][maxn], p[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> p[i];
    dp[0][1] = p[0];
    dp[0][0] = 1 - p[0];
    for(int i = 1; i < n; i++)
    {
        for(int h = 0; h <= i; h++)
        {
            int t = i - h;
            dp[i][h + 1] += (dp[i - 1][h] * p[i]);
            dp[i][h] += dp[i - 1][h] * (1 - p[i]);
        }
    }
    ld ans = 0;
    for(int i = (n + 1) / 2; i <= n; i++)
        ans += dp[n - 1][i];
    cout << setprecision(10) << fixed << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	 printf
#define sf			 scanf
#define pb(a)        push_back(a)
#define mp			 make_pair
#define ff			 first
#define ss			 second
#define for0(i,n)    for(int i=0;i<n;i++)
#define for1(i,n)    for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define sq(a)		 (a)*(a)
#define endl		     "\n"
#define abs(x)		 fabs(x)
#define all(v) 		 v.begin(),v.end()
#define pcase(z,x)   cout<<"Case "<<z<<": "<<x<<"\n"
#define mod 1000000007
#define WakandaForever     ios_base::sync_with_stdio(0); cin.tie(0);
ll fac[1000007];
ll pow_mod(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b /= 2;
    }
    return res%mod;
}

int main()
{
    WakandaForever
    
    ll n;
    cin>>n;
    ll x = (pow_mod(9,n) + pow_mod(9,n))%mod;
    x = (x - pow_mod(8,n))%mod;
    ll ans = (pow_mod(10,n) - x)%mod;
    cout<<(ans+mod)%mod<<endl;


    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int64_t a, b, c, k;
  cin >> a >> b >> c >> k;

  int64_t ans;
  if (k % 2 == 1) {
    ans = b - a;
  } else {
    ans = a - b;
  }
  if (ans > 1e18) {
    cout << "Unfair" << '\n';
    return 0;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <memory>
using namespace std;
int main(){
	string suit,line;
	for(;getline(cin,suit),suit!="#";){
		vector<unique_ptr<istringstream>> v;
		for(int i=0;i<4;i++){
			getline(cin,line);
			//lovely "use of deleted function std::basic_istringstream"...
			//http://stackoverflow.com/a/12018358/2641271
			//Note: gcc 5.0.0 head and clang don't have this issue.
			v.push_back(unique_ptr<istringstream>(new istringstream(line)));
		}
		vector<string>card(4);
		vector<int>num(4);
		vector<int>point(4);
		for(int Z=0,winner=0;Z<13;Z++){
			for(int i=0;i<4;i++)(*v[i])>>card[i];
			for(int i=0;i<4;i++){
				num[i]=card[i][1]==suit[0]?26:card[i][1]==card[winner][1]?13:0;
				num[i]+=card[i][0]=='T'?10:card[i][0]=='J'?11:card[i][0]=='Q'?12:card[i][0]=='K'?13:card[i][0]=='A'?14:card[i][0]-'0';
			}
			winner=distance(num.begin(),max_element(num.begin(),num.end()));
			point[winner]++;
		}
		if(point[0]+point[2]>point[1]+point[3]){
			printf("NS %d\n",point[0]+point[2]-6);
		}else{
			printf("EW %d\n",point[1]+point[3]-6);
		}
	}
}

Measured memory_bytes: 1208
//MD. HASNAIN ALI (UNSOLVED)
#include <bits/stdc++.h>

#define ll long long
#define pii pair<int,int>

#define distance(a,b) (sq(a.x-b.x) + sq(a.y-b.y))
#define MAX3(a,b,c) max(a,max(b,c))
#define SQ(x) ((x) * (x))
#define SWAP(a,b) {        \
                    a=a+b; \
                    b=a-b; \
                    a=a-b; }

using namespace std;

int main()
{
    int a,b,c;
    double d;
    scanf("%d %d",&a,&b);
    d=(a+b)/2.0;
    c=(a+b)/2.0;
    if(c==d) printf("%d\n",c);
    else printf("IMPOSSIBLE\n");

    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int AB = A + B;
  int CD = C + D;
  if (AB > CD) cout << "Left" << endl;
  if (AB == CD) cout << "Balanced" << endl;
  if (AB < CD) cout << "Right" << endl;
}

Measured memory_bytes: 3604