akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 100000 + 5;
const int M = 3000 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, ans;
int a[N], pre[N], suc[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    pre[1] = a[1];
    for (int i = 2; i <= n; i++) {
        pre[i] = std::__gcd(pre[i - 1], a[i]);
    }
    suc[n] = a[n];
    for (int i = n - 1; i >= 1; i--) {
        suc[i] = std::__gcd(suc[i + 1], a[i]);
    }
    for (int i = 2; i < n; i++) {
        ans = std::max(ans, std::__gcd(pre[i - 1], suc[i + 1]));
    }
    ans = std::max(ans, std::max(suc[2], pre[n - 1]));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1408
def dfs(v, visited):
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False


xn, yn, e = map(int, input().split())
edges = [set() for _ in range(xn)]
matched = [-1] * yn

for _ in range(e):
    x, y = map(int, input().split())
    edges[x].add(y)

print(sum(map(lambda s: dfs(s, set()), range(xn))))

Measured memory_bytes: 8532
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		//String result = "NO";
		for(int i = 0; i < min(k, 100); i++){
		    int[] b = new int[n];
		    for(int j = 0; j < n; j++){
		        int cnt = a[j];
		        int from = max(0, j-cnt);
		        int to = min(n-1, j+cnt);
		        b[from]++;
		        if(to+1 < n) b[to+1]--;
		    }
		    for(int j = 0; j < n; j++){
		        if(j == 0) a[j] = b[j];
		        if(j > 0) a[j] = b[j] + a[j-1];
		    }
		}
		
		// 出力
		for(int i = 0; i < n; i++){
		    System.out.print(a[i] + " ");
		}
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 55200
N = int(input())
S = input()
a = 0
if N%2 == 1:
    print("No")
else:
    for i in range(N//2):
        if S[i] == S[i+(N//2)]:
            a += 1
    if a == N//2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, Q;
    ll K;
    vector<int> A(100010);
    cin >> N >> K >> Q;
    for (int i=0;i<Q;i++) cin >> A[i];
    vector<ll> S(N,K-Q);
    for (int i=0;i<Q;i++) S[A[i]-1]++;
    for (int j=0;j<N;j++) {
        if (S[j]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
import sys,collections as cl,bisect as bs
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,k = m()

a = 1/n

su = 0
nn = 0
for i in range(1,n+1):
	kk = -(-k//i)
	n = 1
	while True:
		if kk <= n:
			break
		else:
			n = n * 2
			nn += 1
	su += a * ((1/2) ** nn)
	nn = 0

print(su)


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
// const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll k;cin>>k;
    if(k%2==0||k%5==0)dame(-1);
    if(k%7==0)k/=7;
    if(k==1)dame(1);
    ll sum=1;
    rep(i,inf){
        sum=sum*10%k;sum++;
        sum%=k;
        if(sum==0)dame(i+2);
        if(i>10000000)dame(-1);
    }
}

Measured memory_bytes: 3612
from itertools import groupby
# https://atcoder.jp/contests/abc122/tasks/abc122_b
S = list(input())
b = [i in list('ACGT') for i in S]

ans = 0
for i, j in groupby(b):
    num_elements = len(list(j))
    if i and num_elements > ans:
        ans = num_elements
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace Atcoder
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }
        private static object GetResult()
        {
            var input = ReadTexts();
            string result;

            System.Numerics.BigInteger x = input[0].ToLong();
            System.Numerics.BigInteger y = 100;

            for (int i = 1; true; i++)
            {
                y = y + (y / 100);

                if (y >= x)
                {
                    result = i.ToString();
                    break;
                }
            }

            return result;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }

        #endregion
    }

    public static class CastExtention
    {
        public static long ToLong(this string a) { return long.Parse(a); }
    }
}

Measured memory_bytes: 28628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll h, w; cin >> h >> w;
    ll ans = h*w;
    if(h==1 || w==1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (ans-1)/2+1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,m;
	cin >> n >> m;
	n *= (n-1);
	m *= (m-1);
	cout << ((n+m)/2) << endl;
	return 0;
}


Measured memory_bytes: 764
S = list(map(int, input()[::-1]))

R=[0]
r=0
k=1
for c in S:
    r = (r+k*c) % 2019
    k = k*10 % 2019
    R.append(r)
    
N = [0]*2019
ans = 0
for r in R:
    ans += N[r]
    N[r] += 1
print(ans)


Measured memory_bytes: 17852
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

set<string> st;

int main(){
	int n; cin >> n;
	REP(i, n){
		string s; cin >> s;
		st.emplace(s);
	}
	printf("%d\n", (int)st.size());
}


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

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

	long long work = N/K;
	long long ans = work * work * work;

	work = 0;

	if(K % 2 == 0) work = (N + K/2) / K;

	cout << ans + work * work * work << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
	*/
	string a, b;
	cin >> a >> b;
	int count = 0;
	rep0(i,2)if (a[i] == b[i])count++;
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    int N,d,td;
    bool flag = false;
    cin >> N;

    vector<int> t(N+1,0);
    vector<vector<int>> p(N+1,vector<int>(2,0));

    for(int i=1;i<N+1;i++){
        cin >> t[i];
        cin >> p[i][0] >> p[i][1];
    }
    for(int i=1;i<N+1;i++){
        d = p[i][0] - p[i-1][0] + p[i][1] - p[i-1][1];
        td = t[i]-t[i-1];

        if(d > td || (d+td)%2 == 1){
            flag = true;
            break;
        }
    }
    
    
    cout << (!flag ? "Yes" : "No") << endl;
    //cout << ans << endl;

}


Measured memory_bytes: 6144
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

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

const int max_N = 1e5 + 10;
vector<int> E[max_N];
int vis[max_N];

void dfs(int node, int isRoot, vector<int> &mp);

int main()
{
	fast_cin();
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= M; ++i) {
		int u, v;
		cin >> u >> v;
		E[u].push_back(v);
		E[v].push_back(u);
	}

	vector<int> ans = {1};
	dfs(1, 1, ans);

	cout << ans.size() << endl;
	for (auto &v : ans) {
		cout << v << ' ';
	}
	cout << endl;
}

void dfs(int node, int isRoot, vector<int> &mp)
{
	vis[node] = 1;
	int f1 = 0;
	for (auto &v : E[node]) {
		if (!vis[v]) {
			if (!f1) {
				mp.push_back(v);
				dfs(v, 0, mp);
			} else {
				vector<int> temp = {v};
				dfs(v, 0, temp);
				reverse(temp.begin(), temp.end());
				mp.insert(mp.begin(), temp.begin(), temp.end());
				return;
			}
			if (!isRoot) {
				return;
			} else {
				f1 = 1;
			}
		}
	}
}


Measured memory_bytes: 15736
n=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

tmp=make_divisors(n-1)
tmp.remove(1)
ans=set(tmp)
cnt=make_divisors(n)
cnt.remove(1)
for i in range(len(cnt)):
    k=cnt[i]
    gh=n
    while(gh%k==0):
        gh//=k
    if gh%k==1:
        ans.add(k)

print(len(ans))

Measured memory_bytes: 3188
#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;
#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);

	int N;
	cin >> N;
	VI P(N);
	REP(i, N)cin >> P[i];
	rSORT(P);
	for (int i = 100; i >= 0;i--) {
		int cnt = 0;
		REP(j, N) {
			if (i <= P[j])cnt++;
		}
		if (cnt >= i) {
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}




Measured memory_bytes: 3212
import java.io.IOException;
import java.util.Scanner;

public class Main {
	private int sumNum;
	private int gyosya;
	private int point=0;
	
	public Main(int gyosya,Scanner in){
		this.gyosya=gyosya/4;
		point=0;
		for(int i=0;i<this.gyosya;i++){
			point+=in.nextInt();
		}
		System.out.println(point);
	}
	public static void main(String[] args)throws IOException{
		int sumNum;
		Scanner in =new Scanner(System.in);
		while(true){
			sumNum=in.nextInt();
			if(sumNum==0){
				break;
			}
			if(sumNum!=0){
				Main main=new Main(sumNum,in);
			}
		}
	}
	
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, M;
  cin >> N >> M;
  int max = 0;
  if(M%N == 0){
    cout << M / N <<endl;
    return 0;
  }
  for(int i = 1; i <= M/N; i++){
    if(M % i == 0 && M % i <= N){
      max = i;
    }
  }
  cout << max <<endl; 
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <stdlib.h>

bool DP[80][80][(80+80)*80];
int main()
{
	int H,W;
	int G1[80][80];
	int G2[80][80];
	
	scanf("%d %d", &H, &W);
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			scanf("%d", &G1[i][j]);
		}
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			scanf("%d", &G2[i][j]);
		}
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			for(int k = 0; k < (H+W)*80; k++){
				DP[i][j][k] = false;
			}
		}
	}
	
	// ここから解法
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			int diff = abs(G1[i][j] - G2[i][j]);
			if(i == 0 && j == 0){
				DP[i][j][diff] = true;
			}
			else{
				if(i > 0) {
					for(int k = 0; k < (H+W)*80; k++){
						if(DP[i-1][j][k]){
							int up = k + diff;
							int down = abs(k - diff);
							DP[i][j][up] = true;
							DP[i][j][down] = true;
						}
					}
				}
				if(j > 0) {
					for(int k = 0; k < (H+W)*80; k++){
						if(DP[i][j-1][k]){
							int up = k + diff;
							int down = abs(k - diff);
							DP[i][j][up] = true;
							DP[i][j][down] = true;
						}
					}
				}
			}
		}
	}
	
	int min = (H+W)*80;
	for(int k = 0; k < (H+W)*80; k++){
		if(DP[H-1][W-1][k]){
			min = k;
			break;
		}
	}
	
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 80256
#include<iostream>
using namespace std;
int main(){
    int n,k,p;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k>>p;
        if(k%p==0){
            cout<<p<<endl;
        }
        else{
            cout<<k%p<<endl;
        }
    }
}

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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

