akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main(void){
	while(1){
		double n;
		int a[12]={0};
		int i;
		
		scanf(" %lf", &n);
		if(n<0) break;
	
		for(i=0; i<12; i++){
			//printf("%lf\n", n);
			if( n>=pow(2.0, 7-i) ){
				n -= pow(2.0, 7-i);
				a[i] = 1;
			}
		
			if(n==0) break;
		}
	
		if(n==0) {
			for(i=0; i<12; i++){
				printf("%d", a[i]);
				if(i==7) printf(".");
			}
			printf("\n");
		}
		else printf("NA\n");
	
	}

	return 0;
}

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

using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T> inline void IN(T &x) {
	x = 0; T f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); }
	x *= f;
}
template<typename A, typename B> inline void IN(A &x, B &y) { IN(x); IN(y); }
template<typename A, typename B, typename C> inline void IN(A &x, B &y, C &z) { IN(x); IN(y); IN(z); }

#define FastI ios_base::sync_with_stdio(0), cin.tie(0);
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl '\n'
#define REP(i, l, r) for (auto i = (l); i <= (r); ++i)
#define PER(i, l, r) for (auto i = (l); i >= (r); --i)
#define FOR(i, l, r) for (auto i = (l); i < (r); ++i)
#define ROF(i, l, r) for (auto i = (l); i > (r); --i)
#define FORN(i, n) for (auto i = 0; i < (n); ++i)
#define REPN(i, n) for (auto i = 1; i <= (n); ++i)
#define FORA(i, a) for (auto &i : a)
template<class T> void cout_1d(T &v) { FORA(i, v) cout << i << " "; puts(""); }
template<class T> void cout_2d(T &vv) { FORA(v, vv) cout_1d(v); }
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define SIZE(X) ((int)(X).size())
#define UNIQUE(x) (X).erase(unique(ALL(x), (X).end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define NEG1(a) memset(a, -1, sizeof(a))
#define MAXA(a) memset(a, 0x3f, sizeof(a))
#define MAXB(b) memset(b, 0x7f, sizeof(b))
#define MP make_pair
#define PB push_back
#define X first
#define Y second

const LD PI = acos(-1.0);
const LL MOD = 998244353;
//const LL MOD = 1e9+7;
const LL MAXN = 2e5 + 7;

int h[MAXN];
void solve1() {
	int N;  IN(N);
	REPN(i, N) IN(h[i]);
	VI dp(N+1, 0);  dp[2] = abs(h[2] - h[1]);
	REP(i, 3, N) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	cout << dp[N] << endl;
}

void solve2() {
	int N, K;  IN(N, K);
	REPN(i, N) IN(h[i]);
	VI dp(N+1, INT_MAX);
	dp[1] = 0;
	REP(i, 2, N) REP(j, 1, K) // if (j >= i) break;
		dp[i] = min(dp[i], i <= j ? INT_MAX : dp[i-j] + abs(h[i] - h[i-j]));
	cout << dp[N] << endl;
}

