akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
int n,i,j,count=1;
char s[100005];
scanf("%d",&n);
scanf("%s",&s);

  for(i=0;i<n-1;i++)
  {
   if(s[i+1]!=s[i])
    count++;
  }
  printf("%d",count);
count = 0;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long gcd(long long a, long long b) {
    if (a == 0) return b;
    return gcd(b % a, a);
}

int main(){
    int X;
    cin >> X;
    cout << 360/gcd(360, X) << endl;
    return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

# input

N = int(input())
S = input()
K = int(input())


m = [i for i in S]
mm = S[K-1]

moji = ""
for n in S:
    if n==mm:
        moji += n
    else:
        moji+="*"


print(moji)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> as(m);
  vector<int> cs(m, 0);
  
  for (int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    as[i] = a;
    for (int j = 0; j < b; j++) {
      int c;
      cin >> c;
      cs[i] |= (1<<(c-1));
    }
  }
  
  const int INF = pow(10,9);
  //計算量的にdpで解けるはず
  vector<vector<int>> dp(2, vector<int>(pow(2,n), INF));
  dp[0][0]=0;
  
  for (int i = 0; i < m; i++) {
    const auto& current = dp[i%2];
    auto& next = dp[(i+1)%2];
    const auto& a = as[i];
    const auto& c = cs[i];
    // cout << "a: " << a << " c: " << c << endl;
    
    for (int j = 0; j < current.size(); j++) {
      next[j] = min(next[j], current[j]);//今回のカギを買わない場合
      next[j|c] = min(next[j|c], current[j] + a);//今回のカギを買う場合
    }
    
    //TODO
    /*
    for (int j = 0; j < next.size(); j++) {
      cout << next[j] << " ";
    }
    cout << endl;
    */
  }
  
  int result = dp[m%2][pow(2,n)-1];
  if (result == INF) { result = -1; }
  cout << result << endl;
 }


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

