akhauriyash/Code-Regression huggingface dataset:
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 100, OO = 1e16 + 7, T = 13, M = 1e9 + 7, P = 6151, SQ = 800, lg = 32;
typedef pair <int, int> pii;
int dp[N][20], dk[N];

int32_t main() {
	use_fast;
	int n, ans = 0;
	cin >> n;
	int t = n - 1;
	for(int i = 1; i * i <= t; i++) {
		if(i * i == t)
			ans++;
		else if(t % i == 0)
			ans += 2;
	}
	for(int i = 2; i * i <= n; i++) {
		if(i * i == n) 
			ans++;
		else if(n % i == 0) {
			int q = n;
			while(q % i == 0) 
				q /= i;
			if(q % i == 1)
				ans++;
			q = n;
			int f = n / i;
			while(q % f == 0)
				q /= f;
			if(q % f == 1)
				ans++;
		}
	}
	cout << ans << endl;
	return 0; 
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  a.at(N)=0;
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int A=0, B=0;
  for(int i=0; i<N; i+=2){
    A+=a.at(i);
    B+=a.at(i+1);
  }
  cout << A-B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#define MEM(i,n) memset(i, (n), sizeof(i))
#define ALL(i) i.begin(),i.edn()
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x,S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MOD = 1000000007;
const int MAXN = 1000006;
int main () {
    IOS();

    int a, b;
    cin >> a >> b;
    cout << max({a+b,a*b,a-b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
const int MOD = 1000000007;

int D;//問題数
int G;//総合スコア
vector<ll> p,c;//問題数，ボーナス
//コンプリートボーナス: 100 i 点を付けられた 
//p i 問の問題すべてを解いたユーザーは、基本スコアと別にコンプリートボーナス c i 点を獲得します ( 1 ≤ i ≤ D ) 。


//全完する難易度帯を2^D通り決め打ちする
//それだけでG点に到達する場合はそれでOK
//それだけで到達しない場合は，Greedyに高い難易度からといて行く

//全完対象でないものを結果的に全完する場合は，全完すると決め打ちした場合で考慮サれるのでおｋ
int main(){
    cin>>D>>G;
    p.resize(D),c.resize(D);
    REP(i,D){
        cin>>p[i]>>c[i];
    }
    ll res = 1<<29;
    for(int bit = 0;bit<(1<<(D));bit++){
        ll sum = 0;
        ll num = 0;
        for(int i=0;i<D;i++){
            if(bit & (1<<i)){
                sum += c[i] + p[i] * 100 * (i+1);
                num += p[i];
            }
        }
    if(sum >= G) res = min(res,num);
    else{
        for(int i = D-1;i>=0;i--){
            //追加するbitを選ぶ
            if(bit & (1<<i)) continue;
            for(int j = 0;j<p[i];j++){
                if(sum>=G) break;
                sum += 100 * (i+1);
                num++;
            }
        }
        res = min(res,num);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

def Fib(n):
	a,b=0,1
	if n==1:
		return a
	elif n==2:
		return b
	else:
		for i in range(n-2):
			a,b=b,a+b
		return b

n,m=input2()
A=[int(input()) for _ in range(m)]
INF = 1000000007

start=0 #階段の開始点
ans=1 #
for a in A:
	tmp=a-start
	if tmp>1:
		fib=Fib(tmp+1)
		ans*=fib
		ans%=INF
	elif tmp==0:
		ans=0
		break
	start=a+1

if n-start>1:
	ans*=Fib(n-start+2)
	ans%=INF
print(ans)

Measured memory_bytes: 12912
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
long long dp[25000001];
int main(){
	int a;scanf("%d",&a);
	int ax,ay,az,bx,by,bz;
	scanf("%d%d%d%d%d%d",&ax,&ay,&az,&bx,&by,&bz);
	if(ax-bx<ay-by){
		swap(ax,ay);swap(bx,by);
	}
	if(ay-by<az-bz){
		swap(az,ay);swap(bz,by);
	}
	if(ax-bx<ay-by){
		swap(ax,ay);swap(bx,by);
	}
	for(int i=0;i<25000001;i++)dp[i]=-inf;
	dp[0]=0;
	for(int i=0;i<=a;i++){
		if(i+ax<=a)dp[i+ax]=max(dp[i+ax],dp[i]+bx);
		if(i+ay<=a)dp[i+ay]=max(dp[i+ay],dp[i]+by);
		if(i+az<=a)dp[i+az]=max(dp[i+az],dp[i]+bz);
	}
	long long t=0;
	for(int i=0;i<=a;i++){
		t=max(t,a-i+dp[i]);
	}
	for(int i=0;i<25000001;i++)dp[i]=-inf;
	dp[0]=0;
	for(int i=0;i<=t;i++){
		if(i+bx<=t)dp[i+bx]=max(dp[i+bx],dp[i]+ax);
		if(i+by<=t)dp[i+by]=max(dp[i+by],dp[i]+ay);
		if(i+bz<=t)dp[i+bz]=max(dp[i+bz],dp[i]+az);
	}
	long long ret=0;
	for(int i=0;i<=t;i++){
		ret=max(ret,t-i+dp[i]);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 195456
#include <iostream>
using namespace std;
void dfs(int x,int y,char c);
int h,w;
char mas[102][102];
int flag[102][102];
int main(){
  int sum;
  int i,j;
  while(1){
    cin >> h >> w;
    sum = 0;
    if(h == 0 && w == 0)break;
    for(i = 0;i < 102;i++){
      for(j = 0;j < 102;j++){
	flag[i][j] = 0;
      }
    }
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
	cin >> mas[i][j];
      }
    }
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
	if(flag[i][j] == 0){
	  sum++;
	  dfs(j,i,mas[i][j]);
	}
      }
    }
    cout << sum << endl;
  }
  return(0);
}
void dfs(int x,int y,char c){
  int mx[4] = {1,0,-1,0};
  int my[4] = {0,1,0,-1};
  if(x < 0 || y < 0 || h <= y || w <= x)return;
  if(c != mas[y][x])return;
  if(flag[y][x] != 0)return;
  flag[y][x] = 1;
  for(int i = 0;i < 4;i++){
    dfs(x + mx[i],y + my[i],c);
  }
  return;
}

Measured memory_bytes: 1988
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
 
 
def main():
    N = int(input())
    A, B, C = 0, 0, 0
    for _ in range(N):
        a, b, c = abc = map(int, input().split())
        A, B, C = max(B, C) + a, max(A, C) + b, max(A, B) + c
 
    print(max(A, B, C))
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n;
    scan(n);
    auto d = readln.split.to!(int[]).sort();

    int ans = d[n / 2] - d[n / 2 - 1];

    writeln(ans);
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4284
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  int N;
  cin >> N;
  int flag=0;
  if(N/100==7){
    flag=1;
  }
  else{
    N=N%100;
    if(N/10==7){
      flag=1;
    }
    else{
      N=N%10;
      if(N==7) flag=1;
    }
  }

    if(flag==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
using namespace std;

vector< pair<int,int> > newVec;
bool cmp(pair<int,int> one, pair<int,int> two){
    if(one.first == two.first){
        return one.second < two.second;
    } else {
        return one.first < two.first;
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> input;
    int ans;
    for(int i = 0; i < N; i++){
        cin >> ans;
        newVec.push_back(make_pair(ans,i));
    }

    sort(newVec.begin(), newVec.end(), cmp);

    //cout << endl;
    for(int i = 0; i < newVec.size(); i++){
        //cout << newVec[i].first << " " << newVec[i].second << endl;
    }

    int num = 0;
    int lastIndex = -1;
    for(int i = 0; i < newVec.size(); i++){
        if(newVec[i].first == num + 1 && newVec[i].second > lastIndex){
            num = newVec[i].first;
            lastIndex = newVec[i].second;
        }
    }

    if(lastIndex == -1){
        cout << lastIndex << endl;
    } else {
        cout << newVec.size() - num << endl;
    }

    //cout << num << " " << lastIndex << endl;


}

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

int main() {
    int n;
    cin >> n;

    string ans;
    do {
        if (n % 2 == 0) {
            ans += '0';
        } else {
            ans += '1';
            n -= 1;
        }
    } while (n /= -2);

    reverse(ans.begin(), ans.end());

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
int main()
{
    int n, tmp;
    double sum = 0.;
    vector<int> a;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> tmp;
        sum += 1./tmp;
    }
    
    cout << 1./sum << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    println!("{}", s.chars().filter(|&c| c == '1').count());
}


Measured memory_bytes: 4352
import sys
readline=sys.stdin.readline
read=sys.stdin.read
 
h,w,d=map(int,readline().split())
a=[list(map(int,readline().split())) for _ in range(h)]
q,*lr=map(int,read().split())

ca=dict()
for i,l in enumerate(a):
  for j,e in enumerate(l):
    ca[e]=(i+1,j+1)
mp=[[0]*((h*w)//d+1) for _ in range(d)]
for i,mpl in enumerate(mp):
  for j,_ in enumerate(mpl[:-1]):
    if 0<i+d*j<=h*w-d:
      mpl[j+1]=mpl[j]+abs(ca[i+d*j][0]-ca[i+d*(j+1)][0])\
                +abs(ca[i+d*j][1]-ca[i+d*(j+1)][1])
for l,r in zip(*[iter(lr)]*2):
  print(mp[l%d][r//d]-mp[l%d][l//d])

Measured memory_bytes: 40576
#include<bits/stdc++.h>
using namespace std;
void solve() {
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << i + 1;
			return;
		}
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	while (t--) {
		solve();
	}
}



Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[2100];

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int ret=mod;
	for(int i=0;i<a;i++){
		vector<int>v;
		int kj=p[i];
		int cur=0;
		for(int j=0;j<a;j++){
			if(p[j]<kj){
				vector<int>tmp;
				for(int k=1;k<=cur;k++){
					tmp.push_back(p[j-k]);
				}
				std::sort(tmp.begin(),tmp.end());
				for(int k=0;k+b<=tmp.size();k++){
					v.push_back(tmp[k]);
				}
				cur=0;
			}else cur++;
		}
		vector<int>tmp;
		for(int k=1;k<=cur;k++){
			tmp.push_back(p[a-k]);
		}
		std::sort(tmp.begin(),tmp.end());
		for(int k=0;k+b<=tmp.size();k++){
			v.push_back(tmp[k]);
		}
		std::sort(v.begin(),v.end());
		if(v.size()>=c){
			ret=min(ret,v[c-1]-kj);
		}
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		String a=s.next();

		int r=0;
		for(int i=0;i+3<=n;++i) {
			if(a.substring(i,i+3).equals("ABC"))
				++r;
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string S; cin >> S;
    const int N = 13;
    vector<int64_t> dp(N);
    dp[0] = 1;
    int64_t mod = 1e9 + 7;
    int64_t mul = 1;
    for (int i = S.size()-1; i >= 0; i--) {
        vector<int64_t> nextDP(N);
        char c = S[i];
        if (c == '?') {
            for (int k = 0; k < 10; k++) {
                for (int j = 0; j < N; j++) {
                    nextDP[(k * mul + j) % 13] += dp[j];
                    nextDP[(k * mul + j) % 13] %= mod;
                }
            }
        } else {
            int k = (int)(c - '0');
            for (int j = 0; j < N; j++) {
                nextDP[(k * mul + j) % 13] += dp[j];
                nextDP[(k * mul + j) % 13] %= mod;
            }
        }

        dp = nextDP;

        mul *= 10;
        mul %= N;
    }

    cout << dp[5] << endl;
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func gcd(n, m int) int {
	if n%m == 0 {
		return m
	}
	return gcd(m, n%m)
}

func main() {
	var n int
	var a []int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		a = append(a, tmp)
	}

	var res int
	for i := 0; i < n-1; i++ {
		if i == 0 {
			res = gcd(a[i], a[i+1])
			continue
		}
		res = gcd(res, a[i+1])
	}
	fmt.Println(res)
}


Measured memory_bytes: 5504
#include <cstdio>
#include <algorithm>
#include <bitset>
#define MAXN 50005
#define MAXBS 70005
using namespace std;
bitset<MAXBS> bs;
int a[MAXN];
int main(void){
    int n,k;
    int ll,rr;
    scanf("%d%d",&n,&k);
    for (int i=0;i<n;i++){
        scanf("%d",a+i);
        a[i]=min(a[i],k);
    }
    sort(a,a+n);
    //(ll,rr]
    ll=-1,rr=n;
    while (rr-ll>1){
        int mid=(ll+rr+1)>>1;
        int necessary=0;
        bs.reset(); // bs=0
        bs.set(0); // bs[0]=1;
        for (int i=0;i<n;i++)
            if (i!=mid)
                bs|=(bs<<a[i]);
        bs>>=(k-a[mid]);
        for (int i=0;i<a[mid];i++){
            if (bs.test(i)){
                necessary=1;
                break;
            }
        }
        if (necessary)
            rr=mid;
        else
            ll=mid;
    }
    printf("%d\n",ll+1);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        double n = sc.nextDouble();
        
        p(Math.ceil((n/2))/n);
    }
    public static String stringCopy(String str) {
        StringBuilder builder = new StringBuilder();
        builder.append(str.toCharArray());
        return builder.toString();
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static <T> void pp(T element) {
        System.out.print(element);
        }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            //

            var ans = (GetIntArray().Sum() + 1) / 2;

            Console.WriteLine(ans);

            //
            Console.Out.Flush();
            Console.ReadKey();
        }

        static void Solve()
        {

        }

        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
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);
}
int main() {
  int n;cin>>n;
  double ans=0.0;
  REP(i,n){
    double x;string u;cin>>x>>u;
    if(u=="BTC"){
      ans+=x*380000.0;
    }else{
      ans+=x;
    }
  }
  cout << ans << endl;
}


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

int main(){
    ll n;
    cin>>n;
    ll num[n];
    map <ll,ll> data;
    for (ll i=0; i<n; i++){
        cin>>num[i];
        data[num[i]]++;
    }
    
    ll base=0;
    for (const auto&x:data){
        ll v=x.second;
        base+=v*(v-1)/2;
    }
    
    for (ll i=0; i<n; i++){
        ll v=data[num[i]];
        ll p=v*(v-1)/2;
        ll q=(v-1)*(v-2)/2;
        ll sum=base-p+q;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false; }

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

bool factors(const int n) {
  int ret = 2;
  for (int i = 2; i <= n/2; ++i) {
    if (n % i == 0) {
      ++ret;
    }
  }
  return (ret == 8);
}

int main() {
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    ans += (int)factors(i);
  }
  cout << ans << '\n';
}


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

int main() {
	int a,b,c,maxabc,sumabc;cin>>a>>b>>c;
    maxabc=max(a,max(b,c));
  	sumabc=a+b+c;
  	if((sumabc%2==0 && maxabc%2==0)||(sumabc%2!=0 && maxabc%2!=0)){
      cout<<(maxabc*3-sumabc)/2<<endl;
    }else{
       cout<<((maxabc+1)*3-sumabc)/2<<endl;
    }
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n , k;
	cin >> n >> k;
	
	vector<pii> pts;
	
	set<int> xx;
	set<int> yy;
	
	rep(i , n){
		int x , y;
		cin >> x >> y;
		pts.pb({x , y});
		xx.insert(x);
		yy.insert(y);
	}
	
	int lx = 0;
	int ly = 0;
	
	map<int , int> cx , cy;
	map<int , int> rx , ry;
	
	for(int x : xx){
		cx[x] = lx;	
		rx[lx] = x;
		++lx;
	}
	
	for(int y : yy){
		cy[y] = ly;
		ry[ly] = y;
		++ly;
	}
	
	int N = max(lx , ly) + 5;
	vector<vi> a(N , vi(N));
	
	
	rep(i , n){
		++a[cx[pts[i].fi]][cy[pts[i].se]];	
	//	cout << cx[pts[i].fi] << " " << cy[pts[i].se] << nl;
	}
	
	rep(i , N){
		rep(j , N){
			if(i > 0)a[i][j] += a[i - 1][j];
			if(j > 0)a[i][j] += a[i][j - 1];
			if(i * j)a[i][j] -= a[i - 1][j - 1];
		}
	}
	/*
	rep(i , N){
		rep(j , N){
			cout << a[i][j] << " " ;
		}
		cout << nl;
	}*/
	
	
	ll ans = LLONG_MAX;
	
	rep(x1 , lx){
		rep(y1 , ly){
			repf(x2 , x1 , lx){
				repf(y2 , y1 , ly){
					int cur = a[x2][y2];
					if(x1 > 0)cur -= a[x1 - 1][y2];
					if(y1 > 0)cur -= a[x2][y1 - 1];
					if(x1 * y1)cur += a[x1 - 1][y1 - 1];
					
					ll s = 1ll * (rx[x2] - rx[x1]) * (ry[y2] - ry[y1]);
				/*	if(x1 == 0 && y1 == 0 && x2 == 3 && y2 == 3){
						cout << cur << nl;
						cout << rx[x1] << " " << ry[y1] << nl;
						cout << rx[x2] << " " << ry[y2] << nl;
						cout << 1ll * (rx[x2] - rx[x1]) * (ry[y2] - ry[y1]) << nl;
					}*/
					if(cur >= k)ans = min(ans , s);
				}
			}
		}
	}
	
	cout << ans << nl;
	
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    int num[50][3]={};
    char str;
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		cin>>str;
    		if(str=='W')num[i][0]++;
    		else if(str=='B')num[i][1]++;
    		else num[i][2]++;
    	}
    }
    int ans=25000;
    for(int i=0,notw=0;i<n-2;i++){
    	notw+=num[i][1]+num[i][2];
    	for(int j=i+1,notb=0;j<n-1;j++){
    		notb+=num[j][0]+num[j][2];
    		for(int k=j+1,notr=0;k<n;k++){
    			notr+=num[k][0]+num[k][1];
    			if(k==n-1)ans=min(ans,notw+notb+notr);
    		}
    	}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.StringTokenizer;

class Calendar2004 {
    int MonthDays[] = new int[12];

    Calendar2004() {
	for (int i=0;i<12;i++) {
	    if (i==1) this.MonthDays[i] = 29;
	    else if (i==3||i==5||i==8||i==10) this.MonthDays[i] = 30;
	    else this.MonthDays[i] = 31;
	}
    }

    int SumofDays(int m,int d) {
	int sum = 0;
	for (int i=0;i<m-1;i++) {
	    sum += this.MonthDays[i];
	}
	return sum+d;
    }

    String Day(int m,int d) {
	switch (SumofDays(m,d)%7) {
	case 1: return "Thursday";
	case 2: return "Friday";
	case 3: return "Saturday";
	case 4: return "Sunday";
	case 5: return "Monday";
	case 6: return "Tuesday";
	case 0: return "Wednesday";
       	}
	return "Error";
    }
}

class Main {
    public static void main(String args[]) {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf;

	try {
	    Calendar2004 c = new Calendar2004();
	    while ((buf = br.readLine())!=null) {
		StringTokenizer st = new StringTokenizer(buf);
		int month = Integer.parseInt(st.nextToken());
		int day = Integer.parseInt(st.nextToken());
		if (month==0) break;
		System.out.println(c.Day(month,day));
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
    } 
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
	//cin.sync_with_stdio(false);
	int cases;
	scanf("%d",&cases);
	while(cases--){
		ll a[8];
		rep(i,8)scanf("%llx",a+i);
		ll sum;
		scanf("%llx",&sum);
		ll key=0;
		rep(i,32){
			bool bit=0;
			ll s=0;
			rep(i,8){
				s+=(a[i]^key)&0xffffffff;
			}
			s&=0xffffffff;
			key|=(1<<i&sum)^(1<<i&s);
		}
		printf("%x\n", (int)key);
	}
	return 0;
}

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

const long long N=200000;

int main(){
	
ios_base::sync_with_stdio(false);

long long i,n,flag=0;

cin>>n;

for(i=1;i<=9;i++)
	if((n%i==0)&&((n/i)>=1)&&((n/i)<=9))
		flag=1;
	
	if(flag)
		cout<<"Yes\n";
	
	else
		cout<<"No\n";
	
return 0;}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans=0;
    cin >> n;
    vector<int> a1(n), a2(n);
    cin >> a1[0];
    for (int i=1; i<n; i++) {
        int a;
        cin >> a;
        a1[i] = a + a1[i-1];
    }
    for (int i=0; i<n; i++)
        cin >> a2[i];
    reverse(a2.begin(), a2.end());
    for (int i=1; i<n; i++) {
        a2[i] = a2[i] + a2[i-1];
    }
    for (int i=0; i<n; i++) {
        ans = max(ans, a1[i]+a2[n-i-1]);
    }
    cout << ans << endl;
}


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

//#define FILE_INPUT
//#define DEBUG_MODE

char Move(int position, int n, int q, string s, vector<char> &t, vector<char> &d)
{
	for (int i = 0; i < q; ++i) {
		if (s[position] == t[i]) {
			if (d[i] == 'L') {
				position--;
			}
			else {
				position++;
			}
		}
		if (0 > position) {
			return 'L';
		}
		if (n <= position) {
			return 'R';
		}
	}
	return ' ';
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  
	int n, q;

	cin >> n >> q;
	string s;
	cin >> s;
	vector<char> t(q);
	vector<char> d(q);
	for (int i = 0; i < q; ++i) {
		cin >> t[i] >> d[i];
	}


	int left_limit = n;		// from right
	int left = 0;
	int right = n - 1;
	if ('R' == Move(left, n, q, s, t, d)) {
		left_limit = left;
	}
	else if ('R' != Move(right, n, q, s, t, d)) {
		left_limit = n;
	}
	else {
		for (;;) {
			int mid = (left + right) / 2;
			if ('R' == Move(mid, n, q, s, t, d)) {
				if (left == mid) {
					left_limit = left;
					break;
				}
				right = mid;
			}
			else {
				if (left == mid) {
					left_limit = right;
					break;
				}
				left = mid;
			}
		}
	}



	int right_limit = -1;	// from left
	left = 0;
	right = n - 1;
	if ('L' == Move(right, n, q, s, t, d)) {
		right_limit = right;
	}
	else if ('L' != Move(left, n, q, s, t, d)) {
		right_limit = -1;
	}
	else {
		for (;;) {
			int mid = (left + right) / 2;
			if ('L' == Move(mid, n, q, s, t, d)) {
				if (left == mid) {
					right_limit = left;
					break;
				}
				left = mid;
			}
			else {
				right = mid;
			}
		}
	}

	int alive = left_limit - right_limit - 1;
	alive = max(alive, 0);
	//cout << left_limit << " " << right_limit << " ";
	cout << alive << endl;


	return 0;
}

Measured memory_bytes: 1156
n, k = gets.split.map(&:to_i)

dd = []
aaa = []
k.times do
  dd << gets.to_i
  aaa << gets.split.map(&:to_i)
end

aaa.flatten!
aaa.uniq!

ret = 0
(1..n).each do |i|
  ret += 1 unless aaa.include?(i)
end
puts ret


Measured memory_bytes: 14368
n,m=map(int,input().split())
a = [int(input()) for i in range(m)]
broken = set(a)
dp=[0]*(n+1)
mod = 10**9 + 7

for i in range(n,-1,-1):
  if i in broken:
    continue
  elif i==n or i==n-1:
    dp[i]=1
  else:
    dp[i]=dp[i+1]+dp[i+2]
    dp[i]=dp[i]%mod
print(dp[0])

Measured memory_bytes: 13192
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

int main() {

	int A, B;
	cin >> A >> B;

	int sum = 1;
	int ans = 0;

	while (sum < B) {
		sum -= 1;
		ans += 1;
		sum += A;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

const int inf=1e9+10;
const int maxn=16;

int dp[1<<maxn][maxn],dp2[1<<maxn],n,m,cost[maxn][maxn],dp3[1<<maxn]; 
vector <int> g[1<<maxn]; 

int main(){
	for(int i=0;i<maxn;i++) for(int j=0;j<maxn;j++) 
		cost[i][j]=0;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--; v--;
		cost[u][v]=c;
		cost[v][u]=c;
	}
	for(int mask=0;mask<(1<<n);mask++) 
		for(int i=0;i<n;i++) for(int j=0;j<n;j++)
			if((mask&(1<<i))&&(mask&(1<<j)))
				dp2[mask]=dp2[mask]+cost[i][j];
	for(int mask=0;mask<(1<<n);mask++) dp2[mask]=dp2[mask]/2;
	for(int mask=0;mask<(1<<n);mask++) for(int i=0;i<n;i++) dp[mask][i]=-inf;
	dp[1<<0][0]=0;
	for(int mask=0;mask<(1<<n);mask++)
		for(int i=0;i<n;i++){
			if((dp[mask][i]==-inf)||!(mask&(1<<i))) continue;
			for(int j=0;j<n;j++) if((!(mask&(1<<j)))&&(cost[i][j]>0))
				dp[mask|(1<<j)][j]=max(dp[mask|(1<<j)][j],dp[mask][i]+cost[i][j]);
		}
	for(int mask=0;mask<(1<<n);mask++)
		dp3[mask]=dp[mask][n-1];
	for(int mask=0;mask<(1<<n);mask++){
		if(dp3[mask]==-inf) continue;
		for (int mask2=mask;mask2<(1<<n);mask2++,mask2|=mask){
			if(mask==mask2) continue;
			int mask3=(mask^mask2);  
			int mcst=max(dp2[1|mask3],dp2[(1<<(n-1))|mask3]);
			for(int i=0;i<n;i++) if((mask>>i)&1)
				mcst=max(mcst,dp2[1<<i|mask3]);
			dp3[mask2]=max(dp3[mask2],dp3[mask]+mcst);
		}
	}
	printf("%d\n",dp2[(1<<n)-1]-dp3[(1<<n)-1]);
	return 0;
}

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

long long A, B , C , K ;

void input() {
    cin >> A >> B >> C >> K ;
}

int main() {
    input() ;
    
    if( A >= K ){
        cout << K << endl;
    }
    
    else if( A+B >= K ){
        cout << A << endl;
    }
    
    else{
        cout << 2*A + B - K << endl;
    }
    
}


Measured memory_bytes: 3640
#!/usr/bin/env python3

n, a, b = map(int, input().split())

ans = 0
if (b-a)%2 == 0:
    ans = (b-a)//2
else:
    if a-1 >= n-b:
        ans = n + (1-a-b)//2
    else:
        ans = (a+b)//2

print(int(ans))


Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		Set<Integer> setA = new TreeSet<>();
		Set<Integer> setB = new TreeSet<>();

		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			setA.add(sc.nextInt());
		}

		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			setB.add(sc.nextInt());
		}


		setA.removeAll(setB);

		for(int value : setA) {
			System.out.println(value);
		}
	}

}



Measured memory_bytes: 190576
#include <stdio.h>
 
int main(void)
{
    int n,a[100],i;
    double x,y,z;
      
    scanf("%d",&n);
  
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        x=(double)1/a[i];
        y=y+x;
    }
    z=(double)1/y;
    printf("%lf",z);
  
  return 0;
}  

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(unused_macros)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;


//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}


//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


//
// Main
//

fn main() {
    input! {
        n: usize,
        xs: [usize; n+1],
        bs: [usize; n],
    }

    let mut ys = vec![0; n+1];

    for i in 0..n {
        let rest = xs[i] - ys[i];
        let a = min(rest, bs[i]);
        ys[i] += a;
        ys[i+1] = min(xs[i+1], bs[i] - a);
    }

    let ans: usize = ys.iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 10232
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;

int calc(long long  num) {

	int keta=0;

	while (num>0) {		
		num = num / 10;
		keta++;
	}

	return keta;
}


int main(){
	long long n;
	cin >> n;

	int ans = 100;

	long long i = 1;
	while ( i*i <= n) {
		if (n % i == 0) {
			long long b = n / i;            
			
			int c=max(calc(i), calc(b));
			
			if (ans > c)ans = c;
			if (ans < c)break;
		}
		i++;
	}

	cout<<ans<<endl;

	return 0;
}

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

int m,n,Free[200];

int main()
{
    cin>>m>>n;
    int c1=0,c2=0;
    if(m%2==1&&n%2==1)
    {
        c1=m+n-2;
        c2=1;
    }
    else
    if(m%2==1)
        c1=n;
    else
    if(n%2==1)
        c1=m;
    char c;
    for(int i=1;i<=m*n;i++)
    {
        cin>>c;
        Free[c]++;
    }
    for(int i='a';i<='z';i++)
        if(Free[i]%2==1)
        {
            if(c2==0)
            {
                cout<<"No";
                return 0;
            }
            c2--;
            Free[i]--;
        }
    for(int i='a';i<='z';i++)
        if(Free[i]%4==2)
        {
            if(c1==0)
            {
                cout<<"No";
                return 0;
            }
            c1-=2;
            Free[i]-=2;
        }
    cout<<"Yes";
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
    int h, w, n; cin >> h >> w >> n;
    set<int> se[200200];
    rep(i, w) {
        se[i].insert(h);
    }
    map<pair<int, int>, int> mp;
    rep(i, n) {
        int x, y; cin >> x >> y;
        --x; --y;
        mp[make_pair(x, y)] = 1;
        se[y].insert(x);
    }
    //番兵
    rep(i, h) {
        se[w].insert(i);
        mp[make_pair(i, w)] = 1;
    }
    rep(i, w) {
        se[i].insert(h);
        mp[make_pair(h, i)] = 1;
    }
    int ans = h;
    int curx = 0, cury = 0;
    while(true) {
        if(!mp[P(curx + 1, cury)]) {
            ++curx;
        } else {
            chmin(ans, curx + 1);
            break;
        }

        if(!mp[P(curx, cury + 1)]) {
            int k = *se[cury].lower_bound(curx + 1);
            chmin(ans, k);
            ++cury;
        } else {
            continue;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 95872
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> L(N, 0);
  for(auto& l : L) {cin >> l;}
  sort(L.begin(), L.end());
  
  int ans = 0;
  for(int i = N-1; i >= 0; --i) {
    for(int j = i-1; j >= 0; --j) {
      auto it = lower_bound(L.begin(), L.end(), L[i] + L[j]);
      auto ng = distance(it, L.end());
      ans += (N - 1 - i) - ng;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
T = set()
def counter(array):
    from collections import Counter
    return Counter(array)
c = counter(A)
for x in A:
    T.add(x)
cnt = 0
maxi = max(A)
for x in sorted(A):
    i = 2
    while x * i <= maxi:
        if x * i in T:
            T.remove(x*i)
        i += 1
ans = 0
for x in T:
    if c[x] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 147752
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,all;
    for(;;){
    int glap[12][12]={0};
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>glap[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            glap[i][n]+=glap[i][j];
            glap[n][i]+=glap[j][i];
        }
    }
    for(int i=0;i<n;i++){
        glap[n][n]+=glap[n][i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            printf("%5d",glap[i][j]);
        }
        cout<<endl;
    }
    }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, M;
    long long mformas =0, nformas=0;
    cin >> N >> M;
    if (N!=1) {
        for (int i = 1; i<=N ;++i){
            nformas += N-i;
        }
    }
    if (M!=1) {
        for (int i = 1; i<=M ;++i){
            mformas += M-i;
        }
    }
    cout << mformas+nformas;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, k, tmp;
	int yaku[100];
	int yakunum=0;

	if(scanf("%d %d %d", &a, &b, &k) == EOF) return 0;


	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}

	for (int i = 1; i <= a; i++)
	{
		if (a % i == 0 && b % i == 0)
		{
			yaku[yakunum] = i;
			yakunum++;
		}
	}

	printf("%d\n", yaku[yakunum - k]);

	return 0;
}

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

using namespace std;

const int N = 1e5 + 10;
vector<int> g[N];
int dp[N], in[N];

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

  int n, m;
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    ++in[v];
  }
  set<pair<int, int>> s;
  for (int i = 0; i < n; ++i) {
    s.emplace(in[i], i);
  }
  while (!s.empty()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    for (int to : g[v]) {
      s.erase({in[to], to});
      --in[to];
      s.emplace(in[to], to);
      dp[to] = max(dp[to], dp[v] + 1);
    }
  }
  cout << *max_element(dp, dp + n);

  return 0;
}

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

ll n,m,a,b,num[100009],ans[100009];
vector<ll>e[100009];

int main(){
    cin>>n>>m;
    rep(i,n-1+m){
        cin>>a>>b;
        e[a].push_back(b);
        num[b]++;
    }
    queue<ll> que;
    FOR(i,1,n+1)if(num[i]==0)que.push(i);
    while(!que.empty()){
        ll now=que.front();
        que.pop();
        rep(i,e[now].size()){
            num[e[now][i]]--;
            if(num[e[now][i]]==0){
                ans[e[now][i]]=now;
                que.push(e[now][i]);
            }
        }
    }
    FOR(i,1,n+1)cout<<ans[i]<<endl;
}

Measured memory_bytes: 7808