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

bool used[100001];
vector<pair<int, int> > adj[100001];
long long a[100001], e[100001];
int n, m;

void dfs(int n) {
    used[n] = true;
    for (auto x : adj[n]) {
        int v = x.first, s = x.second;
        if (used[v]) continue;
        // s = num(n) + num(v) = a[v] + e[v]*n1 + a[n] + e[n]*n1
        // num(v) = s - num(n) = s - (a[n] + e[n]*n1)
        a[v] = s - a[n]; e[v] = -e[n];
        dfs(v);
    }
}

int main(int argc, char** argv) {
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int from, to, sum; cin >> from >> to >> sum;
        adj[from].push_back(make_pair(to, sum));
        adj[to].push_back(make_pair(from, sum));
    }
    fill(used, used+n+1, false);
    e[1] = 1; a[1] = 0;
    dfs(1);
    // for (int i=1; i<=n; i++) cout << i << ' ' << a[i] << ' ' << e[i] << endl;
    long long n1max = 1<<30, n1min = 1;
    for (int i=1; i<=n; i++) {
        // num(i) = a[i] + e[i]*num(1) >= 1
        if (e[i] == 1) {
            // num(1) >= 1 - a[i]
            n1min = max(n1min, 1 - a[i]);
        } else {
            // num(1) <= a[i] - 1
            n1max = min(n1max, a[i] - 1);
        }
        for (auto x : adj[i]) {
            int j = x.first, s = x.second;
            // s = a[i] + a[j] + (e[i] + e[j]) * num(1)
            if (e[i] == e[j]) {
                // num(1) = (s - a[i] -a[j]) / (e[i] + e[j])
                if ((s - a[i] - a[j]) % 2 != 0) { cout << "0\n"; return 0; }
                long long n1 = (s - a[i] -a[j]) / (e[i] + e[j]);
                n1min = max(n1min, n1);
                n1max = min(n1max, n1);
            } else if (a[i] + a[j] != s) { cout << "0\n"; return 0; }
        }
    }
    cout << max(0LL, n1max - n1min + 1) << endl;
}


