akhauriyash/Code-Regression huggingface dataset:
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# N = 3
# A = [[1, 1], [5, 1], [5, 5]]

# N = 2
# A = [[10, 20], [20, 20]]

N = get()
A = getss(N)
UF = {}


def find(x):
    if x != UF[x]:
        UF[x] = find(UF[x])
    return UF[x]


def union(x, y):
    UF.setdefault(x, x)
    UF.setdefault(y, y)
    UF[find(x)] = find(y)


for i, j in A:
    union(i, -j)
count = {}
for x in UF:
    root = find(x)
    if root not in count:
        count[root] = [0, 0]
    count[root][x > 0] += 1

print sum(u[0] * u[1] for u in count.values()) - N


Measured memory_bytes: 28604
#include <iostream>
#include <string>
using namespace std;
#define int long long
string s;
int k;
int sum=0;
int n;

signed main()

{
	ios::sync_with_stdio(false);
	cin>>s>>k;
	n=s.size();
	if (s==string(n,s[0])){
		cout<<n*k/2<<endl;
		return 0;
	}
	for (int i=0;i<n;i++){
		int cnt=1;
		while (i+1<n&&s[i]==s[i+1]){
			i++;
			cnt++;
		}
		sum+=cnt/2;
	}
	//cout<<sum<<endl;

	if (s[0]!=s[n-1]){
		cout<<sum*k<<endl;
	}
	else{
		int cnt0=1,cnt1=1;
		int i=0;
		while (i+1<n&&s[i]==s[i+1]){
			i++;
			cnt0++;
		}

		i=n-1;
		while (i>0&&s[i]==s[i-1]){
			i--;
			cnt1++;
		}

		if (cnt0%2==1 && cnt1%2==1){
			cout<<(sum+1ll)*k-1ll<<endl;
		}
		else cout<<sum*k<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n, p = read_int_list()
    a = read_int_list()
    a = map(lambda x: x % 2, a)
    o = sum(a)
    e = n - o
    res = 0
    c = 1
    for k in range(o + 1):
        if k % 2 == p % 2:
            res += c
        c *= o - k
        c //= k + 1
    res *= 2 ** e
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

int main() {
    int A, B, C, X, Y;
    scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
    
    int ans = 0;
    int cheaper_price = A + B < 2*C ? A + B : 2*C;
    while(X > 0 && Y > 0){
        X--; Y--;
        ans += cheaper_price; 
    }
    
    if (X > 0) {
        cheaper_price = A < 2*C ? A : 2*C;
        for (; X > 0; X--) ans += cheaper_price;
    } else if (Y > 0) {
        cheaper_price = B < 2*C ? B : 2*C;
        for (; Y > 0; Y--) ans += cheaper_price;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
K = int(input())
D = int(input())
MOD = 10**9 + 7

dp = [[[0]*(int(len(str(K)))+1) for _ in range(D)] for _ in range(2)]
dp[0][0][0] = 1

for digit in range(int(len(str(K)))):
    for smaller_flg in [0,1]:
        lim = 9 if smaller_flg else int(str(K)[digit])
        for digit_num in range(lim+1):
            new_smaller_flg = smaller_flg or digit_num < lim
            for mod_d in range(D):
                new_mod_d = (mod_d + digit_num)%D
                dp[new_smaller_flg][new_mod_d][digit+1] += dp[smaller_flg][mod_d][digit]
                dp[new_smaller_flg][new_mod_d][digit+1] %= MOD

print((dp[1][0][int(len(str(K)))] + dp[0][0][int(len(str(K)))] - 1) % MOD)

Measured memory_bytes: 59740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int l , r , d;
    cin >> l >> r >> d;
    if(l % d == 0){
        l = l / d;
    }
    else{
        l = l / d + 1;
    }
    if(r % d == 0){
        r = r / d;
    }
    else{
        r = r / d;
    }
    cout << r - l + 1 << endl;
}

Measured memory_bytes: 3616
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

@SuppressWarnings("unchecked")
public class Main {
	Scanner sc = new Scanner(System.in);

	class E implements Comparable<E> {
		int p;
		int d;
		int c;

		E(int pp, int dd, int cc) {
			p = pp;
			d = dd;
			c = cc;
		}

		public int compareTo(E tar) {
			if (tar.d == d) {
				return -tar.c + c;
			}
			return -tar.d + d;
		}
	}

	class ed {
		int t;
		int c;
		int d;

		ed(int tt, int cc, int dd) {
			t = tt;
			c = cc;
			d = dd;
		}
	}

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}

			LinkedList<ed>[] el = new LinkedList[n];
			for (int i = 0; i < n; i++) {
				el[i] = new LinkedList<ed>();
			}
			for (int i = 0; i < m; i++) {
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				int d = sc.nextInt();
				int c = sc.nextInt();

				el[a].add(new ed(b, c, d));
				el[b].add(new ed(a, c, d));
			}

			PriorityQueue<E> q = new PriorityQueue<E>();
			q.add(new E(0,0,0));
			boolean visited[] = new boolean[n];
			int ream = n;
			long res = 0;
			for (;;) {
				if(q.isEmpty()){
					break;
				}
				E now = q.poll();
				if(visited[now.p]){
					continue;
				}
				visited[now.p] = true;
				res += now.c;
//				System.out.println(now.p + " "+now.c);
				ream--;
				if(ream == 0){
					break;
				}
				
				for(ed e: el[now.p]){
					if(!visited[e.t]){
						q.add(new E(e.t , now.d + e.d, e.c));
					}
				}
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 16000
using System;


public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var s = Console.ReadLine().Trim();
            for (int loop = 0; loop < n; loop++)
            {
                var pre = s[0];
                var precount = 1;
                var consstring = "";
                for (int i = 1; i < s.Length; i++)
                {
                    if (s[i] == pre) precount += 1;
                    else
                    {
                        consstring += precount.ToString() + pre.ToString();
                        pre = s[i];
                        precount = 1;
                    }
                }
                consstring += precount.ToString() + pre.ToString();
                s = consstring;
            }
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 10228
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	int n = 0, max = 0;
	cin >> n;
	int sum = 0;
	int tab[n];
	for(int i = 0; i < n; i++) {
		cin >> tab[i];
		if(max < tab[i]) {
			max = tab[i];
		}
	}
	for(int j = 0; j < n; j++) {
		sum+=tab[j];
	}
	sum -= max;
	if(max < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        H.append(abs(x-cx)+abs(y-cy)+h)
      else:
        Z.append(abs(x-cx)+abs(y-cy))
    if len(Z)==0:
      Z.append(10**18)
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H[0])
      exit()

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

ll fact(ll a){
    ll b = 1;
    REPS(i, a)
    {
        b *= i;
        b = b % MOD;
    }
    return b;
}

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

    ll N,M;
    string S;
    cin >> N>>M;

    if(abs(N-M)>=2){
        cout << 0 << endl;
    }
    else if(N==M){
        cout << (fact(N) * fact(N) * 2)%MOD << endl;
    }
    else{
        cout << (fact(N) * fact(M)) % MOD << endl;
    }
}


Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Jan 27 21:06:32 2019
//
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type pair struct {
	a, b int
}

type pairs []pair

func (ps pairs) Len() int {
	return len(ps)
}
func (ps pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}

func (ps pairs) Less(i, j int) bool {
	return ps[i].a+ps[i].b > ps[j].a+ps[j].b
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()

	ps := make(pairs, N)
	for i := range ps {
		ps[i].a, ps[i].b = nextInt(), nextInt()
	}
	sort.Sort(ps)

	takahashi := 0
	aoki := 0
	for i := range ps {
		if i%2 == 0 {
			takahashi += ps[i].a
		} else {
			aoki += ps[i].b
		}
	}

	fmt.Println(takahashi - aoki)
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[n - i - 1] = sc.nextInt();
        }

        long ret = 0;
        for (int i = 0; i < n-1; i++) {
            int tmp = a[i] - a[i+1];
            if(tmp == 1) {
                ret++;
            }
            else if(tmp > 1) {
                System.out.println(-1);
                return;
            }
            else {
                ret += a[i];
            }
        }
        if(a[n-1] != 0) {
            System.out.println(-1);
        }
        else {
            System.out.println(ret);
        }
    }
}

Measured memory_bytes: 84384
#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;
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; }

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

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<cstdio>
#include<stack>
using namespace std;
const int N = 100010;
int f[N];
bool is[N];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	cin>>n>>m;
	if(m>=n){
		cout<<n<<endl;
		return 0;
	}
	for(int i=1;i<=n+1;i++){
		char c;
		cin>>c;
		is[i]=c-'0';
	}
	int last=-1;
	for(int i=n-m+1;i<=n+1;i++){
		if(!is[i]){
			last=f[n+1]=i;
			break;
		}
	}
	if(last==n+1){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=n;i>=m+1;i--){
		int l=i-m;
		int r=i;
		if(!is[l]){
			last=l;
		}
		if(last>r){
			cout<<-1<<endl;
			return 0;
		}
		f[i]=last;
	}
