akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

#define NIL -1

int main() {
    int N; cin >> N;
    vector<vector<pair<int, int>>> G(N);
    int u, v, w;
    rep(i, N-1) {
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }
    vector<int> ans(N, NIL);
    queue<int> q;
    q.push(0);
    ans[0] = 0;
    int tmp;
    while (!q.empty()) {
        tmp = q.front(); q.pop();
        rep(i, G[tmp].size()) {
            if (ans[G[tmp][i].first] == NIL) {
                ans[G[tmp][i].first] = abs(G[tmp][i].second%2 - ans[tmp]);
                q.push(G[tmp][i].first);
            }
        }
    }
    rep(i, N) cout << ans[i] << endl;
}


Measured memory_bytes: 9500
#include <stdio.h>

int main(){
  int n, i, j, k, key;
  scanf("%d\n",&n);
  int a[n];
  for (i = 0; i < n; i++){
    scanf("%d",&a[i]);
  }
  for (i = 1; i <= n; i++){
    for (k = 0; k < n-1; k++){
      printf("%d ", a[k]);
    }
    printf("%d\n",a[k]);
    key = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > key){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = key;
  }
}



Measured memory_bytes: 2104
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int K;

// 幅優先探索
ll bfs() {
    int count = 0;
	queue<ll> que; //待ち配列
	reps(i,9) que.push(i);
	while (!que.empty()) {
		ll v = que.front(); // キューから先頭頂点を取り出す
		que.pop();
        count++;
        if (count==K) return v;
    	if (v%10 != 0) que.push(10*v+v%10-1);
        que.push(10*v+v%10);
        if (v%10 != 9) que.push(10*v+v%10+1);
	}
}

int main(void) {
  cin >> K;
  cout << bfs() << "\n";
  return 0;
}


Measured memory_bytes: 1792
mod = 10**9+7

n = int(input())

dp = [0]*(n+1)
if n < 3:
    print(0)
    exit()
dp[3] = 1

for i in range(4,n+1):
    for j in range(0,i-3+1):
        dp[i] = (dp[i]+dp[j])%mod
    dp[i] = (dp[i]+1)%mod

print(dp[n]%mod)

Measured memory_bytes: 64784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<ll> l(90,0);
    l[0]=2;l[1]=1;
    rep(i,n){
        if(i==0)continue;
        l[i+1]=l[i]+l[i-1];
    }
    cout<<l[n]<<endl;
}

Measured memory_bytes: 3588
def run():
    n, q = [int(x) for x in input().split()]
    ls = [[] for _ in range(n)]

    for _ in range(q):
        command = input()
        if command.startswith('0'):
            i, j = [int(x) for x in command[2:].split()]
            ls[i].append(j)
        elif command.startswith('1'):
            i = int(command[2:])
            print(" ".join([str(x) for x in ls[i]]))
        elif command.startswith('2'):
            i = int(command[2:])
            ls[i] = []
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()



Measured memory_bytes: 60452
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


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

	vector<vector<int>> dp(m+1, vector<int>(1<<n,INF));

	dp[0][0] = 0;

	for (int i = 1; i < m+1; i++) {
		int a, b; cin >> a >> b;

		int num = 0;
		for (int j = 0; j < b; j++) {
			
			int x; cin >> x;
			x--;
			num += (1 << x);
		}

		for (int bit = 0; bit < (1 << n); bit++) {
			int subset = bit | num;
			
			//鍵を使う
			dp[i][subset] = min(dp[i][subset], dp[i - 1][bit]+a);

			//鍵を使わない
			dp[i][bit] = min(dp[i][bit], dp[i - 1][bit]);
		}

	}

	int ans = dp[m][(1 << n) - 1];

	if (ans == INF) {
		cout << "-1" << endl;
		return 0;
	}

	cout <<ans<< endl;

	return 0;
}

Measured memory_bytes: 16256
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int m ,int n){
	while(n!=0){
		int r=m%n;
		m=n;
		n=r;
	}
	return m;
}

int main(){
         int a ,b ,g ,l;
		 while(cin >> a >> b){
			g = gcd(a,b);
			l = a/g*b;
			cout << g <<" " << l << endl;
		 }
		 return 0;
}

