akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	int n;
	cin >> n;

	Yes(n % SED(n) == 0);

	please AC;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			StringTokenizer st = new StringTokenizer(str, " ");
			
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			
			int ans1 = a*b;
			int ans2 = 2*a+2*b;
			
			System.out.print(ans1+" ");
			System.out.println(ans2);
			
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

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

int main(){
  int n; cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i ++) {
    int q, v;
    cin >> q;

    if (q == 0) cin >> v, a.push_back(v);
    else if (q == 1) cin >> v, cout << a[v] << endl;
    else if (q == 2) a.pop_back();
  }
}


Measured memory_bytes: 3840
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int, int> Edge;



int main() {
	long long int  q,x,l1,l2,l3,l4,X;
	int a,b,s0, s1, t0, t1;
	vector<long long int> s, t;
	cin >> a >> b >> q;
	for (int i = 0; i < a; i++) {
		cin >>X ;
		s.push_back(X);
	}
	for (int i = 0; i < b; i++) {
		cin >> X;
		t.push_back(X);
	}


	for ( int i = 0; i < q; i++) {
		cin >> x;
        int ss=lower_bound(s.begin(), s.end(), x) - s.begin(),sss=a-1;
		s1 = min(sss,ss);
        int tt=lower_bound(t.begin(), t.end(), x) - t.begin(),ttt=b-1;
		t1=min(tt,ttt);
		s0 = max(s1 - 1,0);
		t0 = max(t1 - 1,0);
		l1 = abs(s[s0] - t[t0]) + min(abs(x - s[s0]), abs(x - t[t0]));
		l2 = abs(s[s1] - t[t0]) + min(abs(x - s[s1]), abs(x - t[t0]));
		l3 = abs(s[s0] - t[t1]) + min(abs(x - s[s0]), abs(x - t[t1]));
		l4 = abs(s[s1] - t[t1]) + min(abs(x - s[s1]), abs(x - t[t1]));
		l1 = min(l1, l2);
		l3=min( l3, l4);
		cout << min(l1, l3) <<endl;
	}

}


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