//	cout<<f[m+1]<<endl;
	for(int i=m;i>=1;i--){
		f[i]=f[m+1];
	}
//	for(int i=1;i<=n+1;i++){
//		cout<<f[i]<<endl;
//	}
	int t=n+1;
	stack<int> s;
	while(t!=1){
		s.push(t-f[t]);
		t=f[t];
		if(t==f[t] && t!=1){
			cout<<-1<<endl;
			return 0;
		}
	}
	while(!s.empty()){
		cout<<s.top()<<' ';
		s.pop();
	}
	return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>
int main(void){
   int W,H,x,y,r;
   scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
   W -= r,H -= r;
   if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
   else printf("No\n");
   return 0;
}


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

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

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  string s;
  cin >> s;
  
  int count = 0,mn = 0;
  
  for ( int i = 0; i < s.size(); i++){
    if ( s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T' ){
      count++;
      mn = max(mn,count);
    }else{
      count = 0;
    }
  }
  
  cout << mn << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visited = true;
    for(int i = 0; i < N; i++){
        if(!visited[i])all_visited = false;
    }
    
    if(all_visited)return 1;
    
    int ret = 0;
    for(int i = 0; i < N; i++){
        if(!graph[v][i])continue;
        if(visited[i])continue;
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
    return ret;
}