int main() {
#ifdef _DEBUG
    freopen("../in.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    FastI

	// solve1();
	solve2();

    return 0;
}


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

int main() {
    int D, E;
    while (cin >> D >> E, D && E) {
        double ans = 1e9;
        for (int i = 0; i <= D; i++) {
            ans = min(ans, abs(sqrt(i * i + (D - i) * (D - i)) - E));
        }
        printf("%.12f\n", ans);
    }

    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(), .end());
int main(){
  ll n, a, x=0, y=0;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> a;
    if (a % 4 == 2) x++;
    if (a % 4 == 0) y++;
  }
  str ans = "Yes";
  if (n - 2*y > x) ans = "No";
  if (x == 0 && n/2 <= y) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
let solve n k =
  let rec mkls n' tmp =
    if n' <= 0 then List.fast_sort (fun i j -> j - i) tmp
    else
      mkls (pred n') ((Scanf.scanf "%d " (fun x -> x)) :: tmp)
  in
  let rec sum i ans ls =
    if i > k then ans
    else sum (succ i) (ans + List.hd ls) (List.tl ls)
  in
  mkls n [] |> sum 1 0

let () = Scanf.scanf "%d %d\n" solve |> Printf.printf "%d\n"

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=15,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
int main(){
    IOS();
    ll n;
    cin >> n;
    REP (i,5) cin >> d[i];
    cout << (n-1)/(*min_element(d,d+5)) + 5 << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  for(char i = 'a'; i <= 'z'; i++){
    REP(j,s.length()){
      if(s[j]==i) goto next;
    }
    cout << i << endl;
    return 0;
    next:;
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
struct UnionFind
{
    vector<int> r;
    UnionFind(int N)
    {
        r = vector<int>(N, -1); //全員の友達の数を1とする
    }
    int root(int x)
    {
        if (r[x] < 0)
            return x;
        return r[x] = root(r[x]);
    }
    bool unite(int x, int y)
    {
        x = root(x), y = root(y); //2人を友達にする
        if (x == y)               //2人が同じ人の場合は何もしない
            return false;
        if (r[x] > r[y]) //xの友達の数がyよりも少ないときはxとyを交換する(xのほうがyよりも友達の数が多くなるようにする)
            swap(x, y);
        r[x] += r[y]; //xの友達の数を増やす
        r[y] = x;     //yの友達の数はx
        return true;
    }
    int size(int x)
    {
        return -r[root(x)];
    }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    UnionFind UF(n);
    rep(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        UF.unite(a, b);
    }
    int ans = 0;
    rep(i, 0, n)
    {
        ans = max(ans, UF.size(i));
    }
    cout << ans << endl;
}

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

#define ll long long

using namespace std;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long n,m;cin >> n >> m;
	priority_queue<pair<ll,ll>> pq;
	ll a,b;
	
	//first will contain value and second will contain frequency
	for(int i = 0; i<n; i++){
		cin >> a;
		pq.push({a,1});
	}
	
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		pq.push({b,a});
	}
	
	long long total = 0;
	while(n > 0){
		
		auto x = pq.top();pq.pop();
		if(x.second <= n){
			total += (x.first*x.second);
			n -= x.second;
		}else{
			total += n*x.first;
			break;
		}
	}
	cout << total;
	return 0;
}

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

int main(){
  int A , B ,C ,K;
  cin >> A >> B >> C >> K;
  
  if( K <= A){
    cout << K << endl;
  }
  else if( K <= A + B){
    cout << A << endl;
  }
  else{ //ﾏｲﾅｽ含むとき
    cout << A - (K - A - B) << endl; //合計AからK -(A + B)した枚数ぶん-1の札をとる 
  }
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while (a>0 &&c>0){
    c-=b;
    if (c<=0) {
      cout << "Yes";
      return 0;
    }
    a-=d;
    if (a<=0) {
      cout << "No";
      return 0;
    }
  }
}

Measured memory_bytes: 3636
def popcount(x):
    if x in memo:
        return memo[x]
    res=0
    while(x>0):
        if x&1:
            res+=1
        x//=2
    memo[x]=res
    return res
memo={}

N=int(input())
X=input()[::-1]
c=X.count('1')
count=[0]*(c+2)
for i in range(c+2):
    x=i
    cnt=0
    while(x>0):
        x=x%popcount(x)
        cnt+=1
    count[i]=cnt

if X[0]=='0':
    summ,sumn,sump=0,0,0
else:
    summ,sumn,sump=1,1,1
bitm,bitn,bitp=[0]*N,[0]*N,[0]*N
bitm[0],bitn[0],bitp[0]=1,1,1
for i in range(1,N):
    if c>1:
        bitm[i]=bitm[i-1]*2%(c-1)
    bitn[i]=bitn[i-1]*2%c
    bitp[i]=bitp[i-1]*2%(c+1)
    if X[i]=='1':
        if c>1:
            summ=(summ+bitm[i])%(c-1)
        sumn=(sumn+bitn[i])%c
        sump=(sump+bitp[i])%(c+1)
ans=[]
for i in range(N):
    if X[i]=='0':
        x=(sump+bitp[i])%(c+1)
        ans.append(count[x]+1)
    else:
        if c==1:
            ans.append(0)
        else:
            x=(summ-bitm[i]+c-1)%(c-1)
            ans.append(count[x]+1)
print(*ans[::-1],sep='\n')

Measured memory_bytes: 102948
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

vector<string> f;
vector< vector<int> > d;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
   int H, W;
   cin >> H >> W;
   f.resize(H);
   for (int i = 0; i < H; i++) cin >> f[i];

   d.resize(H);
   for (int h = 0; h < H; h++) {
      d[h].resize(W);
      for (int w = 0; w < W; w++) {
         d[h][w] = -1;
      }
   }
   queue<ipair> q;
   for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
         if (f[h][w] == '#') {
            d[h][w] = 0;
            q.push(ipair(h, w));
         }
      }
   }

   while (!q.empty()) {
      auto cur = q.front();
      q.pop();
      for (int dir = 0; dir < 4; dir++) {
         int nx = cur.first + dx[dir];
         int ny = cur.second + dy[dir];
         if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
         if (d[nx][ny] == -1) {
            d[nx][ny] = d[cur.first][cur.second] + 1;
            q.push(ipair(nx, ny));
         }
      }
   }
   int ans = 0;
   for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
         ans = max(ans, d[h][w]);
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 13456
import sys