// Mod int
// cf. https://www.youtube.com/watch?v=1Z6ofKN03_Y
struct mint {
  ll x;
  mint(ll x = 0) : x((x + MOD) % MOD) {}
  mint& operator+= (const mint a) {
    if ((x += a.x) >= MOD) x %= MOD;
    return *this;
  }
  mint operator+ (const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint& operator-= (const mint a) {
    if ((x += MOD - a.x) >= MOD) x %= MOD;
    return *this;
  }
  mint operator- (const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint& operator*= (const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator* (const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) { return 1; }
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/= (const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/ (const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// Combination mod prime.
// cf. https://www.youtube.com/watch?v=1Z6ofKN03_Y
struct Combination {
  vector<mint> fact, ifact;
  Combination(int n) { init(n); }
  void init(int n) {
    assert(n < MOD); // n must be lower than MOD.

    fact.resize(n + 1);
    ifact.resize(n + 1);

    fact[0] = 1;
    for (int i = 1; i <= n; ++i) { fact[i] = fact[i-1] * i; }
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) { ifact[i-1] = ifact[i] * i; }
  }
  mint operator() (int n, int k) const {
    if (k < 0 || k > n) { return 0; }
    return fact[n] * ifact[k] * ifact[n-k];
  }
  mint perm(int n, int k) const {
    if (k < 0 || k > n) { return 0; }
    return fact[n] * ifact[n-k];
  }
};

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

  Combination c(N);

  for (int i = 1; i <= K; ++i) {
    mint ans = c(K-1, i-1) * c(N-K+1, i);
    cout << ans.x << endl;
  }

  // - b:
  //   - remain: K - k
  //   - position: k
  // - r:
  //   - remain: (N-K - (k-1))
  //   - position: k+1
  // if remain is i and position is j, then (i+j-1)C(j-1) is the result.
  // - ans: (K-k + k-1)C(k-1) * (N-K-(k-1) + k)C(k)
  //        = (K-1)C(k-1) * (N-K+1)C(k)
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,K;
  cin >> N >> K;
  
  if(N-1<=2*(N-K)){
    if(N%2==0){
      REP(i,N/2){
        cout << i + K SP(N - 2 * (i + 1)) + K + N SP(N / 2 - (i + 1)) + K + 2 * N << endl;
      }
      REP(i,N/2){
        cout << i + (N/2) + K SP (N - 2 * (i + 1) + 1) + K + N SP(N - (i + 1)) + K + 2 * N << endl;
      }
    }else{
      cout << 0 + K SP(N - 1) + K + N SP N / 2 + K + 2 * N << endl;
      REP(i, N / 2)
      {
        cout << i + 1 + K SP(N - 2 * (i + 1)) - 1 + K + N SP(N / 2 - (i + 1)) + K + 2 * N << endl;
      }
      REP(i,N/2){
        cout << i + 1 + (N/2) + K SP (N - 2 * (i + 1) + 1) - 1 + K + N SP(N - (i + 1)) + K + 2 * N << endl;
      }
    }
  }else{
    cout << -1 << endl;
  }

  // LL sum1 = 0;
  // LL sum2 = 0;

  // FOR(i, N, N + 2 * K){
  //   sum1 += i;
  // }
  // FOR(i, N + 2 * K, N + 3 * K){
  //   sum2 += i;
  // }

  // cout << sum1 SP sum2 << endl;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
using namespace std;

int main(){
	
	int A[2],B[2],C[2];
	int cnt=0;
	int ans=0;
	cin>>A[0]>>B[0]>>C[0];

	while(1){
		if(A[cnt%2]%2==0 && B[cnt%2]%2==0 && C[cnt%2]%2==0){
			if(A[cnt%2]==B[cnt%2] && B[cnt%2]==C[cnt%2]){
				cout<<-1<<endl;
				return 0;
			}
			else{
				A[(cnt+1)%2]=(B[cnt%2]+C[cnt%2])/2;
				B[(cnt+1)%2]=(A[cnt%2]+C[cnt%2])/2;
				C[(cnt+1)%2]=(A[cnt%2]+B[cnt%2])/2;
				ans++;
			}
		}
		else{
			cout<<ans<<endl;
			return 0;
		}
		cnt++;
	}
}


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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
int go[1000005][40];
LL val[1000005][40];
void solve(){
    LL n;
    int x,m;
    scanf("%lld %d %d",&n,&x,&m);
    for(int i = 0;i<m;i++){
        val[i][0]=i;
        go[i][0]=i*1ll*i%m;
    }
    for(int i = 1;i<40;i++){
        for(int j  =0;j<m;j++){
            go[j][i]=go[go[j][i-1]][i-1];
            val[j][i]=val[j][i-1]+val[go[j][i-1]][i-1];
        }
    }
    int now=x;
    LL ans=0;
    for(int i = 0;i<40;i++){
        if((1ll<<i)&n){
            ans+=val[now][i];
            now=go[now][i];
        }
    }
    printf("%lld\n",ans);
}
int main(){
    int t=1;
    int T=1;
    while(t--){
        solve();
    }
}
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/


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

vector<int>prime(int N){
    vector<int>factor(N+1);//factor[i]:iの最小の素因数 iが素数の場合は0
    factor[0]=0,factor[1]=0;//for osa_k
    for(int i=2;i*i<=N;i++){
        if(factor[i]!=0)continue;
        for(int j=i*2;j<=N;j+=i)if(factor[j]==0)factor[j]=i;
    }
    return factor;
}
vector<int>S(1000001);

map<int,int>osa_k(int N){
    //vector<int>factor=prime(N);
    map<int,int>prime_factor;
    for(;S[N]!=0;N/=S[N])prime_factor[S[N]]++;
    prime_factor[N]++;
    return prime_factor;
}

int N;
bool pairwise=true,setwise=true;
int main(){
    cin>>N;
    vector<long long>A(N); 
    for(int i=0;i<N;i++)cin>>A[i];
    map<long long,bool>factor;
    map<long long,long long>f_cnt;

    S=prime(1000001);

    for(int k=0;k<N;k++){
        long long Num=A[k];
        if(Num==1)continue;
        auto p=osa_k(Num);
        for(auto x:p){
            if(factor[x.first])pairwise=false;
            factor[x.first]=true;
            f_cnt[x.first]++;
        }
    }

    for(auto x:f_cnt)if(x.second==N)setwise=false;

    if(pairwise){cout<<"pairwise coprime"<<endl;return 0;}
    if(setwise){cout<<"setwise coprime"<<endl;return 0;}
    cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 24688
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <climits>
using namespace std;
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, init, n) for (int i = (init); i < (n); ++i)
#define RepLong(i, n) for (int64 i = 0; i < (n); ++i)
#define InitRepLong(i, init, n) for (int64 i = (init); i < (n); ++i)
#define RepItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)


int64 getGCD(int64 a, int64 b)
{
	if (a < b) return getGCD(b, a);

	int64 r = a % b;
	if (r == 0) return b;
	return getGCD(b, r);
}
int64 getLCM(int64 a, int64 b)
{
	return a * b / getGCD(a, b);
}

int main()
{
	int64 n, m;
	cin >> n >> m;
	vint64 a(n);
	Rep(i, n)
	{
		cin >> a[i];
	}

	int64 lcm = a[0];
	InitRep(i, 1, n)
	{
		lcm = getLCM(lcm, a[i]);
		if (lcm > 2 * m)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	//*
	//cout << "lcm = " << lcm << endl;
	//*/

	int64 minHlcm = lcm / 2;
	Rep(i, n)
	{
		if (minHlcm / a[i] * a[i] == minHlcm)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	cout << ((m + minHlcm) / lcm) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  set<string>k;
  for(int i=0;i<N;i++){
    string w;
    cin>>w;
    char a,b;
    b=w[0];
    int n=w.size();
    if(i>0&&a!=b){cout<<"No"<<endl;return 0;}
    if(k.count(w)){cout<<"No"<<endl;return 0;}
    a=w[n-1];
    k.insert(w);
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vi v(n, 0);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		v[a - 1]++; v[b - 1]++;
	}
	int flag = 1;
	REP(i, n) {
		if (v[i] % 2 == 1)flag = 0;
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


bool is_prime(int x){
  if(x<2) return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return false;
  }
  return true;
}

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

  int x;
  cin>>x;
  while(true){
    if(is_prime(x)){
      cout<<x<<endl;
      break;
    }
    x++;
  }


}

Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)
      .map {
        case n if n > 9 * 4 => 0
        case n =>
          (for (a <- 0 to 9; b <- 0 to 9; c <- 0 to 9; d <- 0 to 9 if a + b + c + d == n) yield 0)
            .length
      }
      .foreach(println)
  }
}

Measured memory_bytes: 68748
#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 int MOD = 1e9+7;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  
  vector<vector<int>> dp(h, vector<int>(w, 0));
  dp[0][0] = 1;
  rep(i, h) rep(j, w) {
    if (a[i][j] == '#') continue;
    if (i) dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
    if (j) dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    int all = 0;
    for (int i = 0;i < n;i++){
        cin >> m.at(i);
        all += m.at(i);
    }
    int amount = x - all;
    sort(m.begin(),m.end());
    int can = amount / m.front();

    cout << can + n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))


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

    ll wa = X,goukei = 0;

    wa -= 2 * Z;

    while(wa > 0){
        if(wa >= Y){
            wa -= Y;
            goukei++;
        }else
            break;
        
        wa -= Z;
    }

    cout << goukei << endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <numeric>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(n==i*j){
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 2010;
const ll bits = 30;
const ll mod = 998244353;



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

    vector<ll>dp(n+1,inf),arr(n+1,0);

    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }

    dp[1] = 0;

    for(int i=1;i<=n;i++){

        for(int j=1;j<=k && j+i<=n;j++){
            dp[i+j] = min(dp[i+j],dp[i]+abs(arr[i]-arr[i+j]));
        }
    }

    cout<<dp[n]<<"\n";




    
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
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++)

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    int k = d - t*s;
    if(k <= 0)cout << "Yes" <<  endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	ll ans = 0;
	rep(i,n-1){
		ll dis = x[i+1]-x[i];
		if(dis*a<b) ans += dis*a;
		else ans += b;
	}
	cout << ans << endl;
}

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


int main(){

ll k;
cin>>k;

if( k ==1 ){
    cout<<2<<endl<<2<<" "<<0<<endl;
    return 0;
}

for(ll n=2;n<=50;n++)
for(ll rem=n-1;rem<n;rem++){

ll mx=0,mn=1ll<<60;
for(int i=0;i<n;i++){
       ll s = (k/n);
       if( k%n ){
            if( k%n >i ){
                s+=-(k%n)+1+n;
            }else{
                s+=-(k%n);
            }

       }
       mn=min(mn,s+rem);
        mx=max(mx,s+rem);
}

if( mx <= 1e16 + 1e3 && mn>=0  ){

cout<<n<<endl;
for(int i=0;i<n;i++){
       ll s = (k/n)*( n ) - (k/n)*(n-1);
       if( k%n ){
            if( k%n >i ){
                s+=-(k%n)+1+n;
            }else{
                s+=-(k%n);
            }
       }
       cout<<rem+s<<" \n"[i+1==n];
}

return 0;
}

}

cout<<-1<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int x=-1, y=-1,z=-1;
	int c=0;
	cin >> x >> y >> z;

	for (int i = x; i <= y; i++){
		if (z%i == 0){ c++; }
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  int ans2 = ( (x == W / 2.0 && y == H / 2.0) ? 1 : 0 );
  cout << W * H / 2.0 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int head[200010],o=0,di=-1,ans=0,n;
bool vis[200010];
struct edge{
	int to,link;
}e[400010];
void add_edge(int u,int v){
	e[++o].link=head[u],e[o].to=v,head[u]=o;
	e[++o].link=head[v],e[o].to=u,head[v]=o;
}
void dfs(int u,int d,bool k){
	vis[u]=k;
	if(ans<d){
		ans=d;
		di=u;
	}
	for(int i=head[u];i;i=e[i].link){
		if(vis[e[i].to]!=k) dfs(e[i].to,d+1,k);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++) scanf("%d %d",&u,&v),add_edge(u,v);
	dfs(1,1,1);
	dfs(di,1,0);
	ans%3==2?printf("Second\n"):printf("First\n");
}

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

int main() {
  int kosuu, devide = 100000000;
  cin >> kosuu;
  for (int i = 0; i < kosuu; i++){
    int i2, number, devideX = 0;
    cin >> number;
    while (number % 2 == 0){
      number = number / 2;
      devideX = devideX + 1;
    }
    if (devideX <= devide){
      devide = devideX;
    }
  }
cout << devide << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=[0]*N
for _ in[0]*K:
 a,b=map(int,input().split())
 S[a-1]=b
dp=[0]*9
st,nd=S[:2]
if st:
 if nd:dp[~-st*3+~-nd]=1
 else:dp[~-st*3:~-st*3]=[1]*3
elif nd:dp[~-nd::3]=[1]*3
else:dp=[1]*9
for i in range(2,N):
 cur=S[i]-1;tmp=[0]*9
 if cur+1:
  for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 else:
  for cur in range(3):
   for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 dp=tmp[:]
print(sum(dp)%10000)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 610;
vector<int> e[N];
double dp[N];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back(y);
	}
	for (int i = n - 1; i >= 1; i--) {
		for (auto j : e[i]) {
			dp[i] += dp[j];
		}
		dp[i] /= e[i].size();
		dp[i] += 1;
	}
	double ans = dp[1];
	for (int i = 1; i < n; i++) if (e[i].size() > 1) {
		int k = -1;
		double mx = 0;
		for (auto j : e[i]) {
			if (dp[j] > mx) {
				k = j;
				mx = dp[j];
			}
		}
		dp[i] = ((dp[i]-1) * e[i].size() - mx) / (e[i].size() - 1) + 1;
		for (int k = i - 1; k >= 1; k--) {
			dp[k] = 0;
			for (auto j : e[k]) {
				dp[k] += dp[j];
			}
			dp[k] /= e[k].size();
			dp[k] += 1;
		}
		ans = min(ans, dp[1]);
	}
	printf("%.9lf\n", ans);
	return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };


signed main() {
	int a, b,c,x;
	int kazu = 0;
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) {
					kazu++;
				}
			}
		}
	}

	cout << kazu;

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