int main(){
    int N, M;
    cin >> N >> M;
    
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    
    bool visited[nmax];
    for(int i = 0; i < nmax; i++)visited[i] = false;
    visited[0] = true;
    
    cout << dfs(0, N, visited) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  //string S = {"SUN", "MON", "TUE", "WED", "TUE", "FRI", "SAT"};
  string S;
  cin >> S;

  if(S == "SUN")cout << 7;
  else if(S == "MON")cout << 6;
  else if(S == "TUE")cout << 5;
  else if(S == "WED")cout << 4;
  else if(S == "THU")cout << 3;
  else if(S == "FRI")cout << 2;
  else if(S == "SAT")cout << 1;

 return 0;
}

Measured memory_bytes: 256
#B AcCepted
b = input()
a = list(b)
c=z = len(b)
d =""
if a[0] == "A":
    a[0] = "a"
    c = 10000
for i in range(2,z-1):
    if a[i] == "C":
        a[i]="c"
        c+=1
for i in a:
    d+=i
if d.islower() and c == 10001:
    print("AC")
else:
    print("WA")
    
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <utility>


#define  PB push_back
#define  pB pop_back
#define  MP make_pair
#define  endl "\n"
using ll = long long;
using namespace std;
//128 bit integer :- __int128_t
const int INF = 1e9;
const int N = 1e5+1;

