akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B && B == C) {
		cout << (A % 2 == 1 ? 0 : -1) << endl;
		return 0;
	}
	int ans = 0;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		ans++;
		int a = (B + C) / 2;
		int c = (A + B) / 2;
		B = (A + C) / 2;
		A = a;
		C = c;
	}
	cout << ans << endl;
}

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

int main() {
	long long int n,ans1=0,ans2=0,msum=0,temp=0;;cin>>n;
  	vector<long long int> a(n);for(int i=0;i<n;i++) cin>>a[i];
  	//最初が正の場合
  	for(int i=0;i<n;i++){
    	temp+=a[i];
        if(i%2==0 && temp<=0){
        	ans1+=1-temp;
          	temp=1;
        }
      	if(i%2==1 && temp>=0){
        	ans1+=temp+1;
          	temp=-1;
        }
    }  	
  	
  	temp=0;
  	//最初が負の場合
  	for(int i=0;i<n;i++){
    	temp+=a[i];
        if(i%2==1 && temp<=0){
        	ans2+=1-temp;
          	temp=1;
        }
      	if(i%2==0 && temp>=0){
        	ans2+=temp+1;
          	temp=-1;
        }
    }
  cout<<(min(ans1,ans2))<<endl;
}


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

string solve() {
    ll K;
    string S;
    cin >> K >> S;
    if ( S.size() <= K ) return S;
    string ans(S.substr(0,K));
    ans.append("...");
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

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

bool s[200050];
bool t[200050];
set<pair<int, int>> e;
int n, m, a, b;

string f() {
  for (int i = 1; i <= n; ++i)
    if (e.count({1, i}) && e.count({i, n})) return "POSSIBLE";
  return "IMPOSSIBLE";
}

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

    rep(i, m) {
      cin >> a >> b;
      e.insert({a, b});
      e.insert({b, a});
    }

    cout << f() << endl;
    return 0;

    // rep(i, m) {
    //   cin >> a >> b;
    //   if (a == 1) s[b] = true;
    //   if (b == n) t[a] = true;
    // }
    // for (int i = 0; i < 200050; ++i) {
    //   if (s[i] && t[i]) {
    //     cout << "POSSIBLE" << endl;
    //     return 0;
    //   }
    // }
    // cout << "IMPOSSIBLE" << endl;
    // return 0;
  }

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(int argc, char const *argv[]) {
  long long n, m1 = 0, m2 = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(all(a),greater<int>());

  int cnt = 0;
  while (cnt < n) {
    if (a[cnt] == a[cnt + 1]) {
      if (m1 == 0) {
        m1 = a[cnt];
        cnt++;
      } else if (m2 == 0) {
        m2 = a[cnt];
        cnt++;
      }
    }
    cnt++;
  }
  cout << m1 * m2;

  return 0;
}


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