using LL = long long;

const int Mod = 1e9 + 7;
const int N = 3e5 + 3;
LL a[N];

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) cin >> a[i];
    LL ans = 0;

    for (int i = 0; i < 62; i++) {
        int on = 0, off = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] & 1)
                on++;
            else
                off++;
            a[j] >>= 1;
        }

        LL s = 1ll * off * on % Mod * ((1ll << i) % Mod) % Mod;

        ans = (ans + s) % Mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];
  const Int OFS = 1e9;
  for(Int i=0;i<n;i++) x[i]=x[i]*2+OFS,y[i]=y[i]*2+OFS;

  const Int R = 20;
  auto calc=
    [&](Int u,Int v)->Int{
      auto dist=
        [&](Int a,Int b,Int c,Int d)->Int{
          if((a/R)!=(c/R)&&(b/R)!=(d/R))
            return abs(a-c)+abs(b-d);
          
          if((a/R)==(c/R)&&(b/R)==(d/R))
            return abs(a-c)+abs(b-d);

          if((a/R)==(c/R)&&(b/R)!=(d/R))
            return abs(b-d)+min((a%R)+(c%R),(R-(a%R))+(R-(c%R)));
          
          if((a/R)!=(c/R)&&(b/R)==(d/R))
            return abs(a-c)+min((b%R)+(d%R),(R-(b%R))+(R-(d%R)));

          assert(0);
          return -1;
        };
      Int res=0;
      for(Int i=0;i<n;i++) chmax(res,dist(u,v,x[i],y[i]));
      //cout<<u<<" "<<v<<":"<<res<<endl;
      return res;
    };

  const Int C = 5;
  auto check=
    [&](Int u,Int v)->Int{
      Int res=1e18;
      Int s=u/R,t=v/R;
      for(Int a=-C;a<=C;a++){
        for(Int b=-C;b<=C;b++){
          for(Int k=0;k<R;k++){
            chmin(res,calc((s+a)*R+k,(t+b)*R));
            chmin(res,calc((s+a)*R  ,(t+b)*R+k));
          }          
        }        
      }              
      return res;
    };
  Int au=0,av=0;
  {
    vector<Int> u(n),v(n);
    for(Int i=0;i<n;i++) u[i]=x[i]+y[i],v[i]=x[i]-y[i];

    auto rect=[&](Int &a1,Int &b1,Int &c1,Int &d1,
                  Int a2,Int b2,Int c2,Int d2)->void{               
                chmax(a1,a2);
                chmin(b1,b2);
                chmax(c1,c2);
                chmin(d1,d2);
              };
    const Int INF = 1e18;
    
    auto check2=[&](Int m)->Int{
                  Int a1=-INF,b1=INF,c1=-INF,d1=INF;
                  for(Int i=0;i<n;i++)
                    rect(a1,b1,c1,d1,u[i]-m,u[i]+m,v[i]-m,v[i]+m);

                  if(a1<=b1&&c1<=d1) au=a1,av=c1;
                  
                  return a1<=b1&&c1<=d1;
                };
    
    Int l=0,r=1e15;
    while(l+1<r){
      Int m=(l+r)>>1;
      if(check2(m)) r=m;
      else l=m;
    }    
  }
  
  Int ax=(au+av)/2,ay=(au-av)/2;
  double ans=check(ax,ay);
  cout<<ans/2.0<<endl;
  return 0;
}