def main(lines=None):
    # ここは変えない
    if not lines:
        lines = sys.stdin.readlines()
    lines = [line.split() for line in lines]
    # ここまで

    lines_int = [sorted(list(map(int, line))) for line in lines]
    a = 0
    b = 0
    c = 0

    for line in lines_int:
        if line[0] + line[1] > line[2]:
            if line[2] ** 2 == line[0] ** 2 + line[1] ** 2:
                a += 1
            elif line[2] ** 2 < line[0] ** 2 + line[1] ** 2:
                b += 1
            elif line[2] ** 2 > line[0] ** 2 + line[1] ** 2:
                c += 1
        else:
            # answer = "{0} {1} {2} {3}".format(a + b + c, a, b, c)
            break

    answer = "{0} {1} {2} {3}".format(a + b + c, a, b, c)

    print(answer)
    return answer


def test_main():
    test_inputs = """
3 4 5
2 1 2
6 3 4
1 1 1
1 2 3
""".strip()
    test_inputs = test_inputs.split("\n")
    answer = main(test_inputs)
    expect = """
4 1 2 1
""".strip()

    assert answer == expect


if __name__ == "__main__":
    main()



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

int main() {
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A +3);
	(A[0] == 5 && A[1] == 5 && A[2] == 7) ? cout << "YES\n": cout << "NO\n";
    return 0;
}

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

int main(){
    int sin;
    int h, m, s;
    
    cin >> sin;
    h = sin / 3600;
    m = sin % 3600;
    s = m % 60;
    m /= 60;
    cout << h << ":" << m << ":" << s << endl;
}


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

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

using namespace std;
using lint=long long;

inline int popcount(long long x){
	x-=(x>>1)&0x5555555555555555LL;
	x=(x&0x3333333333333333LL)+((x>>2)&0x3333333333333333LL);
	x=(x+(x>>4))&0x0f0f0f0f0f0f0f0fLL;
	x=(x*0x0101010101010101LL)>>56;
	return x;
}

template<class T> struct edge{
	int to;
	T wt;
	edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using weighted_graph=vector<vector<edge<T>>>;

weighted_graph<int> T;

pair<bool,lint> dfs(int u,int p,int g){
	if(u==g) return {true,0};

	for(auto e:T[u]) if(e.to!=p) {
		auto tmp=dfs(e.to,u,g);
		if(tmp.first){
			return {true,(1LL<<e.wt)|tmp.second};
		}
	}
	return {false,0};
}

int main(){
	int n; scanf("%d",&n);
	T.resize(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		T[u].emplace_back(v,i);
		T[v].emplace_back(u,i);
	}

	int m; scanf("%d",&m);
	lint E[20];
	rep(i,m){
		int a,b; scanf("%d%d",&a,&b); a--; b--;
		E[i]=dfs(a,-1,b).second;
	}

	lint ans=0;
	rep(S,1<<m){
		lint white=0;
		rep(i,m) if(S>>i&1) white|=E[i];
		ans+=(popcount(S)%2==0?1:-1)*(1LL<<(n-1-popcount(white)));
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
import math
l, k = map(int, input().split())
c = 0
for i in range(1, int((l + 1) / 2) + 1):
    for j in range(i + 1):
        if 2 * i - 1 + j * (k - 1) <= l:
            c += math.factorial(i) / math.factorial(j) / math.factorial(i - j)
        else:
            break
print(int(c))


Measured memory_bytes: 5664
#include <cmath>
#include <string>
#include <iostream>
using namespace std;
int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
string s;
int main() {
	cin >> s;
	string t1 = s.substr(0, s.find('.')), t2 = s.substr(s.find('.') + 1);
	int d1 = stoi(t1), d2 = 1;
	if (s.find('(') == string::npos) {
		d2 = (int)pow(10, t2.size()); d1 *= d2;
		d1 += stoi(t2);
	}
	else {
		string t3 = t2.substr(0, t2.find('(')), t4 = t2.substr(t2.find('(') + 1); t4.pop_back();
		if (t3.size()) {
			d2 = (int)pow(10, t3.size()); d1 *= d2;
			d1 += stoi(t3);
		}
		int e1 = stoi(t4), e2 = (int)pow(10, t3.size()) * ((int)pow(10, t4.size()) - 1);
		d1 = d1 * e2 + d2 * e1;
		d2 *= e2;
	}
	int g = gcd(d1, d2);
	d1 /= g, d2 /= g;
	cout << d1 << '/' << d2 << endl;
	return 0;
}

Measured memory_bytes: 3348
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        System.out.println(sc.nextInt() * sc.nextInt());
    }
}

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 static 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: 32528
N, W = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
    v,w = map(int, input().split())
    for j in range(1,W+1):
        if j<w:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v)
print(dp[-1][-1])


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