int main()
{
	deque<int> a;
	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int query;
		cin >> query;
		switch (query)
		{
			int d;
		case 0:	
			cin >> d;
			if (d == 0) {
				int x;
				cin >> x;
				a.push_front(x);
			}
			else {
				int x;
				cin >> x;
				a.push_back(x);
			}
			break;
		case 1:
			int p;
			cin >> p;
			cout << a[p] << endl;
			break;
		case 2:
			cin >> d;
			if (d == 0) {
				a.pop_front();
			}
			else {
				a.pop_back();
			}
			break;
		default:
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 4640
#include <iostream>

using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  
  if(a == b){
    for(int i = 0;i < b;i++){
      cout << a;
    }
  }else if(a > b){
    for(int i = 0;i < a;i++){
      cout << b;
    }
  }else{
    for(int i = 0;i < b;i++){
      cout << a;
    }
  }
}

Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_4-B: Binary Search

#include <cstdio>

const int NOT_FOUND = -1;
static int binary_search(const int as[], int f, int t, const int target)
{
  while (f < t) {
    int m = (f+t)/2; // f+(t-f)/2
    if (target < as[m]) {
      t = m;
    } else if (as[m] < target) {
      f = m+1;
    } else { // as[m] == target
      return m;
    }
  }
  return NOT_FOUND;
}

int main()
{
  int n;
  std::scanf("%d", &n);
  int ss[n];
  for (auto i = 0; i < n; ++i) {
    std::scanf("%d", &ss[i]);
  }

  int q;
  std::scanf("%d", &q);
  auto c = 0u;
  for (auto i = 0; i < q; ++i) {
    int t;
    std::scanf("%d", &t);
    auto j = binary_search(ss, 0, n, t);
    if (j != NOT_FOUND) ++c;
  }

  std::printf("%u\n", c);
}

// eof

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, count=0;
  
  cin >> A >> B;
  
  for(int i=A; i<=B; i++){
    if(i/10000 == i%10 && (i%10000)/1000 == (i%100) / 10) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 636
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,K;
ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll p[100010];
int main(){
    cin>>N>>K;
    ll ans=0;
    for(ll i=K;i>=1;i--){
        ll minus=0;
        for(ll j=i*2;j<=K;j+=i){
            minus=(minus+p[j])%MOD;
        }
        p[i]=(modpow(K/i,N,MOD)-minus);
        if(p[i]<0)p[i]+=MOD;
        ans=(ans+i*p[i]%MOD)%MOD;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4364
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    ll n, m, a;
    cin >> n >> m;
    ll res = 0;
    for(int i = 0; i < m; i ++) {
        cin >> a;
        res += a;
        if (res > n) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << n - res << endl;
    return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 505;

int N, M, Q;

int tot[MAXN];
int trains[MAXN][MAXN];
vector<pii> queries[MAXN];
int out[100005];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> N >> M >> Q;

    for(int a = 1; a <= M; a++){
        int l, r;
        cin >> l >> r;
        trains[l][r]++;
    }

    for(int a = 1; a <= Q; a++){
        int p, q;
        cin >> p >> q;
        queries[p].push_back({q, a});
    }

    for(int a = N; a >= 1; a--){
        for(int b = a, accum = 0; b <= N; b++){
            accum += trains[a][b];
            tot[b] += accum;
        }

        for(pii p : queries[a]){
            out[p.second] = tot[p.first];
        }
    }

    for(int a = 1; a <= Q; a++){
        cout << out[a] << "\n";
    }
}


Measured memory_bytes: 3456
N,Y = map(int, input().split())

num10000 = -1
num5000 = -1
num1000 = -1

total = 0

for i in range(0,N+1):
    for j in range(0, N-i+1):
        k = N - i - j
        total = 10000*i + 5000*j + 1000*k
        if total == Y:
            num10000 = i
            num5000 = j
            num1000 = k

print(str(num10000)+' ' +str(num5000) + ' ' +str(num1000))


Measured memory_bytes: 3060
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);

	double x1 = scan.nextDouble();
	double y1 = scan.nextDouble();
	double x2 = scan.nextDouble();
	double y2 = scan.nextDouble();

	double x = Math.abs(x2 - x1);
	double y = Math.abs(y2 - y1);
	
	System.out.println(Math.sqrt(x * x + y * y));


}
}

Measured memory_bytes: 18384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    int x[n];
    for(int i=0;i<n;i++)
        cin >> x[i];
    ll best = x[k-1]-x[0];
    best += min(abs(x[k-1]),abs(x[0]));
    ll curr;
    for(int i=1;i<n;i++){
        if(i+k-1<n){
            curr = x[i+k-1]-x[i];
            curr += min(abs(x[i]),abs(x[i+k-1]));
            best = min(best,curr);
        }
    }
    cout << best;
}

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

int main() {
	int a, b, c;
	char q;
	cin >> a >> q >> b >> q >> c;
	a = 10000 * a + 100 * b + c;
	if (a > 20190430) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
}

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

const ll maxs = 5e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

vector<ll> A[20];

void solve(){
    
    ll n,m,x;
    cin >> n >> m >> x;

    for(ll i=0;i<n;i++){
        ll c;
        cin >> c;
        A[i].pb(c);
        for(ll j=0;j<m;j++){
            ll val;
            cin >> val;
            A[i].pb(val);
        }
    }

    for(ll j=1;j<=m;j++){
        ll sum=0;
        for(ll i=0;i<n;i++){
            sum += A[i][j];
        }
        if(sum < x){
            cout << -1 ;
            return;
        }
    }
    ll ANS = oo;
    ll MAX = (1<<n)-1;
    ll sum;
    for(ll mask=1;mask<=MAX;mask++){
        ll flg=1;
        for(ll j=1;j<=m;j++){
            sum=0;
            ll lvl=0;
            for(ll i=0;i<n;i++){
                if( (mask>>i)&1 ){
                    sum += A[i][0];
                    lvl += A[i][j];
                }
            }
            if(lvl < x){
                flg=0;
                break;
            }
        }
        if(flg){
            ANS = min(ANS , sum);
        }
    }

    cout << ANS << endl;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

public class Main
{

	static int[] dp,a;
	static int n,k;

		
	public static void main(String[] args)throws IOException{

			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String[] s=br.readLine().split(" ");
			n=Integer.parseInt(s[0]);k=Integer.parseInt(s[1]);
			dp=new int[n];a=new int[n];
			s=br.readLine().split(" ");

			for(int i=0;i<n;i++)
				a[i]=Integer.parseInt(s[i]);

			Arrays.fill(dp,2000000000);
			dp[0]=0;
			dp[1]=Math.abs(a[0]-a[1]);

			for(int i=2;i<n;i++)
			{
				for(int j=1;j<=k && (i-j)>=0;j++)
				{
					dp[i]=Math.min(dp[i],Math.abs(a[i]-a[i-j])+dp[i-j]);
				}
			}
			
			System.out.println(dp[n-1]);
			

	}
	
}







Measured memory_bytes: 34072
//
//  main.cpp
//  oct_26
//
//  Created by 田中諒 on 2019/10/26.
//  Copyright © 2019 田中諒. All rights reserved.
//

#include <iostream>
using namespace std;

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    
    if (A[A.length()-1] == B[0] and B[B.length()-1] == C[0]){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back

# define inOut(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
# define RESET(a) memset(a,0,sizeof(a))
# define MEMO(a) memset(a,-1,sizeof(a))
# define DEBUG puts("Debug-Has-Come-Until-Here")


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	cin.tie(NULL);
	
	ll money = 100000;
	int n, i, j;
	scanf("%d", &n);
	for (i=1; i<=n; i++){
		money = money + (money/100 * 5);
		if (money %1000 > 0){
			money += 1000;
			money -= money % 1000;
		}
	}
	printf("%lld\n",money);

	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9+7;

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    
    int r, c;
    cin >> r >> c;
    vector<vector<char>> grid(r, vector<char>(c));
    vector<vector<int>> dp(r, vector<int>(c));

    for(int i=0; i<r; ++i) {
        for(int j=0; j<c; ++j) {
            cin >> grid[i][j];
        }
    }

    dp[0][0] = 1;
    for(int i=0; i<r; ++i) {
        for(int j=0; j<c; ++j) { 
            for(int r2: {i, i+1}) {
                int c2 = j;
                if(r2==i) {
                    c2 = j+1;
                }
                if(r2 < r && c2 < c && grid[r2][c2] == '.') {
                    add_self(dp[r2][c2], dp[i][j]);
                }
            }
        }
    }
    cout << dp[r-1][c-1]<< "\n";
	return 0;
}


Measured memory_bytes: 5248
def main():
    n = input()
    aa = map(int, raw_input().split())
    mod = 10 ** 9 + 7 
    s = 0
    for i in xrange(60):
        c0 = 0
        c1 = 0
        mask = 1 << i
        for a in aa:
            if a & mask:
                c1 += 1
            else:
                c0 += 1
        s = (s + 2 ** i * c0 * c1) % mod
    print s


main()


Measured memory_bytes: 75116
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)
#define END(x) (*(x.end()-1))

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)/b;
}