Measured memory_bytes: 3360
#include <bits/stdc++.h>
#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)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int k;
    cin >> k;
    vector<ll> lun;
    queue<ll> q;
    for (int i = 1; i <= 9; ++i) q.push(i);

    while (1) {
        ll x = q.front();
        q.pop();        
        lun.push_back(x);
        if (lun.size() == k) break;
        int n = x % 10;
        for (int i = max(0, n-1); i <= min(9, n+1); ++i) {
            q.push(x * 10 + i);
        }
    }

    cout << lun.back() << endl;
}


Measured memory_bytes: 5680
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    N %= 10;
    
    switch (N) {
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        default:
            cout << "bon" << endl;
            break;
    }

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int A[100001];
int main(){
	cin>>N;
	REP(i,N){
		string s;
		cin>>s;
		if(s[0]=='T'){
			A[i]=1;
		}else{
			A[i]=0;
		}
	}
	REP(i,N-1){
		if(A[i]==1&&A[i+1]==0){
			A[i+1]=0;
		}else{
			A[i+1]=1;
		}
	}
	if(A[N-1]==1){
		cout<<"T"<<endl;
	}else{
		cout<<"F"<<endl;
	}
}


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

int main()
{
        int X;
        cin >> X;
        long long  A, B;
        int ans = pow(X, 0.2);
        ans *= 10;
        int mi = ans * -1;
        for (int i = mi; i < ans; ++i) {

                for (int j = mi; j < ans; ++j) {

                        A = pow(i, 5);
                        B = pow(j, 5);
                        if ((A-B) == X) {
                                cout << i << " " << j << endl;
                                exit(0);
                        }
                }
        }

}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int n; cin >> n;
	cout << n / 3 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