const int MAX = 1000010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    int X,Y,m,n;
    cin>>X>>Y;
    COMinit();
    if((2*Y-X)%3!=0||(2*X-Y)%3!=0){cout<<0;return 0;}
    else{
         n=(2*Y-X)/3;
         m=(2*X-Y)/3;
         cout<< COM(n+m,m) << endl;;
    }
    // 計算例
    
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  map<string, int> mp;
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s.at(i);
    mp[s.at(i)]++;
  }
  
  int keep = 0;
  for(int i = 0; i < n; i++){
    keep = max(keep, mp[s.at(i)]);
  }
  
  vector<string> ans;
  for(int i = 0; i < n; i++){
    if(mp[s.at(i)] == keep) ans.emplace_back(s.at(i));
  }
  
  sort(ans.begin(), ans.end());
  
  cout << ans.at(0) << '\n';
  for(int i = 1; i < ans.size(); i++){
    if(ans.at(i - 1) != ans.at(i)) cout << ans.at(i) << '\n';
  }
}

Measured memory_bytes: 27120
//??????//


#include<stdio.h>
int main()
{
	int m, f, r;
	while(1){
		scanf("%d %d %d", &m, &f, &r);
		if(m == -1 && f == -1 && r == -1) break;
		
		if(m == -1 || f == -1){
			printf("F\n");
		}
		else if(m+f >= 80){
			printf("A\n");
		}
		else if(m+f >= 65){
			printf("B\n");
		}
		else if(m+f >= 50){
			printf("C\n");
		}
		else if(m+f >=30){
			if(r >= 50){
				printf("C\n");
			}
			else{
				printf("D\n");
			}
		}
		else{
			printf("F\n");
		}
	}

	return 0;
}

Measured memory_bytes: 584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>

namespace IO{
    const int insiz = 1 << 12, outsiz = 1 << 18;
    char in[insiz], *A(in), *B(in); char out[outsiz], *ptr(out);
    inline char getc(){
    	#ifndef LOCAL
        return (A == B) && (B = (A = in) + fread(in, 1, insiz, stdin), A == B) ? EOF : *A++;
        #endif
        return getchar();
    }
    template <typename T> inline T read(){
        T ret(0), p(1); char ch(getc());
        while(ch < '0' || ch > '9'){
            if(ch == '-') p = -1; ch = getc();
        }
        while(ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getc();
        return ret*p;
    }
    inline void flush(){ fwrite(out, 1, ptr - out, stdout); ptr = out; }
    template <typename T> inline void write(T x, char cmd = '\n'){
        if(x < 0) *ptr++ = '-', x = -x;
        if(x == 0) *ptr++ = '0';
        static char s[123]; int cnt = 0;
        for(; x; x /= 10) s[++cnt] = x % 10 + '0';
        for(; cnt; --cnt) *ptr++ = s[cnt];
        *ptr++ = cmd;
        if((outsiz >> 1) > ptr - out) flush();
    }
} using IO::getc; using IO::read; using IO::write; using IO::flush;

int main(){
	int a = read<int>(), b = read<int>(), t = read<int>();
	write(b*(int)((t+0.5)/a));
	flush(); return 0;
}




Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=100010;
const int P=1000000007;
long long int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
int min(int a, int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	len = strlen(s);
文字列長さ*/


/*
	string s;
	s.size()
*/


/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/


/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("Yes");
	else puts("No");
*/
/*文字列比較
if(strcmp(name[i],s)==0)
*/
/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
	char a[N];
	int n=0;
	cin>>a;
	char b[]="hi";
	char c[]="hihi";
	char d[]="hihihi";
	char e[]="hihihihi";
	char f[]="hihihihihi";
	if(strcmp(a,b)!=0){	if(strcmp(a,c)!=0){	if(strcmp(a,d)!=0){	if(strcmp(a,e)!=0){	if(strcmp(a,f)!=0){n=1;}}}}}
	if(n==1){
		puts("No");
	}else{
		puts("Yes");
	}

}
	

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const long long a=1e9+7;
map<long long,long long>arr;
inline long long read() {
    char ch = getchar(); long long x = 0;
    while(ch < '0' || ch > '9')
        ch = getchar();
   while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } 
	return x ;
}
long long digui(long long s)
{
	if(arr[s]==0)
		return arr[s]=(digui(s/2)+digui((s-1)/2)+digui((s-2)/2))%a;
	return arr[s];
}
int main()
{
	arr[0]=1,arr[1]=2,arr[2]=4;
	printf("%lld",digui(read())%a);
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0)cout<<s[i];
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string toupper( string s ){
    string t = s;
    for ( int i = 0; i < s.size(); i++){
        t[i] = toupper( s[i] );
    }
    return t;
}
    

