akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


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

    P(min(b/a,c));
    return  0;
}


Measured memory_bytes: 256
# http://at274.hatenablog.com/entry/2018/02/02/173000#%E5%AE%8C%E6%88%90%E5%BD%A2 より引用


class UnionFind:
    def __init__(self, n):
        # 0indexは使用しない. 親要素のノード番号を格納．par[x]==xの時，xは根
        self.par = [i for i in range(n+1)]
        # 木の高さを表す
        self.rank = [0] * (n+1)
        # それぞれの要素数を持つ
        self.size = [0] + [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 同じ根を持つ要素数を返す
    def get_size(self, x):
        return self.size[x]


N,M,*t=map(int,open(0).read().split())
# 壊していく橋の始点
A = [0] + t[0::2]

# 壊していく橋の終点
B = [0] + t[1::2]

# 出力用の解答を格納する変数
out_ans = [0] * (M + 1)

# 1 ~ Mについて到達不可能な2点の組み合わせの数(不便さ)を計算する
# 解答より，M, M-1,...,1の順で計算する

UF = UnionFind(N)

# i番目に出力すべき不便さを求める
# def ans(i, UF):
#     global N,A,B,out_ans
#     if UF.same_check(A[i+1], B[i+1]):
#         return out_ans[i+1]
#     else:
#         n1 = UF.get_size(A[i+1])
#         n2 = UF.get_size(B[i+1])
#         UF.union(A[i+1], B[i+1])
#         return out_ans[i+1] - (n1 * n2)


# 全ての辺を削除した時の答えを格納
sm=N*(N-1)//2

out_ans[M] = sm

group=[1]*(N+1)

for i in range(M, 0, -1):
    # out_ans[i] = (ans(i, UF))
    if not UF.same_check(A[i], B[i]):
        grpa = UF.find(A[i])
        grpb = UF.find(B[i])
        UF.union(A[i], B[i])
        sm -= group[grpa] * group[grpb]
        group[grpa] = group[grpb] = group[grpa] + group[grpb]
    out_ans[i-1] = sm

[print(tmp) for tmp in out_ans[1:]]

Measured memory_bytes: 25712
MOD = 998244353
N, K = map(int, input().split())
rl = [list(map(int, input().split())) for _ in range(K)]
dp = [0] * (N + 1)
dp[1] = 1
dp[2] = -1

for i in range(1, N + 1):
    dp[i] += dp[i - 1]
    for j in range(K):
        l, r = rl[j][0], rl[j][1]
        if i + l <= N:
            dp[i + l] += dp[i]
            dp[i + l] %= MOD
        if i + r + 1 <= N:
            dp[i + r + 1] -= dp[i]
            dp[i + r + 1] %= MOD
print(dp[N] % MOD)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r;
    cin>>r;
    double c=2*3.141592653589*r;
    cout<<fixed<<setprecision(15)<<c;
    return 0;
}

Measured memory_bytes: 3804
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_GRD_SIZE		3										// グリッドサイズ

// 内部変数
static int si2Grid[D_GRD_SIZE][D_GRD_SIZE];						// グリッド

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 値取得 - 対象行のb(列２)-b(列１)
int
fGetVal(
	int piRow1					// <I> 行１ 0～
	, int piCol1				// <I> 列１ 0～
	, int piCol2				// <I> 列２ 0～
)
{
	// [a1 + b1 = v1] -> [a1 = v1 - b1] -> [v1 - b1 + b2 = v2] -> [b2 - b1 = v2 - v1]
	return si2Grid[piRow1][piCol2] - si2Grid[piRow1][piCol1];
}