char table1[255][256];
int slash[255][255];
int yen[255][255];
int yoko[255][255];
int tate[255][255];
int main(){
	int n;
	while(scanf("%d",&n),n){
		for(int i=0;i<255;i++)
			for(int j=0;j<255;j++)
				table1[i][j]='0';
		for(int i=0;i<n;i++){
			scanf("%s",table1[i]);
		}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				yen[i][j]=slash[i][j]=tate[i][j]=yoko[i][j]=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==0&&table1[i][j]=='1')tate[i][j]=1;
				else if(i>0&&table1[i][j]=='1')tate[i][j]=tate[i-1][j]+1;
				if(j==0&&table1[i][j]=='1')yoko[i][j]=1;
				else if(j>0&&table1[i][j]=='1')yoko[i][j]=yoko[i][j-1]+1;
				if((i==0||j==n-1)&&table1[i][j]=='1')yen[i][j]=1;
				else if(table1[i][j]=='1')yen[i][j]=yen[i-1][j+1]+1;
			}
		}
		for(int i=n-1;i>=0;i--){
			for(int j=0;j<n;j++){
				if((i==n-1||j==n-1)&&table1[i][j]=='1')slash[i][j]=1;
				else if(table1[i][j]=='1')slash[i][j]=slash[i+1][j+1]+1;
			}
		}
		int ret=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				if(ret<yen[i][j])ret=yen[i][j];
				if(ret<slash[i][j])ret=slash[i][j];
				if(ret<yoko[i][j])ret=yoko[i][j];
				if(ret<tate[i][j])ret=tate[i][j];
			}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashSet;

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [(usize1, usize1); m]
    }
    let mut num = vec![1; n];
    let mut red = HashSet::new();
    red.insert(0);
    for &(x, y) in &v {
        num[x] -= 1;
        num[y] += 1;
        if red.contains(&x) {
            if num[x] == 0 {
                red.remove(&x);
            }
            red.insert(y);
        }
    }
    println!("{}", red.len());
}