int main(){
    string target, source;
    
    cin >> target;
    target = toupper(target);
    
    int cnt = 0;
    
    while(1){
        cin >> source;
        if ( source == "END_OF_TEXT" ) break;
        source = toupper(source);
        if ( target == source ) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
    
}

Measured memory_bytes: 3216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>  
#include<cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include<map>
#include<algorithm>
#include<functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include<deque>
#include<climits>
#include<typeinfo>
#include<utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10)



int main() {

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

	if (k <= a)cout << k << endl;
	else if (k <= a + b)cout << a << endl;
	else cout<<a-(k-a-b)<<endl;

	return 0;
}



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

int main()
{
    vector <char> vec;
    string O,E;
    cin>>O>>E;
    int len1=O.size();
    int len2=E.size();
    int i,j;
    for(i=0,j=0;i!=len1 and j!=len2;i++,j++)
    {
        vec.push_back(O[i]);
        vec.push_back(E[j]);
    }
    if(i==len1)
    {
        while(j!=len2)
        {
            vec.push_back(E[j]);
            j++;
        }
    }
    else
    {
        while(i!=len1)
        {
            vec.push_back(O[i]);
            i++;
        }
    }
    for(int i=0;i<vec.size();i++) cout<<vec[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int len[100005];
int main()
{
	int n,m,i,i2;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		scanf("%d",&len[i]);
	for(i=1;i<n;i++)
	{
		if(len[i]+len[i+1]>=m)
		{
			printf("Possible\n");
			for(i2=1;i2<i;i2++)
				printf("%d\n",i2);
			for(i2=n-1;i2>=i+1;i2--)
				printf("%d\n",i2);
			printf("%d",i);
			return 0;	
		}
	}
	printf("Impossible");
	return 0;
}

Measured memory_bytes: 1152
# https://atcoder.jp/contests/abc113/tasks/abc113_d
# 1からスタートKまで到着
# 横棒はH本引ける
# 縦棒はW本ある

# DP的に数え上げることを考える
# DP[i][j]...(0,i]まで考慮したときに、jにたどり着ける通りの数
MOD = 10**9 + 7
ra = range
enu = enumerate
H, W, K = map(int, input().split())


'''
DP[i][j]...(0,i]まで考慮したときに、jにたどり着ける通りの数

更新則
if iにおいてjとj+1の間に横棒があったら
DP[i+1][j+1] += D[i][j]
DP[i+1][j] += D[i][j+1]
else
DP[i+1][j] = D[i][j]

for all paterns at i

初期条件
DP[i][j]=0
DP[0][0]=1
'''

if W == 1:  # コーナーケース処理
    print(1)
    exit()


def iter_p_adic(p, length):
    '''
    連続して増加するp進数をリストとして返す。lengthはリストの長さ
    return
    ----------
    所望のp進数リストを次々返してくれるiterator
    '''
    from itertools import product
    tmp = [range(p)] * length
    return product(*tmp)


def ret_valid_swapset():
    # (j,j+1)でswapできるならjで1に成るようにする
    for p in iter_p_adic(2, W - 1):
        pre = 0
        skip = False
        for pp in p:
            if pre == 1 and pp == 1:
                skip = True
                break  # 条件を満たさない
            pre = pp
        if skip:
            continue
        yield p


pattern = list(ret_valid_swapset())

DP = [[0] * W for _ in ra(H + 1)]
DP[0][0] = 1
for i in ra(H):
    for p in pattern:
        pre_is_swap = False
        for j, is_swap in enu(p):
            if is_swap:
                DP[i + 1][j + 1] += DP[i][j]
                DP[i + 1][j] += DP[i][j + 1]
            # swapしない線の処理
            elif not pre_is_swap:
                DP[i + 1][j] += DP[i][j]
            pre_is_swap = is_swap
        if not pre_is_swap:  # 一番端の処理も忘れずに
            DP[i + 1][j + 1] += DP[i][j + 1]

            # あまりの処理
    for j in ra(W):
        DP[i + 1][j] %= MOD
print(DP[H][K - 1])
# from pprint import pprint
# print(*DP, sep='\n')


Measured memory_bytes: 40176
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , m , x , c = 0 , d = 0;
    cin >> n >> m >> x;
	int a[m + 1] , b[n + 1] = {};
	for( int i = 1 ; i <= m ; i++ ) {
		cin >> a[i];
		b[a[i]] = 1;
	}
	for( int i = x ; i <= n ; i++ ) {
		if( b[i] == 1 ) c++;
	} 
	for( int i = x ; i >= 1 ; i-- ) {
		if( b[i] == 1 ) d++;
	}
	cout << min( c , d );
}

Measured memory_bytes: 3548
#include<iostream>
#include<vector>
using namespace std;
int N;
long K;
int A[2<<17];
int to[2<<17];
int nxt[2<<17];
long ap[2<<17];
main()
{
	cin>>N>>K;
	int cnt=0;
	for(int i=0;i<2<<17;i++)nxt[i]=ap[i]=-1;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=2*N;i--;)
	{
		to[i%N]=nxt[A[i%N]];
		if(nxt[A[i%N]]==-1)cnt++;
		nxt[A[i%N]]=i;
	}
	int id=0,tern=0;
	ap[id]=K;
	while(K>1)
	{
		int xt=to[id];
		if(K<=(xt+1)/N)
		{
			if((xt+1)/N==2)
			{
				K=0;
			}
			break;
		}
		K-=(xt+1)/N;
		id=(xt+1)%N;
		if(ap[id]>=0)K%=ap[id]-K;
		//if(ap[id]>=0&&K>2)K-=(K-2)/(tern-ap[id])*(tern-ap[id]);
		ap[id]=K;
	}
	if(K==0)
	{
		cout<<endl;
		return 0;
	}
	for(int i=0;i<2<<17;i++)ap[i]=0;
	vector<int>ans;
	for(int i=id;i<N;i++)
	{
		if(ap[A[i]]==0)
		{
			ans.push_back(A[i]);
			ap[A[i]]++;
		}
		else
		{
			while(ap[A[i]]>0)
			{
				ap[ans.back()]--;
				ans.pop_back();
			}
		}
	}
	for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";
	cout<<endl;
}


Measured memory_bytes: 7284
#include <stdio.h>
#include <string.h>

int main(void) {
    int n;
    int ac=0,wa=0,tle=0,re=0;
    char s[3];
        scanf("%d", &n);
        for(int i=0;i<n;i++){
          scanf("%s", s);
          if(!strcmp(s,"AC"))
            ac += 1;
          if(!strcmp(s,"WA"))
            wa += 1;
          if(!strcmp(s,"TLE"))
            tle += 1;
          if(!strcmp(s,"RE"))
            re += 1;
        }
        printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);

        return 0;
}


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

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;

  long long A[X], B[Y], C[Z];
  for (int i = 0; i < X; i++) cin >> A[i];
  for (int i = 0; i < Y; i++) cin >> B[i];
  for (int i = 0; i < Z; i++) cin >> C[i];

  long long AB[X * Y];
  int k = 0;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      AB[k++] = A[i] + B[j];
    }
  }

  sort(AB, AB + X * Y, greater<long long>());
  int xy = min(X * Y, K);
  long long ABC[xy * Z];
  k = 0;
  for (int i = 0; i < xy; i++) {
    for (int j = 0; j < Z; j++) {
      ABC[k++] = AB[i] + C[j];
    }
  }

  sort(ABC, ABC + xy * Z, greater<long long>());
  for (int i = 0; i < K; i++) cout << ABC[i] << endl;

  return 0;
}