int k, n;
int A[MAXN];

int main(){
    k=read();n=read();

    for(int i=0;i<n;++i)A[i]=read();

    int mx=0;

    for(int i=0;i<n;++i){
        if(i==n-1){
            mx=max(mx,k-A[n-1]+A[0]);
        }else{
            mx=max(mx,A[i+1]-A[i]);
        }
    }

    cout<<k-mx;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define dump(x)                     \
  cerr << #x << "=" << (x) << endl; \
  ;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

  string S;
  cin >> S;

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

  return 0;
}


Measured memory_bytes: 256
import java.util.*; 
import java.io.*; 

public class Main {
	public static void main(String[] args) throws IOException {
     Scanner sc = new Scanner(System.in);
     int health = sc.nextInt(); 
     int attack = sc.nextInt(); 
     for(int i = 0; i<attack;i++) {
    	 health -= sc.nextInt(); 
     }
     if(health <= 0) {
    	 System.out.println("Yes");
     }
     else System.out.println("No"); 
	}
}


Measured memory_bytes: 46936
#include <iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 5 && b == 5 && c == 7){
        cout << "YES" << endl;
    }
    else if(a == 5 && b == 7 && c == 5){
        cout << "YES" << endl;
    }
    else if(a == 7 && b == 5 && c == 5){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
	string s;
	cin >> s;
	while((int)s.length() < 15){
		s += "o";
	}
	int count = 0;
	for(char c: s){
		if(c == 'o') count++;
	}
	if(count >= 8){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

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

using VI = vector<long>;
using VVI = vector<VI>;

long eraseStone(VI &v) {
  long ans = 0;
  if (v[0] == v[1] && v[1] == v[2]) {
    if (v[0] == -1) return -1;
    if (v[2] == v[3]) {
      if (v[3] == v[4]) {
        ans += v[4];
        v[4] = -1;
      }
      ans += v[3];
      v[3] = -1;
    }
    ans += v[0] * 3;
    v[0] = -1;
    v[1] = -1;
    v[2] = -1;
    return ans;
  }
  if (v[1] == v[2] && v[2] == v[3]) {
    if (v[1] == -1) return -1;
    if (v[3] == v[4]) {
      ans += v[4];
      v[4] = -1;
    }
    ans += v[1] * 3;
    v[1] = -1;
    v[2] = -1;
    v[3] = -1;
    return ans;
  }
  if (v[2] == v[3] && v[3] == v[4]) {
    if (v[2] == -1) return -1;
    ans += v[2] * 3;
    v[2] = -1;
    v[3] = -1;
    v[4] = -1;
    return ans;
  }
  return -1;
}

void dropStone(VVI &board) {
  long n = board.size();
  for (int i = 0; i < 5; i++) {
    VI sub;
    for (int j = 0; j < n; j++) {
      if (board[j][i] != -1) {
        sub.push_back(board[j][i]);
      }
    }
    for (int j = 0; j < n - sub.size(); j++) {
      board[j][i] = -1;
    }
    for (int j = 0; j < sub.size(); j++) {
      assert(n - sub.size() + j < n);
      board[n - sub.size() + j][i] = sub[j];
    }
  }
}

void solve(long n) {
  VVI board(n, VI(5));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 5; j++) {
      cin >> board[i][j];
    }
  }
  long score = 0;
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < n; i++) {
      long er = eraseStone(board[i]);
      if (er != -1) {
        score += er;
      }
    }
    for (int i = 0; i < 5; i++) {
      dropStone(board);
    }
  }
  cout << score << endl;
}