int idx (int a, int b, int x) 
{
    if (a <= b) return x;
    return x+1;
}
int main () {
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    /*10/08/2020
    int T;
    cin >> T;
    while (T--) {
        int n, i;
        string s;
        cin >> s;
        n = s.length ();
        int ans = 0;
        vector <int> index;
        int k = s.find ("two");
        while (k != -1) {
            ans++;
            index.PB (k+3);
            s.erase (s.begin ()+k+2);
            k = s.find ("two");
        }
        k = s.find ("one");
        while (k != -1) {
            ans++;
            index.PB (k+3);
            s.erase (s.begin ()+k+2);
            k = s.find ("one");
        }
        cout << ans << endl;
        for (auto b : index) cout << b << " ";
        cout << endl;
    }*/
    
    int n, i;
    cin >> n;
    int h [n];
    for (i = 0; i < n; i++) cin >> h [i];
    int ans [n];
    ans [n-1] = 0, ans [n-2] = abs (h [n-1] - h [n-2]);
    i = n-3;
    while (i >= 0) {
        ans[i]=min (abs (h[i]-h[i+1])+ans[i+1], abs (h[i+2]-h[i])+ans[i+2]);
        i--;
    }
    cout << ans [0];
    return 0;
}

Measured memory_bytes: 4404
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int as[256];

int s2i(string s){
    stringstream ss;
    ss << s;
    int ret;
    ss >> ret;
    return ret;
}

int m2i(string s){
    string soe;
    int ret = 0;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'm' or s[i] == 'c' or s[i] == 'x' or s[i] == 'i'){
            if(soe == ""){
                ret += as[s[i]];
            }else{
                ret += s2i(soe) * as[s[i]];
            }
            soe = "";
        }else{
            soe += s[i];
        }
    }
    return ret;
}