// 判定
int
fJudge(
)
{
	int i, j;

	// 列１を、列２・３と比較
	for (i = 1; i < D_GRD_SIZE; i++) {

		// 行１
		int liVal = fGetVal(0, 0, i);

		// 行２・３と比較
		for (j = 1; j < D_GRD_SIZE; j++) {
			int liVal2 = fGetVal(j, 0, i);
			if (liVal != liVal2) {
				return -1;
			}
		}
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, liRet;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// グリッド取得
	for (i = 0; i < D_GRD_SIZE; i++) {
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
		sscanf(lc1Buf, "%d%d%d", &si2Grid[i][0], &si2Grid[i][1], &si2Grid[i][2]);
	}

	// 判定
	liRet = fJudge();

	// 結果セット
	if (liRet == 0) {
		sprintf(lc1Out, "Yes\n");
	}
	else {
		sprintf(lc1Out, "No\n");
	}

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=200000+10;
const int INF=10000000;
int p1[N],p2[N];
map<pair<int,int>,int>m;
int find(int x,int *p)
{
    return p[x]==x?p[x]:p[x]=find(p[x],p);
}
void cha(int x,int y,int *p)
{
    int px=find(x,p);
    int py=find(y,p);
    if(px!=py)
    {
        p[px]=py;
    }
}
int main()
{
    int n,k,l;
    cin>>n>>k>>l;
    for(int i=1;i<=n;i++)
        p1[i]=i,p2[i]=i;
    for(int i=1;i<=k;i++)
    {
        int x,y;
        scanf("%d%d,",&x,&y);
        cha(x,y,p1);
    }
    for(int i=1;i<=l;i++)
    {
        int x,y;
        scanf("%d%d,",&x,&y);
        cha(x,y,p2);
    }
    for(int i=1;i<=n;i++)
    {
        find(i,p1);
        find(i,p2);
    }
    for(int i=1;i<=n;i++)
        m[make_pair(p1[i],p2[i])]++;
    for(int i=1;i<=n;i++)
        printf("%d ",m[make_pair(p1[i],p2[i])]);
    return 0;
}

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

int main() {
    int n, l;
    cin >> n >> l;
    string s[n];
    rep(i, n) cin >> s[i];

    sort(s, s + n);
    rep(i, n) cout << s[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main () {
	int n = ri();
	int k = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	
	int64_t res = 0;
	for (int i = 0; i < n; i++) {
		int every = 0;
		int cur = 0;
		for (int j = 0; j < n; j++) if (a[j] > a[i]) {
			if (j < i) cur++;
			every++;
		}
		res += ((int64_t)k * (k - 1) / 2 % MOD * every + (int64_t) k * cur) % MOD;
	}
	std::cout << res % MOD << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

void exec()
{
	int dist[11][11]={0};
	int n;
	cin >> n;
	if(n==0){
		exit(0);
	}
	int t=0;
	for(int i=0;i<11;i++){
		for(int j=0;j<11;j++){
			dist[i][j]=1<<29;
		}
		dist[i][i]=0;
	}
	for(int i=0;i<n;i++){
		int a,b,c;
		cin >> a >> b >> c;
		dist[b][a]=dist[a][b]=c;
		t=max(t,a);
		t=max(t,b);
	}
	t++;
	for(int i=0;i<t;i++){
		for(int j=0;j<t;j++){
			for(int k=0;k<t;k++){
				dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
				//cout << i << " " << j << " " << k << ": " << dist[j][k] << endl;
			}
		}
	}

	int ret=1<<30;
	int town=0;
	for(int i=0;i<t;i++) {
		int sum=0;
		for(int j=0;j<t;j++) {
			sum+=dist[i][j];
		}
		if(sum<ret){
			ret=sum;
			town=i;
		}
	}

	cout << town << " " << ret << endl;

}
int main() {
	while(true)
		exec();

}

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

int main(){
  int N,K;
  cin >> N >> K;
  if(N==K){
    cout << 1 << endl;
    return 0;
  }else{
    if((N-1)%(K-1)==0){
      cout << (N-1)/(K-1) << endl;
    }else{
      cout << (N-1)/(K-1) + 1 << endl;
    }
  }
}

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

using namespace std;
int n,k,h[100000],dp[100000];
int main()
{
    cin >>n>>k;
    for (int i=0;i<n;i++)
        cin >>h[i];
    dp[1]=abs(h[1]-h[0]);
    for (int i=2;i<n;i++)
    {
        dp[i]=1000000000;
        for (int e=i-1;i-e<=k&&e>=0;e--)
           dp[i]=min(abs(h[e]-h[i])+dp[e],dp[i]);
    }
    cout <<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class Main
{
  public static long d[] = new long[123456];
  public static HashMap<Integer, ArrayList<Integer>> h = new HashMap<>();
  public static HashMap<Integer, ArrayList<Long>> hd = new HashMap<>();

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s = r.readLine();

    boolean f = true;
    int z = 0;
    int w = 0;
    for(int i = 0; i < s.length(); i++)
    {
      char c = s.charAt(i);
      if(i == 0)
      {
        f = c == 'A';
      }
      if(2 <= i && i <= s.length() - 2 && c == 'C')
      {
        z++;
      }
      if(!('a' <= c && c <= 'z'))
      {
        w++;
      }
    }
    
    System.out.println(f && z == 1 && w == 2? "AC" : "WA");

  }

}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main(void){
    int N, K;
    int d[1000];
    int A[1000][1000];
    int ans[1000];
    int a = 0;
    
    cin >> N >> K;
    
    for(int i = 1; i <= K; i++){
        cin >> d[i];
        for(int j = 1; j <= d[i]; j++){
            cin >> A[i][j];
            ans[A[i][j]]++;
        }
    }
    
    for(int i = 1; i <= N; i++){
        if(ans[i] != 0){
            a++;
        }
    }
    
    cout << N - a << endl;
}


Measured memory_bytes: 3992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        double res = 0;
        for(int i = 0 ;i<n;i++)
        {
            res += 1/ (double)sc.nextInt();
        }
        System.out.println(1/res);

    }
}

Measured memory_bytes: 22612
def main():
    from collections import defaultdict
    from collections import Counter
    import sys

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    d = Counter(a)
    e = defaultdict(int)

    base = sum(v * (v - 1) // 2 for v in d.values())

    for k, v in d.items():
        if v <= 1:
            e[k] = base - 0
        else:
            e[k] = base - (v - 1)

    p = [str(e[x]) + '\n' for x in a]
    q = ''.join(p)
    print(q)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44448
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n,k;
vi vec;
vi bit(63);
vi ls;

signed main(){
    io();

    in(n,k);
    vec.pb(0);
    rep(i,n){
        int a;
        in(a);
        vec.pb(a);
        vec[i+1]+=vec[i];
    }
    // show(vec);
    rep(l,n+1){
        REP(r,l+1,n+1){
            ls.pb(vec[r]-vec[l]);
        }
    }
    // show(ls);
    int ans=0;
    REPEAT(i,0,63,false){
        vi tmp;
        int cmp=ans;
        cmp|=1LL<<i;
        show(cmp);
        rep(j,ls.size()){
            if((cmp&ls[j])==cmp) tmp.pb(ls[j]);
        }
        if(tmp.size()>=k){
            ans|=1LL<<i;
        }
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 6768
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	if (n >= 1000) cout << "ABD" << endl;
	else cout << "ABC" << endl;


	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        String[] str2 = br.readLine().split(" ");
        long sum=0;
        int max=-1000000, min=1000000, tmp=0;
        for(int i=0;i<n;i++){
            tmp=Integer.parseInt(str2[i]);
            if(tmp>max)max=tmp;
            if(tmp<min)min=tmp;
            sum=sum+tmp;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}

Measured memory_bytes: 28496
#include "bits/stdc++.h"
using namespace std;
const int MAXN=1e5+1,OO=0x3f3f3f3f;
typedef  long long ll;
int main(){
    ll a,b; cin>>a>>b;
 ll gd=__gcd(a,b),ans=1;
 for(ll i=2;i*i<=gd;i+=(i&1)+1){
     if(!(gd%i))ans++;
     while(gd%i==0)
         gd/=i;
 }
 if(gd>1)ans++;
 cout<<ans;
}

Measured memory_bytes: 384
#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>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        set<int> st;
        for (int i = 0; i < 2; ++i) {
            int a;
            cin >> a;
            st.insert(a);
        }
        for (int i = 1; i <= 3; ++i) {
            if (!st.count(i)) {
                cout << i << endl;
                return;
            }
        }
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//It's 1600 problem!
	int n,i;cin>>n;
	vector<pair<llint,int>>cho(n);
	for(i=0;i<n;i++){
		cin>>cho[i].fir;
		cho[i].sec=i;
	}
	SO(cho);
	vector<llint>kaz(n,1);
	vector<llint>red(n);
	vector<pair<int,int>>ans;
	for(i=n-1;i>0;i--){
		llint mok=cho[i].fir-n+kaz[i]*2;
		int bas=LBI(cho,mp(mok,-9999));
		if(cho[bas].fir!=mok){cout<<"-1"<<endl;return 0;}
		kaz[bas]+=kaz[i];
		red[bas]+=red[i];
		red[bas]+=kaz[i];
		//cerr<<"a";
		ans.pub(mp(cho[i].sec,cho[bas].sec));
	}
	//cerr<<red[0]<<endl;
	if(red[0]!=cho[0].fir){cout<<"-1"<<endl;return 0;}
	for(i=0;i<n-1;i++){cout<<ans[i].fir+1<<" "<<ans[i].sec+1<<endl;}
	return 0;
}


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

int main(void) {
  int rows, columns, i, j, rowSum, columnSum, totalSum;
  scanf(" %d %d", &rows, &columns);
  int *table = (int *) malloc(sizeof(int) * rows * columns);
  for (i = 0; i < rows * columns; i++)
    scanf(" %d", table + i);
  rowSum = 0;
  totalSum = 0; 
  for (i = 0; i < rows * columns; i++) {
    printf("%d ", *(table + i));
    rowSum += *(table + i);
    if (i % columns == columns - 1) {
      printf("%d\n", rowSum);
      totalSum += rowSum;
      rowSum = 0;
    }
  }
  for (i = 0; i < columns; i++) {
    columnSum = 0;
    for (j = 0; j < rows; j++) {
      columnSum += *(table + j * columns + i);
    }
    printf("%d ", columnSum);
  }
  printf("%d", totalSum);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll

using namespace std;
using Graph = vector<vector<int> >;


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

  string S; cin >> S;

  vector<pair<int, int> > Input(N);
  
  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    Input[i] = make_pair(a, b);
  }

  int ansarray[L];
  memset(ansarray, 0, sizeof(ansarray));
  
  for (int i = 1; i < S.size(); i++) {
    if (S[i] == 'C' && S[i-1] == 'A') {
      ansarray[i] = ansarray[i - 1] + 1;
    } else {
      ansarray[i] = ansarray[i - 1];
    }
  }


  // for (int i = 0; i < S.size(); i++) {
  //   cout << ansarray[i] << endl;
  // }

  for (auto x : Input) {
    cout << ansarray[x.second - 1] - ansarray[x.first  - 1] << endl;
  }
}


Measured memory_bytes: 2176
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	ma := 0
	for i := 0; i < n; i++ {
		ma = max(ma, a[i])
	}
	k := 0
	for i := 0; i < n; i++ {
		if ma == a[i] {
			continue
		}
		if min(ma-k, k) < min(ma-a[i], a[i]) {
			k = a[i]
		}
	}
	fmt.Fprintln(wr, ma, k)
}


Measured memory_bytes: 3072
(let ((n (read))
      (a (make-array 0 :element-type 'string
                       :fill-pointer 0
                       :adjustable t))
      temp
      lst
      (flg t))
  (setf temp (read-line))
  (loop repeat (1- n) do
        (vector-push-extend temp a)
        (setf lst (char temp (1- (length temp))))
        (setf temp (read-line))
        (if (not (equal lst (char temp 0))) (setf flg nil))
        (loop for i across a do
              (if (equal i temp) (setf flg nil))))
  (princ (if flg "Yes" "No")))


Measured memory_bytes: 16484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    if (A >= B)
    {
        cout << "delicious";
        return 0;
    }
    if (A + X >= B)
    {
        cout << "safe";
        return 0;
    }
    else
    {
        cout << "dangerous";
        return 0;
    }

    return 0;
}

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

using namespace std;
const int maxn =  1e6 + 50;
#define ll long long
#define ios std::ios::sync_with_stdio(false)
const ll INF(0x3f3f3f3f3f3f3f3fll);
const int inf(0x3f3f3f3f);
/*


ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll pow_mod(ll x,ll n,ll mod){ll res=1;while(n){if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}//xµÄn´Î·½mod


ll mult(ll a,ll b,ll p){a%=p;b%=p;ll r=0,v=a;while(b){if(b&1){r+=v;if(r>p)r-=p;}v<<=1;if(v>p)v-=p;b>>=1;}return r;}
ll quick_pow(ll a,ll b,ll p){ll r=1,v=a%p;while(b){if(b&1)r=mult(r,v,p);v=mult(v,v,p);b>>=1;}return r;}
bool CH(ll a,ll n,ll x,ll t)
{ll r=quick_pow(a,x,n);ll z=r;for(ll i=1;i<=t;i++){r=mult(r,r,n);if(r==1&&z!=1&&z!=n-1)return true;z=r;}return r!=1;}
bool Miller_Rabin(ll n)
{if(n<2)return false;if(n==2)return true;if(!(n&1))return false;ll x=n-1,t=0;while(!(x&1)){x>>=1;t++;}srand(time(NULL));
ll o=8;for(ll i=0;i<o;i++){ll a=rand()%(n-1)+1;if(CH(a,n,x,t))return false;}return true;}


*/

#define int long long
#define sc(t) scanf("%lld",&t)
#define pr(ans) printf("%lld\n",ans)
ll pow_mod(ll x,ll n,ll mod){ll res=1;while(n){if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}//xµÄn´Î·½mod
template<typename T>void read(T &res){bool flag=false;char ch;while(!isdigit(ch=getchar()))(ch=='-')&&(flag=true);
for(res=ch-48;isdigit(ch=getchar());res=(res<<1)+(res<<3)+ch - 48);flag&&(res=-res);}
typedef unsigned long long ULL;

int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
#define debug(x) cout << #x << " : " << x << '\n';
#define sb cout << "sb\n" << '\n';
#define fi first
#define se second
#define pb(a) push_back(a)
#define cn cout << '\n'

signed main()
{
    ios;
    int k;
    cin >> k;
    string str;
    cin >> str;
    int n = str.size();
    if(n <= k){
        cout << str << '\n';
    }
    else{
        for(int i = 0 ; i < k ; i ++){
            cout << str[i];
        }
        cout << "...";
        cn;
    }
    return 0;
}
/*

*/


Measured memory_bytes: 3656
n = int(input())
div=[]
for i in range(1, int(n**0.5)+1):
  if n % i == 0:
    if i-1 != 0:
    	div.append(i-1)
    if i != n // i:
      	div.append(n//i-1)
print(sum([m for m in div if int(n/m)==n%m]))

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,mi=1000000,ma=-1000000;
    long long sum=0;
    cin>>n;
    int i,b;
    for(i=0;i<n;i++){
        cin>>b;
        mi=min(mi,b);
        ma=max(ma,b);
        sum+=b;
    }
    cout<<mi<<" "<<ma<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int R[10];
int d[10][10];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) R[i] = i;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		d[a][b] = 1;
		d[b][a] = 1;
	}
	int ans = 0;
	do {
		bool plus = true;
		if (R[0] != 0) continue;
		for (int i = 0; i < N - 1; i++) {
			if (d[R[i]][R[i + 1]] == 0) {
				plus = false;
				break;
			}
		}
		if (plus) ans++;
	} while (next_permutation(R, R + N));
	cout << ans << endl;
}


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



int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> a;
    priority_queue<ll> jun;
    rep(i, n) {
        ll as;
        cin >> as;

        if(!a[as]) jun.push(as);
        a[as]++;
    }
    rep(i, m) {
        int b;
        ll c;
        cin >> b >> c;

        if(!a[c]) jun.push(c);
        a[c] += b;
    }

    int counter=0;
    ll ans=0LL;

    while(1) {
        ll now = jun.top();
        jun.pop();

        if(a[now]+counter >= n) {
            ans += (n-counter)*now;
            break;
        } else {
            ans += a[now] * now;
            counter += a[now];
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 11120
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,cnt=0;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		if(i%2)
			cnt++;
	printf("%.6lf\n",1.0*cnt/n);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
using namespace std;

bool graph[10001][10001];
int value[10001];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    vector<int> c(n+1);
    c[0] = 1 << 30;
    for(int i = 1; i <= n; i++){
        cin >> c[i];
    }
    sort(c.begin(), c.end(), greater<>());
//    for(int i = 0; i <= n; i++){
//        cerr << c[i] << endl;
//    }

    queue<pair<int, int> > q;
    q.push(make_pair(1, 0));
    long long s = -c[1];
    int value_index = 1;
    while(!q.empty()){
        int index = q.front().first;
        int pre = q.front().second;
//        cerr << index << endl;
        q.pop();
        value[index] = c[value_index];
        s += c[value_index];
        value_index++;
        for(int i = 1; i <= n; i++){
            if(graph[index][i] && i != pre){
                q.push(make_pair(i, index));
            }
        }
    }
    cout << s << endl;
    cout << value[1];
    for(int i = 2; i <= n; i++){
        cout << " " << value[i];
    }
    cout << endl;
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  string as = "";
  string bs = "";
  rep(i, b) {
    as += to_string(a);
  }
  rep(i, a) {
    bs += to_string(b);
  }

  if(as <= bs) {
    cout << as << endl;
  } else {
    cout << bs << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_i = []
for x in range(n):
    a_i.append(int(input()))
a_i2 = []
num = 1
for i in range(n):
    a_i2.append(num)
    num = a_i[num-1]
if a_i2.count(2) == 0:
    print(-1)
else:
    print(a_i2.index(2))

Measured memory_bytes: 7852
import sys
n, x, y = map(int, sys.stdin.readline().split())

g = [[i+1] for i in range(n-1)]
g[x-1].append(y-1)

ans_list = [0 for _ in range(n-1)]

for i in range(n-1):
    for j in range(i+1, n):
        temp = min(j-i, abs(x-1-i)+1+abs(j-y+1))
        ans_list[temp-1] += 1

for num in ans_list:
    print(num)


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

/*
##Knigh's moves without attack
ll sq = n*n;
ll a = sq*(sq-1)/2; //all moves
ll b = 4*(n-1)*(n-2); //moves with attack
z = a - b; //moves without

##2^k
for(int i = 0; i < n; ++i)
ans = 2*ans%((int)1e9+7);

## 'x' from (a) and 'y' from (b) 
(a+b)%(x+y)==0  2*a>=b && 2*b>=a gap checker 




*/

const int MOD = 1e9+7;
const int MX = 1e6+5;
int arr[MX];
//int dp[MX];



int main() {
      ios::sync_with_stdio(0);
      cin.tie(0);
      int n, x;
      cin >> n;

      for(int i = 0; i < n; ++i)
        cin >> arr[i];
      vector<int> dp(n,1e9);
      dp[0] = 0;

      for(int i = 0; i < n; ++i)
        for(int j = i+1; j <= i+2; ++j)
          dp[j] = min(dp[j], dp[i] + abs(arr[i]-arr[j]));

        cout<<dp[n-1];
      
    return 0;
}




Measured memory_bytes: 3936
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 1000200;
typedef long long ll;
const int mod = 998244353;
const int inv2 = mod + 1 >> 1;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int fac[maxn], ifac[maxn], inv[maxn];
inline ll c(int x,int y){ return x >= 0 && y >= 0 ? (ll) fac[x + y] * ifac[y] % mod * ifac[x] % mod : 0; }
inline ll ic(int x,int y){ return (ll) ifac[x + y] * fac[y] % mod * fac[x] % mod; }
int n, m;
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	for(int i = 2;i < maxn;++i) {
		inv[i] = ll(mod - mod / i) * inv[mod % i] % mod;
		fac[i] = (ll) fac[i - 1] * i % mod;
		ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
	}
	cin >> n >> m;
	ll ans = 0;
	if(n > m) std::swap(n, m);
	for(int i = 1;i <= n;++i) {
		ans = (ans + c(i, i) * c(n - i, m - i)) % mod;
	}
	cout << (m + ans * inv2 % mod * ic(n, m)) % mod << '\n';
}


Measured memory_bytes: 12032
use std::collections::HashMap;
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut n = is.trim().parse::<usize>().unwrap();
    let mut map = HashMap::new();

    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            *map.entry(i).or_insert(0) += 1;
            n /= i;
        }

        i += 1;
    }

    if n != 1 {
        *map.entry(n).or_insert(0) += 1;
    }

    let mut ans = 0;
    for (_, v) in map {
        let mut i = 1;
        let mut v = v;
        while v >= i {
            v -= i;
            i += 1;
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2188
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()
  from collections import defaultdict

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n = 6
    A = [2, 3, 3, 1, 3, 1]

  else:
    ##INPUT 
    n = int(input())
    A = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  d = defaultdict(int)
  ans = 0
  for j in range(n):
    Dif = j - A[j]
    ans += d[Dif]
    Sum = A[j] + j
    d[Sum] += 1
  print(ans)
  
main()

Measured memory_bytes: 61568
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int dfs(int cur, int n, vector<bool> &done, const vector<vector<int>> &g)
{
    if (done[cur])
        return 0;

    int ret = cur < n ? 1 : 0;

    done[cur] = true;
    for (auto &next: g[cur]) {
        ret += dfs(next, n, done, g);
    }

    return ret;
}

int main()
{
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    vector<vector<int>> g(n + m);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int l;
            cin >> l;
            l--;

            g[i].push_back(n + l);
            g[n + l].push_back(i);
        }
    }

    vector<bool> done(n + m, false);
    auto t = dfs(0, n, done, g);

    cout << (t == n ? "YES" : "NO") << endl;

    return 0;
}

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

int main() {
    int a[100][2], n, f = 0;
    cin>>n;
    for (int i = 0; i < n; i++)
        cin>>a[i][0]>>a[i][1];
    for (int i = 0; i <= n-3; i++)
        if (a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1] && a[i+2][0] == a[i+2][1])
        {
            f =1;
            cout<<"Yes";
            break;
        }
    if(!f)
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T& container, typename T::key_type& key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法

struct Task {
	int A;
	int B;
};

int main(void) {
	int N;
	vector<Task> t;
	cin >> N;
	t.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> t[i].A >> t[i].B;
	}

	sort(t.begin(), t.end(), [](const Task& lhs, const Task& rhs) {
		return lhs.B < rhs.B;
	});

	ll need_time = 0;
	bool ok = true;
	for (int i = 0; i < N; ++i) {
		need_time += t[i].A;
		if (t[i].B < need_time) {
			ok = false;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 1792
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,k = get_nums_l()
hs = sorted(map(int, sys.stdin.readlines()))

ans = 99999999999999999999999999
for i in range(n-k+1):
    ans = min(ans, hs[i+k-1] - hs[i])

print(ans)

Measured memory_bytes: 56924
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    set<string> S;
    REP(i, N)
    {
        string ss;
        cin >> ss;
        S.insert(ss);
    }
    cout << S.size() << endl;
    return 0;
}


Measured memory_bytes: 19228
import sys
from io import StringIO
import unittest


def resolve():
    n, k = map(int, input().split())

    if n == 0:
        print("0")
        return

    if k == 1:
        print("0")
        return

    # いつ最小になるか = 桁が変わる前後のタイミング。
    q, mod = divmod(n, k)
    # print(q, mod)
    # 7 と　4　の場合：1　あまり 3。

    # 3 から 一回だけ引いてみる。
    minus_edge = abs(mod - k)

    print(str(min(mod, minus_edge)))




class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """7 4"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2 6"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1000000000000000000 1"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 5604
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 H[100];

i64 modpow(i64 a, int pw)
{
	if (pw == 0) return 1;
	i64 ret = modpow(a, pw / 2);
	ret = ret * ret % MOD;
	if (pw % 2 == 1) ret = ret * a % MOD;
	return ret;
}

pair<i64, i64> solve(int l, int r, i64 base)
{
	i64 lowest = 1001001001;
	for (int i = l; i < r; ++i) lowest = min(lowest, H[i]);

	i64 alt = 2, nalt = 1;
	int start = -1; bool flg = false; int nl = 0;
	for (int i = l; i < r; ++i) {
		if (H[i] != lowest) {
			if (start == -1) start = i;

			if (i == r - 1 || H[i + 1] == lowest) {
				auto tmp = solve(start, i + 1, lowest);
				start = -1;

				alt = alt * tmp.first % MOD * 2 % MOD;
				nalt = nalt * (tmp.first * 2 + tmp.second) % MOD;

				alt = alt * (MOD + 1) / 2 % MOD;
				flg = true;
			}
		} else {
			nalt = nalt * 2 % MOD;
			++nl;
		}
	}
	ADD(nalt, MOD - alt);

	alt = alt * modpow(2, (lowest - base - 1)) % MOD;

	return {alt, nalt};
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld", H + i);

	auto sol = solve(0, N, 0);
	i64 ret = (sol.first + sol.second) % MOD;
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}
int a,b;
int main() 
{   
    fast();
    cin>>a>>b;
    for(int i=10*b;i<10*(b+1);i++)
    {
        if(int(i*0.08)==a)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[]args){
    	Scanner sc=new Scanner(System.in);
        String a=sc.next();
      String b=sc.next();
      String c=sc.next();
      char[]aa=a.toCharArray();
      char[]ab=b.toCharArray();char[]ac=c.toCharArray();
        System.out.print((char)(aa[0]-32));System.out.print((char)(ab[0]-32));System.out.println((char)(ac[0]-32));
    }
}


Measured memory_bytes: 23252
#include<stdio.h>

int main()
{
  int N,i,j,k = 0,minj,x,A[100];

  scanf("%d",&N);

  for(i = 0;i < N;i++)
    scanf("%d",&A[i]);

  for(i = 0;i <= N - 1;i++)
    {
      minj = i;
      for(j = i;j <= N - 1;j++)
	{
	  if(A[j] < A[minj])
	    minj = j;

	}
      if(A[i] != A[minj])
	k++;
      
      x = A[i];
      A[i] = A[minj];
      A[minj] = x;
    }
  for(i = 0;i < N - 1;i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d",A[N - 1]);
  printf("\n");
  printf("%d\n",k);

  return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst ll T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    ll a, b, c, d, t;
    cin >> a >> b >> c >> d >> t;
    if(d>b)
        cout << "NO";
    else if(a==c)
        cout << "YES";
    else 
    {
        if(abs((d-b)*t)>=abs((c-a)))
            cout << "YES ";
        else
            cout << "NO";
    }

    return 0;
}

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

int main(){
	int M,K;
	cin >> M >> K;
	if(M==1){
		if(K==0)cout << "0 0 1 1" << endl;
		else cout << "-1" << endl;
		return 0;
	}
	
	if(K>pow(2,M)-1){
		cout << "-1" << endl;
		return 0;
	}
	
	
	for(int i=0;i<pow(2,M);i++){
		if(i==K)continue;
		printf("%d ",i);
	}
	printf("%d ",K);
	for(int i=pow(2,M)-1;i>=0;i--){
		if(i==K)continue;
		printf("%d ",i);
	}
	printf("%d\n",K);
	return 0;
}

Measured memory_bytes: 1792
S = int(input())

A = [S]
idx = 0
while True:
  if A[idx] % 2 == 0:
    A.append(A[idx]//2)
  else:
    A.append(A[idx]*3+1)
  if A[idx+1] in A[:idx+1]:
    print(idx+2)
    break
  idx += 1


Measured memory_bytes: 2940