Measured memory_bytes: 1160
using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()


void solve() {
	ld d, T, s; cin >> d >> T >> s;
	ld t1 = d / s;
	if (t1 <= T)cout << "Yes";
	else cout << "No";
}






int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif

	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}






Measured memory_bytes: 3736
using System;
using System.Text;

namespace ALDS1_6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = getint();
            var input= getsplit();
            int[] A = new int[n + 1];
            int k = 0;
            for (int i = 1; i < n+1; i++)
            {
                A[i] = int.Parse(input[i - 1]);
                if (A[i] > k)
                {
                    k = A[i];
                }
            }

            int[] B = new int[n+1];

            countingsort(A, B, k);

            var sb = new StringBuilder();
            for (int i = 1; i < n+1; i++)
            {
                sb.Append(B[i] + " ");
            }
            Console.WriteLine(sb.ToString().Trim());



        }
        static void countingsort(int[] A,int[] B,int k)
        {
            var C = new int[k+1];
            for (int i = 0; i < k+1; i++)
            {
                C[i] = 0;
            }
            for (int j = 1; j < A.Length ; j++)
            {
                C[A[j]]++;
            }
            for (int i = 1; i <= k; i++)
            {
                C[i] += C[i - 1];
            }
            for (int j = A.Length-1; j >= 1; j--)
            {
                B[C[A[j]]] = A[j];
                C[A[j]]--;
            }
        }
        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n;
	cin>>n;
	int dp[50];
	dp[0]=1,dp[1]=1;
	for(int i=2;i<=n;i++){
		dp[i]=dp[i-1]+dp[i-2];	
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 3116
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

x = ni()
if x % 11 == 0:
    print(x // 11 * 2)
else:
    if x % 11 <= 6:
        print(x // 11 * 2 + 1)
    else:
        print(x // 11 * 2 + 2)


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

ll calc(int N, ll X){
    ll ret = 0;
    if(X == 0) ret = 0;
    else if(X == 1){ 
        if(N == 0) ret = 1;
        else ret = 0;
    }
    else if(1 < X && X <= nLayer[N-1] + 1){
        ret = calc(N-1,X-1);
    }else if(X == nLayer[N-1] + 2){
        ret = nPatty[N-1] + 1;
    }else if(nLayer[N-1] + 2 < X && X <= 2*nLayer[N-1] + 2){
        ret = nPatty[N-1] + 1 + calc(N - 1, X - nLayer[N-1] - 2);
    }else{
        ret = 2*nPatty[N-1] + 1;
    }
    return ret;
}

int main(){
    int N;  ll X;
    cin >> N >> X;

    nLayer = vector<ll>(N+1, 0);
    nPatty = vector<ll>(N+1, 0);
    nLayer[0] = 1;  nPatty[0] = 1;
    for(int i=0; i<N; i++){
        nLayer[i+1] = 2*nLayer[i] + 3;
        nPatty[i+1] = 2*nPatty[i] + 1;
    }
    cout << calc(N, X) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int a,b,n;
	char s[100];

	while(fgets(s,sizeof(s),stdin) != NULL){
		sscanf(s,"%d %d",&a,&b);
		n = GCD(a,b);
		printf("%d %d\n",n,a*(b/n));
	}
	return(0);
}

int GCD(int a , int b){

	while(1){
		if(a > b){
			a = a - b;
		}else if(b > a){
			b = b - a;
		}else{
			return a;
		}
	}

}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
//const ll INFL = 1LL << 60;//10^18 = 2^60
const ll INFL = 1LL << 60;
const int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

int main(void){
  ll N, M;
  cin >> N >> M;
  vector<ll> x(M), y(M);
  rep(i, M){
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }
  vector<ll> num(N, 1);
  vector<ll> pos(N, 0);
  pos[0] = 1;
  rep(i, M){
    num[y[i]]++;
    num[x[i]]--;
    if(pos[x[i]]) pos[y[i]] = 1;
    if(num[x[i]] == 0) pos[x[i]] = 0;
  }
  ll ans = 0;
  rep(i, N)if(pos[i]) ans++;
  cout << ans << endl;
}


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

int n;
double dp[310][310][310];

double rec(int i, int j, int k){
  if(dp[i][j][k]>=0)return dp[i][j][k];
  if(i==0 && j==0 && k==0)return 0.0;

  double res=0.0;
  if(i>0)res+=rec(i-1, j, k)*i;
  if(j>0)res+=rec(i+1, j-1, k)*j;
  if(k>0)res+=rec(i, j+1, k-1)*k;
  res+=n*1.0;
  res*=1.0/(i+j+k);

  return dp[i][j][k]=res;
}

int main(){
  cin>>n;
  int a=0,b=0,c=0;
  for(int i=0; i<n; ++i){
    int x; cin>>x;
    if(x==1)++a;
    else if(x==2)++b;
    else ++c;
  }

  memset(dp, -1, sizeof(dp));

  cout<<fixed<<setprecision(10)<<rec(a,b,c)<<endl;
}


Measured memory_bytes: 233088
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
    string W, T;
    int cnt {0};
    cin >> W ;

    while(true){
        cin >> T;
        if( T == "END_OF_TEXT")
            break;
        for(auto&& c: T){
            c = tolower(c);
        }
        if( W == T){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3220
import sys
N, = map(int, input().split())
mx, md, my = 0, 0, 10**9
ps = []

for _ in range(N):
    x, y = map(int, input().split())
    mx = max(x, mx)
    my = min(y, my)
    md = max(y-x+1, md)
    ps.append([x,y])

ps.sort()
for p in ps:
#    p[1] *= -1
    if p == [mx, my]:
        print(my-mx+1+md)
        sys.exit()

for i, (x, y) in enumerate(ps):
    if y == my:
        mmx = x
        del ps[i]
        break

from collections import deque
rs = []
dq = deque()
for i in range(N-1):
    while True:
        if not len(dq):
            dq.append(i)
            break
        lxi = dq[-1]
        if ps[i][1] >= ps[lxi][1]:
            dq.append(i)
            break
        dq.pop()

r = max(my-mx+1, 0) + md
r = max(r, max(my - mmx + 1, 0) + max(ps[dq.popleft()][1] - mx + 1, 0))
#SegTree(pys, N-1, 10**9, min)
for i in range(N-2):
    x = max(ps[i][0], mmx)
    if len(dq):
        if i+1 == dq[0]:
            y = ps[dq.popleft()][1] # mx
    #y = min(p[1] for p in ps[i+1:])
#    print(r)
    r = max(r, max(my - x + 1, 0) + max(y - mx + 1, 0))
print(r)


Measured memory_bytes: 24052
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

int main() {
  int x;
  cin >> x;
  int t = 2000;
  FOR(i, 1, 9) {
    t -= 200;
    if(x < t) continue;
    cout << i << endl;
    break;
  }

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long a[3000005];
int main()
{
	long long n,m;
	cin>>n>>m;
	long long x;
	long long ans=0,s=0;
	for(long long i=1;i<=n;i++)
	{
		cin>>x;
		ans+=x;
		while(x!=0)
		{
			s++;
			a[s]=x-x/2;
			x=x/2;
		}
	}
	sort(a+1,a+s+1);
	long long t=0;
	for(long long i=s;i>=1;i--)
	{
		t++;
		ans-=a[i];
		if(t==m)
		{
			cout<<ans;
			return 0;
		}
	}
	cout<<ans;
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int k; cin >> k;
    ll ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                int tmp = gcd(b, c);
                ans += std::gcd(a, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3
)");
#define cin input
#endif

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

	int mn = 5000000;
	FOR (i, 1, n / 2 + 1)
	{
		int s = 0;
		for (auto c : to_string(i))
			s += c - '0';
		for (auto c : to_string(n - i))
			s += c - '0';
		if (mn > s)
			mn = s;
	}

	cout << mn << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>

#define mp std::make_pair
#define fi first
#define se second
typedef long long LL;
typedef std::pair<int, int> pii;
const int MN = 200005;

int N, A[MN], B[MN];
std::priority_queue<pii> pq;
LL Ans;

inline int nx(const int &x) { return x % N + 1; }
inline int ls(const int &x) { return (x - 2 + N) % N + 1; }

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (int i = 1; i <= N; ++i) scanf("%d", &B[i]);
	for (int i = 1; i <= N; ++i) {
		if (B[i] < A[i]) return puts("-1"), 0;
		if (B[i] > A[i]) pq.push(mp(B[i], i));
	}
	while (!pq.empty()) {
		pii p = pq.top(); pq.pop();
		int i = p.se, v = p.fi;
		int x = B[ls(i)] + B[nx(i)], t = (v - A[i]) / x;
		if (!t) return puts("-1"), 0;
		Ans += t;
		B[i] -= t * x;
		if (B[i] > A[i]) pq.push(mp(B[i], i));
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 3956
n,m = map(int,input().split())
if n == 3:
  print(1,2)
elif n == 4:
  print(1,2)
else:
  ansst = set()
  if n%2:
    for i in range(m):
      print(i+1,n-i-1)
  else:
    for i in range(min(m,n//4)):
      if abs(i+1-(n-i-1))*2 == n:
        print(i+1,n-i-2)
      else:
        print(i+1,n-i-1)
    if m >= n//4:
      for i in range(n//4,m):
        print(i+1,n-i-2)

Measured memory_bytes: 69500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line) >> 2;
			if (n == 0) {
				break;
			}
			int sum = 0;
			for (int i = 0; i < n; i++) {
				sum += Integer.parseInt(br.readLine());
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 16872
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<string >v(1005);
int h,w;
ll dp[1009][1009];
const int mod=1e9+7;
ll call(int i,int j){

if(i>=h || j>=w) return 0;

ll &ret=dp[i][j];
if(ret!=-1) return ret;
if(v[i][j]=='#') return 0;
else if( i==h-1 && j==w-1) return 1;
ret=call(i+1,j)%mod;
ret= (ret+ call(i, j+1))%mod;
return ret;




}
int main(){
memset(dp, -1, sizeof dp);
cin>>h>>w;
for(int i=0; i<h;i++){
    cin>>v[i];
}
ll ans=call(0,0);cout<<ans<<endl;
}


Measured memory_bytes: 9344
#include <cstdio>

char s[555][555];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	for(int j=1;j<=m;++j)putchar('.');putchar('\n');
	for(int i=2;i<n;++i,putchar('\n'))
	for(int j=1;j<=m;++j)
		if(j==1)putchar('.');
		else if(!(i&1)&&s[i][j]!='#'&&j!=m) putchar('.');
		else putchar('#');
	for(int j=1;j<=m;++j)putchar('.');putchar('\n');
	putchar('\n');
	for(int j=1;j<=m;++j)putchar('.');putchar('\n');
	for(int i=2;i<n;++i,putchar('\n'))
	for(int j=1;j<=m;++j)
		if(j==m)putchar('.');
		else if((i&1)&&s[i][j]!='#'&&j!=1) putchar('.');
		else putchar('#');
	for(int j=1;j<=m;++j)putchar('.');putchar('\n');
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;

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

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == ',')
		{
			s[i] = ' ';
		}
	}

	cout << s << endl;

	return 0;
}

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

int main() {
	int temp;
	string s, p;
	getline(cin, s);
	getline(cin, p);
	int flag = 0;
	s = s + s;
	int size = s.size();
	//cout << size << endl;
	for (int i = 0; i < size; i++) {
		temp = i;
		for (int j = 0; j < p.size(); j++) {

			//cout << "(" << i << ", " << j << ")  ";
			if (s[temp] != p[j]) break;
			//cout << "_";
			temp++;
			if (j == p.size()-1) {
				flag = 1;
			}
		}
	}
	if (flag == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1180
import sys
import itertools
input = sys.stdin.readline
Q = int(input())
l = []
r = []
for i in range(Q) :
    p, q = map(int,input().split())
    l.append(p)
    r.append(q)

def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while True:
      if search_list[0]**2 > number:
        prime_list.extend(search_list)
        break
      else:
        head_num = search_list[0]
        prime_list.append(head_num)
        search_list.pop(0)
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

primes = get_primenumber(10**5+1)
like2017 = [0 for _ in range(10**5+1)]

for p in primes :
    if (p+1)//2 in primes :
        like2017[p] = 1

like2017s = list(itertools.accumulate(like2017))

for i in range(Q) :
    print(like2017s[r[i]] - like2017s[l[i]-1])


Measured memory_bytes: 60124
package main

import (
"fmt"
//    "unicode/utf8"

)


func main() {
    var a, b, c string
    fmt.Scan(&a, &b, &c)

  var fv, sv int

  for _, s := range []string{a,b,c} {
    //if utf8.RuneCountInString(s) == 5 {
    if s == "5" {
      fv++
    }
    if s == "7" {
      sv++
    }
  }

  if fv == 2 && sv == 1 {
    fmt.Println("YES")
    return
  }
  fmt.Println("NO")
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = s[0].ToString() + s[1].ToString() + s[2].ToString();


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 25796
/*
ID: 18126251
LANG: C++
TASK: 
*/
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

const int maxn = 1005;
const int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int w, h, n;
int x1[maxn], x2[maxn], y1[maxn], y2[maxn];
int vis[maxn*3][maxn*3];

int comp(int *x1, int *x2, int w){
	std::vector<int> v;
	for(int i = 0; i < n; i++){
		for(int j = -1; j <= 1; j++){
			if(0 <= x1[i]+j && x1[i] + j < w) v.push_back(x1[i]+j);
			if(0 <= x2[i] + j && x2[i] + j < w) v.push_back(x2[i]+j);
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for(int i = 0; i < n; i++){
		x1[i] = lower_bound(v.begin(), v.end(), x1[i]) - v.begin();
		x2[i] = lower_bound(v.begin(), v.end(), x2[i]) - v.begin();
	}
	return v.size();
}

void bfs(int y, int x){
	queue<pair<int, int> >q;
	q.push(make_pair(y, x));
	vis[y][x] = 1;
	while(!q.empty()){
		int sy = q.front().first, sx = q.front().second;
		q.pop();
		for(int i = 0; i < 4; i++){
			int tx = sx + d[i][0], ty = sy + d[i][1];
			if(0 <= tx && tx < w && 0 <= ty && ty < h && !vis[ty][tx]){
				vis[ty][tx] = 1;
				q.push(make_pair(ty, tx));
			}
		}
	}
}



int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
#endif
	// clock_t start = clock();
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> w >> h && w){
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		}

		w = comp(x1, x2, w); 
		h = comp(y1, y2, h);

		for(int y = 0; y < h; y++){
			for(int x = 0; x < h; x++){
				vis[y][x] = 0;
			}
		}
		for(int i = 0; i < n; i++){
			for(int y = y1[i]; y < y2[i]; y++){
				for(int x = x1[i]; x < x2[i]; x++){
					vis[y][x] = 1;
				}
			}
		}


		int ans = 0;
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++){
				if(!vis[y][x]){
					ans++;
					bfs(y, x);
				}
			}
		}
		cout << ans << endl;
	}

	// clock_t ends = clock();
    // cout <<"Running Time : "<<(double)(ends - start)/ CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 15568
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;

#define EPSILON 1.0e-12

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
};
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
};
bool compare_by_b_higheer(tuple<string, int, int> a, tuple<string, int, int> b) {
    if(get<0>(a) != get<0>(b)){
      return get<0>(a) <get<0>(b);
    }else{
        if(get<1>(a) != get<1>(b)){return get<1>(a) > get<1>(b);}
        else{return get<2>(a) > get<2>(b);}
    }
};



int main(){
  int a,b,c;cin>>a>>b>>c;
  set<int> d{a,b,c};
  int s=0;
  for(auto itr=d.begin();itr!=d.end();++itr){
    s++;
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

ll modpow(ll a, ll p) {
    if(p == 0)
        return 1;
    if(p % 2 == 0) {
        ll halfp = p / 2;
        ll half = modpow(a, halfp);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while(b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if(u < 0)
        u += m;
    return u;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> cnt;
    REP(i, N) {
        cin >> A[i];
        REP(j, 61) {
            if(!(A[i] & (1LL << j))) {
                cnt[j]++;
            }
        }
    };
    ll ans = 0LL;
    REP(i, N) {
        REP(j, 61) {
            if(A[i] & (1LL << j)) {
                // flagが立っていたら
                // cout << i << " hoge" << j << ":" << cnt[j] << endl;
                // 1 0
                ans += modpow(2LL, j) * cnt[j];
            } else {
                // 0 1
                ans += modpow(2LL, j) * (N - cnt[j]);
            }
            ans %= MOD;
        }
        ans %= MOD;
    }
    cout << ans * modinv(2, MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>s1>>s2;
    x=sz(s1);y=sz(s2);
    vvl dp(x+1,vl(y+1,0));
    for(int i=1;i<=x;i++){
        for(int j=1;j<=y;j++){
            if(s1[i-1]==s2[j-1])dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<el;
        }
    }
    while(x>0&&y>0){
        if(dp[x][y]==dp[x][y-1])y--;
        else if(dp[x][y]==dp[x-1][y])x--;
        else s+=s1[x-1],x--,y--;
        //cout<<x<<" "<<y<<el;
    }
    reverse(all(s));
    cout<<s;
    return 0;
}


Measured memory_bytes: 70784
/*
  AOJ 1037
  Title:Midnight Tea Time
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int a1,a2,a3,a4;
char node[20];
char s_exp[100];
int dist[16],n;

dump(int dist[])
{
  int i;
  for(i=0;i<16;i++)
    printf("%d|",dist[i]);
  printf("\n");
}

void evaluate(char s_exp[],int dist[])
{
  int ret,dist1[16],dist2[16],lv,len;
  int i,j;
  char *p,*q; 

#ifdef DEBUG
  printf("s-exp=[%s]\n",s_exp);
#endif
  memset(dist,0,sizeof(dist1));
  memset(dist1,0,sizeof(dist1));
  memset(dist2,0,sizeof(dist2));

  if((ret=atoi(s_exp))>0) // atom?
    {
      dist[node[ret]]=1;
      return;
    }

  lv=0;
  len=strlen(s_exp);
  for(p=s_exp;*p;p++)
    {
      if(*p=='(')
	lv++;
      if(*p==')')
	lv--;
      if(lv==1 && *p==' ')
	{
	  q=p;
	  break;
	}
    }
  *q=0;
  evaluate(s_exp+1,dist1); //car
  s_exp[len-1]='\0';
  evaluate(p+1,dist2);     //cadr

#ifdef DEBUG  
  dump(dist1);
  dump(dist2);
#endif

  for(i=0;i<16;i++)
    for(j=0;j<16;j++)
      {
	dist[i & j] += dist1[i]*dist2[j];
	dist[i | j] += dist1[i]*dist2[j];
	dist[i ^ j] += dist1[i]*dist2[j];
      }
}
rtrim(char s[])
{
  int i=strlen(s)-1;
  while(!isgraph(s[i]))
    s[i--]='\0';

}
main()
{
  int i,ret,dn;
  
  while(fgets(s_exp,100,stdin) && *s_exp != 'E')
    {
#ifdef DEBUG
      rtrim(s_exp);
      printf(":s-exp=%s\n",s_exp);
#endif
      scanf("%d",&n);
      for(i=1;i<=n;i++)
	{
	  scanf("%d %d %d %d ",&a1,&a2,&a3,&a4);
	  node[i]=8*a1+4*a2+2*a3+a4;
	}
      
      evaluate(s_exp,dist);
#ifdef DEBUG  
  dump(dist);
#endif
      printf("%d\n",dist[15]);
      memset(s_exp,0,sizeof(s_exp));
    }
  return(0);
}

Measured memory_bytes: 616
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,a=0,b=0,d[100010],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
    if(a<d[i])a=d[i];
  }
  for(i=0;i<n;i++){
    if(abs(a/2-d[i])<abs(a/2-b))b=d[i];
  }
  printf("%d %d\n",a,b);
  return 0;
}


Measured memory_bytes: 512
def prime?(x)
  return true if x == 2
  return false if x < 2 || x.even?
  3.step(Math.sqrt(x), 2).each do |i|
    return false if x % i == 0
  end
  true
end
n = gets.to_i
numbers = n.times.map { gets.to_i }
puts numbers.count {|x| prime?(x) }

Measured memory_bytes: 6212
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;



int main() {
	
	ll n, y;
	cin >> n >> y;
	
	ll sum = y;
	bool yes = false;
	ll d, e, f;
	for (ll a = 0; a < n+1; a++)
	{
		sum = y - a * 10000;
		if (sum < 0) {
			break;
		}

		for (ll b = 0; b < n-a+1; b++)
		{
			sum = y - a * 10000 - b * 5000;
			if (sum < 0) {
				break;
			}
			ll c = sum / 1000;
			if (a + b + c == n) {
				yes = true;
				d = a;
				e = b;
				f = c;
				break;
			}
			if (a + b + c < n) {
				break;
			}
		}
		if (yes) {
			break;
		}
	}

	if (yes) {
		cout << d << " " << e << " " << f << endl;
	}
	else {
		cout << "-1 -1 -1" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
while True :
    try :
        a, b, c, d, e, f = map(int, input().split())
    except EOFError :
        break
    
    x = (e*c - b*f) / (a*e - b*d)
    y = (c*d - a*f) / (b*d - a*e)
    
    if x == -0.0 :
        x = 0.0
    if y == -0.0 :
        y == 0.0
    print(f'{x:.3f}', f'{y:.3f}')


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }



int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n), f(n);
    rep(i, n) cin>>a[i];
    rep(i, n) cin>>f[i];
    sort(a.begin(), a.end(), greater<ll>());
    sort(f.begin(), f.end());
    ll ng = -1, ok = 1e15;
    while(ok - ng > 1){
        ll mid = (ng + ok)/2;
        ll cnt = 0;
        rep(i, n){
            if(a[i] * f[i] > mid){
                cnt += a[i] - (mid / f[i]);
            } // just mid is ok
        }
        if(cnt > k){
            ng = mid;
        }else{
            ok = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, A, B; 
  cin >> N >> A >> B;

  int ans = 0;
  FOR(i, 1, N+1){
    string s = to_string(i);
    int ret = 0;
    REP(j, s.size()) ret += s[j]-'0';
    if(IN(A, ret, B+1)) ans += i;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> v(9);
    int cnt = 0;
    int cnt2 = 0;
    rep(i, n)
    {
        cin >> a[i];
        int x = a[i]/400;
        if(x <= 7 && !v[x]){
            cnt++;
            v[x]++;
        }else if (x > 7){
            cnt2++;
        }
    }
    cout << max(1, cnt) << " " << cnt2 + cnt << "\n";

}

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

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;

  for (int i = 0; i < b; ++i) {
    if ((i*a)%b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}



Measured memory_bytes: 256
using System;

class Atcoder114
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        int sound = b / a;

        if (sound < c)
            Console.WriteLine(sound);
        else
            Console.WriteLine(c);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
   int n;
   string space;
   cin>>n;
   vs a(n);
   vi b(n);
   vector<pair<string,int>> cost;
   getline(cin,space);
   rep(i,n){
       cin>>a.at(i)>>b.at(i);
       b.at(i)=100-b.at(i);
       a.at(i)+=b.at(i);
       //cost.push_back(pair(a.at(i), i+1));
       cost.push_back(make_pair(a.at(i), i+1));
   }
   
   //cout<<a.at(0)<<endl;
   //sort(ALL(a));
   sort(ALL(cost));
   //rep(i,n)cout<<a.at(i)<<endl;
    for ( auto& i: cost )
    
        std::cout << i.second << endl;
       // cout << i.first << endl;
   
}

Measured memory_bytes: 256
N=int(input())
max_count=0
answer=1
for num_x in range(1,N+1):
    num=num_x
    count=0
    flag=True
    while(flag):
        if num%2==0:
            count+=1
            num=num/2
        else:
            flag=False
    if count>max_count:
        answer=num_x
        max_count=count
print(answer)

Measured memory_bytes: 3060
#include<vector>
#include<string>
using namespace std;
int main(){
	int p,q;
	while(cin>>p>>q){
		vector<int> amari; bool f=1; int keta;
		amari.push_back(p);
		p*=10; int len;
		for(len=0;;len++){
			cout<<p/q;
			p%=q;
			if(p==0){
				f=0;
				break;
			}
			for(int j=0;j<amari.size();j++)if(amari[j]==p){
				keta=j; goto END;
			}
			amari.push_back(p);
			p*=10;
		}
		END:;
		cout<<endl;
		if(f){
			string s;
			for(int i=0;i<keta;i++)s+=" ";
			for(int i=0;i<=len-keta;i++)s+="^";
			cout<<s<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,k,sum,check;
    int t=1;
    vector<int> prime;
    prime.push_back(0);
    prime.push_back(0);
    for(int i=2;i<1000000;i++){
        prime.push_back(1);
    }
    while(t<1000000){
        for(int j=t+1;j<=1000000;j++){
            if(prime[j]==1){
                t=j;
                for(k=2*j;k<=1000000;k+=j){
                    prime[k]=0;
                }
                break;
            }
            else if(j==1000000){
                t=1000000;
            }
        }
    }
    while(cin>>n){
        sum=0;
        for(check=1;check<=n;check++){
            if(prime[check]==1){
                sum+=1;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

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

using namespace std;

template<class INT>
INT mod_pow(INT n, INT k, INT p){
    if (k == 0)
        return 1;
    if (k % 2 == 0){
        INT res = mod_pow(n, k / 2, p);
        return res * res % p;
    }
    return mod_pow(n, k - 1, p) * n % p;
}

template<class INT>
vector<INT> fact(INT n, INT p=INT(1e9 + 7)){
    vector<INT> f(n + 1);
    f[0] = 1;
    for (INT i = 0; i < n; i++)
        f[i + 1] = (i + 1) * f[i] % p;
    return f;
}

template<class INT>
vector<INT> invfact(INT n, const vector<INT> &f, INT p=INT(1e9 + 7)){
    vector<INT> inv(n + 1);
    inv[n] = mod_pow<INT>(f[n], p - 2, p);
    for (INT i = n; i > 0; i--)
        inv[i - 1] = inv[i] * i % p;
    return inv;
}

template<class INT>
INT comb(INT a, INT b, const vector<INT> &f, const vector<INT> &invf, INT p=(INT)(1e9 + 7)){
    if (a < b)
        return 0;
    if (a < 0 or b < 0)
        return 0;
    return f[a] * invf[b] % p * invf[a - b] % p;
}

int main(){
    int64_t r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    const int64_t p = 1e9 + 7;
    auto f = fact(r2 + c2 + 10);
    auto invf = invfact(r2 + c2 + 10, f);
    int64_t ans = 0;
    ans = p - comb(c1 + r2 + 1, r2 + 1, f, invf);
    ans += comb(c1 + r1, r1, f, invf);
    ans %= p;
    ans += comb(c2 + r2 + 2, r2 + 1, f, invf);
    ans %= p;
    ans += p - comb(c2 + r1 + 1, r1, f, invf);
    ans %= p; 
    cout << ans << endl;
}

Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct Node {
    int value = 0;
    vector<int> children;
};

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

    vector<Node> nodes(n + 1);

    for (int i = 1; i <= n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        nodes[a].children.push_back(b);
    }

    for (int i = 0; i < q; ++i) {
        int p, x;
        cin >> p >> x;
        nodes[p].value += x;
    }

    queue<int> que;
    que.push(1);

    while (!que.empty()) {
        int cur = que.front();
        que.pop();

        for (int idx : nodes[cur].children) {
            nodes[idx].value += nodes[cur].value;
            que.push(idx);
        }
    }

    for (int i = 1; i <= n; ++i) {
        cout << nodes[i].value << ' ';
    }
    cout << endl;

    return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  cout << S.substr(0, S.length() - 8) << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector <int> a,b;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
        b.push_back(tmp);
    }
    sort(b.begin(),b.end());
    int left = b[n/2-1];
    int right = b[n/2];
    for(int i=0;i<n;i++){
        if(a[i] <=left){
            cout << right << endl;
        }
        else if(right <= a[i]){
            cout << left << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3948