Measured memory_bytes: 31488
x,y,z,k = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A = sorted(A,reverse=True)[:k]
B = sorted(B,reverse=True)[:k]
C = sorted(C,reverse=True)[:k]

list_ans = []
for index_a,a in enumerate(A):
  for index_b,b in enumerate(B):
    for index_c,c in enumerate(C):
      if (index_a + 1) * (index_b + 1) * (index_c + 1) > k:
        break
      list_ans.append(a+b+c)


list_ans.sort(reverse=True)
for i in list_ans[:k]:
  print(i)

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e3 + 7;
const int N = 2e5 + 7;
const int M = 22;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);

void solve1()
{
    ll a,b,n;
    cin >> a >> b >> n;
    ll ans = 0;
    if( b <= n )ans = (a * (b - 1) / b);
    else ans = a * n / b;
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 3648
open System
open System.Collections.Generic

#nowarn "0037"

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev (s: string): string =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    let inline roundup (x: ^a) (y: ^a): ^a =
        let one = LanguagePrimitives.GenericOne
        (x + y - one) / y

type ModInt = MVal of int64

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
[<RequireQualifiedAccess>]
module ModInt =
    let modulo = (int64 1e9) + 7L

    let inline init (x: ^a) : ModInt =
        let x = (int64 x) % modulo
        match x with
        | _ when x < 0L -> MVal (x + modulo)
        | _ when x >= modulo -> MVal (x - modulo)
        | _ -> MVal x

    let value (MVal x) = x

    let value2 (x: ModInt) (y: ModInt) = (value x, value y)

    let toString (MVal v) : string = sprintf "%d" v

    /// 拡張ユークリッドの互除法
    /// a (mod m) における逆元 a^-1
    let inline inverse (MVal a) : ModInt =
        let mutable (a, b, u, v) = (a, modulo, 1L, 0L)
        while b > 0L do
            let t = a / b
            a <- a - (t * b)
            let tmp = a
            a <- b
            b <- tmp
            u <- u - (t * v)
            let tmp = u
            u <- v
            v <- tmp
        init u

type ModInt with
    static member inline (+) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l + r)

    static member inline (-) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l - r)

    static member inline (*) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l * r)

    /// a / b = a * b^-1 (mod m)
    static member inline (/) (lhs: ModInt, rhs: ModInt) : ModInt =
        let r = ModInt.inverse rhs
        lhs * r

    /// a^n (mod m) 繰り返しニ乗法
    /// O(log n)
    static member inline Pow (a: ModInt, n: int64) : ModInt =
        let mutable (res, a, n) = (ModInt.init 1, a, n)
        while n > 0L do
            if (n &&& 1L) = 1L then res <- res * a
            a <- a * a
            n <- n >>> 1
        res