int main(void){
    ll n,m;
    cin>>n>>m;
    if(2*n>m){
        cout<<m/2;
        return 0;
    }
    ll ans=n;
    m-=2*n;
    ans+=m/4;
    cout<<ans;
}
/*

*/

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long int gw=0, jw=0, total=0;
int ag[9], aj[9];
int table[9][9];
bool flag[9];

void dfs(int n, int sum){
  if( n==9 ){
    total++;
    if( sum > 0 ) gw++;
    else if( sum < 0 ) jw++;
  }
  int nn=n+1;
  for( int i=0;i<9;i++ ){
    if( flag[i] ) continue;
    flag[i] = true;
    dfs(nn, sum + table[n][i]);
    flag[i] = false;
  }
};

int main(){
  int datasetn;
  cin >> datasetn;
  while( datasetn-- ){
    for( int i=0;i<9;i++ )      cin >> ag[i];
    for( int i=0;i<9;i++ )      cin >> aj[i];

    for( int i=0;i<9;i++ ){
      for( int j=0;j<9;j++ ){
	table[i][j] = ag[i] + aj[j];
	if( aj[j] > ag[i] )  table[i][j] *= -1;
      }
    }

    for( int i=0;i<9;i++ )
      flag[i] = false;

    gw=0; jw=0; total=0;
    dfs(0, 0);
    cout << (double)gw/total << " " << (double)jw/total << endl;

  }

  return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<fstream>
#include<queue>
#include<iostream>
#include<cstring>
#define N 100010
using namespace std;
int n,m;
struct rode{
  int y,next;
}e[N<<1]={};
int fl[N]={},len=0;
int a[N]={};
inline int read()
{
	int s = 0, w = 1;
	char c = getchar();
	while ((c<'0' || c>'9') && c != '0')c = getchar();
	if (c == '-')w = -1, c = getchar();
	while (c <= '9'&&c >= '0')s = (s << 3) + (s << 1) + c - '0', c = getchar();
	return s * w;
}
inline void inc(int x,int y)
{
  e[++len].y=y;
  e[len].next=fl[x];
  fl[x]=len;
}
struct que{
  int u,d,c;
}qu[N]={};
int c[N]={};
bool vis[N]={};
int s=0;
void dfs(int u,int v,int d,int co)
{
  if(d==0)return ;
  for(int i=fl[u];i;i=e[i].next)
   {
     int vv=e[i].y;
     if(vis[vv])continue;
     if(c[vv]==0)c[vv]=co,--s;
     if(s==0)return ;
     vis[vv]=1;
     dfs(vv,v,d-1,co);
     vis[vv]=0;
   }
}
int main()
{
  n=read();m=read();
  s=n;
  // for(int i=1;i<=n;++i)a[i]=read(),c[i]=0;
  for(int i=1;i<=m;++i)
  {
    int x=read(),y=read();
    inc(x,y);inc(y,x);
  }
  int q=read();
  for(int i=1;i<=q;++i)qu[i].u=read(),qu[i].d=read(),qu[i].c=read();
  for(int i=q;i>=1;--i)
  {
    int u=qu[i].u,d=qu[i].d,co=qu[i].c;
    if(c[u]==0)c[u]=co,--s;
    if(s==0)break;
    vis[u]=1;
    dfs(u,u,d,co);
    vis[u]=0;
  }
  for(int i=1;i<=n;++i)printf("%d\n",c[i]);
  return 0;
}


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

char sw(char test, char before, char now) {
    if ((test == 'o' && now == 'S') || (test == 'x' && now == 'W')) {
        return before;
    } else {
        return before == 'S' ? 'W' : 'S';
    }
}

string candidate(string s, char i0, char i1) {
    string res(s.length(), ' ');
    res[0] = i0, res[1] = i1;
    for (int i = 2; i < s.length(); i++) {
        res[i] = sw(s[i - 1], res[i - 2], res[i - 1]);
    }
    return res;
}

bool isVarid(string s, string cand) {
    return cand == candidate(s + s, cand[0], cand[1]).substr(s.length());
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    string SS = candidate(s, 'S', 'S');
    if (isVarid(s, SS)) {
        cout << SS << endl;
        return 0;
    }
    string SW = candidate(s, 'S', 'W');
    if (isVarid(s, SW)) {
        cout << SW << endl;
        return 0;
    }
    string WS = candidate(s, 'W', 'S');
    if (isVarid(s, WS)) {
        cout << WS << endl;
        return 0;
    }
    string WW = candidate(s, 'W', 'W');
    if (isVarid(s, WW)) {
        cout << WW << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1304
#define SORT(v) sort(v.begin(), v.end())
#include "iostream"
#include "map"
#include "vector"
#include <stack>
#include "cstdlib"
#include <algorithm>
#include <cstdarg>
// #include "ane.cpp"

#define INF (int)1e9
#define NMAX 200005
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> P;

int N,M,dp[NMAX][MMAX] = {};
string s;

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

int ans = 0;

void solve(){
    // 解答アルゴリズム
    int from, to;
    for (int i = 0; i < N; ++i)
    {
        if (s[i] == 'A')
        {
            from = i;
            break;
        }
    }
    for (int i = N-1; i >= 0; --i)
    {
        if (s[i] == 'Z')
        {
            to = i;
            break;
        }
    }
    ans = to - from + 1;
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    cout << ans << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);

    Fill(dp, -1);

    cin >> s;
    N = s.size();
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 156992
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){ 
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
vector<vector<int>>gr;
int dp[100005];
int dfs(int node){
	if (!sz(gr[node]))
		return 0;
	int &ret = dp[node];
	if (~ret)
		return ret;
	for (auto child : gr[node]){
		ret = max(ret, dfs(child) + 1);
	}
	return ret;
}
int main(){
	K_K();
	int n, m;
	cin >> n >> m;
	gr.resize(n + 1);
	clr(dp, -1);
	for (int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		gr[u].push_back(v);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++){
		dfs(i);
		ans = max(ans, dp[i]);
	}
	cout << ans;
}

Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    vector<pair<char, char>> v(Q);
    for(int i=0; i<Q; ++i){
        char t, d; cin >> t >> d;
        v[Q-i-1]=make_pair(t, d);
    }
    int le=-1, ri=N;
    for(int i=0; i<Q; ++i){
        if(le<N) if(S[le+1]==v[i].first && v[i].second=='L') ++le;
        if(le>-1) if(S[le]==v[i].first && v[i].second=='R') --le;
        if(ri<N) if(S[ri]==v[i].first && v[i].second=='L') ++ri;
        if(ri>0) if(S[ri-1]==v[i].first && v[i].second=='R') --ri;
    }
    cout << max(0, ri-le-1) << endl;
    return 0;
}


Measured memory_bytes: 900
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 100010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int used[maxn];
void solve(int x,int las)
{
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        solve(to[i],x);
    }
    if(!used[x])
    {
        if(used[las])
        {
            puts("First");
            exit(0);
        }
        used[x]=used[las]=1;
    }
}
int main()
{
    n=read();
    for(int i=1;i<n;i++)
    {
        int q=read(),w=read();
        add(q,w);
        add(w,q);
    }
    used[0]=1;
    solve(1,0);
    puts("Second");
    return 0;
}

Measured memory_bytes: 2560
n, m = list(map(int, input().split()))
a = []
for i in range(n) :
    a.extend(list(map(int, input().split()))[1:])
b = []
for i in range(1, m + 1) :
    if a.count(i) == n :
        b.append(i)
print(len(b))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
string str;
int main(void){
    // Your code here!
    cin >> str;
    if (str[0] == str[1] && str[1] == str[2]) cout << "Yes" << endl;
    else if (str[1] == str[2] && str[2] == str[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
string s;

int main() {
	cin >> s;
	if (s == "ABC")
		puts("ARC");
	else
		puts("ABC");

	return 0;
}

Measured memory_bytes: 3556
#include <stdio.h>
#include <stdlib.h>
#define STRLEN 12

typedef struct node{
  int exist;
  struct node *a;
  struct node *c;
  struct node *g;
  struct node *t;
}Node;

Node* create_node(){
  Node * node = ( Node * ) malloc ( sizeof( Node ) );
  node -> exist = 0;
  node -> a = NULL;
  node -> c = NULL;
  node -> g = NULL;
  node -> t = NULL;
  return node;
}

void insert( Node *node, char *str ){
  switch( str[ 0 ] ){
  case '\0':
    node -> exist = 1;
    return;
  case 'A':
    if( node -> a == NULL ) node -> a = create_node();
    insert( node -> a, str + 1 );
    return;
  case 'C':
    if( node -> c == NULL ) node -> c = create_node();
    insert( node -> c, str + 1 );
    return;
  case 'G':
    if( node -> g == NULL ) node -> g = create_node();
    insert( node -> g, str + 1 );
    return;
  case 'T':
    if( node -> t == NULL ) node -> t = create_node();
    insert( node -> t, str + 1 );
    return;
  }
  printf("error\n");
  return;
}


int find( Node * node, char *str ){
  if( node == NULL ) return 0;
  switch( str[0] ){
  case '\0':
    return node -> exist;
  case 'A':
    return find( node -> a, str + 1 );
  case 'C':
    return find( node -> c, str + 1 );
  case 'G':
    return find( node -> g, str + 1 );
  case 'T':
    return find( node -> t, str + 1 );
  }
  printf("error\n");
  return 0;
}

void kill( Node * node ){
  if( node == NULL ) return;
  if( node -> a != NULL ) kill( node -> a );
  if( node -> c != NULL ) kill( node -> c );
  if( node -> g != NULL ) kill( node -> g );
  if( node -> t != NULL ) kill( node -> t );
  free( node );
}


int main( void ){
  int n;
  scanf("%d\n", &n );
  char op[ 10 ], str[ STRLEN + 1 ];
  Node *head = create_node();
  for( int i = 0; i < n; i ++ ){
    scanf("%s %s", op, str );
    if( op[ 0 ] == 'i' )insert( head, str );
    else {
      if( find( head, str ) ) printf("yes\n", str );
      else printf("no\n", str);
    }
  }
  kill( head );
  return 0;
}


Measured memory_bytes: 18048
N=int(input())
wa=[] # 既に出たワード
wp="" # 前のワード
NGflag=False # だめフラグ

# 各ワードについて
for _ in range(N):
    w=input() # 現在のワード

    if wp!="": # 2回目以降の場合
        if wp[-1]!=w[0] or (w in wa): # しりを取っていないか、既に出たワードの場合
            NGflag=True
            break

    wa.append(w) # 既に出たワードのリストに追加
    wp=w # 次は今のワードを見る

if NGflag==False: # ルールを守れたなら
    print("Yes")
else: # 守れなかった。。。
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i;i<s.size();i++){
	if(s[i]!=t[i]){
      count++;
    }    
  }
  cout<<count<<endl;

}

Measured memory_bytes: 3852
import sys

#+++++
		
def main():
	a,b = map(int, input().split())
	ans=max(a+b,a-b,a*b)
	print(ans)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;

int main()
{
	IOS;
	string a="Christmas";
	string b="Eve";
	int d;
	cin>>d;
	int num2=25-d;
	cout<<a;
	forn(i,num2){
		cout<<" "<<b;
	}
}

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

vector<int64_t> sheets(50);
vector<int64_t> patties(50);

int64_t f(int64_t n, int64_t x)
{
  if (n == 0) {
    return x <= 0 ? 0 : 1;
  } else if (x <= sheets[n - 1] + 1) {
    return f(n - 1, x - 1);
  } else {
    return patties[n - 1] + 1 + f(n - 1, x - 2 - sheets[n - 1]);
  }
}

int main()
{
  int64_t n, x;
  cin >> n >> x;
  sheets[0] = 1;
  patties[0] = 1;
  for (auto i = 1; i < n; i++) {
    sheets[i] = sheets[i - 1] * 2 + 3;
    patties[i] = patties[i - 1] * 2 + 1;
  }
  cout << f(n, x) << endl;
}


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

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2612
#include <cstdio>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 605;

int N, K, J[MN], G[MN], f[MN][MN], Ans;

int main() {
	scanf("%d%d", &N, &K), N <<= 1, G[0] = 1;
	for (int i = 2; i <= N; i += 2) G[i] = (LL)G[i - 2] * (i - 1) % Mod;
	for (int i = 1, x, y; i <= K; ++i) scanf("%d%d", &x, &y), J[x] = y, J[y] = x;
	for (int i = 1; i <= N; ++i)
		for (int j = i + 1; j <= N; j += 2) {
			int ok = 1, c = j - i + 1;
			for (int k = i; k <= j; ++k) if (J[k] && (--c, J[k] < i || J[k] > j)) ok = 0;
			if (!ok) continue;
			f[i][j] = G[c];
			for (int k = j, d = 0; k > i; --k)
				d += !J[k], f[i][j] = (f[i][j] - (LL)f[i][k - 1] * G[d]) % Mod;
			Ans = (Ans + (LL)f[i][j] * G[N - 2 * K - c]) % Mod;
		}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 1536
n=int(input())
lists=[]
lists1=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append((a+b,a,b))
listed=sorted(lists,key=lambda x:x[0],reverse=True)

ans=0
for n in range(n):
    if n%2==0:
        ans+=listed[n][1]
    
    elif n%2!=0:
        ans-=listed[n][2]
print(ans)
    
    

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;cin>>n;
    vc<string> s(n);
    vi t(n);
    rep(i,n)cin>>s[i]>>t[i];
    string x;
    cin>>x;

    int ans=0,tmp=0;
    rep(i,n){
        ans+=tmp*t[i];
        if(s[i]==x)tmp=1;
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
#print(n,k,q)
l = [0] * n
#print(l)
katen = []
my_append = katen.append
for i in range(q):
    my_append(int(input()))
#print(katen)

    
for j in katen:
    l[j-1] += 1 

    
#print(l)

for y in range(n):
    if l[y] > q-k:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8592
X = int(input())

if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
elif X < 2000:
    print(1)

Measured memory_bytes: 61592
// <--sbhmsh-- Shubham Jaiswal-->//

  #include <bits/stdc++.h>
  #define FASTIO std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  using namespace std;
  #define endl '\n'
  #define deb cout<<"sab_badhiya"<<endl;
  typedef long long int ll;
  // const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
  const long INF = 2000 * 1000 * 1000 + 7;

  int main() {
    FASTIO
    double n;
    cin >> n;
    double a = n / 3, ans = a * a * a;
    cout << setprecision(10) << fixed << ans << endl;
  }


Measured memory_bytes: 256
n = int(input())
x_list = list(map(int, input().split()))
power_list = [0] * 100
def cost(p, q):
  return (p - q) ** 2
for i in range(100):
  for j in range(n):
    power_list[i] += cost(x_list[j], i)
print(min(power_list))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <array>
#include <map>
#include <set>

using namespace std;

array<array<int64_t, 2001>, 2001> dp;

constexpr int64_t mod = 1000000007;

int64_t comb(int n, int m)
{
    if (dp[n][m] == -1)
    {
        dp[n][m] = comb(n - 1, m) + comb(n - 1, m - 1);
        dp[n][m] %= mod;
    }
    return dp[n][m];
}

int main()
{
    int n, k;
    cin >> n >> k;
    for (auto &v : dp)
    {
        fill(v.begin(), v.end(), -1);
    }

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

    int l = n - k;

    for (int i = 1; i <= k; i++)
    {
        if (i <= l + 1)
        {
            int64_t ret = comb(l + 1, i) * comb(k - 1, i - 1);
            ret %= mod;
            cout << ret << endl;
        }
        else
        {
            cout << 0 << endl;
        }           
    }
}

Measured memory_bytes: 31616
n = int(input())
v = list(map(int , input().split()))

n = len(v)
from collections import defaultdict
c0 = defaultdict(int)
for vi in v[0::2]:
    c0[vi] += 1
c1 = defaultdict(int)
for vi in v[1::2]:
    c1[vi] += 1

sc0 = sorted(c0.items(), key=lambda x: x[1])
sc1 = sorted(c1.items(), key=lambda x: x[1])
#print(n)
#print(sc0)
#print('------------------')
#print(sc1)
if sc0[-1][0] != sc1[-1][0]:
    #print('--1')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])
    exit()
if len(sc0) == 1 and len(sc1) == 1:
    #print('--2')
    print(n//2)
    exit()
if sc0[-1][1] > sc1[-1][1]:
    #print('--3')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    exit()
if sc0[-1][1] < sc1[-1][1]:
    #print('--4')
    print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()
if sc0[-1][1] == sc1[-1][1]:
    if sc0[-2][1] < sc1[-2][1]:
        #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])
        print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    else:
        #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])
        print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()

#(92753, 12393), (2054, 12394), (27775, 12395)
#(55530, 10),    (50652, 12393),   (27775, 12395)

Measured memory_bytes: 20976
#include <cstdio>
#include <cstring>
#include <vector>
 
using namespace std;
 
////////////////////////最大流开始//////////////////////////////////////
#define MAX_V 1000 * 2 + 16
int V;                 // 顶点数
vector<int> G[MAX_V];    // 图的邻接表
int match[MAX_V];      // 所匹配的顶点
bool used[MAX_V];      // DFS中用到的访问标记
 
// 向图中增加一条连接u和v的边
void add_edge(int u, int v)
{
	G[u].push_back(v);
	G[v].push_back(u);
}
 
// 通过DFS寻找增广路
bool dfs(int v)
{
	used[v] = true;
	for (vector<int>::iterator it = G[v].begin(); it != G[v].end(); ++it)
	{
		int u = *it, w = match[u];
		if (w < 0 || !used[w] && dfs(w))
		{
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
 
	return false;
}
 
// 求解二分图的最大匹配
int bipartite_matching()
{
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < V; ++v)
	{
		if (match[v] < 0)
		{
			memset(used, 0, sizeof(used));
			if (dfs(v))
			{
				++res;
			}
		}
	}
 
	return res;
}
 
void clear()
{
	for (int i = 0; i < V; ++i)
	{
		G[i].clear();
	}
}
 
///////////////////////////////最大流结束/////////////////////////////////////
#define  MAX_N 100
#define  MAX_L 1000
#define  INF 0x3f3f3f3f
 
int distance_matrix[MAX_N][MAX_N];		// 两点间最短路
int p[MAX_L], t[MAX_L];					// 房间编号，时刻
 
bool update_min(int& v, const int& t)
{
	if (t < v)
	{
		v = t;
		return true;
	}
	return false;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	int N, M, L;
	while (scanf("%d%d%d", &N, &M, &L) != EOF && N)
	{
		V = L * 2;
		clear();
		memset(distance_matrix, INF, sizeof(distance_matrix));
 
		for (int _ = 0; _ < M; ++_)
		{
			int u, v, d;
			scanf("%d%d%d", &u, &v, &d);
			distance_matrix[u][v] = distance_matrix[v][u] = d;
		}
 
		for (int i = 0; i < L; ++i)
		{
			scanf("%d%d", p + i, t + i);
		}
 
		// warshall_floyd 两点间最短路
		for (int k = 0; k < N; ++k) 
		{
			distance_matrix[k][k] = 0;
			for (int i = 0; i < N; ++i) 
			{
				for (int j = 0; j < N; ++j) 
				{
					update_min(distance_matrix[i][j], distance_matrix[i][k] + distance_matrix[k][j]);
				}
			}
		}
 
		for (int i = 0; i < L; ++i) 
		{
			for (int j = 0; j < L; ++j)  
			{
				if (i != j && t[i] + distance_matrix[p[i]][p[j]] <= t[j])
				{
					add_edge(2 * i, 2 * j + 1);	// 可以在i之后处理j，连一条边
				}
			}
		}
 
		printf("%d\n", L - bipartite_matching());
	}
	return 0;
}


Measured memory_bytes: 10956
#include<iostream>
#include<string>
using namespace std;
int main()
{

    string s; 
    int c;
    cin >> s;

    if(s[0]=='1') c++;
    if(s[1]=='1') c++;
    if(s[2]=='1') c++;
    cout << c;

    return 0;

}

Measured memory_bytes: 256
// C++(GCC 9.2.1)
// 解き直し.
// https://img.atcoder.jp/arc064/editorial.pdf
// ① 1_27.txt, 1_28.txt, 1_30.txt, 1_31.txt で, WA版となったため, ロジック修正.
// -> d[i] / 2 は d[i] * 500000004 % MOD に 修正 -> 最終的に, もとに戻した.
// ② 1_27.txt で, WA版となったため, ロジック修正.
// -> mPow の 第二引数が, 切り捨てだったものを, 切り上げに修正.
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
const LL MOD = 1e9 + 7;

// 与えられた正の整数のすべての約数を抽出.
// @param X: 約数を抽出したい正の整数.
// @return ret: すべての約数.
vector<LL> div(LL X){
    vector<LL> ret;
    ret.pb(1);
    for(LL d = 2; d * d <= X; d++){
        if(X % d == 0){
            ret.pb(d);
            if(d * d != X) ret.pb(X / d);
        }
    }
    if(X > 1) ret.pb(X);
    sort(all(ret));
    return ret;
}

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

int main(){
    
    // 1. 入力情報.
    LL N, K;
    scanf("%lld %lld", &N, &K);
    
    // 2. 例外.
    if(N == 1){
        printf("%lld\n", K);
        return 0;
    }
    
    // 3. N の 約数.
    vector<LL> d = div(N);
    // for(auto &p : d) printf("%lld ", p);
    // puts("");
    
    // 4. 各最小周期に対応する数列の個数.
    int l = d.size();
    LL num[l];
    memset(num, 0, sizeof(num));
    rep(i, l){
        // num[i] = mPow(K, d[i] / 2);
        // num[i] = mPow(K, d[i] * 500000004 % MOD);
        num[i] = mPow(K, (d[i] + 1) / 2);
        rep(j, i){
            if(d[i] % d[j] == 0) num[i] = (num[i] + MOD - num[j]) % MOD;
        }
    }
    
    // 5. 解答を求めるための数式を計算.
    LL ans = 0, nd;
    rep(i, l){
        // nd = (d[i] & 1) ? d[i] : d[i] / 2;
        // nd = (d[i] & 1) ? d[i] : (d[i] * 500000004 % MOD);
        nd = (d[i] & 1) ? d[i] : d[i] / 2;
        ans += num[i] * nd;
        ans %= MOD;
    }
    
    // 6. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  string hi = "hi";

  string ans = "Yes";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != hi[i % 2]) {
      ans = "No";
    }
  }

  if (s.size() % 2) {
    ans = "No";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	int r;
	if(B/A > C){
		r = C;
	} else {
		r = B/A;
	}
	printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr char sp = ' ';

int N, M, A[100], S;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		S += A[i];
	}
	sort(A, A + N, greater<>());
	if (A[M - 1] * 4 * M >= S) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<21

using namespace std;

int main()
{	
	int n;
	cin >> n;
	
	int a[101][101];
	rep(i,101) rep(j,101) a[i][j] = INF;

	rep(i,n)
	{
		int r,k,temp;
		cin >> r >> k;
			
		rep(j,k)
		{
			cin >> temp;
			a[r-1][temp-1] = 1;
		}
	}

	rep(k,n)
	{
		rep(i,n)
		{
			rep(j,n)
			{
				a[i][j] = min(a[i][j],a[i][k]+a[k][j]);
			}
		}
	}

	int p;
	cin >> p;
	rep(i,p)
	{
		int from,to,cost;
		cin >> from >> to >> cost;
		
		if(cost > a[from-1][to-1])
		{
			cout << a[from-1][to-1] + 1 << endl;
		}
		else
		{
			cout << "NA" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1204
//ABC 165 B
#include<iostream>
using namespace std;

int main(){
    long long int A,b,c,d;
    long double a;
    cin >>a;
    c =0;
    b = 100;
    A = a;
    while(a >= 100){
    a = a / 1.01;
    c++;
    }
    for(int i=0;i < c;i++){
        b = b *1.01;
    }
    if(b < A){
        while(b < A){
            b*=1.01;
            c++;
        }
    }
    cout<< c <<endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;
const int N=3e5;
const int inf=1<<30;
int i,j,k,m,n,x,y,s,t,tot;
int a[N],nxt[N],head[N],edge[N],dis[N][3],ver[N];
bool vis[N];
void add(int x,int y)
{
    ver[++tot]=y,nxt[tot]=head[x],head[x]=tot,edge[tot]=1;
}
int main()
{
    scanf("%d%d",&n,&m);
    tot=1;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        add(x,y);
    }
    scanf("%d%d",&s,&t);
    for(int i=1;i<=n;i++) 
        for(int j=0;j<3;j++)
            dis[i][j]=inf;
    queue<pp> q;
    q.push(pp(s,0));
    dis[s][0]=0;
    while(!q.empty())
    {
        int x=q.front().first;
        int k=q.front().second;
        q.pop();
        for(int i=head[x];i;i=nxt[i])
        {
            if(dis[ver[i]][(k+1)%3]>dis[x][k]+1)
            {
                if(!vis[ver[i]])
                {
                    dis[ver[i]][(k+1)%3]=dis[x][k]+1;
                    q.push(pp(ver[i],(k+1)%3));
                }
            }
        }
    }
    if(dis[t][0]==inf) printf("-1");
    else printf("%d",dis[t][0]/3);
}

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

int main(){
  int N;
  long long T;
  cin>>N>>T;
  long long ans=0;
  long long pre=-LLONG_MAX;
  for(int i=0;i<N;++i){
    long long t;cin>>t;
     if(pre+T<t) ans+=T;
    else ans+=T-((pre+T)-t);
    pre=t;
  }
cout<<ans<<endl;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	string s; cin >> s;
	ll N = (ll)s.size();

	ll cnt{0};
	for (auto &c : s)
		cnt += c == 'p';
	std::cout << N/2 - cnt<< std::endl;
}

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

//all defines
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;


#define pb push_back
#define INF 2e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 2001
#define acmpIN "input.txt"
#define acmpOUT "output.txt"
#define IN "input.in"
#define OUT "output.out"
#define ff first
#define ss second


/**
    CHANGE SIZE!!!
**/

int a, b;



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


    cin >> a >> b;
    b *= 10;
    for(int i = 0; i <= 9; i++)
    {
        int cur = b + i;
        int x = cur * 0.08;
        if(x == a)
        {
            cout << cur;
            return 0;
        }
    }

    cout << -1;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
main()
{
    int a,b,n,i;
    a=b=i=0;
    cin>>n;
    for(;i<n;i++){
        string t,h;
        cin>>t>> h;
        a+=(t>h)*3+(t==h);
        b+=(h>t)*3+(t==h);
    }
    cout<<a<<" "<<b<<endl;
}

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

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

    int x, y, z;
    x = -1;
    y = -1;
    z = -1;

    bool end = false;

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            int k = N - (i + j);

            if (k < 0) {
                continue;
            }

            if (10000 * i + 5000 * j + 1000 * k == Y ) {
                end = true;
                x = i;
                y = j;
                z = k;
                break;
            }

        }

        if (end) {
            break;
        }
    }

    cout << x << " " << y << " " << z << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

int n;

bitset<1005> val;
vector<int> primes;

map<ll, ll> cnt;

void sieve() {
    val.set();
    for (int i = 2; i < 1005; i++) {
        if (val[i]) {
            primes.push_back(i);
            for (int j = i * i; j < 1005; j += i) val[j] = 0;
        }
    }   
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    sieve();
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int num = i;
        for (auto& prime : primes) {
            while (num % prime == 0) {
                cnt[prime]++;
                num /= prime;
            }
        }
        
        if (num != 1) cnt[num]++;
    }
    ll ans = 1;
    for (auto i : cnt) {
        ans = modMul(ans, i.second + 1);
    }
    cout << ans;
    return 0;
}









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

using namespace std;

int main(){
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        sort(a, a+3);
        if(a[0]+a[1]==a[2]){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256