akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int n;

set<int> ans;

bool check(int i) {
    int a = n;
    while(a%i == 0) {
        a /= i;
    }
    a %= i;
    return a == 1;
}

void solve() {
    //mod is 1
    int a = n-1;
    ans.insert(a);
    for(int i = 2; i*i <= a; ++i) {
        if(a%i == 0) {
            ans.insert(i);
            ans.insert(a/i);
        }
    }

    //divisor
    ans.insert(n);
    for(int i = 2; i*i <= n; ++i) {
        if(check(i)) {
            ans.insert(i);
        }
    }
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    if(n == 2) {
        cout << 1 << '\n';
        return 0;
    }

    solve();

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int K; cin >> K;
    for (int i = 0; i < K; i++) cout << "ACL";
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3612
from collections import deque
s = deque(list(input()))   # deque オブジェクトを取得

ans=0
cach=-1
while True:
    if s==deque([]):
        break
    else:
        tmp=s.popleft()

    if tmp != cach:
        ans +=1
        cach=tmp
    else:
        if s!=deque([]):
            tmp+=s.popleft()
            ans +=1
            cach=tmp

print(ans)


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

int main()
{
    LL n,total,i,j,k,temp;
    cin>>n>>total;
    LL weight[n+1],value[n+1];
   // LL dp[total+1][n+1];
    LL maxima[total+1][n+1];
    for(i=1;i<=n;i++)
    {
        cin>>weight[i]>>value[i];
        //cout<<i<<" "<<weight[i]<<" "<<value[i]<<endl;
    }  

    for(i=0;i<=total;i++)
    {
        for(j=0;j<=n;j++)
        {
            //dp[i][j]=0;
            maxima[i][j]=0;     
        }
    }
    for(i=1;i<=total;i++)
    {
        for(j=1;j<=n;j++)
        {
            temp=0;
            if(i-weight[j]>=0)
            {
                temp=value[j]+maxima[i-weight[j]][j-1];                 
            }          
            maxima[i][j]=max(maxima[i][j-1],temp); 
        }
    } 
    cout<<maxima[total][n]<<endl;    
}

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/************************************************************************************************************************************************/
void solve(){
    int X, Y;
    cin >> X >> Y;
    if(Y >= X*2 && Y <= X*4 && Y%2 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3644
from itertools import product
from collections import defaultdict
n = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


d = defaultdict(lambda: 0)
for i in range(2, n+1):
    a = factorization(i)
    for aa, k in a:
        d[aa] += k
t = [v for v in d.values()]


def num(t, a):
    return sum([1 if tt >= a-1 else 0 for tt in t])


print(num(t, 75) +
      num(t, 25)*(num(t, 3)-1) +
      num(t, 15)*(num(t, 5)-1) +
      num(t, 5)*(num(t, 5)-1)*(num(t, 3)-2)//2)


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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    // cout.precision(20);
    ll n,i,w,j;
    cin>>n>>w;
    
    ll v[n],p[n],tt=0;
    
    for(i=0;i<n;i++)
    {
        cin>>v[i]>>p[i];
        tt+=p[i];
    }
    
    ll dp[n+1][tt+1];
    
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=tt;j++)
        {
            if(j==0)
                dp[i][j]=0;
            else if(i==0)
                dp[i][j]=INT_MAX;
                
            else
            {
                if(j<p[i-1])
                    dp[i][j]=dp[i-1][j];
                else
                {
                    if(dp[i-1][j-p[i-1]]!=INT_MAX)
                        dp[i][j]=min(dp[i-1][j],v[i-1]+dp[i-1][j-p[i-1]]);
                    else
                        dp[i][j]=dp[i-1][j];
                }
            }
        }
    }
    ll ans=0;
    // for(i=0;i<=n;i++)
    // {
    //     for(j=0;j<=tt;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    for(i=tt;i>=0;i--)
    {
        if(dp[n][i]<=w)
        {
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 79232
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	string S; cin >> S;

	for (int i = 0; i < (S.length()-1)/2; i++) {
		if (S[i] != S[S.length() - i - 1]) {
			cout << "No" << endl; 
			return 0; 
		}
	}

	for (int i = 0; i < (S.length() - 1) / 4; i++) {
		if (S[i] != S[(S.length() - 1) / 2 - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

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

int main(void){
    int N;
    cin >> N;
    set<string> gacha;
    
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        gacha.insert(S);
    }
    
    cout << gacha.size() << endl;
}

Measured memory_bytes: 19180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


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

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll count=0;
    bool flag=false;
    string s,t;
    cin>>s>>t;
    while(count!=s.size()){
        if(s==t){
            cout<<"Yes"<<endl;
            exit(0); 
        }
        else{
            string a=s.substr(s.size()-1,1);
            s.insert(0,a);
            s.erase(s.end()-1);
            //cout<<s<<endl;
            count++;
        }
    }
    cout<<"No"<<endl;
    
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include <climits>
using namespace std;

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

//const int MOD=1e9+7;
const int INF=INT_MAX/2;

int n1=0,n2=0;
int N;
vector<int> G[1000000+5];
int vis[100005]; 

//vector<int> bfs(int N,vector<vector<int>>&G,int s){
vector<int> bfs(int N,int s){
	vector<int> d(N,INF); d[s]=0;
	queue<int> q; q.push(s);
	while(q.size()){
		int u=q.front();
		q.pop();
		/*for(int v: G[u]){
			if(d[v]>d[u]+1){
				d[v]=d[u]+1;
				q.push(v);
			}
		}*/
	for(int i=0;i<(int)G[u].size();i++){
		//printf("u=%d\n",u);
		int v=G[u][i];
		if(d[v]>d[u]+1){
			d[v]=d[u]+1;
		q.push(v); 
	}
	}
}
return d;
} 

int main(){
	//int i; 
	//cin>>N;
	scanf("%d",&N);
	//vector<vector<int>> G(N);
	for(int i=0;i<N-1;i++){
		int u,v;
		scanf("%d%d",&u,&v);
	u--,v--;
	G[u].push_back(v),G[v].push_back(u);
	}
	//vector<int> d1=bfs(N,G,0);
	//vector<int> d2=bfs(N,G,N-1);
	vector<int> d1=bfs(N,0);
	vector<int> d2=bfs(N,N-1);
	//printf("N=%d\n",N);
	for(int u=0;u<N;u++){
		//printf("d1[%d]=%d\n",u,d1[u]); 
		//printf("d2[%d]=%d\n",u,d2[u]);
	if(d1[u]<=d2[u])
	n1++;
	else n2++;
	}
	//printf("n1=%d\n",n1);
	//printf("n2=%d\n",n2);
	if(n1>n2)
	printf("Fennec\n");
	else
	printf("Snuke\n");
	return 0;
}
/*input1:
7
3 6
1 2
3 1
7 4
5 7
1 4
output1:
Fennec
*/
  
/*inout2:
4
1 4
4 2
2 3
output2:
Snuke  
*/ 

Measured memory_bytes: 27776
#include <bits/stdc++.h>
#define _itr ::iterator
#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define ford(i, x, y) for (ll i = x; i > y; --i)
#define forne(i, x, y) for (ll i = x; i <= y; ++i)
#define forde(i, x, y) for (ll i = x; i >= y; --i)
#define rd(x) cin >> x; cin.ignore();
#define rdstr(x) getline(cin, x);
#define rdarr(x, y) for (ll i = 0; i < y; ++i) cin >> x[i];
#define rdmtr(x, y, z) for (ll i = 0; i < y; ++i) for (ll j = 0; j < z; ++j) cin >> x[i][j];
#define pb push_back

#define X first
#define Y second

#define MaxN 3007
#define MaxM 507
#define Mdl 1000000007

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef ll arr[MaxN];

ll REPIT = 1;

const bool MQ = false;
ll R, C, k;
ll so[MaxN][MaxN];
ll dp[MaxN][MaxN][4];

void Solve()
{
    cin >> R >> C >> k;
    forn(i, 0, R) fill(so[i], so[i] + C, 0);
    forn(i, 0, k)
    {
        ll u, v, w;
        cin >> u >> v >> w;
        so[--u][--v] = w;
    }
    forn(i, 0, R)
    forn(j, 0, C)
    {
        forn(a, 0, 4) dp[i][j][a] = 0;
        if (i > 0)
        {
            forn(a, 0, 4)
            {
                dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][a]);
                dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][a] + so[i][j]);
            }
        }
        if (j > 0)
        {
            forn(a, 0, 4)
            {
                dp[i][j][a] = max(dp[i][j][a], dp[i][j - 1][a]);
                if (a > 0) dp[i][j][a] = max(dp[i][j][a], dp[i][j - 1][a - 1] + so[i][j]);
            }
        }
        if (i == 0 && j == 0)
        {
            dp[0][0][1] = so[0][0];
        }
    }
//    forn(a, 0, 4)
//    {
//        forn(i, 0, R)
//        {
//            forn(j, 0, C) cout << dp[i][j][a] << ' ';
//            cout << '\n';
//        }
//        cout << "\n\n";
//    }
    ll res = dp[R - 1][C - 1][0];
    forn(i, 1, 4) res = max(res, dp[R - 1][C - 1][i]);
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef OFFLINE
    freopen("INPUT.inp", "r", stdin);
    #endif
    if (MQ == true)
    {
        rd(REPIT);
    }
    while (REPIT--) Solve();
    cout.flush();
    #ifdef OFFLINE
    fclose(stdin);
    #endif
}


Measured memory_bytes: 355732
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

  for (int i = 1; i <= 9; ++i)
  {
    if (N <= i * 111)
    {
      cout << i * 111 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int n;
  cin>>n;
  long long x=0;
  for(int i=1;i<=n;i++) {
    if(i%3!=0 && i%5!=0) {
      x+=i;
    }
  }
  cout<<x;
  return 0;
}

Measured memory_bytes: 3676
def GCD(a,b): 
  if a<b:
    a,b = b,a

  r = a % b
  
  while r!=0:
    a = b
    b = r
    r = a % b
 
  return b

N, X = map(int, input().split())

T = list(map(int, input().split()))
for i in range(N):
  T[i] = abs(T[i] - X)

ans = T[0]
for i in range(1,N):
  ans = GCD(ans, T[i])
  
print(ans)


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

using namespace std;

#define ll long long
#define ld long double

int main()
{
	ll a,b;
	cin>>a>>b;

	if(a >= 13)
	{
		cout<<b<<endl;
	}
	else if(a >= 6 && a <= 12)
	{
		cout<<b/2<<endl;
	}
	else
	{
		cout<<0<<endl;
	}

}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,d,cmp,cmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("357"),s,co;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    s=to_string(n);
    rrep(i,3,Size(s)+1){
        vector<ll> p(i);
        rep(j,i-2){
            rep(k,i-1){
                cnt=0;
              if(i-j-k-2<=0)continue;
                rep(l,j+1)p[cnt++]=3;
                rep(l,k+1)p[cnt++]=5;
                rep(l,i-j-k-2)p[cnt++]=7;
                do{
                    ll cntt=1;
                    rep(i,cnt-1)cntt*=10;
                    pos=0;
                    rep(i,cnt){
                        pos+=p[i]*cntt;
                        cntt/=10;
                    }
                    if(pos<=n)ans++;
                }while(next_permutation(all(p)));
            }
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 1e5 + 5;

vector<int> g[N];
vector<int> ans[N];
bool tag[N];
int dfn[N];

void dfs(int u, int p = 0) {
    static int tme = 0;
    dfn[u] = ++tme;
    for (int v : g[u]) {
        if (v == p) continue;
        if (dfn[v]) {
            if (dfn[v] < dfn[u]) {
                tag[u] ^= 1;
                ans[u].emplace_back(v);
            }
        } else {
            dfs(v, u);
        }
    }
    if (p) {
        if (tag[u]) {
            ans[u].emplace_back(p);
        } else {
            ans[p].emplace_back(u);
            tag[p] ^= 1;
        }
    } else {
        assert(!tag[u]);
    }
}

int main() {
    int n = read();
    int m = read();
    if (m & 1) {
        return puts("-1"), 0;
    }

    while (m--) {
        int u = read(), v = read();
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    dfs(1);

    for (int u = 1; u <= n; ++u) {
        for (int v : ans[u]) {
            printf("%d %d\n", u, v);
        }
    }
    return 0;
}

Measured memory_bytes: 18048
#include <iostream>
#include <string>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++ )

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(c >= a && c <= b) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

int N;
int vec[20][20];


//ビットが立っているものは正直者
bool ok(int S){
  REP(i,N){
    if(S &(1<<i)){
      REP(j,N){
        if(vec[i][j]==1){
          if(!(S &(1<<j))) return false;
        }else if(vec[i][j]==0){
          if((S&(1<<j))) return false;
        }
      }
    }
  }
  return true;
}

int main(){
  cin>>N;
  REP(i,N+2){
    REP(j,N+2){
      vec[i][j]=-1;
    }
  }

  REP(i,N){
    int s;
    cin>>s;
    REP(j,s){
      int t,u;
      cin>>t>>u;
      t--;
      vec[i][t]=u;
    }
  }
  int ans=0;
  REP(S,1<<N){
    if(ok(S)){
      ans=max(ans,__builtin_popcount(S));
    }
  }
  cout<<ans<<endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-------------------------------------------------

int t;
ll a, b, c, d;

ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}

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

	cin >> t;
	while(t--) {
		cin >> a >> b >> c >> d;
		if (a < b || d < b) {
			cout << "No" << endl;
			continue;
		}
		if (c >= b - 1) {
			cout << "Yes" << endl;
			continue;
		}
        ll g = gcd(b, d);
		ll l = ((c + 1 - a) % b + b) % b;
		ll r = ((b - a - 1) % b + b) % b;
		if (l <= r) {
			ll tmp = g * (l / g + !!(l % g));
			if (l <= tmp && tmp <= r) cout << "No" << endl;
			else cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> a,b;
  bool p=true;
  int cur=0;
  rep(i,0,s.size()){
    if(s[i]=='F') cur++;
    else{
      if(p){
        a.push_back(cur);
        p=false;
      }
      else{
        b.push_back(cur);
        p=true;
      }
      cur=0;
    }
  }
  if(cur!=0){
    if(p){
      a.push_back(cur);
    }
    else{
      b.push_back(cur);
    }
  }
  bool c[a.size()][16001];
  rep(i,0,16001) c[0][i]=false;
  c[0][8000+a[0]]=true;
  rep(i,0,a.size()-1){
    rep(j,0,16001){
      if(c[i][j]){
        c[i+1][j+a[i+1]]=true;
        c[i+1][j-a[i+1]]=true;
      }
    }
  }
  
  bool d[b.size()+1][16001];
  rep(i,0,16001) d[0][i]=false;
  d[0][8000]=true;
  rep(i,0,b.size()){
    rep(j,0,16001){
      if(d[i][j]){
        d[i+1][j+b[i]]=true;
        d[i+1][j-b[i]]=true;
      }
    }
  }
  
  if(c[a.size()-1][x+8000] && d[b.size()][y+8000]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 121984
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[][] map = new int[M][2];
		for (int m = 0; m < M; m++) {
			int[] tmp = new int[2];
			tmp[0] = sc.nextInt() - 1;
			tmp[1] = sc.nextInt() - 1;
			map[m] = tmp;
		}
		
		Arrays.sort(map, 0, map.length, (tmp1, tmp2) -> { return tmp1[1] - tmp2[1];} );
		
		int left = 0;
		int ans = 0;
		for (int i = 0; i < M; i++) {
			int[] tmp = map[i];
			if (left > tmp[0])
				continue;
			else {
				left = tmp[1];
				ans++;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 95288
#include<stdio.h>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<math.h>
#include<map>
#include<algorithm>
#include<queue>
#include<string>
#include<climits>
#include<bitset>
#include<set>
#include<functional>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	ll n,k;
	cin>>k>>n;
	ll a[n];
	ll minval=k, max=0;
	for(ll i=0;i<n;i++) {
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans = a[n-1]-a[0];
	for(ll i=1;i<n;i++) {
		ans = min(ans,k-a[i]+a[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
int main(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int aa=min(a,b);
    aa+=min(c,d);
    cout<<aa<<endl;





return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int64 Solve() {
  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int64 b = 0;
  for (int i = 2; i < n; i++) {
    b ^= xs[i];
  }

  if (b > xs[0] + xs[1]) return -1;
  if ((xs[0] + xs[1] - b) % 2) return -1;
  int64 base = (xs[0] + xs[1] - b) / 2;
  if (base & b) return -1;
  if (xs[0] < base) return -1;

  int64 a0 = base;
  for (int bit = 40; bit >= 0; bit--) {
    if ((1LL << bit) & b) {
      if (a0 + (1LL << bit) <= xs[0]) {
        a0 += 1LL << bit;
      }
    }
  }
  if (a0 == 0) return -1;
  return xs[0] - a0;
}

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

  cout << Solve() << endl;
}

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

long long n,ans;

struct N {
	long long size,color,sum;
}a[100009];

bool cmp(N a,N b) {
	return a.size<b.size;
}

int main() {
	cin>>n;
	for (int i=1; i<=n; ++i) {
		cin>>a[i].size;
		a[i].color=i;
	}
	sort(a+1,a+n+1,cmp);
	for (int i=1; i<=n; ++i) {
		a[i].sum=a[i-1].sum+a[i].size;
	}
	for (int i=n; i>=1; --i) {
		if (a[i].size<=a[i-1].sum*2)
			++ans;
		else break;
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 5956
N = int(input())

dic = [[] for i in range(N)]
for i in range(N-1):
  inf = input().split()
  u = int(inf[0])
  v = int(inf[1])
  w = int(inf[2])
  dic[u-1] +=[(v-1, w)]
  dic[v-1] +=[(u-1, w)]

dist = [-1]*N
stack = []
stack.append(0)
dist[0] = 0

while stack:
  label = stack.pop(-1)
  for i, c in dic[label]:
    if dist[i] == -1:
      dist[i] = dist[label]+c
      stack += [i]

ls = [0]
print(0)
for i in range(1,N):
  if dist[i]%2==0:
    print(0)
  else:
    print(1)

Measured memory_bytes: 42796
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int A,B,M,x = 1000000,y = 1000000;
  cin >> A >> B >> M;
  vector<int>a(A);
  vector<int>b(B);
  for (int i = 0; i < A; i++) {
    cin >> a.at(i);
    x = min(x,a.at(i));
  }
  for (int i = 0; i < B; i++) {
    cin >> b.at(i);
    y = min(y,b.at(i));
  }
  int ans = x+y;
  for (int i = 0; i < M; i++) {
    int s,t,r;
    cin >> s >> t >> r;
    ans = min(ans, a.at(s-1)+b.at(t-1)-r);
  }
  cout << ans << endl;
}  

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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef long double dd;
typedef pair<ll, ll> pl;

void Solve(ll test_num) {
  (void) test_num;
  ll X, Y, Z;
  cin >> X >> Y >> Z;
  ll N = X + Y + Z;
  vector<ll> A(N), B(N), C(N);
  VERA(i, 0, N) {
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<pl> vals(N); // U=A-C,V=B-C
  VERA(i, 0, N) {
    vals[i] = {A[i] - C[i], B[i] - C[i]};
  }
  sort(vals.begin(), vals.end(),
       [&](pl x, pl y) { return x.first - x.second < y.first - y.second; });
  vector<ll> best(N + 1, 0);
  {
    priority_queue<ll> que;
    ll sum_a = 0;
    ANDY(i, N - 1, -1) {
      que.push(-vals[i].first);
      sum_a += vals[i].first;
      if (que.size() > X) {
        sum_a -= -que.top();
        que.pop();
      }
      best[i] = sum_a;
    }
  }
  priority_queue<ll> que;
  ll sum_b = 0;
  ll res = -(1LL << 60);
  VERA(i, 0, N - X) {
    sum_b += vals[i].second;
    que.push(-vals[i].second);
    if (que.size() > Y) {
      sum_b -= -que.top();
      que.pop();
    }
    if (que.size() == Y)
      res = max(res, sum_b + best[i + 1]);
  }
  VERA(i, 0, N)res += C[i];
  cout << res << endl;
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll tests = 1;
//  cin >> tests;
  VERA(test, 1, tests + 1) {
    Solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}


Measured memory_bytes: 6136
#include <iostream>
#include <math.h>
using namespace std;

double cross(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4) {
	double m;
	m=(x4-x3)*(y2-y1)-(x2-x1)*(y4-y3);
	if (m==0) return -1;
	return ((x1-x3)*(y4-y3)-(x4-x3)*(y1-y3))/m;
 }

int main() {
  double a,s,sx[3],sy[3],ex[3],ey[3],cx[3],cy[3],hx,lx,hy,ly;
  int i,k;
  while(true) {
	lx=ly=9999999; hx=hy=-lx;  
   for (i=0;i<3;i++) {
	      cin >> sx[i] >> sy[i] >> ex[i] >> ey[i];
	      if (sx[i]==0 &&  sy[i]==0 && ex[i]==0 && ey[i]==0) return 0; 
	      }
	   for (i=0;i<3;i++) {
		k=(i+1) % 3;
		s=cross(sx[i],sy[i],ex[i],ey[i],sx[k],sy[k],ex[k],ey[k]);
		cx[i]=sx[i]+s*(ex[i]-sx[i]); cy[i]=sy[i]+s*(ey[i]-sy[i]);
		if (s<0 || s>1 || (cx[i]<sx[k] && cx[i]<ex[k]) || (cx[i]>sx[k] && cx[i]>ex[k]) || (cy[i]<sy[k] && cy[i]<ey[k]) || (cy[i]>sy[k] && cy[i]>ey[k])) break;
		hx=hx<cx[i] ? cx[i]:hx; lx=lx>cx[i] ? cx[i]:lx;
		hy=hy<cy[i] ? cy[i]:hy; ly=ly>cy[i] ? cy[i]:ly;
	}
	if (i!=3) { cout << "kyo" << endl; continue;}
	for (s=0,i=0;i<3;i++) s+=fabs(cx[i]-cx[(i+1) % 3])*fabs(cy[i]-cy[(i+1) % 3]);
	a=(hx-lx)*(hy-ly)-s/2;
	if (a>=1900000) cout << "dai-kichi"; else if (a>=1000000) cout << "chu-kichi";
	else if (a>=100000) cout << "kichi"; else if (a>0) cout << "syo-kichi";
	else cout << "kyo";
	cout << endl; 
 } 
  return 0;
}	

Measured memory_bytes: 1212
import bisect
n = int(input())
a = sorted(list(int(i) for i in input().split()))
minct= 0
ov32 = n-bisect.bisect_left(a,3200)
#400で割る
def calc(n):
    return (n //400)
a2 = list(map(calc, a))
for i in range(8):
 if i in a2:
  minct +=1
minans = 0 

if minct == 0 and ov32>=1:
 minans =1
else:
 minans = minct
if minct+ov32>= 8:
 maxans = minct+ov32
else:
 maxans = minct+ov32
print(*[minans,maxans])

Measured memory_bytes: 3064
// AOJ  0528: Common Sub-String
// 2017.10.a bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 4005

int dp[MAX][MAX];
char s1[MAX], s2[MAX];
int sz1, sz2;

int main()
{
	int i, j, ans;

	while (scanf("%s", s1) == 1) {
		scanf("%s", s2);
		sz1 = strlen(s1), sz2 = strlen(s2);
		memset(dp, 0, sizeof(dp));
        for (ans = 0, i = 0; i < sz1; i++) for (j = 0; j < sz2; j++) {
			if (s1[i] == s2[j]) {
				dp[i+1][j+1] = dp[i][j] + 1;
				if (dp[i+1][j+1] > ans) ans = dp[i+1][j+1];
			} else dp[i+1][j+1] = 0;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 64420
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<int> mountain(10);
    for (int i = 0 ; i < 10 ; i++)
        scanf("%d",&mountain[i]);
    sort(mountain.rbegin(),mountain.rend());
    printf("%d\n%d\n%d\n",mountain[0],mountain[1],mountain[2]);
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;

namespace Atcoder0128_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            int ame = 0;
            int ameMax = 0;
            string[] input2 = Console.ReadLine().Split();
            List<int> a = new List<int>();
            List<int> a2 = new List<int>();

            for (int k = 0; k < n; k++)
            {
                a.Add(int.Parse(input2[k]));
            }

            input2 = Console.ReadLine().Split();

            for (int k = 0; k < n; k++)
            {
                a2.Add(int.Parse(input2[k]));
            }

            for (int i = 0; i < n; i++){
                for (int k = 0; k < i+1; k++){
                    ame += a[k];
                }

                for (int k = i; k < n; k++){
                    ame += a2[k];
                }
                if(ameMax < ame){
                    ameMax = ame;
                }
                ame = 0;
            }
            Console.WriteLine(ameMax);
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  int a, b, c, d, e, f, g, h, i;
  a = N / 100000000;
  b = (N - a * 100000000) / 10000000;
  c = (N - a * 100000000 - b * 10000000) / 1000000;
  d = (N - a * 100000000 - b * 10000000 - c *1000000) / 100000;
  e = (N - a * 100000000 - b * 10000000 - c *1000000 - d * 100000) / 10000;
  f = (N - a * 100000000 - b * 10000000 - c *1000000 - d * 100000 - e * 10000) / 1000;
  g = (N - a * 100000000 - b * 10000000 - c *1000000 - d * 100000 - e * 10000 - f * 1000) / 100;
  h = (N - a * 100000000 - b * 10000000 - c *1000000 - d * 100000 - e * 10000 - f * 1000 - g * 100) / 10;
  i = N - a * 100000000 - b * 10000000 - c *1000000 - d * 100000 - e * 10000 - f * 1000 - g * 100 - h * 10;
  int fx;
  fx = a + b + c + d + e + f + g + h + i;
  if(N % fx == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

total = 0


for i in range(len(A)):
    total += B[A[i]-1]
    if i!=0 and A[i-1]+1 == A[i]:
        total += C[A[i-1]-1]

print(total)

# print(N)
# print(A)
# print(B)
# print(C)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int M = L.at(N - 1);
  int S = 0;
  for (int i = 0; i < N - 1; i++) {
    S += L.at(i);
  }
  if (S > M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
n,k,*a=map(int,open(0).read().split())
for _ in range(k):
 b=[0]*n
 for i,q in enumerate(a):
  b[max(0,i-q)]+=1
  if i+q+1<n:b[i+q+1]-=1
 for i in range(1,n):b[i]+=b[i-1]
 if b==a:break
 a=b[:]
print(*a)

Measured memory_bytes: 171480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long w = sc.nextLong();
		sc.close();

		if (h == 1 || w == 1) {
			print(1);
			return;
		}

		print((h * w + 1) / 2);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 22996
def f(n):
    sum_num = 0
    while n > 0:
        sum_num += n % 10 # 864 -> 4,  86 -> 6 , 8 -> 8
        n //= 10
    return sum_num

n = int(input())
num = f(n)
if n % num == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
N, K = gets.split.map(&:to_i)

h=[]

N.times do |i|
  h[i] = gets.to_i
end

h.sort!

min = 10**9

for i in 0..N-K do
  tmp = h[i+K-1] - h[i]
  min = tmp if min > tmp
end

puts min


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> s(n);
    for(int i=0; i<k; i++){
        int d; cin >> d;
        for(int j=0; j<d; j++){
            int a; cin >> a;
            s[a-1] = 1;
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 0) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3612
N = int(input())
T,A = map(int,input().split())
Heights = list(map(int,input().split()))
sa_list = []
for i in Heights:
    temp = T-i*0.006
    sa = abs(A-temp)
    sa_list.append(sa)
print(sa_list.index(min(sa_list))+1)

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

using namespace std;

typedef long long ll;

int const N = 300 * 1000 + 16;

int n, m;
int a[N];
pair<int,int> q[N];

bool comp(pair<int,int> const& a, pair<int,int> const& b) {
  return (a.second-a.first) < (b.second-b.first);
}

struct bit {
  int fa[N];

  void update(int l, int r) {
    while(l <= m)
      ++fa[l], l += l&-l;

    r++;
    while(r <= m)
      --fa[r], r += r&-r;
  }

  int query(int i) {
    int sum = 0;
    while(i > 0)
      sum += fa[i], i -= i&-i;
    return sum;
  }
} t;

int main() {
  scanf("%d%d", &n, &m);
  for(int i = 0; i < n; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    q[i] = {l, r};
  }

  sort(q, q+n, comp);
  int R = 0;
  for(int i = 1; i <= m; ++i) {
    while(R < n && q[R].second-q[R].first+1 < i) {
      t.update(q[R].first, q[R].second);
      R++;
    }

    int cnt = 0;
    for(int j = i; j <= m; j += i)
      cnt += t.query(j);

    printf("%d\n", cnt+(n-R));
  }
}

Measured memory_bytes: 3712
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
//main function
fn main() {
    let a: i8 = read();
    let b: i8 = read();
    let c: i8 = read();
    if (a==b && b!=c) || (b==c && a!=b) || (a==c && a!=b){
	println!("Yes");
    }else {
	println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#include<bitset>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
    int n,x;
    cin >> n >> x;
    int l[n] = {};
    for(int i=0;i<n;i++)cin >> l[i];
    static int ans = 1;
    int sum = 0;
    for(int i=0;i<n;i++){
sum += l[i];
if(sum <= x)ans++;
else break;
    }
    cout << ans << endl;
    return 0;
}

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



int main() {
 int a,b,c; cin >> a >> b >> c;
 if(a == b && b == c && a % 2 == 0) {
   cout << -1 << endl;
   return 0;
 }

 int ans = 0;
 while(true) { 
   int tempA = a;
   int tempB = b;
   int tempC = c;
   if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
     break;
   } 
   ans ++;
   
   a = (tempB/2) + (tempC/2);
   b = (tempA/2) + (tempC/2);
   c = (tempA/2) + (tempB/2);   
 }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int V,E;
const int VMAX = 1010, EMAX = 2010;
vector<vector<int> > G(VMAX);

bool bfs(int s,vector<int> & route){
  queue<int> que;
  que.push(s);
  vector<bool> used  = vector<bool>(VMAX,false);
  while(!que.empty()){
    int v = que.front();que.pop();
    for(const int& u : G[v]){
      if(!used[u]){
        que.push(u);
        route[u] = v;
      }
      if(u == s)return true;
      used[u] = true;
    }
  }
  return false;
}


int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E;
  rep(e,E){
    int x,y;cin >> x >> y;
    G[x].push_back(y);
  }
  repp(v,1,V+1) sort(all(G[v]));
  int u = 0;
  vector<int> route;
  vector<int> ans(VMAX);
  repp(v,1,V+1){
    route = vector<int>(VMAX,0);
    if(bfs(v,route)){
      vector<int> a;
      a.push_back(v);
      int u = v;
      while(route[u]!=v){
        u = route[u];
        a.push_back(u);
      }
      if(a.size()<ans.size())ans = a;
    }
  }

  if(ans.size()==VMAX) cout << -1 << endl;
  else{
    cout << ans.size() << endl;
    for(const int& x:ans) cout << x << endl;
  }
  return 0;

}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n, h;
  cin >> n >> h;

  vll a(n), b(n);
  REP(i, n)
    cin >> a[i] >> b[i];

  sort(a.begin(), a.end(), [](const ll &x, const ll &y){
      return x > y;
      });
  sort(b.begin(), b.end(), [](const ll &x, const ll &y){
      return x > y;
      });

  ll ans = 0;
  REP(i, n){
    if(h <= 0 || b[i] <= a[0])
      break;

    h -= b[i];
    ans++;
  }


  if(h > 0){
    ans += h/a[0];
    if(h % a[0] != 0)
      ans += 1;
  }

  cout << ans << endl;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

//nの最大値が1e5の時とかは使える
const int MAX = 510000;
const int MOD = 1000000007;

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

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> vec(n+1),sum(n+1);
  rep(i,n+1){
    vec[i] = i;
  }
  ll piv1 = 0;
  ll piv2 = 0;
  rep(i,n+1){
    sum[i] += piv2 - piv1 + 1;
    piv2 += vec[n-i];
    piv1 += vec[i];
    //cout << sum[i] << endl;
  }
  ll ans = 1;
  REP(i,k,n+1){
    ans += sum[i];
    //cout << ans << endl;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6340
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<LLONG> as(N), bs(N), cs(N);
    for (auto &i : as) cin >> i;
    for (auto &i : bs) cin >> i;
    for (auto &i : cs) cin >> i;
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    sort(cs.begin(), cs.end());
    // bNexts[i]：bのi番目を選んだとき利用できるcの総和
    vector<int> bNexts(N);
    for (int i = 0; i < N; ++i)
    {
        // O(NlogN)
        bNexts[i] = N -
            distance(cs.begin(),
                upper_bound(cs.begin(), cs.end(), bs[i]));
    }
    // bSums[i]：i番目以上を選ぶときに利用できるcの総和
    vector<LLONG> bSums(N, 0);
    LLONG sum = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        sum += bNexts[i];
        bSums[i] = sum;
    }
    LLONG ans = 0;
    for (int i = 0; i < N; ++i)
    {
        // O(NlogN)
        int bMin =
            distance(bs.begin(),
                upper_bound(bs.begin(), bs.end(), as[i]));
        if (bMin == N) continue;
        ans += bSums[bMin];
    }
    cout << ans << endl;
}

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

n = int(input())
edges = [[] for _ in range(n)]
edge_list = []

for i in range(n-1):
    a, b = map(int, input().split())
    edge_list.append((a, b))
    edges[a-1].append((b-1, i))
    edges[b-1].append((a-1, i))

num_colors = max(list(map(len, edges)))
edge_colors = [0] * (n-1)


def set_color(current, parent, color):
    next_color = 1
    for node, i in edges[current]:
        if next_color == color:
            next_color += 1
        if node != parent:
            edge_colors[i] = next_color
            set_color(node, current, next_color)
            next_color += 1


set_color(0, -1, 0)
print(num_colors)
for v in edge_colors:
    print(v)

Measured memory_bytes: 112412