[<EntryPoint>]
let main _ =
    let n = read int

    let mutable ans = ModInt.init 1
    for i in 1..n do ans <- ans * ModInt.init i

    printfn "%s" (ModInt.toString ans)
    0 // return an integer exit code


Measured memory_bytes: 16212
#include<stdio.h>

int a,b,c;

int main() {
	scanf("%d %d %d", &a, &b, &c);
	if(a<=b && b<=c){
		printf("%d %d %d\n",a,b,c);
	} else if(a<=c && c<=b){
		printf("%d %d %d\n",a,c,b);
	} else if(b<=a && a<=c){
		printf("%d %d %d\n",b,a,c);
	} else if(c<=a && a<=b){
		printf("%d %d %d\n",c,a,b);
	} else if(c<=b && b<=a){
		printf("%d %d %d\n",c,b,a);
	} else if(b<=c && c<=a){
		printf("%d %d %d\n",b,c,a);
	} else
	return 0;
}


Measured memory_bytes: 2080
#include<cstdio>
#include<iostream>

using namespace std;

int main(void){

	int n,a,b,as,bs;

	while(1){
		as=0,bs=0;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b) as+=a+b;
			else if(a<b) bs+=a+b;
			else if(a==b) as+=a,bs+=b;
		}
		cout<<as<<" "<<bs<<endl;
	}
}

Measured memory_bytes: 1160
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
using namespace std;
int a[3][3], vis[3][3];
void fnd(int x){
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(a[i][j]==x) vis[i][j]=1;
        }
    }
}
bool check(){
    for(int i=0; i<3; i++) if(vis[i][0]&&vis[i][1]&&vis[i][2]) return 1;
    for(int i=0; i<3; i++) if(vis[0][i]&&vis[1][i]&&vis[2][i]) return 1;
    if(vis[0][0]&&vis[1][1]&&vis[2][2]) return 1;
    if(vis[0][2]&&vis[1][1]&&vis[2][0]) return 1;
    return 0;
}
int main(){
    int n  = 3;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        fnd(x);
    }
    if(check()) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
const int maxn=2e5+100;
ll a[maxn];
ll b[maxn];
ll aa[40][maxn],bb[40][maxn];
ll n;
ll ans[40];
ll p;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    p=0;
    for(int i=0;i<30;i++){
        p=p<<1;
        p+=1;
        for(int j=0;j<n;j++){
            aa[i][j]=a[j]&p;
            bb[i][j]=b[j]&p;
        }
        sort(aa[i],aa[i]+n);
        sort(bb[i],bb[i]+n);
    }
    ll mod=1;
    for(int i=0;i<30;i++){
        for(int j=0;j<n;j++){
            ll now=aa[i][j];
            ll l,r;
            l=mod-now;
            r=mod*2-now;
            ans[i]+=(lower_bound(bb[i],bb[i]+n,r)-bb[i])-(lower_bound(bb[i],bb[i]+n,l)-bb[i]);
            l=mod*3-now;
            r=mod*4-now;
            ans[i]+=(lower_bound(bb[i],bb[i]+n,r)-bb[i])-(lower_bound(bb[i],bb[i]+n,l)-bb[i]);
        }
        mod=mod<<1;
    }
    ll k=0;
    for(int i=30;i>=0;i--){
        k=k<<1;
        if(ans[i]%2==1)k+=1;
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 99840
import java.util.Scanner;

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

        int[] num = new int[4];
        int n = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            switch (sc.nextLine()) {
                case "AC":
                    num[0]++;
                    break;
                case "WA":
                    num[1]++;
                    break;
                case "TLE":
                    num[2]++;
                    break;
                case "RE":
                    num[3]++;
                    break;
            }
        }
        System.out.println("AC x " + num[0]);
        System.out.println("WA x " + num[1]);
        System.out.println("TLE x " + num[2]);
        System.out.println("RE x " + num[3]);
    }
}


Measured memory_bytes: 60124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0&&b>0){
    c =c-b;
    a =a-d;
  }
  if(a<=0&&c<=0)
    cout<<"Yes"<<endl;
  else if(a<=0)
  cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 3644
#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;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    int ans = 0;
    REP(i, 4)
    {
        if(s[i]=='+')
        {
            ans++;
        }
    }

    cout << ans - (4 - ans) << endl;
}