Measured memory_bytes: 10496
#include <stdio.h>
#include <math.h>
int main(){
	int k, ans=0, r1, r2, l, m, n, a=1, b=1, c=1;
	scanf("%d", &k);

	while(a <= k){
		while(b <= k){
			while(c <= k){
				if(a==c){
					ans += a;
				}
				else{
					l = a, m = b, n = c;//aとcの最大公約数r1
					r1 = n % l;
					while(r1!=0){
						n = l;
						l = r1;
						r1 = n % l;
					}
					if(a==b || b==c){
						ans = ans + l*3;
					}
					else{
						r2 = m % l;
						while(r2!=0){//r1とbの最大公約数r2
							m = l;
							l = r2;
							r2 = m % l;
						}
						ans = ans + l*6;
					}
				}

				//printf("(%d,%d,%d), l = %d, ans = %d\n", a, b, c, l, ans);
				c++;
			}
			b++;
			c = b;
		}
		a++;
		b = a;
		c = a;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, M;
   cin >> N >> M;
   vector< vector<int> > log;
   // log.resize(M + 1);
   log.resize(100001);
   int a, b;
   for (int i = 0; i < N; i++) {
      cin >> a >> b;
      log[a].push_back(b);
   }

   priority_queue<int> q;
   ll ans = 0;
   for (int i = 1; i <= M; i++) {
      if (log[i].size() != 0) {
         for (auto& tmp : log[i]) {
            // cout << i << " " << tmp << endl;
            q.push(tmp);
         }
      }
      if (!q.empty()) {
         ans += q.top();
         q.pop();
      }
   }
   cout << ans << endl;
   return 0;
}


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

using namespace std;
int main(){
  int a,b,c;
  cin>> a>>b>>c;
  int n;
  cin >> n;
  int x = 0;
  for(int i = 0;i< n;i++)
  {
    
    if(a<b)
    {
      break;
    }
    b*=2;
    x++;
  }
  bool ans = false;
  for(int i = 0;i< n-x;i++)
  {
    c*=2;
    if(a<b&&b<c)
    {
      ans = true;
    }
  }
  if(ans == true)
  {
    cout << "Yes" << endl;
  }
  else 
  {
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,M;
    cin >> N >> M;
    vc<pair<ll, ll>> A;
    rep(i,M){
        ll a, b;
        cin>>a>>b;
        A.eb(a,b);
    }

    sort(all(A), [](auto p1, auto p2) { return p1.second < p2.second; });
    ll cnt = 0, x = -1;
    rep(i,M){
        ll a, b;
        tie(a, b) = A[i];
        if (a < x) continue;
        cnt++;
        x = b;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll a[200005];
ll b[200005];
ll c[200005];
ll h[200005];
ll dp[200005][8] = {};
typedef pair<int, int> P;

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

Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	ll a, b, c; cin >> a >> b >> c;
    if(a+b+1 >= c){
        cout << b+c << endl;
    }
    else cout << b+(a+b+1) << endl;
    system("pause");
}


Measured memory_bytes: 504
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import decimal

def main():
    numbers=[]
    n = int(input())
    t,a = map(int,input().split())
    numbers=list(map(int,input().split()))
    dp=[]
    hensu=decimal.Decimal('0.006')
    for number in numbers:
        tmp=abs(t-number*hensu-a)
        dp.append(tmp)
    answer=dp.index(min(dp))+1
    print(answer)

if __name__=="__main__":
    main()

Measured memory_bytes: 9928
#include<stdio.h>
#include<string.h>

int main(void){
  struct place{
    int x;
    int y;
    char dir;
  } now;
  unsigned int m,n;
  int k;
  char input[32],command[16];

  while(scanf("%u%u%*c",&m,&n) && m && n){
    now=(struct place){1,1,0};
    
    while(scanf("%31[^\n]%*c",input) && strcmp(input,"STOP")){
      if(!strcmp(input,"RIGHT")){
	now.dir+=1;
	now.dir%=4;
	continue;
      }else if(!strcmp(input,"LEFT")){
	now.dir+=3;
	now.dir%=4;
	continue;
      }
      sscanf(input,"%15s%d",command,&k);
      if(!strcmp(command,"BACKWARD")) k*=-1;
      if(now.dir%2){
	k*=(now.dir==3)?-1:1;
	now.x+=k;
	if(now.x<1) now.x=1;
	else if(now.x>m) now.x=m;
      }else{
	k*=(now.dir==2)?-1:1;
	now.y+=k;
	if(now.y<1) now.y=1;
	else if(now.y>n) now.y=n;
      }
    }
    printf("%d %d\n",now.x,now.y);
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {


	int n;

	cin >> n;

	vector<vector<int>> blue(n, vector<int>(2));
	vector<vector<int>> red(n, vector<int>(2));

	REP(i, n) {
		cin >> blue[i][0] >> blue[i][1];
	}
	REP(i, n) {
		cin >> red[i][0] >> red[i][1];
	}

	sort(blue.begin(), blue.end(), [](vector<int> x, vector<int> y) {return x[0] == y[0] ? x[1] > y[1] : x[0] > y[0]; });
	sort(red.begin(), red.end(), [](vector<int> x, vector<int> y) {return x[0] == y[0] ? x[1] > y[1] : x[0] > y[0]; });

	int ans = 0;
	REP(i, n) {
		list<pair<vector<int>, int>> cand;
		REP(j, red.size()) {
			if (blue[i][0] < red[j][0] && blue[i][1] < red[j][1]) {
				cand.push_back(pair<vector<int>, int>(red[j], j));
			}
		}
		if (cand.empty()) continue;
		cand.sort([](pair<vector<int>, int> x, pair<vector<int>, int> y) {return x.first[1] < y.first[1]; });
		red.erase(red.begin() + cand.front().second);
		ans++;
	}

	cout << ans NL;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int cntNum(int l, int r, int div) {
	return (r - 1) / div - (l - 1) / div;
}
int calc(int x) {
	int p = 1;
	int np = 10 * p;
	int ans = 0;
	int cnt(1);
	while (np < x) {
		int fizzbuzz = cntNum(p, np, 15);
		int fizz = cntNum(p, np, 3) - fizzbuzz;
		int buzz = cntNum(p, np, 5) - fizzbuzz;
		int other = (np - p) - (fizzbuzz + fizz + buzz);
		ans += fizzbuzz * 8 + (fizz + buzz) * 4 + other*cnt;
		cnt++;
		p = np;
		np *= 10;
	}
	int fizzbuzz = cntNum(p, x + 1, 15);
	int fizz = cntNum(p, x + 1, 3) - fizzbuzz;
	int buzz = cntNum(p, x + 1, 5) - fizzbuzz;
	int other = (x + 1 - p) - (fizzbuzz + buzz + fizz);
	ans += fizzbuzz * 8 + (fizz + buzz) * 4 + other*cnt;
	return ans;
}
string number = "0123456789";
string trans(int x) {
	if (x % 15 == 0)return "FizzBuzz";
	else if (x % 5 == 0)return "Buzz";
	else if (x % 3 == 0)return "Fizz";
	string ret;
	while (x) {
		ret += number[(int)(x % 10)];
		x /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}
signed main() {
	int n; cin >> n;
	int low(0), high(1ll << 60);
	while (low + 1 < high) {
		int mid = (low + high) / 2;
		if (calc(mid) >= n)high = mid;
		else low = mid;
	}
	n -= calc(low);
	string ans;
	//cout << n << endl;
	rep(i, 0, 20) {
		low++;
		if (low % 15 == 0)ans += "FizzBuzz";
		else if (low % 5 == 0)ans += "Buzz";
		else if (low % 3 == 0)ans += "Fizz";
		else ans += trans(low);
	}
	//cout << ans << endl;
	cout << ans.substr(n-1, 20) << endl;
	return 0;
}

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

int main(void)
{
  int n = 0, min = 0;
  char s[200002], t[200002];
  fgets(s, 200002, stdin);
  fgets(t, 200002, stdin);

  while (s[n] != '\0')
  {
    n++;
  }

  for (int i = 0; i < n - 1; i++)
  {
    if (s[i] != t[i])
    {
      min++;
    }
  }

  printf("%d\n", min);
  return 0;
}

Measured memory_bytes: 1972
H,W,N = map(int, input().split())
s_r, s_c = map(int, input().split())
S = input()
T = input()
Judge = False

S_L, S_R, S_U, S_D = 0, 0, 0, 0
T_L, T_R, T_U, T_D = 0, 0, 0, 0

for x in range(N):
    if S[x] == 'L':
        S_L += 1
        if S_L - T_R - s_c == 0:
            Judge = True
    elif S[x] == 'R':
        S_R += 1
        if s_c + (S_R - T_L) == W+1:
            Judge = True
    elif S[x] == 'U':
        S_U += 1
        if S_U - T_D - s_r == 0:
            Judge = True
    elif S[x] == 'D':
        S_D += 1
        if s_r + (S_D - T_U) == H+1:
            Judge = True
    if T[x] == 'L':
        if S_R - T_L + s_c != 1:
            T_L += 1
    if T[x] == 'R':
        if s_c + (T_R - S_L) != W:
            T_R += 1
    if T[x] == 'U':
        if S_D - T_U + s_r != 1:
            T_U += 1
    if T[x] == 'D':
        if s_r + (T_D - S_U) != H:
            T_D += 1
    
if Judge:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
typedef long long ll;
#define Ls (u << 1)
#define Rs (u << 1 | 1)
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define Rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
using namespace std;

const int N = 2000000 + 7;
int n , k , Ord[N] , Min[N] , Ans[N] , In[N];
vector <int> E[N];
void Update(int u , int l , int r , int Pos , int w) {
	if(l == r) {
		Min[u] = min(Min[u] , w);
		return;
	}
	int Mid = (l + r) >> 1;
	if(Mid >= Pos) Update(Ls , l , Mid , Pos , w);
	else Update(Rs , Mid + 1 , r , Pos , w);
	Min[u] = min(Min[Ls] , Min[Rs]);
}
int Query(int u , int l , int r , int L , int R) {
	if(L > R) return Min[0];
	if(L <= l && R >= r) return Min[u];
	int Mid = (l + r) >> 1 , Ret = Min[0];
	if(Mid >= L) Ret = Query(Ls , l , Mid , L , R);
	if(Mid < R) Ret = min(Ret , Query(Rs , Mid + 1 , r , L , R));
	return Ret;
}
priority_queue <int> Q;
inline void TopSort() {
	int Sz = 0;
	Rep(i , 1 , n) if(!In[i]) Q.push(-i);
	while(!Q.empty()) {
		int u = Q.top(); Q.pop();
		Ans[-u] = inc(Sz);
		for(auto v: E[-u])
			if(!dec(In[v])) Q.push(-v);
	}
}

int main() {
	int x;
	scanf("%d%d" , &n , &k);
	memset(Min , 127 , sizeof(Min));
	Rep(i , 1 , n) scanf("%d" , &x) , Ord[x] = i;
	rep(i , n , 1) {
		int t = Query(1 , 1 , n , max(1 , Ord[i] - k + 1) , Ord[i] - 1);
		if(t != Min[0]) E[Ord[i]].push_back(Ord[t]) , inc(In[Ord[t]]);// , printf("%d %d\n" , Ord[i] , Ord[t]);
		t = Query(1 , 1 , n , Ord[i] + 1 , min(n , Ord[i] + k - 1));
		if(t != Min[0]) E[Ord[i]].push_back(Ord[t]) , inc(In[Ord[t]]);// , printf("%d %d\n" , Ord[i] , Ord[t]);
		Update(1 , 1 , n , Ord[i] , i);
	}
	TopSort();
	Rep(i , 1 , n) printf("%d\n" , Ans[i]);
	return 0;
}

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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef long double ld;

const int N = 1000 * 1000 + 10, mod = 998244353; 

int a[N];

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m, k;
	cin>> n >> m >> k;
	for(int i = 1; i <= n; i++) a[i] = m + 1;
	while(k--)
	{
		int x, y;
		cin>> x >> y;
		a[x] = min(a[x], y);
	}
	int mx = 1;
	for(int i = 2; i <= n; i++)
	{
		if(a[i]<=mx) return cout<< i - 1 << endl, 0;
		if(a[i]>mx+1)
			mx++;
	}
	cout<< n << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int s,ans=1000000 ;
  cin >>s ;
  vector<int> b(1000000);
  vector<int> a(1000000);
  a[0]=s;
  b[a[0]] ++;
  for(int i=0; i<1000000;i++){
    if(a[i]%2 == 0){
      a[i+1] = a[i]/2;
    }
    else{
      a[i+1] = 3*a[i] +1;
    }
    b[a[i+1]] ++;
    if(b[a[i+1]] ==2 ){
      ans = i+1 +1 ;
      break;
    }
    
  }
  cout <<ans <<endl;

    

}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
string s,t;
set<string> se;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int n=read();
	cin>>s;
	se.insert(s);
	for (int i=1; i<n; i++) {
		cin>>t;
		if (s[s.size()-1]!=t[0]) {
			printf("No\n");
			exit(0);
		}
		if (se.find(t)!=se.end()) {
			printf("No\n");
			exit(0);
		}
		se.insert(t);
		s=t;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s;this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s.split("\n")[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s.split("\n")[this._l];this._c=0;this._l++;return l.split(" ").map(this._f)};

// TODO test and remove comment
function main(input) {
  const o = new I(input);

  const arr = Array(4).fill(0);
  for (let i=0;i<3;i++) {
    let a = o.a();
    let b = o.a();
    arr[a-1]++;
    arr[b-1]++;
  }

  if (arr.sort((a,b) => a-b).join(" ") === "1 1 2 2") {
    console.log("YES")
  } else {
    console.log("NO")
  }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
	int x[5] = {};
	cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

	for (int i; i<5; i++) {
		if (x[i] == 0) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3480
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    string s;
    cin >> s;
    REP(i, 3) {
        if(s[i] == s[i+1]) {
            OUT("Bad");
            return 0;
        }
    }
    OUT("Good");
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

ll func(ll y, ll m, ll d)
{
	ll ret = 0;
	ret += (y-1)/3 * (2*39*5+20*10);
	ret += (y-1)%3 * (39*5);
	for(int i=1; i<m; i++){
		if (i%2 == 1 || y%3 == 0){
			ret += 20;
		}else{
			ret += 19;
		}
	}
	ret += d;
	return ret;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n; cin>>n;
	ll ans1000 = func(1000, 1, 1);
	rep(i, n){
		ll y, m, d; cin>>y>>m>>d;
		ll ans = ans1000 - func(y, m, d);
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3204
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(n,d,x);
  Vi A(n);
  Vi DAY(n);
  VIN(A)
  REP(i,n){
    DAY[i] = A[i] + 1;
  }
  c+=n;
  FOR(i,2,d+1){
    REP(j,n){
      if(DAY[j]==i){
        c++;
        DAY[j] += A[j]; 
      }
    }
  }
  OUT(c+x);
}

Measured memory_bytes: 256
A=[]
for i in range(3):
  A.append(list(map(int,input().split())))

N=int(input())
for i in range(N):
  x=int(input())
  for row in A:
    for num in range(len(row)):
      if x==row[num]:
        row[num]=0

for i in A:
  if i==[0,0,0]:
    print("Yes")
    exit(0)
for i in range(3):
  if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
    print("Yes")
    exit(0)
if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    print("Yes")
    exit(0)
if A[2][0]==0 and A[1][1]==0 and A[0][2]==0:
    print("Yes")
    exit(0)
print("No")


Measured memory_bytes: 9176
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		int m=nextInt();
		long ans=(1l*n*(n-1)/2)+(1l*m*(m-1)/2);
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 20948
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

#define MOD (int)(1e9+7)

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

	vector<int>cnt1(2*N, 1e9);
	for(int i=0;i<2*N;i++)cnt1[i]=(S[i]=='B'?1:0);

	ll ans = 1;

	int lc = 0;
	for (int i = 0; i < 2*N; i++)
	{
		if (lc % 2 != cnt1[i] % 2)
		{
			lc++;
		}
		else
		{	
			if (lc%2 == cnt1[i]%2)
			{
				ans *= lc;
				ans %= MOD;
				lc--;
			}
		}
	}

	if(lc != 0)ans = 0;

	for (int i = N; i >= 1; i--)
	{
		ans *= i;
		ans %= MOD;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int cost[10] = { 0,2,5,5,4,5,6,3,7,6 };
int canuse[10]; //rest2->1, rest5->5...

string dp[10100];

int main() {
	int N, M; cin >> N >> M;
	vector<int>A;
	for (int i = 0; i < M; i++) {
		int ips; cin >> ips; A.push_back(ips);
	}
	sort(A.begin(), A.end());
	while (A.size() > 0) {
		canuse[cost[A.front()]] = A.front();
		A.erase(A.begin());
	}
	dp[N] = "o";
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 2; j <= 7; j++) {
			if (canuse[j] == 0)continue;
			else if (dp[i + j] == "")continue;
			else {
				string ads = dp[i+j]+to_string(canuse[j]);
				if (dp[i] == "")dp[i] = ads;
				else {
					if (dp[i].length() < ads.length())dp[i] = ads;
					else if (dp[i].length() == ads.length())dp[i] = max(dp[i], ads);
				}
			}
		}

	}
	dp[0].erase(dp[0].begin());
	print(dp[0]);




	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= -100 || a >= 100) {
        return 0;
    }
    if (b <= -100 || b >= 100) {
        return 0;
    }
    if (c <= -100 || c >= 100) {
        return 0;
    }
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3104
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    int n, d, x, a;

    cin >> n >> d >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        x += 1 + (d - 1) / a;
    }
    cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;

long long lcm(long long x, long long y){
    long long tmp, a, b;
    if (x > y){
        b = x;
        a = y;
    }
    else {
        a = x;
        b = y;
    }
    while (a > 0){
        tmp = a;
        a = b % a;
        b = tmp;
    }
    return x * y / b;
}


int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long c_tmp = b / c - (a - 1) / c;
    long long d_tmp = b / d - (a - 1) / d;
    long long cd_tmp = b / lcm(c, d) - (a - 1) / lcm(c, d);
    cout << b - a + 1 - (c_tmp + d_tmp - cd_tmp) << endl;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int n, a, b; readV(n, a, b);
  writeln(min(n*a, b));
}


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

total_rain = sum(A) // 2

one = total_rain
for j in range(1, N-1, 2):
    one -= A[j]
rain = one*2
ans = str(rain)
prerain = rain

for m in range(1, N):
    rain = (A[m-1] - prerain//2)*2
    ans+=" "
    ans+=str(rain)
    prerain = rain

print(ans)

Measured memory_bytes: 14028
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  vector<int> mochi(N);
  for(int i = 0; i < N; i++){
    cin >> mochi.at(i);
  }
  
  int count = 0, max1 = 0;
  for(int i = 0; i < N; i++){
    int max2 = 0;
    
    for(int j = 0; j < N; j++){
      if(mochi.at(j) > max2){
        max2 = mochi.at(j);
      }
    }
    
    for(int j = 0; j < N; j++){
      if(mochi.at(j) == max2){
        mochi.at(j) = 0;
        count++;
        break;
      }
    }
    
    if(max2 == max1){
      count--;
    }
    
    max1 = max2;
  }
  
  cout << count << endl;
  
}

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

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


/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

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

  for(auto c : s){
    int t = c-'A';
    t = (t+n)%26;
    cout << (char)(t+'A');
  }
  cout << endl;

  return 0;
}



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

int opeA (int num) {
  return 2 * num;
}
  
int opeB (int num, int K) {
  return num + K;
}
  

int main() {
  int N, K, num = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    num = min(opeA(num), opeB(num, K));
  }
  
  cout << num << endl;
  
}
  


      

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

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

    for (int i = 0; i < S.size() - 1; i++) {
        if (S[i] == S[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

n=int(sys.stdin.readline())
for i in range(0,n):
	a=map(int,sys.stdin.readline().split())
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Measured memory_bytes: 4212
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    val (n, m, _k) = readIs()
    val k = _k.toLong()
    val aa = readIs()
    val bb = readIs()

    val at = LongArray(n + 1)
    for (i in 0 until n) at[i + 1] = at[i] + aa[i]
    val bt = LongArray(m + 1)
    for (i in 0 until m) bt[i + 1] = bt[i] + bb[i]

    var x = 0
    var j = m
    for (i in 0..n) {
        if (k < at[i]) break
        while (k < at[i] + bt[j]) j--
        x = max(x, i + j)
    }
    println(x)
}


Measured memory_bytes: 83432
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#define sorn(i, n) char((i == n-1)?'\n':' ')
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

int main(){
    ll n, m, k; cin >> n >> m >> k;
    ll ca[n+1], cb[m+1];
    ca[0] = cb[0] = 0;
    rep(i, n) {
        ll tmp; cin >> tmp;
        ca[i+1] = ca[i] + tmp;
    }
    rep(i, m) {
        ll tmp; cin >> tmp;
        cb[i+1] = cb[i] + tmp;
    }

    ll ans = 0;
    ll bestj = m;
    ll j = m;
    for(ll i = 0; i <= n; i++) {
        if(ca[i] > k) break;
        while(cb[j] > k - ca[i]) j--;
        ans = max(ans, i+j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6704
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int X = sc.nextInt();
	        int Y = sc.nextInt();
	        if(X>Y) {
	        	int tmp=X;
	        	X=Y;Y=X;
	        }
	        
	        int[] ans=new int[N];
	        for(int i=1;i<=N-1;i++) {
	        	for(int j=i+1;j<=N;j++) {
	        		int min=j-i;
	        		min=Math.min(min, Math.abs(X-i)+1+Math.abs(Y-j));
	        		ans[min-1]++;
	        	}
	        }
	        
	        for(int i=0;i<N-1;i++) {
	        	System.out.println(ans[i]);
	        }
	        	        	        
	 }
}


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

#pragma warning(disable:4996)
using namespace std;
using ld=long double;
ld eps=1e-9;

struct Edge {
	int from;
	int to;
	long long int val;
};

struct Status {
	int now;
	int hot;
	int rest;
	long long int cost;
};
bool operator<(const Status&l, const Status&r) {
	return l.cost>r.cost;
}

void add_edge(vector<vector<Edge>>&graph,int a, int b, int c) {
	graph[a].push_back(Edge{ a,b,c });
	graph[b].push_back(Edge{ b,a,c });
}

int main() {
	int X;
	int N,M;cin>>N>>M>>X;
	vector<int>hots(N);
	for (int i = 0; i < N; ++i) {
		cin>>hots[i];
	}
	vector<vector<Edge>>graph(N);
	for (int i = 0; i < M; ++i) {
		int a,b,c;cin>>a>>b>>c;a--;b--;
		add_edge(graph,a,b,c);
	}
	vector<vector<vector<long long int>>>memo(N,
		vector<vector<long long int>>(2,vector<long long int>(X+1,1e18)));

	memo[0][0][X]=0;
	priority_queue<Status>que; 
	que.push(Status{ 0,0,X,0 });
	while (!que.empty()) {
		auto atop(que.top());
		que.pop();
		const int now(atop.now);
		int now_hot=atop.hot;
		const int now_rest=atop.rest;
		const long long int now_cost=atop.cost;

		for (auto e : graph[now]) {
			const int next(e.to);
			int next_hot=hots[next];
			const long long int next_cost = now_cost + e.val;
			if (next_hot==1) {
				const int next_rest=max(0ll,now_rest-e.val);

				if (memo[next][now_hot][next_rest] > next_cost) {
					memo[next][now_hot][next_rest]=next_cost;
					que.push(Status{ next,now_hot,next_rest,next_cost });
				}
			}
			else if (next_hot == 0) {
				if (now_hot == 1&&(now_rest-e.val>0)) {

				}
				else {
					if (memo[next][0][X] > next_cost) {
						memo[next][0][X]=next_cost;
						que.push(Status{ next,0,X,next_cost });
					}
				}
			}
			else {
				if (now_hot == 0 && (now_rest - e.val > 0)) {

				}
				else {
					if (memo[next][1][X] > next_cost) {
						memo[next][1][X]=next_cost;
						que.push(Status{ next,1,X,next_cost });
					}
				}
			}
		}
	}
	long long int ans=1e18;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j <= X; ++j) {
			ans=min(ans,memo[N-1][i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 36776
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)

    # divisors.sort()
    return divisors

n_list = make_divisors(n)
n_ans = []

for i in range(0, len(n_list)-1, 2):
    n_ans.append(n_list[i]+n_list[i+1])

n_ans.sort()

print(n_ans[0]-2)

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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	if(a+b>c+d) cout<<"Left"<<endl;
	else if(a+b<c+d) cout<<"Right"<<endl;
	else cout<<"Balanced"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	int[] s;
	int[][] dp;
	public void solve() {
		N = nextInt();
		s = new int[N];

		for(int i = 0;i < N;i++){
			s[i] = nextInt();
		}

		dp = new int[N+1][10];

		for(int i = 0;i < N;i++){
			for(int j = 0;j < 10;j++){
				if(dp[i][j] % 10 != j)continue;
				dp[i + 1][(j+s[i]) % 10] = Math.max(dp[i+1][(j+s[i])%10],dp[i][j] + s[i]);
				dp[i+1][j] = Math.max(dp[i+1][j],dp[i][j]);
			}
		}

		int max = 0;
		for(int i = 1;i < 10;i++){
			max = Math.max(max,dp[N][i]);
		}

		out.println(max);

	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<string> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	vector<string> tmp;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < tmp.size(); j++) {
			if(tmp[j] == v[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		
		if(tmp.empty() == false) {
			if(tmp[i - 1][tmp[i - 1].size() - 1] != v[i][0]) {
				cout << "No" << endl;
				return 0;
			}
		}
		
		tmp.push_back(v[i]);
	}
	
	cout << "Yes" << endl;
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

static std::vector<std::vector<int>> from;

std::vector<int> dfs(int start, int pos, std::vector<int> hist, std::vector<bool> except) {
  hist.push_back(pos);
  if(std::find(from[pos].begin(), from[pos].end(), start) != from[pos].end()) {
    return hist;
  }
  
  std::vector<bool> new_except(except);
  for(int b : from[pos]) new_except[b] = true;
  for(int b : from[pos]) {
    if(except[b]) continue;

    bool is_rec = false;
    for(int c : from[b]) {
      if(c == start) continue;
      if(std::find(hist.begin(), hist.end(), c) != hist.end()) {
        is_rec = true;
        break;
      }
    }
    if(is_rec) continue;

    return dfs(start, b, hist, new_except);
  }

  return std::vector<int>(0);
}

int main() {
  int N, M;
  std::cin >> N >> M;

  from = std::vector<std::vector<int>>(N);
  rep(i, M) {
    int A, B;
    std::cin >> A >> B;
    --A;
    --B;
    from[A].push_back(B);
  }

  rep(a, N) {
    std::vector<bool> except(N, false);
    for(int x : from[a]) except[x] = true;
    std::vector<int> hist{a};

    for(int b : from[a]) {
      auto ret = dfs(a, b, hist, except);
      if(ret.size() > 1) {
        std::cout << ret.size() << '\n';
        for(int x : ret) {
          std::cout << x + 1 << '\n';
        }
        return 0;
      }
    }
  }
  std::cout << -1 << '\n';
}


Measured memory_bytes: 4992
#include<stdio.h>
#define MAX (100)
int number[MAX][MAX];
int main(void)
{
  int a,b,l,c,i,j;

  scanf("%d", &l);
  for(i=0;i<l;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    for(j = 0; j < b; j++){
      scanf("%d", &c);
      number[a-1][c-1] = 1;
      }
  }
  for(i = 0; i < l; i++){
        for(j = 0; j < l-1; j++)
      printf("%d ", number[i][j]);
        printf("%d\n", number[i][j]);
  }
  return 0;
}

Measured memory_bytes: 628
n=int(input())
#a,b,n=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

def div2(v):
    res=0
    if v==0:
        return res
    while v%2==0:
        v=v//2
        res+=1
    return res
ans=0
for ai in al:
    ans+=div2(ai)
print(ans)



Measured memory_bytes: 4212
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	string s;
	cin>>a>>s>>b;
	if(s=="+"){
		cout<<a+b<<endl;
	}else{
		cout<<a-b<<endl;
	}
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  int count = 0;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == '1'){
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
loop do
  card = gets.chop
  if card == "-"
    break
  end
  num = gets.chop.to_i

  shuffle_num = 0
  num.times do
    shuffle_num += gets.chop.to_i
  end

  shuffle_num = shuffle_num % card.size

  puts card.slice(shuffle_num..(card.size)) + card.slice(0,shuffle_num)
end



Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define ll long long
#define X first
#define Y second
#define pii pair<int, int>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define REP(i, y) rep(i, 0, y - 1)
#define pb push_back
#define mp make_pair
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
ll a, b, c, d, n, s;
int main()
{
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &d, &n);
	s = min(min(a * 8, b * 4), min(c * 2, d)) * (n / 2);
	if(n & 1) s += min(min(a * 4, b * 2), c);
	printf("%lld\n", s);
	return 0;
}



Measured memory_bytes: 256
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    if(n>0)
    s << arr[n - 1] ;
    s<< "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];

signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >> s;
		cout <<s;
		if(s.back()!='s')cout<<"s";
		else
			cout<<"es";
		
	
	}
	return 0;
}

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

int main(void) {
  ll n;
  cin >> n;
  ll x = 26LL;
  ll prev = 0LL;
  ll len = 1;
  while(1) {
    if(prev + x >= n) {
      break;
    }
    prev += x;
    ++len;
    x *= 26LL;
  }
  n -= prev;
  --n;
  vector<int> res;
  for(int i = 0;i < len;++i) {
    res.push_back(n % 26);
    n /= 26;
  }
  reverse(res.begin(),res.end());
  for(int i = 0;i < len;++i) {
    cout << (char)('a' + res[i]);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3628
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        norm = 0
        for k in range(d):
            diff = abs(x[i][k] - x[j][k])
            norm += diff * diff
    
        flag = False
        for k in range(norm+1):
            if k * k == norm:
                flag = True
        if flag:
            ans += 1

print(ans)

Measured memory_bytes: 39152
S = gets.chomp

isyymm = false
yymm = S.match(/(\d\d)(\d\d)/)
if yymm && yymm[2].to_i > 0 && yymm[2].to_i <= 12
  isyymm = true
end

ismmyy = false
mmyy = S.match(/(\d\d)(\d\d)/)
if mmyy && yymm[1].to_i > 0 && yymm[1].to_i <= 12
  ismmyy = true
end

if ismmyy && isyymm
  puts 'AMBIGUOUS'
elsif isyymm
  puts 'YYMM'
elsif ismmyy
  puts 'MMYY'
else
  puts 'NA'
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>

using namespace std;

int x,y,ans;

int main()
{
	cin >> x >> y;
	ans = 2e9 + 1;
	if (x < y)
		ans = min(ans,y - x);
	for (int i = 0;i < 2;i++)
		for (int j = 0;j < 2;j++)
		{
			int X = x,Y = y,cur = 0;
			if (i)
			{
				cur++;
				X = -X;
			}
			if (X <= min(Y,-Y))
			{
				cur += min(Y,-Y) - X;
				X = min(Y,-Y);
			}
			else if (X <= max(Y,-Y))
			{
				cur += max(Y,-Y) - X;
				X = max(Y,-Y);
			}
			else
				continue;
			if (j)
			{
				cur++;
				X = -X;
			}
			if (X == Y)
				ans = min(ans,cur);
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
string st;
int d;
long long f[10001][101][2];
int main()
{
	memset(f,0,sizeof(f));
	cin>>st>>d;
	f[0][0][1]=1;
	/*
	for(int i=0;i<=st.size();i++)
	{
		for(int j=0;j<=d;j++)
		{
			cout<<f[i][j][0]<<"-"<<f[i][j][1]<<" ";
		}
		cout<<endl;
	}
	*/
	for(int i=0;i<st.size();i++)
	{
		for(int j=0;j<d;j++)
		{
			for(int k=0;k<10;k++)
			{
				//if(i==1)cout<<"!";
				//if(j-k>=0)
				f[i+1][j][0]+=f[i][(j-k+d*10)%d][0];
				if(k<st[i]-'0')f[i+1][j][0]+=f[i][(j-k+d*10)%d][1];
				f[i+1][j][0]%=LMOD;
			}
		}
		for(int j=0;j<d;j++)
			{
				//if(j-st[i]+'0'>=0)
				f[i+1][j][1]+=f[i][(j-st[i]+'0'+d*10)%d][1];
				f[i+1][j][1]%=LMOD;
			}
	}
	/*
	for(int i=0;i<=st.size();i++)
	{
		for(int j=0;j<=d;j++)
		{
			cout<<f[i][j][0]<<"-"<<f[i][j][1]<<" ";
		}
		cout<<endl;
	}
	*/
	cout<<(f[st.size()][0][0]+f[st.size()][0][1]+LMOD-1)%LMOD;
	return 0;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

const int mod = 1e9 + 7;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    vector<int> v;
    for (int i = 0; i < n;) {
        if (s[0][i] == s[1][i]) {
            v.push_back(1);
            i++;
        } else {
            v.push_back(2);
            i += 2;
        }
    }
    int ans = 3;
    if (v[0] == 2) ans = 6;
    for (int i = 1; i < sz(v); i++) {
        if (v[i] == 1 && v[i - 1] == 1) {
            ans *= 2;
        } else if (v[i] == 2 && v[i - 1] == 1) {
            ans *= 2;
        } else if(v[i] == 2 && v[i - 1] == 2) {
            ans *= 3;
        }
        ans %= mod;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

z = list(range(max(x)+1, min(y)+1))
if len(list(filter(lambda x: X < x <= Y, z))) == 0:
    print('War')
else:
    print('No War')


Measured memory_bytes: 3060