void solve(long long N, std::vector<long long> A) {
  vector<ll> B = A;
  sort(B.rbegin(), B.rend());
  for(int i = 0 ; i < N ; i++){
    if( A[i] == B[0]) cout << B[1] << endl;
    else cout << B[0] << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


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

int main()
{
    int i,temp;
    int d[4] = {0};
    for(i = 0;i < 6;++i){
        cin >> temp;
        d[temp-1]++;
    }
    for(i = 0;i < 4;++i){
        if(d[i] > 2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long

int n,m;
int b[10005];
ll sum=0;

int main()
{
	read(n),read(m);
	for(int i=1;i<=m;i++) read(b[i]),sum+=b[i];
	if(sum>n) printf("%d\n",-1);
	else printf("%d\n",n-sum);
	return 0;
} 

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, ans;
  cin >> n;
  vector<int> x(n), xcp(n);
  int i;
  rep(i, n) {
    cin >> x[i];
    xcp[i] = x[i];
  }
  sort(xcp.begin(), xcp.end());
  int xmae = xcp[n / 2 - 1];
  int xato = xcp[n / 2];

  rep(i, n) {
    if (x[i] > xmae)
      ans = xmae;
    else
      ans = xato;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < K; i++) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
using namespace std;

int main(){
    int x;
    cin >> x;
    if(x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    char x, y;
    cin >> x >> y;
    if(x == y){
        cout << '=' << endl;
    }else{
        cout << (x > y ? '>' : '<') << endl;
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n; scanf("%d", &n);
	int h[10] = {};
	for (int t, i = 0; i < n; ++i, ++h[min(t/400, 8)]) scanf("%d", &t);
	for (int i = 0; i < 8; ++i) h[9] += !!h[i];
	printf("%d %d", max(h[9], (int)!!h[8]), h[9]+h[8]);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  int h,w,a,b;cin>>h>>w>>a>>b;
  if(a*2>w||b*2>h){
    cout<<"No"<<endl;
    return 0;
  }
  vvi v(h,vi(w));
  rep(i,h-b){
    rep(j,a){
      v[i][j]=1;
    }
  }
  for(int i=h-b;i<h;i++){
    for(int j=a;j<w;j++){
      v[i][j]=1;
    }
  }
  rep(i,h){
    rep(j,w){
      cout<<v[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 5120
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var A = long.Parse(inputs[0]);
        var B = long.Parse(inputs[1]);
        var Q = long.Parse(inputs[2]);
        var s = new long[A];
        var t = new long[B];
        var x = new long[Q];
        for (int i = 0; i < s.Length; i++)
        {
            s[i] = long.Parse(Console.ReadLine());
        }

        for (int i = 0; i < t.Length; i++)
        {
            t[i] = long.Parse(Console.ReadLine());
        }

        for (int i = 0; i < x.Length; i++)
        {
            x[i] = long.Parse(Console.ReadLine());
        }

        for (int i = 0; i < x.Length; i++)
        {
            var d = Calc(s, t, x[i]);
            Console.WriteLine(d);
        }

    }

    static long Calc(long[] s, long[] t, long x)
    {
        long[] a, b;
        var min = long.MaxValue;

        // x_iにs,tでスタートした場合（２通り)
        for (int i = 0; i < 2; i++)
        {
            if (i == 0)
            {
                // sからスタート
                a = s;
                b = t;
            }
            else
            {
                // tからスタート
                a = t;
                b = s;
            }

            // a[aPos] <= x or x > a[aPos+1]
            for (int j = 0; j < 2; j++)
            {
                int aPos = Math.Min(BinarySearch(a, x) + j, a.Length - 1);
                long ax = a[aPos];
                // b[bPos] <= x or x > b[bPos+1]
                for (int k = 0; k < 2; k++)
                {
                    long bPos = Math.Min(BinarySearch(b, x) + k, b.Length - 1);
                    long bx = b[bPos];
                    long d = Math.Abs(x - ax) + Math.Abs(bx - ax);
                    min = Math.Min(d, min);
                }
            }
        }
        return min;
    }

    /**
     * 二分探索
     */
    static int BinarySearch(long[] targets, long x)
    {
        // targets[i] <= x を満たすインデックス
        int ok = 0;
        // targets[i] > x を満たすインデックス
        int ng = targets.Length - 1;

        // 
        while (Math.Abs(ok - ng) > 1)
        {
            // 中心を求める
            int mid = (ok + ng) / 2;
            if (targets[mid] <= x)
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        return ok;
    }

}



Measured memory_bytes: 18384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 2000+1;
const int MAXX = MAX * MAX / 64 + 10;

bitset<2000*2000+1> B;

int main()
{
    int n;
    B[0] = 1;
    int s = 0;
    scanf("%d", &n);
    FOR(i, 0, n)
    {
        int x;
        scanf("%d", &x);
        s += x;
        B |= B << x;
    }
    FOR(i, (s + 1) / 2, s+1)
        if (B[i])
        {
            cout << i << endl;
            return 0;
        }
}


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

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	
	long[long] cnt;
	foreach (i; 0..N)
	{
		++cnt[RD!long];
	}

	long ans;
	foreach (key; cnt.keys)
	{
		if (cnt[key] % 2 == 1) ++ans;
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 10364
#include <stdio.h>
 
int main()
{
  while (1)
  {
    int n,x;
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) break;
    int i, j, k, total, ways = 0;
    for (i = 1; i <= n - 2; i++)
    {
      for (j = i + 1; j <= n -1; j++)
      {
        for (k = j + 1; k <= n; k++)
        {
          total = i + j + k;
          if (total == x) ways += 1;
        }
      }
    }
    printf("%d\n", ways);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define MIN(a, b) ((a<b) ? a : b)

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a, x[n+1], p=-1;
  for (int i=0; i<n; i++) {
    scanf("%d", &a);
    if (a>=0) {
      x[i+1] = a;
      if (p==-1) {
        x[i] = 0;
        p=i;
      }
    } else {
      x[i] = a;
    }
  }
  if (p==-1) {
    x[n] = 0;
    p=n;
  }
  long right[n+1], ans = LONG_MAX;
  for (int i=0; i<n+1; i++) {
    if (p+i<=n && p-k+i>=0) {
      right[i] = MIN(abs(x[p+i]) + abs(x[p+i]-x[p-k+i]), abs(x[p-k+i]) + abs(x[p-k+i]-x[p+i]));
    } else right[i] = LONG_MAX;
  }
  for (int i=0; i<n+1; i++) ans = MIN(ans, right[i]);
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;

int main(){
 int n; cin >>n;
 int v[100];
 int c[100];

 for(int i=0;i<n;i++)
 cin >>v[i];

 for(int i=0;i<n;i++)
 cin >>c[i];

 int ans[100];
 int sum=0;
 for(int i=0;i<n;i++){
 ans[i]=v[i]-c[i];
 if(ans[i]>0)
 sum+=ans[i];

}
cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();

		int border = A + B;
		int countOK = 0;
		int countForeignr = 0;

		for(int i = 1; i <= N; i++) {
			char tmp = S.charAt(i - 1);
			if(tmp == 'a') {
				if(countOK < border) {
					System.out.println("Yes");
					countOK++;
				}else {
					System.out.println("No");
				}
			}else if(tmp == 'b') {
				countForeignr++;
				if(countOK < border && countForeignr <= B) {
					System.out.println("Yes");
					countOK++;
				}else {
					System.out.println("No");
				}
			}else {
				System.out.println("No");
			}
		}
	}

}


Measured memory_bytes: 34968
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
a, b, c = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

if b+c > a:
    print(b+c-a)
else:
    print(0)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int a,b;
  cin >> a >> b;
  if(b % a == 0){
    cout << a+b;
  }else{
    cout << b-a;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int s[28] = {0};
int t[28] = {0};

int main(int argc, char* argv[]){
	int N, K;
	cin >> N >> K;

	long long ans = 0;
	//まずKの倍数をカウント
	long long kn = N / K;
	ans = kn * kn * kn;

	//Kが偶数の時は以下の組がある
	//a % K = K/2, b % K = K/2, c % K = K/2
	if(K % 2 == 0){
		long long count = 0;
		while(true){
			if(K*count + K/2 > N){
				break;
			}
			count++;
		}
		ans += (count * count * count);
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int 
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592653589793238463;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&


void solve(){
    int n; cin >> n;
    set<string> s;
    for(int i = 0; i < n; ++i){
        string x; cin >> x;
        s.insert(x);
    }   
    cout << sz(s) << '\n'; 
   
}
 
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    //cin >> T;
    for(int i = 1; i <= T; ++i){
        solve();
    }
    return 0;
}
/*
Sample inp
*/

Measured memory_bytes: 19136
a = input().split()

b = [int(s) for s in a]
c = b[0]*b[1]/2

if(b[0] == 1 or b[1] == 1):
  print(1)
elif(int(b[0]*b[1])%2 != 0):
  print(int(c+1))
else:
  print(int(c))

Measured memory_bytes: 38256
/**
*    created: 16.05.2020 08:12:12
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    int x = 0,y=0;
    //a<b[i],b[i]<c
    vector<ll> aa(n), cc(n); //aa,cc[i]:b[i]が選べるa,cの種類
    rep(i,n){
        auto itra = lower_bound(a.begin(), a.end(), b[i]);
        aa[i] = distance(a.begin(), itra);
        auto itrc = upper_bound(c.begin(), c.end(), b[i]);
        cc[i] = distance(itrc, c.end());
    }
    ll ans = 0;
    rep(i,n){
        ans += aa[i] * cc[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

long long N, V, M, P, A[100005];
long long lo, mid, hi, best;

bool works(long long x) {
  long long bigger = 0;
  long long left = M * (V-1);
  for (long long i = 0; i < N; i++) {
    if (i == x-1) continue;
    if (A[i] > A[x-1] + M) {
      //printf("%lld\n", i);
      left -= M;
      bigger++;
    } else if (bigger < P-1) {
      left -= M;
      bigger++;
    } else {
      left -= min(M, A[x-1] + M - A[i]);
    }
    //printf("%lld %lld %lld %lld\n", x, i, left, bigger);
  }

  return (left <= 0 && bigger <= P-1);
}

int main() {
  scanf("%lld %lld %lld %lld", &N, &M, &V, &P);
  for (long long i = 0; i < N; i++) scanf("%lld", &A[i]);

  sort(A, A + N, greater<int>());

  lo = 0, hi = N;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    if (works(mid)) {
      best = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }

  printf("%lld\n", best);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N, M;
  while (N = in(), M = in(), N || M) {
    vector<int> infected(N + 1, 0);
    using Packet = std::pair<int, std::pair<int, int>>;
    vector<Packet> packet;
    rep(i, M) {
      int t = in(), s = in(), d = in();
      packet.push_back({t, {s, d}});
    }
    infected[1] = true;
    sort(ALL(packet));
    for (auto p : packet) {
      int s = p.se.fi;
      int d = p.se.se;
      infected[d] = infected[d] || infected[s];
    }
    pr(count(ALL(infected), 1));
  }
  return 0;
}

Measured memory_bytes: 3532
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::HashMap;

use itertools::Itertools;

use maplit::*;

use proconio::{input, fastout};
use proconio::marker::*;

const INF: usize = 1_000_000_007;

#[fastout]
fn solve() {
  input!{
    x: i64,
  };

  let mut a = INF as i64;
  let mut b = INF as i64;
  for i in -118..=119 {
    for j in -119..=118 {
      if i * i * i * i * i - j * j * j * j * j == x {
        a = i as i64;
        b = j as i64;
        break;
      }
    }
    if a != INF as i64 {
      break;
    }
  }
  println!("{} {}", a, b);
}

fn main() {
  std::thread::Builder::new()
    .name("big stack size".into())
    .stack_size(32 * 1024 * 1024)
    .spawn(|| {
      solve();
    })
    .unwrap()
    .join()
    .unwrap();
}

Measured memory_bytes: 2248
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x,y,z;
  cin>>x>>y>>z;
  int temp;
  temp=x;
  x=z;
  z=temp;
  temp=z;
  z=y;
  y=temp;
  cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}








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

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

    int sum[200200] = {0};
    //累積和 0~n
    for (int i = 0; i < n; i++) {
        if (s[i] == '.') sum[i + 1]++;
        sum[i + 1] += sum[i];
    }

    /*
    for (int i = 0; i < n + 1; i++) {
        cout << sum[i] << " ";
    }
    cout << endl;
    */

    int cnt, ans = 200200;
    for (int i = 0; i < n; i++) {
        cnt = 0;
        //(#→.)+(.→#)
        cnt += (i - sum[i]) + (sum[n] - sum[i + 1]);
        ans = min(ans, cnt);
    }

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

Measured memory_bytes: 1412
#include <iostream>
#include <cstring>
using namespace std;
char s[200005];
int main()
{
 cin>>s;
 long long len=strlen(s),a=0,b=0,ans=0;
 for(int i=0;i<len;i++)
 {
  if(s[i]=='A'&&(!b))a++;
  else if(s[i]=='B'&&a&&(!b))b++;
  else if(s[i]=='C'&&a&&b)ans+=a,b=0;
  else
  {
   a=b=0;
   if(s[i]=='A')a++;
  }
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

class UFTree {
  std::vector<int> data, rank, _size;

public:
  UFTree(const int &n) : data(n), rank(n), _size(n, 1) { iota(all(data), 0); }

  int root(const int &x) { return data[x] == x ? x : data[x] = root(data[x]); }

  bool same(const int &a, const int &b) { return root(a) == root(b); }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rank[a] < rank[b]) std::swap(a, b);
    data[b] = a;
    _size[a] += _size[b];
    if (rank[a] == rank[b]) rank[a]++;
  }

  int sizeOf(int x) { return _size[root(x)]; }
};

main {
  int n, m;
  cin >> n >> m;
  UFTree uf(n);
  while (m--) {
    int s, t;
    cin >> s >> t;
    uf.unite(s, t);
  }
  int q;
  cin >> q;
  while (q--) {
    int s, t;
    cin >> s >> t;
    cout << (uf.same(s, t) ? "yes" : "no") << endl;
  }
}

Measured memory_bytes: 5204
n,m = map(int, input().split())
a = list(map(int, input().split()))
v = 0
for i in range(0,len(a)):
    v += a[i]
k = v / (4*m)
u = 0
for i in range(0,len(a)):
    if a[i] >= k:
        u += 1

if u >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int func(int n)
{
	if(n%10 == 0)
	{
		return (n/10)*10;
	}

	return  (n/10)*10 + 10;
}

int main()
{
	int Dish[5];
	int last = 0;
	int ans = 0;

	int latest = 10;
	for(int i=0;i<5;i++)
	{
		cin >> Dish[i];
		int tmp = Dish[i]%10;

		if(tmp == 0)continue;

		if(latest > tmp)
		{
			latest = tmp;
			last = i;
		}
	}

	for(int i=0;i<5;i++)
	{
		if(i != last)
		{
			ans += func(Dish[i]);
		}
		else
		{
			ans += Dish[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

vector<int>v1,v2,v3;

int main()
{
    int x,y;
    v1.push_back(1);
    v1.push_back(3);
    v1.push_back(5);
    v1.push_back(7);
    v1.push_back(8);
    v1.push_back(10);
    v1.push_back(12);
    v2.push_back(4);
    v2.push_back(6);
    v2.push_back(9);
    v2.push_back(11);
    while(scanf("%d %d", &x,&y)==2)
    {
        if( x==2 || y==2 ) printf("No\n");
        else if( binary_search(v1.begin(), v1.end(), x) && binary_search(v1.begin(), v1.end(), y))
        {
            printf("Yes\n");
        }
        else if( binary_search(v2.begin(), v2.end(), x) && binary_search(v2.begin(), v2.end(), y) )
        {
            printf("Yes\n");
        }
        else printf("No\n");
    }


    return 0;
}



Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    cin >> N;
    set<ll> st;
    while(N--) {
        ll a;
        cin >> a;
        st.insert(a);
    }

    cout << st.size() << endl;
    return 0;
}



Measured memory_bytes: 7788
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	ll ans = 10000000000LL;
	for (int i = 0; i <= 200000; i++) {
		ll sum = 0;
		sum += (ll)i * c;
		sum += (ll)a * max(0, x - i / 2);
		sum += (ll)b * max(0, y - i / 2);
		chmin(ans, sum);
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BOOST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
typedef long long ll;

#define n_max 100000

int sze;
int p[100000][3];
int dp[100000][3];
int dp_pts[100000];

int points(int n,int nxt=3)
{
    if(nxt==3)
    {
        dp[n][0] = points(n-1,0)+p[n][0];
        dp[n][1] = points(n-1,1)+p[n][1];
        dp[n][2] = points(n-1,2)+p[n][2];

        return dp_pts[n] = max({dp[n][0],dp[n][1],dp[n][2]});
    }
    if(n==-1)
        return 0;
    if(nxt == 0)
    {
        if(dp[n][1]==-1)
            dp[n][1] = points(n-1,1)+p[n][1];
        if(dp[n][2]==-1)
            dp[n][2] = points(n-1,2)+p[n][2];

        return dp_pts[n] = max(dp[n][1],dp[n][2]);
    }
    else if(nxt == 1)
    {
        if(dp[n][0]==-1)
            dp[n][0] = points(n-1,0)+p[n][0];
        if(dp[n][2]==-1)
            dp[n][2] = points(n-1,2)+p[n][2];

        return dp_pts[n] = max(dp[n][0],dp[n][2]);
    }
    else
    {
        if(dp[n][0]==-1)
            dp[n][0] = points(n-1,0)+p[n][0];
        if(dp[n][1]==-1)
            dp[n][1] = points(n-1,1)+p[n][1];

        return dp_pts[n] = max(dp[n][0],dp[n][1]);
    }
}
int main()
{
    BOOST
    cin>>sze;
    for(int i=0;i<sze;i++)
    {
        dp[i][0]=-1;
        dp[i][1]=-1;
        dp[i][2]=-1;
    }
    for(int i=0;i<sze;i++)
        cin>>p[i][0]>>p[i][1]>>p[i][2];
    cout<<points(sze-1)<<'\n'; 
    return 0;
}

Measured memory_bytes: 11056
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next(),b = sc.next();
    //文字列の長さで判断（桁数で判断）
    if(a.length() > b.length()){
      System.out.println("GREATER");
    }else if(a.length() < b.length()){
      System.out.println("LESS");
    }else{//上位桁から判断
      int aa=0 ,bb=0;
      for(int i = 0;i < a.length();i++){
        aa = Integer.valueOf(a.substring(i,i+1));
        bb = Integer.valueOf(b.substring(i,i+1));
        if(!(aa == bb)){
          break;
        }
      }
      if(aa > bb){
        System.out.println("GREATER");
      }else if(aa == bb){
        System.out.println("EQUAL");
      }else{
        System.out.println("LESS");
      }
    }
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
typedef pair<int,int> pii;
typedef long long ll;

int l,r,d,sum;

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

	
	cin >> l >> r >> d;
	for (int i=l;i<=r;i++){
		if (i % d == 0) sum++;
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-*-

from sys import stdin
import itertools


def main():
    N, M = list( map(int, stdin.readline().split()) )

    O = ['遇' for i in range(N)]
    O.extend(['奇' for i in range(M)])

    A = list(itertools.combinations(O, 2))

    cnt = 0
    for i in A:
        if i.count("遇") in [0, 2]:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4468
n,m=map(int,input().split())
road=[[] for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    road[a].append(b)
    road[b].append(a)
dp=[[0]*(n+1) for _ in range(2**n)]
dp[1][1]=1
for i in range(1,2**n):
    for j in range(1,n+1):
        for k in road[j]:
            if not (i>>(k-1))&1:
                dp[i+2**(k-1)][k]+=dp[i][j]
print(sum(dp[2**n-1]))



Measured memory_bytes: 67992
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int a, b, c;
	cin >> a >> b >> c;
	set <int> s;
	s.in (a);
	s.in (b);
	s.in (c);
	if (sz (s) == 2) {
		cout << "Yes";
	}
	else cout << "No";
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

int main(){
    int n; cin >> n;
    int a[3*n];
    for(int i = 0; i<3*n; ++i){
        cin >> a[i];
    }
    sort(a,a+3*n); reverse(a,a+3*n);
    
    long long result = 0L;
    for(int i=0; i<2*n; ++i){
        if(i%2 == 1){ result += a[i];}
    }
    cout << result << endl; return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    string s;
    cin >> s;

    // 処理
    // 出力
    if (s[0] == '9' || s[1] == '9') {
        cout << "Yes " << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
vector <int> readVec(int n){int x;vector <int> v;
    for (int i=0;i<n;i++){scanf("%d",&x);v.push_back(x);}}
void printVec(vector <int> v){for (auto i:v){printf("%d ",v[i]);}printf("\n");}

int main(){
    string s;cin>>s;
    int c=0;
    for (int i=0;i<s.size();i++){
        c+=s[i]-48;
    }
    if (c%9) cout<<"No";
    else cout<<"Yes";
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  *  *  */

signed main() {
  int h, w;
  cin >> h >> w;

  if(h == 1 or w == 1) cout << 1 << endl;
  else cout << (h*w+1)/2 << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		string S[50];
		UL T[50];
		rep(i, N) cin >> S[i] >> T[i];
		string X; cin >> X;
		UL ans = 0;
		rep(ii, N) {
			UL i = N - ii - 1;
			if (S[i] == X) break;
			ans += T[i];
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8


def main():
    n = int(input())
    lb = list(map(int, input().split()))
    ret = []
    for i in range(n):
        for j in range(n-i, 0, -1):
            if lb[j-1] == j:
                ret.append(lb.pop(j-1))
                break
        else:
            print("-1")
            return
    print("\n".join(map(str, ret[::-1])))



if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
def main():
    N = input_int()
    A = input_int_list_in_line()
    A = [-1, -1] + A

    num_buka = [0] * (N+1)

    for i in range(2, len(A)):
        num_buka[A[i]] += 1

    for i in range(1, len(A)):
        print(num_buka[i])


def input_int():
    return int(input())


def input_ints():
    return map(int, input().split())


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


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


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

long long b,w,mod=1e9+7ll,sum2,prob2[500005][2],prob[500005],num[500005][2],sumprob,sumnum[2],ans[500005],denom,tot,fact[1000005],invfact[1000005];


long long fastp(long long base,int exp){
    
    if(exp==0)return 1;
    
    long long tmp=fastp(base,exp/2);
    
    tmp=(tmp*tmp)%mod;
    
    if(exp%2)tmp*=base;
    
    return tmp%mod;
}
 
 
inline long long binom(long long a,long long b){
    
    if(b<0)return 0;
    if(b>a)return 0;
    
    return ((fact[a]*invfact[b])%mod*invfact[a-b])%mod;
    
}
 
 
inline long long invbinom(long long a,long long b){
    
    if(b<0)return 0;
    if(b>a)return 0;
    
    return ((invfact[a]*fact[b])%mod*fact[a-b])%mod;
    
}





int main(){
    
    fact[0]=1;
    
    for(long long i=1;i<1000005;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    
    invfact[1000004]=fastp(fact[1000004],mod-2);
    
    for(long long i=1000003;i>=0;i--){
       invfact[i]=invfact[i+1]*(i+1ll); 
       invfact[i]%=mod;
    }

	cin>>b>>w;
	
	for(int i=0;i<b+w;i++){
	    
	    prob[i]=(binom(i,w-1)*fastp(fastp(2ll,mod-2ll),i+1))%mod;
	    num[i][0]=binom(i,w-1);
	    num[i][0]%=mod;
	    
	    prob2[i][0]=(binom(i-1,w-1)*fastp(fastp(2ll,mod-2ll),i+1))%mod;
	    prob2[i][1]=(binom(i-1,b-2)*fastp(fastp(2ll,mod-2ll),i+1))%mod;
	    
	    if(i!=(b+w-1))sum2+=prob2[i][0]+prob2[i][1];
	    
	    sum2%=mod;
	    
	    num[i][1]=binom(i,b-1);
	    num[i][1]%=mod;
	    prob[i]%=mod;
    }
    
    
    for(int i=0;i<b+w;i++){
        //cout<<i<<endl;
        sum2-=prob2[i][0]+prob2[i][1];
        sum2=(sum2%mod+mod)%mod;
        
        ans[i]=(sumprob+(sum2+num[i][1]*fastp(fastp(2ll,mod-2ll),i+1))%mod)%mod;
        ans[i]=(ans[i]%mod+mod)%mod;
        
        
        sumprob+=prob[i];
        sumprob%=mod;
    }
    
    for(int i=0;i<w+b;i++)cout<<ans[i]<<"\n";   

return 0;
}


Measured memory_bytes: 34944
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<double, double> p;
typedef vector <int> VI;
typedef vector <string> VS;

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

  vector <ll> ans(100001, 0);

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

  for(int i = 1; i < 100001; i++){
    k -= ans[i];
    if(k <= 0){
      cout << i << endl; 
      break;
    }
  }

	return 0;	
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int w,n;
	int i,j,k;
	
	scanf("%d",&w);
	int num[w];
	scanf("%d",&n);
	
	for(k=0;k<w;k++){
		num[k]=k+1;
	}
	for(k=0;k<n;k++){
		scanf("%d,%d",&i,&j);
		i--;
		j--;
		int t=num[i];
		num[i]=num[j];
		num[j]=t;
	}
	for(k=0;k<w;k++){
		printf("%d\n",num[k]);
	}
	
	
	return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def f(n):
    if n <= 1:
        return 1
    else:
        return n * f(n-2)
    
# for i in range(100):
# for i in [90, 100, 140, 150, 160, 200, 1240, 1250, 1250, 1260]:
#     print(i, f(i))

N = INT()

A = []
i = 0
while 5 ** i <= 10 ** 18:
    A.append(5**i * 10)
    i += 1

if N % 2 == 0:
    ans = 0
    for a in A:
        ans += N // a
    print(ans)
else:
    print(0)


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

const double PI = 3.14159;

int main() {
  int r;
  cin >> r;
  double l;
  l = 2 * PI * r;
  cout << l << endl;
  return 0;
}

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

struct union_find{
    vector<ll> par;
    vector<ll> rank;
    vector<ll> siz;
    
    union_find(ll N) : par(N), rank(N), siz(N){
        rep(i,N){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    
    ll root(ll x){
        if (par[x] == x){
            return x;
        }
        return par[x] = root(par[x]);
    }
    
    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]){
            par[rx] = ry;
            siz[ry] += siz[rx];
        }
        else{
            par[ry] = rx;
            siz[rx] += siz[ry];
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }
    
    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
    
    ll size(ll x){
        return siz[root(x)];
    }
};

int main(){
    ll N,M;
    cin >> N >> M;
    vector<pair<ll,ll> > vec(M);
    rep(i,M){
        cin >> vec[i].first >> vec[i].second;
        vec[i].first--;
        vec[i].second--;
    }
    union_find tree(N);
    vector<ll> ans(M);
    ll unconvenience = N * (N - 1) / 2;
    ans[M - 1] = unconvenience;
    for (ll i = M - 1; i >= 1; i--){
        if (tree.same(vec[i].first, vec[i].second)){
            ans[i - 1] = unconvenience;
        }
        else{
            unconvenience -= tree.size(vec[i].first) * tree.size(vec[i].second);
            ans[i - 1] = unconvenience;
            tree.unite(vec[i].first, vec[i].second);
        }
    }
    rep(i,M){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 7936
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
    
    const int LIMIT = 1000000256;
    const int tenfive = 100000;
}

using namespace atcoder;

int main(void){
    int a,b,ab;
    int na,nb;
    cin >> a>> b >> ab >> na >> nb;
    ab*=2;
    int bab=ab;
    int ba = a;
    int bb = b;
    if(ab>a+b){
        bab=a+b;
    }
    if(a>ab){
        ba=ab;
    }
    if(b>ab){
        bb = ab;
    }
    int yen = 0;
    while(na>=0&&nb>=0){
        if(na>0&&nb>0){
            yen+=bab;
            na--;
            nb--;
        }else if(na>0){
            yen+=ba;
            na--;
        }else if(nb>0){
            yen+=bb;
            nb--;
        }else{
             break;
        }
    }
    cout << yen << endl;
    return 0;
}


Measured memory_bytes: 256