string i2m(int i){
    stringstream ss;
    ss << setw(4) << setfill('0') << i;
    string s;
    s = ss.str();
    string ret;
    for(int i=0;i<s.length();i++){
        if(s[i] == '0') continue;
        if(s[i] == '1'){
            switch(i){
            case 0:
                ret += 'm';
                break;
            case 1:
                ret += 'c';
                break;
            case 2:
                ret += 'x';
                break;
            case 3:
                ret += 'i';
                break;
            }
        }else{
            ret += s[i];
            switch(i){
            case 0:
                ret += 'm';
                break;
            case 1:
                ret += 'c';
                break;
            case 2:
                ret += 'x';
                break;
            case 3:
                ret += 'i';
                break;
            }
        }
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    as['m'] = 1000;
    as['c'] = 100;
    as['x'] = 10;
    as['i'] = 1;
    rep(lind,n){
        string a,b;
        cin >> a >> b;
        int ai = m2i(a);
        int bi = m2i(b);
        //cerr << ai << " " << bi << endl;
        cout << i2m(ai+bi) << endl;
    }
    return 0;
}

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

int main(){
    int n,c; cin >> n >> c;
    int p[c]; int sum(0);
    for(int i=0;i<c;i++){
        cin >> p[i];
        sum += p[i];
    }

    int mine = sum/(n+1);
    if(sum%(n+1) != 0){
        mine++;
    }
    cout << mine << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cstdio>

#include <algorithm>
#include <vector>
using namespace std;

int main()
{

	int a[3];
	int max;
	int pos = 0;
	for (int i = 0; i < 3; i++) {

		cin >> a[i];
		if (i == 0) {
			max = a[0];//初期値
		}

		if (max < a[i]) {
			pos = i;
			max = a[i];
		}

	}
	int sum = 0;
	for (int i = 0; i < 3; i++) {

		if (i != pos) {

			sum += a[i];
		}

	}

	cout << sum;






}


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 = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        int[] l = new int[n];
        l[0] = a[0];
        for(int i = 1; i < n-1; i++){
            l[i] = gcd(l[i-1], a[i]);
        }
        int[] r = new int[n];
        r[n-1] = a[n-1];
        for(int i = n-2; i > 0; i--){
            r[i] = gcd(r[i+1], a[i]);
        }
        
        int max = 0;
        int gcd;
        if(r[1] > max){
            max = r[1];
        }
        for(int i = 0; i < n-2; i++){
            gcd = gcd(l[i], r[i+2]);
            if(gcd > max){
                max = gcd;
            }
        }
        if(l[n-2] > max){
            max = l[n-2];
        }
        
        System.out.println(max);
    }
    
    private static int gcd(int a, int b){
        
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 48616
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <cstdio>

using namespace std;

int main()
{
    int n, m, ans=1;
    vector<int> fac, fac2;
    cin>>n>>m;
    for (int i=1; i<=sqrt(m); i++) if (m%i==0) fac.push_back(i);
    for (int i=0; i<fac.size(); i++)
    {
        fac2.push_back(fac[i]);
        fac2.push_back(m/fac[i]);
    }
    for (int i=0; i<fac2.size(); i++)
    {
        if (fac2[i]<=m/n) ans=max(ans, fac2[i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

const int N=100100,mod=1000000007;
typedef long long ll;
int n,f1[N],f2[N];
ll X,Y,q1[N],q2[N]; 

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>X>>Y;
	ll lst=-X-Y;
	int t1=0,w1=-1,t2=0,w2=-1;
	int res1=1,res2=0;
	for(int i=1;i<=n;++i){
		ll x;cin>>x;
		for(;t1<=w1&&x-q1[t1]>=X;++t1)res1=(res1+f1[t1])%mod;
		for(;t2<=w2&&x-q2[t2]>=Y;++t2)res2=(res2+f2[t2])%mod;
		int u=res1,v=res2;
		if(x-lst<X)t2=w2+1,res2=0;
		if(x-lst<Y)t1=w1+1,res1=0;
		++w1;q1[w1]=lst;f1[w1]=v;
		++w2;q2[w2]=lst;f2[w2]=u;
		lst=x;
	}
	for(;t1<=w1;++t1)res1=(res1+f1[t1])%mod;
	for(;t2<=w2;++t2)res2=(res2+f2[t2])%mod;
	cout<<(res1+res2)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 2560
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	unsigned long a[100000] = {0};

	for (int i =0; i<n; ++i){
		cin >> a[i];
	}

	sort(a, a+n);

	unsigned long long count = 0;
	int flag;
	for (int i=0; i<n; ++i){
		flag = 1;
		for(int j = i+1; j<n; ++j){
			if(a[i] == a[j]){
				flag *= -1;
				++i;
			}
			else{
				break;
			}
		}
		if (flag > 0){
			++count;
		}
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


int main()
{
  ll n;
  cin >> n;
  vector<ll> a;
  for(ll i = 0;i < n;i++)
  {
    ll A;
    cin >> A;
    a.push_back(A);
  }
  sort(a.begin(),a.end());
  for(ll i = 0;i < n-1;i++)
  {
    if(a[i] == a[i+1])
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <deque>
#include <math.h>
#include<vector>
#include<map>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
	int a, s, d, f;
	cin >> a >> s >> d;
	map<int, int>m;

	for (int t = 0; t < d; t++) {
		cin >> f;
		m[f]++;
	}

	for (int t = 1; t <= a; t++) {
		if ((s - d) + m[t] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
class Node
	attr_accessor :key, :right, :left, :parent
	def initialize(key, right, left, parent)
		@key = key; @right = right; @left = left; @parent = parent
	end
end

$none = Node.new(0, nil, nil, nil)
#$root = Node.new(0, $none, $none, $none)
$root = $none

def insert(k)
	y = $none	
	x = $root
	z = Node.new(k, $none, $none, $none)

	#cnt = 0
	while x != $none
		#puts cnt
		#cnt += 1

		y = x
		if z.key < x.key
			x = x.left
		else
			x = x.right
		end
	end

	z.parent = y
	if y == $none
		$root = z
	else
		if z.key < y.key
			y.left = z
		else
			y.right = z
		end
	end
end

def inorder(u)
	return if u == $none
	inorder(u.left)
	printf(" %d", u.key)
	inorder(u.right)
end

def preorder(u)
	return if u == $none
	printf(" %d", u.key)
	preorder(u.left)
	preorder(u.right)
end

n = gets.to_i
0...n.times do |i|
	line = gets.split
	com = line[0]
	if com == "insert"
		insert(line[1].to_i)
	elsif com == "print"
		inorder($root)
		puts
		preorder($root)
		puts
	end
end

Measured memory_bytes: 71176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VL a(n); cin >> a;
    ll ans = 0;
    {
        map<ll, ll> m;
        FOR(i, 0, n) {
            ans += m[i - a[i]];
            ++m[i + a[i]];
        }
    }
    {
        map<ll, ll> m;
        rFOR(i, 0, n) {
            ans += m[i - a[i]];
            ++m[i + a[i]];
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 27332
S1 = input()
N = len(S1)

S2 = S1[::-1]

a = S1 == S2

S3 = S1[:int((N - 1) / 2)]
S4 = S3[::-1]

b = S3 == S4

S5 = S1[int((N + 3) / 2) - 1:]
S6 = S5[::-1]

c = S5 == S6

if a and b and c:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 9124
#include<stdio.h>
int main(void)
{
    int n,k,i,s=1;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++){
        if((s*2)<=(s+k))
            s=s*2;
        else 
            s=s+k;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    
    int yen = b;
    if (6 <= a && a <= 12) {
      yen = yen/2;
    }
    else if (a < 6) {
      yen = 0;
    }
    Console.WriteLine(yen);
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long A, long long B) {
  cout << min(A, B) << " " << max(A + B - N, (LL)0) << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
ans = 0
for c1, c2 in zip(s, s[1:]):
    if c1 == 'R' and c2 == "R":
        ans += 1
for c1, c2 in zip(s[-1::-1], s[-2::-1]):
    if c1 == 'L' and c2 == "L":
        ans += 1
print(min(k * 2 + ans, n - 1))


Measured memory_bytes: 3316
// RemainderMinimization.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	long long a;
	long long b;
	cin >> a >> b;
	long long min1 = 2018;
	if (a % 2019 == 0 || b % 2019 == 0||(b-a >= 2020)) {
		cout << 0 << endl;
		return 0;
	}
	for (long long i = a; i < b; i++) {
		for (long long j = a + 1; j <= b; j++) {
			min1 = min((i * j) % 2019, min1);
		}
	}
	cout << min1 << endl;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    ll N, x;
    cin >> N >> x;
    vector<ll> vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    sort(vec.begin(), vec.end());
    ll sum = 0;
    REP(i, N) {
        if (x - vec[i] >= 0) {
            x -= vec[i];
            sum++;
        } else {
            x -= vec[i];
            break;
        }
    }
    
    if (x > 0) {
        sum--;  // 超過分を一人に押し付ける
    }
    
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    t = sum(a_list) / (4 * m)
    if len([a for a in a_list if a >= t]) >= m:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=2e5+7;

int n, c[N], a[N];
ll dp[N];
map<int, ll> M;

int main() {	
	scanf("%d", &n);
	for(int i=1; i<=n; i++) {
		scanf("%d", &c[i]);
	}
	int j=1;
	a[1]=c[1];
	for(int i=2; i<=n; i++) {
		if (c[i]==a[j]) continue;
		a[++j]=c[i];
	}
	dp[0]=1;
	for(int i=1; i<=j; i++) {
		dp[i]+=dp[i-1];
		dp[i]+=M[a[i]];
		dp[i]%=mod;
		M[a[i]]+=dp[i-1];
		M[a[i]]%=mod;
	}
	cout<<dp[j]<<endl;
	return 0;
}


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

int main() {
  vector<int> ant(5);
  for(int i=0;i<5;i++){
    cin >> ant.at(i);
  }
  int k;
  cin >> k;
  sort(ant.begin(), ant.end());
  if(ant.at(4) - ant.at(0) <= k){
    cout << "Yay!" << endl;
    return 0;
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  int x,a;
  cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        100005
#define mod         998244353  
#define pi          3.1415926535897932384626433
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,count,x,ans=0,j;
    cin>>n;
    for(i=2;i<=sqrt(n);i++){
        count=0;
        while(n%i==0){
            count++;
            n=n/i;
        }
        x=0;
        for(j=1;j<=100;j++){
            x+=j;
            if(x<=count){
                ans++;
            }
            else{
                break;
            }
        }
    }
    if(n>2){
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3696
c=[int(i) for i in input().split()]
Q=int(input())
inp=[map(int,input().split()) for i in range(Q)]
d=[(0,0,1),(-1,0,0),(0,1,0),(0,-1,0),(1,0,0),(0,0,-1)]
def north(r):
    res=[]
    for p in r:
        res.append((p[2],p[1],-p[0]))
    return res
def south(r):
    res=[]
    for p in r:
        res.append((-p[2],p[1],p[0]))
    return res
def east(r):
    res=[]
    for p in r:
        res.append((p[0],p[2],-p[1]))
    return res
def west(r):
    res=[]
    for p in r:
        res.append((p[0],-p[2],p[1]))
    return res
for k in range(Q):
    x=(0,0,0)
    y=(0,0,0)
    a,b=inp[k]
    for i in range(6):
        if a==c[i]:
            x=d[i]
        if b==c[i]:
            y=d[i]
    z=(y[1]*x[2]-y[2]*x[1],y[2]*x[0]-y[0]*x[2],y[0]*x[1]-y[1]*x[0])
    for i in range(6):
        if d[i]==z:
            print(c[i])


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

int main()
{
    int N;
    cin >> N;
    vector<ld> v;
    v.resize(N);
    rep(i,N)cin >> v[i];
    sort(v.begin(),v.end());
    ll k=1;
    for(int j=1;j<=N-1;j++,k*=2){
        v[j]=(v[j-1]+v[j]*k);
    }
    cout << v[N-1]/k << endl; 


}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	void solve(){
		char[]c=s.next().toCharArray();
		Arrays.sort(c);
		System.out.println(String.valueOf(c).equals("abc")?"Yes":"No");
	}
	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<double, double>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
ll C(ll a, ll b) {
	ll x = 1, y = 1;
	rep(i, b) {
		x = x * (a - i) % inf;
		y = y * (b - i) % inf;
	}
	rep(i, inf) {
		if (x == y * i % inf) {
			return i;
		}
	}
}
signed main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << max((ll)0,c - (a - b)) << endl;
	ggr
}


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

#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define int long long
using namespace std;
#define mod 1000000007

#define MAXN   1000001
int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i = 2; i < MAXN; i++)
        spf[i] = i;
    for (int i = 4; i < MAXN; i += 2)
        spf[i] = 2;

    for (int i = 3; i * i < MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j = i * i; j < MAXN; j += i)
                if (spf[j] == j)
                    spf[j] = i;
        }
    }
}
set<int> getFactorization(int x)
{
    set<int> ret;
    while (x != 1)
    {
        ret.insert(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    int n;
    cin >> n;
    int arr[n];
    bool flag = false;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }

    int gc = arr[0];
    for(int i = 1; i < n; i++)
    {
        gc = __gcd(gc, arr[i]);
    }
    set<int>set1 = getFactorization(arr[0]);
    for(int i = 1; i < n; i++)
    {
        set<int> v = getFactorization(arr[i]);
        for(auto it : v)
        {
            if(set1.find(it) != set1.end())
            {
                flag = true;
            }
            else
            {
                set1.insert(it);
            }
        }
    }
    if(!flag)
    {
        cout << "pairwise coprime" << endl;
    }
    else
    {
        if(gc == 1)
        {
            cout << "setwise coprime" << endl;
        }
        else
        {
            cout << "not coprime" << endl;
        }
    }
    return 0;
}






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

d = {}
for _ in range(N):
    op, value = input().split()
    if op == 'insert':
        d[value] = value
    elif op == 'find':
        if value in d.keys():
            print('yes')
        else:
            print('no')
    else:
        raise Exception

# print(d.keys())



Measured memory_bytes: 37972
#include <iostream>
#include <cmath>

typedef long long int llint;

int main(void){
  llint n;
  std::cin >> n;

  llint ceil_sqrt = std::ceil(std::sqrt(n));
  //std::cout << ceil_sqrt << std::endl;

  for(llint i=ceil_sqrt; i>=1; i--){
    if(n%i == 0){
      llint b = n/i;
      //std::cout << i << " " << b << std::endl;
      std::cout << (i-1)+(b-1) << std::endl;
      return 0;
    }
    
  }

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
int n,x[2010],y[2010],len,f[2010],d[2010];
void Print(int X,int Y){
	for(int i=1;i<=len;i++){
		if(abs(X)>abs(Y))
			if(X>0) putchar('R'),X-=d[i];
				else putchar('L'),X+=d[i];
		else if(Y>0) putchar('U'),Y-=d[i];
				else putchar('D'),Y+=d[i];
		
	}
	puts("");
	return ;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		f[(x[i]+y[i])%2]++;
	}
	if(f[1]&&f[0])return puts("-1"),0;
	for(int i=30;i>=0;i--)
		d[++len]=(1<<i);
	if(f[0])d[++len]=1;
	printf("%d\n",len);
	for(int i=1;i<=len;i++)
		printf("%d ",d[i]);
	puts("");
	for(int i=1;i<=n;i++)
		Print(x[i],y[i]);
}

Measured memory_bytes: 256
#164b
#1.値を受け取る
A, B, C, D = map(int, input().split())

#2.結果を出力する
while C or A >= 0:
    C =C - B
    A =A - D
    if C <= 0:
        print('Yes')
        break
    if A <= 0:
        print('No')
        break

Measured memory_bytes: 9104
N = int(input())
A = list(map(int,input().split()))
FB = [0 for _ in range(N//2)]
SB = A[N//2:N]
B = FB + SB
S = [i for i in range(1,N//2+1)]
FH = A[0:N//2]
for i in range(1,len(FH)+1):
    s = 0
    for j in range(2,N//S[-i]+1):
        s += B[S[-i]*j-1]
    if N % 2 == 0:
        if s % 2 != FH[-i]:
            B[-i-N//2] = 1
    else:
        if s % 2 != FH[-i]:
            B[-i-N//2-1] = 1            
ans = []
for i in range(N):
    if B[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)

Measured memory_bytes: 74984
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1 << 29;
ll N;
ll m = INF;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    cin >> N;
    for(ll i = 1; i * i <= N; ++i){
        if(N % i == 0){
            ll j = N / i;
            j = max(j, i);
            ll cnt = 1;
            while(j >= 10){
                j /= 10;
                cnt++;
            }
            m = min(cnt, m);
        }
    }
    cout << m << endl;
 
    return 0;
}

Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}


fn main() {
   input! {
      n: usize,
      k: usize,
      ab: [(usize, usize); n],
   }
   let mut ab = ab;
   ab.sort();
   let mut now = 0;
   for (a, b) in ab {
      now += b;
      if now >= k {
         println!("{}", a);
         return;
      }
   }
}


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

int main() {
    int N,M;
    cin >> N >> M;

    string result;

    if ( N == M){
      result = "Yes";
    } else{
      result = "No";
    }

    cout << result << endl; 

}


Measured memory_bytes: 256