Measured memory_bytes: 256
def test_case():
    while True:
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            break
        side = ''.join(['#' for _ in range(b)])
        for _ in range(a):
            print(side)
        print('')


if __name__ == "__main__":
    test_case()
1 


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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;

const int MAX_N = 1e5 + 10;
struct Edge { int to; ll cost; };
vector<Edge> es[MAX_N];

ll ds[MAX_N];
ll dg[MAX_N];


#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using Tree = tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        es[a].pb({b, c});
        es[b].pb({a, c});
    }
    auto dijkstra = [&] (int root, ll d[]) {
        rep(i, MAX_N) d[i] = INF;
        typedef pair<ll, int> P; //dist, from
        priority_queue<P, vector<P>, greater<P> > q;
        d[root] = 0LL;
        q.push({0LL, root});
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            int prv = p.se;
            auto cost = p.fi;
            if (d[prv] < p.fi) continue;
            for (auto& e : es[prv]) {
                int to = e.to;
                auto dist = e.cost + cost;
                if (dist < d[to]) {
                    d[to] = dist;
                    q.push({dist, to});
                }
            }
        }
    };
    dijkstra(0, ds);
    dijkstra(n-1, dg);
    using P = pair<ll, ll>;
    vector<P> v(n);
    rep(i, n) v[i] = {ds[i], dg[i]};
    sort(all(v));
    int Q;
    cin >> Q;
    vector<pair<P, int>> query(Q);
    rep(i, Q) {
        ll s, g;
        cin >> s >> g;
        query[i] = {{s, g}, i};
    }
    sort(all(query));


    map<ll, ll> mp;
    rep(i, n) mp[v[i].se]++;
    rep(i, Q) mp[query[i].fi.se]++;
    int sz = 0;
    for(auto&& p: mp) p.se = sz++;

    vector<int> ans(Q);
    Tree st;
    int cur = 0;
    rep(i, Q) {
        ll s = query[i].fi.fi, g = query[i].fi.se;
        int idx = query[i].se;
        while(cur < n && v[cur].fi <= s) st.insert(mp[v[cur++].se] * MAX_N + cur);
        int tmp = st.order_of_key(mp[g]*MAX_N);
        ans[idx] = (int)st.size() - tmp;
    }
    rep(i, Q) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 31940
n = int(input())
A = list(map(int, input().split()))
used = [False] * (10 ** 6 + 1)
A.sort()
ans = 0
for j in range(n):
    a = A[j]
    if used[a]:
        continue
    ans += 1
    if j < n - 1:
        aa = A[j + 1]
        if aa == a:
            ans -= 1
    for i in range(1, 10 ** 6 // a + 1):
        used[a * i] = True
print(ans)

Measured memory_bytes: 106064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:1
*Problem:E - 木と整数 / Integers on a Tree
*Date:2018-10-20
*Algorithm:Teacher's PQ
*Stats:AC*/

bool debug=false;
template<typename T> struct pq_small{
	priority_queue<T,vector<T>,greater<T> > pq;
	void push(T x){
		pq.push(x);
	}

	void pop(){
		pq.pop();
	}

	int size(){
		return pq.size();
	}

	bool empty(){
		return pq.empty();
	}

	T top(){
		return pq.top();
	}
};

int n;
int k;
vector<int> nei[100005];
pq_small<pii> q;
int d[100005];

int main(int argc,char* argv[]){
	memset(d,-1,sizeof(d));
	
	qi;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	cin>>k;
	for(int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;
		a--;
		d[a]=b;
		q.push(make_pair(b,a));
	}
	
	while(!q.empty()){
		pii last=q.top();
		q.pop();
		for(int i=0;i<nei[last.second].size();i++){
			if(d[nei[last.second][i]]==-1){
				//cout<<"change"<<nei[last.second][i]<<"at"<<last.second<<endl;
				d[nei[last.second][i]]=d[last.second]+1;
				q.push(make_pair(d[nei[last.second][i]],nei[last.second][i]));
			}
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<nei[i].size();i++){
			if(abs(d[nei[i][j]]-d[i])!=1){
				puts("No");
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	
	for(int i=0;i<n;i++){
		cout<<d[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std ;
int main () {
int g,h;
cin>>g>>h;
if (g==1&&h==3||g==3&&h==1)
    cout <<"2";
else if (g==1&&h==2||g==2&&h==1)
  cout <<"3";
else if (g==2&&h==3||g==3&&h==2)
    cout<<"1";




return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans;
int n,m;

signed main(){
	
	string s;
	cin>>s;
	int g=0,p=0;
	rep(i,s.size()){
		if(s[i]=='g'){
			if(g==p)g++;
			else{
				p++;
				ans++;
			}
		}
		if(s[i]=='p'){
			if(g==p){
				g++;
				ans--;
			}
			else p++;
		}
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 512