int main() {
  long n;
  while (1) {
    cin >> n;
    if (n) {
      solve(n);
    } else {
      return 0;
    }
  }
}



Measured memory_bytes: 3136
n = int(input())
mydict = {}

for i in range(n):
	s = input()
	s = ''.join(sorted(s))

	if s in mydict:
		mydict[s] = mydict[s]+1
	else:
		mydict[s] = 1

cnt = 0
for k in mydict:
	num = mydict[k]
	cnt = cnt + (num*(num-1))//2

print(cnt)


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

using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll a[N];
  for(ll i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  bool s[a[N-1]+1];
  for(ll i=1;i<a[N-1]+1;i++){
    s[i] = true;
  }
  ll ans = 0;
  for(ll i=0;i<N;i++){
    if(i < N-1 && a[i]==a[i+1]){
      s[a[i]] = false;
    }
    if(s[a[i]]) ans++; 
    ll j=1;
    while(a[i]*j<=a[N-1]){
      s[a[i]*j] = false;
      j++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5648
#include <iostream>
#include <algorithm>
using namespace std;
int C[100];
int V[100];
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i=0; i<N; i++) cin >> V[i];
  for (int i=0; i<N; i++) cin >> C[i];
  int ans = 0;
  for (int i=0; i<N; i++) ans += max(0, V[i] - C[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    char buf=s[0];
    rep(i,1,(int)s.length()){
        if(buf!=s[i])ans++;
        buf=s[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define N (ll)(1e17+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll n,dp[100005];
vector <ll> v;
ll f(ll pos)
{
     if(dp[pos]!=-1)
      return dp[pos];
     if(pos==n-2)
      return dp[pos]=abs(v[pos+1]-v[pos]);
     if(pos==n-1)
      return 0;
     return dp[pos]=min(abs(v[pos+1]-v[pos])+f(pos+1),abs(v[pos+2]-v[pos])+f(pos+2)); 
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll t=1;
   //cin>>t;
   while(t--)
   {    
        ll i,x,ans;
        cin>>n;
        memset(dp,-1,sizeof(dp));
        for(i=0;i<n;i++)
        {
             cin>>x;
             v.pb(x);
        }
        ans=f(0);
        cout<<ans<<"\n";
   }
}

Measured memory_bytes: 4340
import math
n=int(input())
min=n-1
x=1
y=n
for i in range(1,int(math.sqrt(n)+1)):
  if n%i==0:
    if abs(i-n//i)<min:
      x=i
      y=n//i
      min=abs(i-n//i)
print(x+y-2)

Measured memory_bytes: 3060
N = int(input())
s = [input() for _ in range(N)]

dic = {}
ans = 0

for ss in s:
    temp = [ch for ch in ss]
    temp.sort()
    sss = "".join(temp)
    
    if sss in dic:
        ans += dic[sss]
        dic[sss] += 1
    else:
        dic[sss] = 1

print(ans)

Measured memory_bytes: 24976
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#else
#define gc() 1
#define max3(a,b,c) max(a,b,c)
#define min3(a,b,c) min(a,b,c)
#endif

typedef long long lint;

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

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



#define MAXIN 100

lint gcd(lint a, lint b) {
	if (a<b) swap(a, b);
	lint r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

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

	lint n, in, ans=0; cin >> n;
	vector<lint> a;
	rep(i, n) {
		cin >> in;
		ans += in;
	}
	co(ans - n);
	gc();
}

Measured memory_bytes: 256
K,S = map(int, input().split())

#2 つの整数 K,S が与えられます。
#3 つの変数 X,Y,Z があり、0≦X,Y,Z≦K を満たす整数の値を取ります。
#X+Y+Z=S を満たす X,Y,Z への値の割り当ては何通りありますか。
ans = 0

for i in range(0,min(K,S)+1):
  # Y+Z = S - i
  # 0 <= Y <= S-i
  #print(i,S-i)

  for j in range(0,min(K,S-i)+1):
    #print(" ",j,S-i-j)
    if S-i-j <= K:
      ans += 1
print(ans)

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

using namespace std;

int a[600001], n;

int cnt, last, ori;

int f(int a, int b){
	if (a>b) return 1;
	return -1;
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	
	last = a[1];
	ori = 0;
	for (int i = 2; i <= n; i++){
		if (a[i] != a[i - 1]){
			if (!ori) ori = f(a[i], a[i - 1]);
			else if (ori != f(a[i], a[i - 1])){
				cnt++;
				last = a[i];
				ori = 0;
			}
		}
	}
	
	printf("%d\n", cnt + 1);
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

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


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c = M()
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 74528
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#pragma GCC optimize ("O3")
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)

#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define reps FOR
#define rreps(i,a,b) for (int i=int(b)-1;i>=(a);--i)
#define rrep(i,b) rreps(i,0,b)

#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef long double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ld, ut> pld;
typedef vector<pld> Vpld;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
const LL MOD=1e9+7;
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 188;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K,  H, W, Q, D, T,X;
//ut N,A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];


LL solve(){
  LL A,B;
  cin >> N >> A >> B;
  if(A*N<B){
    cout << A*N << endl;
  }
  else
    cout << B << endl;
  return 0;
}

signed main()
{
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  solve();
}



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

using namespace std;
int main(){
    string S;
    string T;
    cin>>S;
    cin>>T;
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3580
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xyList = mutableListOf<Pair<Long, Long>>()
    val diffList = mutableListOf<Pair<Long, Long>>()
    (1..n).forEach {
        val (x, y) = readLine()!!.split(' ').map(String::toLong)
        xyList.add(Pair(x, y))
    }
    for (i in 0 until n - 1) {
        for (j in i + 1 until n) {
            diffList.add(Pair(xyList[i].first - xyList[j].first, xyList[i].second - xyList[j].second))
            diffList.add(Pair(-xyList[i].first + xyList[j].first, -xyList[i].second + xyList[j].second))
        }
    }
    diffList.sortBy { it.second }
    diffList.sortBy { it.first }
    var sameCount = 1L
    var minCost = 0L
    for (i in 1 until diffList.size) {
        val (bdx, bdy) = diffList[i - 1]
        val (dx, dy) = diffList[i]
        if (dx == 0L && dy == 0L) {
            minCost = Math.max(minCost, sameCount)
            sameCount = 1
            continue
        }
        if (bdx == dx && bdy == dy) {
            sameCount++
        } else {
            minCost = Math.max(minCost, sameCount)
            sameCount = 1
        }
    }
    println(n - minCost)
}

Measured memory_bytes: 38712
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,X[100005],Y[100005],W[100005],mx=0;
map<P,int>M;
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d%d%d",X+i,Y+i,W+i);
		M[make_pair(X[i],Y[i])]=W[i];
	}
	for(int i=0;i<N;i++)
	{
		int tmp1=M[make_pair(X[i],Y[i])]+M[make_pair(X[i]+1,Y[i])]+M[make_pair(X[i],Y[i]+1)]+M[make_pair(X[i]+1,Y[i]+1)];
		int tmp2=M[make_pair(X[i],Y[i])]+M[make_pair(X[i]-1,Y[i])]+M[make_pair(X[i],Y[i]+1)]+M[make_pair(X[i]-1,Y[i]+1)];
		mx=max(mx,max(tmp1,tmp2));
	}
	printf("%d / 1\n",mx);
}

Measured memory_bytes: 39864
#include<iostream>
using namespace std;
main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b)
	{
		int t=a-b;
		int k=c-t;
		if(k>=0)
		{
			cout<<k<<endl;
		}
		else
		{
			cout<<0<<endl;
		}
	}
}


Measured memory_bytes: 3640
import sys
def f0070(A,n,s):
  if n==1: return (s in A)
  c=0
  A=sorted(A)
  A1=A[:n][::-1]
  A2=A[-n:]
  N=range(n)
  def f(A):
    return sum([(i+1)*A[i] for i in N])
  b1=f(A1)
  b2=f(A2)
  if b1<=s<=b2:
    for i in range(len(A)):
      b=s-A[i]*n
      c+=f0070(A[:i]+A[i+1:],n-1,b)
  return c
for a in sys.stdin:
  n,s=map(int,a.split())
  print f0070(range(10),n,s)

Measured memory_bytes: 4248
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

int calc(int n){
    int ret = 0;
    while(n > 0){
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

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

    int N;
    cin >> N;
    int ans = INF;
    rep(A,1,N){
        int B = N - A;
        ans = min(calc(A) + calc(B), ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#define buf 1000001
int i,j,a,c,d,cnt=0,b[buf],left,right,mid,key;
void binary_search(int d);

int main(void){
	scanf("%d",&a);
	for(i=0;i<a;i++)
		scanf("%d",&b[i]);
	scanf("%d",&c);
	for(j=0;j<c;j++){
		scanf("%d",&d);
    		binary_search(d);
	}
	printf("%d\n",cnt);
	return 0;
}

void binary_search(int d){
	left = 0;
	right = a;
	while(left < right){
		mid = (left + right)/2;
		if(b[mid] == d){
			cnt++;
			break;
		}
        	else if(d < b[mid])
            		right = mid;
        	else if(d > b[mid])
            		left = mid+1;
	}
}
 

 
		

Measured memory_bytes: 992
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,n) for(int i=(1);i<(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a=max(a,c);
    b=min(b,d);
    cout<<max(0ll,b-a)<<'\n';
    return 0;
}


Measured memory_bytes: 3620
n=int(input())
P=[2]
for i in range(3,n+1,2):
  for j in range(3,int(i**0.5+1)):
    if i%j==0:
      break
  else:P.append(i)
p=[1]*len(P)
for i in range(1,n+1):
  for j in range(len(P)):
    x=i
    c=0
    while(x%P[j]==0):
      x//=P[j]
      c+=1
    p[j]+=c
a=1
for x in p:
  a*=x
print(a%(10**9+7))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <iostream>
#include <cstdio>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
 
#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
 
using namespace std;
 
const int mod = 998244353;
const int inf = (int)2e9;
const ll INF = (ll)2e18;
const int N = 100100;

int d[11];
int n, k;

bool good(int n) {
	while (n) {
		int x = n % 10;
		if (d[x]) return false;
		n /= 10;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		int x;
		cin >> x;
		d[x] = 1;
	}

	for (int i = n; i <= N * 2; i++) {
		if (good(i)) {
			cout << i << "\n";
			return 0;
		}
	}
	assert(0);

	return 0;
}

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

int main() {
  int x,y;
  cin>>x>>y;
  int ans=0;
  if (x<=3) ans+=(4-x)*100000;
  if (y<=3) ans+=(4-y)*100000;
  if (x==1&&y==1) ans+=400000;
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    string s ;
    getline(cin , s) ;
    for(int i = 0 ; i < s.length() ; i++)
    {
        if((int)s[i] >= 65 && (int)s[i] <= 90) s[i] = tolower(s[i]) ;
        else s[i] = toupper(s[i]) ;
    }
    cout << s << endl ;
}


Measured memory_bytes: 3164
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, M: int, x: "List[int]", y: "List[int]", z: "List[int]"):
    m = 0
    for i in range(1 << 3):
        P = [x, y, z]
        for j in range(3):
            if i >> j & 1 == 1:
                P[j] = [-pp for pp in P[j]]
        [a, b, c] = P
        P = sorted([sum(t) for t in zip(a, b, c)], reverse=True)
        m = max(m, sum(P[:M]))
    print(m)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    z = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        z[i] = int(next(tokens))
    solve(N, M, x, y, z)

if __name__ == '__main__':
    main()


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

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

    long long a, b, c;
    cin >> a >> b >> c;

    long long mc = min(a, c);
    a -= mc;
    c -= mc;

    long long mb = min(b, c) * 2;

    b -= mb / 2;
    c -= mb / 2;

    long long ans = mc + mb + b + (c >= 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256