Measured memory_bytes: 10492
#include <iostream>
#include <queue>

using namespace std;

queue<int> q[1000];
int N;
bool b[1000];

int main(){
    int a;
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> a;
            q[i].push(a-1);  
        }
    }
    int count = 0;
    int t = 0;
    bool f;
    while(true){
        f = false;
        for(int i=0;i<N;i++) b[i] = true;
        for(int i=0;i<N-1;i++){
            if(q[i].empty()) continue;
            a = q[i].front();
            if(q[a].front()==i && b[i] && b[a]){
                f = true;
                q[i].pop();
                q[a].pop();
                b[i]=b[a]=false;
                t++;
            }
        }
        if(!f){
            cout << -1 << endl;
            return 0;
        }
        count++;
        if(t == N*(N-1)/2){
            cout << count << endl;
            break;
        }
    }
    return 0;
}

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

constexpr int maxn = 100000 + 10;

vector<tuple<int, int, int>> edges;
vector<pair<int, int>> vec[maxn] = {};
int poz[maxn] = {};
int in_deg[maxn] = {};

int main(){
int n, m;
cin >> n >> m;
for(int i = 0, x, y, z; i < m; ++i){
cin >> x >> y >> z;
edges.emplace_back(x, y, z);
vec[x].emplace_back(y, z);
++in_deg[y];
}
queue<int> de_viz;
for(int i =0; i < n; ++i)
if(in_deg[i] == 0)
de_viz.push(i);

while(!de_viz.empty()){
int cur = de_viz.front();
de_viz.pop();
for(auto next : vec[cur]){
poz[next.first] = poz[cur] + next.second;
if(--in_deg[next.first] == 0)
de_viz.push(next.first);
}
}
bool good = true;
for(auto& x : edges)
good = (good && poz[get<0>(x)] + get<2>(x) == poz[get<1>(x)]);
cout << (good ? "Yes" : "No");
return 0;
}


Measured memory_bytes: 10164
N,M = map(int,input().split())

ret = [(bin(n)[2:].zfill(N))[::-1] for n in range(2**N)]

# 入力を保持
kss = []
for i in range(M):
  kss.append(input())
ps = list(map(int, input().split()))

#print(ret)

def test(ret):
#  if 0 < sum([int(ret[t-1]) for t in tmp]):
  return sum([int(ret[t-1]) for t in tmp]) % 2 == ps[p_i]
#  return False

# 処理
p_i = 0
for ks in kss:
  l = list(map(int, ks.split()))
  tmp = l[1:]
  ret = list(filter(test, ret))
  if ret == None:
    break
  p_i = p_i + 1
#  print(ret)

if ret != None:
  print(len(ret))
else:
  print(0)


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

template <typename T>
class Matrix
{
public:
    Matrix(int n, int m)
        : m_value(n, vector<T>(m, 0)), m_row(n), m_col(m) {}
    Matrix(initializer_list<initializer_list<T>> init)
        : m_value(init.begin(), init.end()), m_row(init.size()), m_col((*init.begin()).size()) {}

    int row(void) const { return m_row; }
    int col(void) const { return m_col; }

    vector<T> &operator[](int i) { return m_value[i]; }
    const vector<T> &operator[](int i) const { return m_value[i]; }

    // 単位行列E
    static Matrix E(int n)
    {
        Matrix res(n, n);
        for (int i = 0; i < n; i++) res[i][i] = 1;
        return res;
    }

    Matrix &operator+=(const Matrix &A)
    {
        int n = this->row(), m = this->col();
        assert(n == A.row() && m == A.col());

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                (*this)[i][j] += A[i][j];
            }
        } 
        return *this;
    }

    Matrix &operator-=(const Matrix &A)
    {
        int n = this->row(), m = this->col();
        assert(n == A.row() && m == A.col());

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                (*this)[i][j] -= A[i][j];
            }
        } 
        return *this;
    }

    Matrix &operator*=(const Matrix &A)
    {
        int n = this->row(), m = this->col(), l = A.col();
        assert(m == A.row());

        Matrix res(n, l);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int k = 0; k < m; k++) {
                    res[i][j] += (*this)[i][k] * A[k][j];
                }
            }
        }
        return *this = move(res);
    }

    Matrix operator+(const Matrix &A) const { return Matrix(*this) += A; }
    Matrix operator-(const Matrix &A) const { return Matrix(*this) -= A; }
    Matrix operator*(const Matrix &A) const { return Matrix(*this) *= A; }

    Matrix pow(ll n) const
    {
        Matrix e = *this, res = E(this->row());
        while (n) {
            if (n & 1) res *= e;
            e *= e;
            n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const Matrix &A)
    {
        int n = A.row(), m = A.col();
        for (int i = 0; i < n; i++) {
            os << "[";
            for (int j = 0; j < m; j++) {
                os << A[i][j];
                if (j < m - 1) os << ", ";
            }
            os << "]";
            if (i < n - 1) os << endl;
        }
        return os;
    }

private:
    vector<vector<T>> m_value;
    size_t m_row;
    size_t m_col;
};

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

    int n; cin >> n;
    Matrix<ll> A = {{1, 1}, {1, 0}};
    A = A.pow(n);
    cout << A[1][0] + A[1][1] << endl;
    return 0;
}


Measured memory_bytes: 3216
c=[i=0]*6;gets;$<.map{|a|n=a.to_f;c[n<165 ? 0 : n<170 ? 1 : n<175 ? 2 : n<180 ? 3 : n<185 ? 4 : 5]+=1};c.map{|a|puts"#{i+=1}:#{"*"*a}"}


Measured memory_bytes: 6868
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template<int p = 1000000007>
class Z {
	ll x;
public:
	Z(ll X) :x((X + p) % p) { ; }
	Z() :x(0) { ; }
	Z &operator=(ll y) {
		return *this = Z(y);
	}
	Z operator-() const {
		return Z(-x);
	}
	Z operator+(ll y) const {
		return Z(x + y);
	}
	Z &operator+=(ll y) {
		return *this = *this + y;
	}
	Z operator-(ll y) const {
		return Z(x - y);
	}
	Z &operator-=(ll y) {
		return *this = *this - y;
	}
	Z operator*(ll y) const {
		return Z(x * y);
	}
	Z &operator*=(ll y) {
		return *this = *this * y;
	}
	Z operator/(ll y) const {
		return *this * Z(y).pow(p - 2);
	}
	Z &operator/=(ll y) const {
		return *this = *this / y;
	}
	Z operator+(const Z &r) const {
		return *this + r.x;
	}
	Z &operator+=(const Z &r) {
		return *this += r.x;
	}
	Z operator-(const Z &r) const {
		return *this - r.x;
	}
	Z &operator-=(const Z &r) {
		return *this -= r.x;
	}
	Z operator*(const Z &r) const {
		return *this * r.x;
	}
	Z &operator*=(const Z &r) {
		return *this *= r.x;
	}
	Z operator/(const Z &r) const {
		return *this / r.x;
	}
	Z &operator/=(const Z &r) {
		return *this /= r.x;
	}
	Z pow(int i) {
		if (i == 0) return Z(1);
		if (i % 2) return *this * pow(i - 1);
		Z tmp = pow(i / 2);
		return tmp * tmp;
	}
	ll get() {
		return x;
	}
	friend istream &operator>>(istream &istr, Z &z) {
		return istr >> z.x;
	}
	friend ostream &operator<<(ostream &ostr, const Z &z) {
		return ostr << z.x;
	}
};

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

	int N;
	cin >> N;
	vector<ll> A(N);
	ll num[60] = { 0 };
	REP(i, N) {
		cin >> A[i];
		REP(j, 60) {
			num[j] += A[i] >> j & 1;
		}
	}
	Z<> res = 0;
	REP(j, 60) {
		res += Z<>(1LL << j) * num[j] * (N - num[j]);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.math.BigDecimal;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		ArrayList<Data> list;
		while(true) {
			list = new ArrayList<Data>(5000);
			for(int i = 0; i < 5000; i++) {
				list.add(new Data(i+1,0,-1));
			}
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			int count = 0;
			for(int i = 0; i < n; i++) {
				int id = stdIn.nextInt();
				long v = stdIn.nextInt();
				long s = stdIn.nextInt();
				if(list.get(id).number == -1) {
					list.set(id,new Data(id,v*s,count++));
				}
				else {
					Data k = list.get(id);
					k.addValue(v*s);
					list.set(id, k);
				}
			}
			Collections.sort(list,new MyComparator1());
			for(int i = 0; i < list.size(); i++) {
				Data tmp = list.get(i);
				if(tmp.value < 1000000) {
					list.remove(i);
					i--;
					continue;
				}
			}
			Collections.sort(list, new MyComparator2());
			if(list.isEmpty()) {
				System.out.println("NA");
			}
			for(int i = 0; i < list.size(); i++) {
				Data tmp = list.get(i);
				System.out.println(tmp.id);
			}
		}
	}
	
}

class Data {
	public int id;
	public long value;
	public int number;
	Data(int i, long v, int n) {
		id = i;
		value = v;
		number = n;
	}
	public void addValue(long v) {
		value += v;
	}

	
}

class MyComparator1 implements Comparator<Data> {

	public int compare(Data o1, Data o2) {
		if(o1.value < o2.value) {
			return 1;
		}
		else if(o1.value > o2.value) {
			return -1;
		}
		
		return 0;
	}
	
}

class MyComparator2 implements Comparator<Data> {

	public int compare(Data o1, Data o2) {
		if(o1.number < o2.number) {
			return -1;
		}
		else if(o1.number > o2.number) {
			return 1;
		}
		return 0;
	}
	
}

Measured memory_bytes: 39632
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
const int mod=1e9+7;
const int inf=1e17+10;
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define si(a) a.size()
#define pii pair<int,int>
using namespace std;
//#if !defined(ONLINE_JUDGE)
//#include "debugging.h"
//#endif



int32_t main() {
   std::ios::sync_with_stdio(false);cin.tie(NULL);
   int n,r,b;
   cin>>n>>b>>r;
   int s=r+b;
   int x=n/s;
   int ans=x*b;
   x=n%s;
   ans+=min(x,b);
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256