akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N,Q;
int b[100010];

int main(){
	scanf("%d%d" , &N, &Q);
	b[1] = 1;
	b[2] = 1;
	int x = 1;
	repp(i,0,Q){
		int A,B;
		scanf("%d%d" , &A , &B);
		swap(b[A] , b[B]);
		if(A == x){
			x = B;
		} else if(B == x){
			x = A;
		}
		b[x-1] = b[x+1] = 1;
	}
	int ans = 0;
	repp(i,1,N+1){
		if(b[i] > 0) ++ans;
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define ort ((bas+son+1ll)/2ll)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;
 
int a,b,c;
string s;
 
int main() {
	
	cin >> a >> b >> c;
	if(a+b+c >= 22)
		cout << "bust";
	else
		cout << "win";
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        if(Character.getNumericValue(s.charAt(5))==1||Character.getNumericValue(s.charAt(6))>4){
            System.out.println("TBD");
        }else{
            System.out.println("Heisei");
        }
    }

}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b, c; cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    else if(a == c) cout << b << endl;
    else cout << a << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7716
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
	using namespace std;
	typedef long long ll;
	ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
	ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


	int main() {
		int a, b, c;
		cin >> a >> b >> c;
		int mx = max({ a,b,c });
		int ans = a + b + c + 9 * mx;
		cout << ans << endl;
	}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {
  ll A, B;
  cin >> A >> B;

  cout << lcm(A,B) << endl;

  return 0;
}

ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b,a%b);
  }
}
ll lcm(ll a, ll b) {
  return a/gcd(a,b)*b;
}


Measured memory_bytes: 256
#include <stdio.h>

char str[101][101];
int strOrder[101];
int N;
int L;

int strcmp(char a[101], char b[101])
{
	int i;
	for (i = 0; i < L; i++)
	{
		if (a[i] > b[i]) return 1;
		else if (a[i] < b[i]) return 0;
	}
	return 0;
}

int main(void)
{
	//freopen("in.txt", "r", stdin);
	int i, j, k;
	scanf("%d %d", &N, &L);
	for (i = 1; i <= N; ++i)
	{
		scanf("%s", str[i]);
		strOrder[i] = i;
	}

	for (i = 1; i <= N - 1; i++)
	{
		for (j = i + 1; j <= N; j++)
		{
			if (strcmp(str[i], str[j]) > 0)
			{
				for (k = 0; k < L; k++)
				{
					char tmp = str[i][k];
					str[i][k] = str[j][k];
					str[j][k] = tmp;
				}

			}
		}
	}


	for (i = 1; i <= N; i++)
	{
		printf("%s", str[i]);
	}


	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[200010],n;
#define ll long long
ll k;
int in[200010];
queue<int> q;
int vst[200010];
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
        in[a[i]]++;
    }
    for(int i=1;i<=n;i++)if(in[i]==0)q.push(i);
    while(q.size()){
        int u=q.front();
        q.pop();
        in[a[u]]--;
        if(in[a[u]]==0){
            q.push(a[u]);
        }
    }
    int siz=0;
    int nw=1;
    while(vst[nw]==0){
        vst[nw]=siz;
        nw=a[nw];
        siz++;
    }
    siz=siz-vst[nw];
    int u=1;
    while(k&&in[u]==0){
        k--;
        u=a[u];
    }
    if(k==0){cout<<u<<endl;return 0;}
    k%=siz;
    while(k){
        k--;
        u=a[u];
    }
    cout<<u<<endl;
    return 0;
}

Measured memory_bytes: 6316
#include<stdio.h>
int main()
{
    int N,i,j,t,k;
    int a[3],b[1000];
    scanf("%d",&N);
    for(k=0;k<N;k++)
    {
        scanf("%d %d %d",&a[0],&a[1],&a[2]);

    for(i=0;i<3;i++)
    {
        for(j=i+1;j<3;j++)
        {
            if(a[j]>a[i])
            {
                t=a[j];
                a[j]=a[i];
                a[i]=t;
            }
        } }
        if(a[0]*a[0]==a[1]*a[1]+a[2]*a[2])
        {
           b[k]=1;
        }
        else
            b[k]=0;

    }
    for(k=0;k<N;k++)
    {
    if(b[k]==1){printf("YES\n");}
    else
        {printf("NO\n"); }
    }
return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int mod = 998244353;
int a[3005];
int dp[3003][3003];
signed main() {
	int n, S; cin >> n >> S;
	rep(i, n)cin >> a[i];
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, S + 1) {
			dp[i + 1][j] += dp[i][j]*2; dp[i + 1][j] %= mod;
			int nx = min(j + a[i], S+1);
			dp[i + 1][nx] += dp[i][j]; dp[i + 1][nx] %= mod;
		}
	}
	cout << dp[n][S] << endl;
}

Measured memory_bytes: 73940
#include<stdio.h>
int main(void)
{
	int n,c=0,i,j;
	scanf("%d", &n);
	for(i=1; i<10; i++)
	{
		for(j=1; j<10; j++)
		{
			if(i*j==n)
			c=1;
		}
	}
	if(c>0)
	printf("Yes\n");
	else
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> a(N); rep(i,N) cin >> a[i];

  ll ans = 1;
  SORT(a);
  if(a[0] == 0){
    cout << 0 << endl;
    return 0;
  }
  rep(i,N){
    if(a[i] > (ll)1e18 / ans){
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

    if(a < b){
        rep(i, b){
            printf("%d", a);
        }
        printf("\n");
    }
    else{
        rep(i, a){
            printf("%d", b);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
m,d = map(int,input().split())

point = 0

for i in range(1,m+1):
    for j in range(10,d+1):
        s = str(j)
        one = int(s[0])
        two = int(s[1])
        if one >= 2 and two >= 2 and one*two == i:
            point += 1

print(point)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    while(1){
        int n, w, d;
        cin >> n >> w >> d;

        if(n+w+d == 0) break;

        vector<pair<int, int>> cakes;
        cakes.push_back(make_pair(w, d));

        rep(i, n){
            int p, s;
            cin >> p >> s;
            --p;

            pair<int, int> pa = cakes[p];
            int cw = pa.first;
            int cd = pa.second;

            s %= 2*(cw + cd);

            if(0<s && s<=cw || cw+cd<s && s<=2*cw+cd){ // vertical
                int v_pos = s;
                if(cw+cd < s) v_pos = cw-(s-(cw+cd));

                int nw1 = min(v_pos, cw-v_pos);
                int nw2 = cw - nw1;

                if(p == i){
                    cakes[p] = make_pair(nw1, cd);
                    cakes.push_back(make_pair(nw2, cd));
                }
                
                else{
                    cakes.erase(cakes.begin()+p);
                    cakes.push_back(make_pair(nw1, cd));
                    cakes.push_back(make_pair(nw2, cd));
                }
            }

            else{ // horizontal
                int h_pos = s - cw;
                if(2*cw+cd < s) h_pos = cd-(s-(2*cw+cd));

                int nd1 = min(h_pos, cd-h_pos);
                int nd2 = cd - nd1;

                if(p == i){
                    cakes[p] = make_pair(cw, nd1);
                    cakes.push_back(make_pair(cw, nd2));
                }

                else{
                    cakes.erase(cakes.begin()+p);
                    cakes.push_back(make_pair(cw, nd1));
                    cakes.push_back(make_pair(cw, nd2));
                }

            }

        }

        vector<int> res;
        rep(i, cakes.size()){
            res.push_back(cakes[i].first * cakes[i].second);
        }
        sort(res.begin(), res.end());

        rep(i, res.size()){
            if(i!=res.size()-1) cout << res[i] << " ";
        }
        cout << res.back() << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
 
double hantei(double,double,double,double,double,double,double,double);
 
int main(){
double x1,x2,x3,y1,y2,y3,xp,yp;
double heix,heiy;
int f;
 
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
f=0;
heix=(x1+x2+x3)/3;
heiy=(y1+y2+y3)/3;
if(hantei(x1,y1,x2,y2,xp,yp,heix,heiy)<0.0){
f=1;
}
if(hantei(x1,y1,x3,y3,xp,yp,heix,heiy)<0.0){
f=1;
}
if(hantei(x2,y2,x3,y3,xp,yp,heix,heiy)<0.0){
f=1;
}
if(f==1){
printf("NO\n");
}
else if(f==0){
printf("YES\n");
}
}
return 0;
}
 
double hantei(double p1x,double p1y,double p2x,double p2y,double p3x,double p3y,double p4x,double p4y)
{
double a;
a=((p1x-p2x)*(p3y-p1y)+(p1y-p2y)*(p1x-p3x))*((p1x-p2x)*(p4y-p1y)+(p1y-p2y)*(p1x-p4x));
return a;
}

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

using namespace std;

int N, M;
int BibsInfo[101];

void solve() {

	for (int k = 1; k <= M; ++k) {
		for (int i = 1; i < N; ++i) {
			if (BibsInfo[i] % k > BibsInfo[i + 1] % k) {
				swap(BibsInfo[i], BibsInfo[i + 1]);
			}
		}
	}

	for (int i = 1; i <= N; ++i) {
		cout << BibsInfo[i] << endl;
	}
}

int main() {
	int a;

	cin >> N >> M;
	for (int i = 1; i <= N; ++i) {
		cin >> a;
		BibsInfo[i] = a;
	}
	solve();
	
	return 0;
}


Measured memory_bytes: 3104
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  struct Block {
    int w, s, v;
  };

  vector<Block> bs(N);
  FOR(i, 0, N) {
    cin >> bs[i].w >> bs[i].s >> bs[i].v;
  }

  sort(bs.begin(), bs.end(), [](const Block& l, const Block& r)->bool {
    return l.w + l.s < r.w + r.s;
    });

  const int smax = 1e4 * 2 + 1;

  // dp[i][j] := 下から i個詰んだとき、残り詰める重さが[j]の時の価値の総和の最大値
  // ... それだと既に使ったブロックが状態に入っていない...

  // dp[i][j] := 上から i個詰んだとき、既に詰まれた重さが[j]の時の価値の総和の最大値
  // ... 同上...

  // dp[i][j][k] := j 番目までのブロックを使うか使わないかして 上から i個詰んだとき、
  // 既に詰まれた重さが[k]の時の（略）
  // dp[i][j][k] = max(dp[i][j-1][k], dp[i-1][j-1][k-w[j]] + v[j] when k-w[j] <= s[j])
  // ... この式だと [j] の計算に [j-1] しか使えてないから、たとえば
  // 2番目ブロック→1番目ブロックの順に置く方法が探索できていない。

  // snukeさんの解説読む...

  // dp[i][j] := i 番目までのブロック（全て使わなくてもいい）で積むとき、重さ j 以下での価値の総和の最大

  // 既に上に詰んである重さを C として、i と j 2つを下に積むとき
  // C + wj <= si (jを上に積める条件)
  // C + wi <= sj (iを上に積める条件)
  // C を最大化したい場合、si - wj > sj - wi のとき j を上に積むべき
  // 式変形すると si + wi > sj + wj のとき j が上。
  // つまり全要素を予め s + w で昇順ソートしておけば、順に使っていくのが最適となる

  vector<vector<i64>> dp(2, vector<i64>(smax));

  FOR(i, 0, N) {

    Block& b = bs[i];

    FOR(j, 1, b.w) {
      dp[1][j] = dp[0][j];
    }
    FOR(j, b.w, min(b.w+b.s+1,smax)) {
      dp[1][j] = max(dp[0][j], dp[0][j - b.w] + b.v);
    }
    FOR(j, b.w + b.s + 1, smax) {
      dp[1][j] = dp[0][j];
    }

    swap(dp[0], dp[1]);
  }

  i64 result = 0;
  F0R(i, smax) {
    chmax(result, dp[0][i]);
  }
  cout << result;
}
#endif


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    if (x%y==0)
    {
        printf("-1\n");
        return 0;
    }
    printf("%lld\n",x*1ll*(y-1));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int H,n,i,a,b,h;
	vector<pair<int,int>> store;
	cin >> H >> n;
	for(i=0;i<n;i++)
	{
		cin >> a >> b;
		store.push_back(make_pair(a,b));
	}
	int dp[H+1]; dp[0]=0;
	// dp[x] denotes the minimum points using which monster with health H can be killed.
	for(i=1;i<=H;i++)
		dp[i]=INT_MAX;
	
	for(h=1;h<=H;h++)
	{
		for(i=0;i<n;i++)
			dp[h]=min(dp[h],dp[max(h-store[i].first,0)]+ store[i].second);
		
	}
	cout << dp[H] << endl;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }

    sort(S.begin(), S.end());

    string hikaku = S.at(0);
    vector<string> A(N);
    int count = 0;
    vector<int> kaisuu(N, 0);

    for (int i = 0; i < N; i++)
    {
        if (hikaku == S.at(i))
        {
            A.at(count) = S.at(i);
            kaisuu.at(count) ++;
        }

        else
        {
            hikaku = S.at(i);
            count ++;
            A.at(count) = S.at(i);
            kaisuu.at(count) ++;
        }
        
        
    }

    vector<int> kai(N,0);
    kai = kaisuu;
    sort(kai.begin(), kai.end());

    for (int i = 0; i < N; i++)
    {
        if (kai.at(N-1) == kaisuu.at(i))
        {
            cout << A.at(i) << endl;
        }
        
    }
    


    
    
    
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
string s1,s2,s;
int red,blue;
int main()
{
	cin>>s1>>s2;
	cin>>red>>blue;
	cin>>s;
	if(s1==s) red--;
	else blue--;
	cout<<red<<" "<<blue<<endl;
}

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

int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  long long ans;
  int s = 1;
  bool td;
  if (s1[0] != s2[0]) {
    s = 2;
    ans = 6;
    td = true;
  } else {
    ans = 3;
    td = false;
  }

  while (s < s1.length()) {
    if (s1[s] == s2[s]) {
      if (td) {
        td = false;
      } else {
        ans = (ans * 2) % 1000000007;
      }
      s++;
    } else {
      if (td) {
        ans = (ans * 3) % 1000000007;
      } else {
        ans = (ans * 2) % 1000000007;
      }
      td = true;
      s += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> S(N+1,0);

    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    for (int j = 0; j < N; ++j) {
        S[j+1]  = S[j] + A[j];
    }

    long long count = 0;


    map<long long, long long> nums;
    for (int k = 0; k < N + 1 ; ++k) {
        nums[S[k]]++;
    }

    for(auto it : nums){
        long long n = it.second;
        count += n * (n -1) / 2;
    }

    cout << count << endl;

}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
ll n;
cin>>n;
if(n>=30){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}


return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  string slime;
  cin >> slime;
  
  int notonly1=1;
  int ans=0;
  
  while(notonly1){
    int check = 0;
    for(int i=0; i<N; i++){
      if(slime[i]==slime[i+1]){
      	ans++;
        slime.erase(i,1);
        N-=1;
      }
      else{
      	check++;
      }
    }
    if(check==N)
      notonly1=0;
  }
  cout << N << endl;
  return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

void dfs1(int i,int p,int d,vector<int>& cnt,vector<vector<int>>& edges) {
    cnt[d] = max(cnt[d],(int)edges[i].size()-1);
    if (p < 0) cnt[d] = edges[i].size();
    for (int j : edges[i]) if (j-p) dfs1(j,i,d+1,cnt,edges);
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    vector<P> a(n-1);
    for (int i = 0;i < n-1;++i) {
        cin >> a[i].first >> a[i].second;
        a[i].first--;a[i].second--;
        edges[a[i].first].push_back(a[i].second);
        edges[a[i].second].push_back(a[i].first);
    }
    vector<pair<int,ll>> ans;
    for (int p = 0;p < n;++p) {
        vector<int> cnt(n,0);
        dfs1(p,-1,0,cnt,edges);
        int d = 0;
        ll l = 1;
        for (int i = 0;i < n;++i) {
            d = i+1;
            if (cnt[i] == 0) break;
            l *= cnt[i];
        }
        ans.push_back(make_pair(d,l));
    }
    for (P& p : a ) {
        vector<int> cnt1(n,0),cnt2(n,0);
        dfs1(p.first,p.second,0,cnt1,edges);
        dfs1(p.second,p.first,0,cnt2,edges);
        int d = 0;
        ll l = 2;
        for (int i = 0;i < n;++i) {
            d = i+1;
            if (cnt1[i] == 0 && cnt2[i] == 0) break;
            l *= max(cnt1[i],cnt2[i]);
        }
        ans.push_back(make_pair(d,l));
    }
    pair<int,ll> b = *min_element(ans.begin(),ans.end());
    cout << b.first << " " << b.second << endl;
}

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

int main(){
    int n ; cin >> n ;
    vector<int> a(n) ;
    for(int i=0;i<n;i++) cin >> a.at(i) ;
    cout << a.at(0) ;
    for(int i=1;i<n;i++) cout << " " << a.at(i) ;
    cout << endl ;
    for(int i=1;i<n;i++){
        int v = a.at(i) ;
        int j = i-1 ;
        while(j>=0&&a.at(j)>v){
            a.at(j+1) = a.at(j) ;
            j-- ;
        }
        a.at(j+1) = v ;
        cout << a.at(0) ;
        for(int i=1;i<n;i++) cout << " " << a.at(i) ;
        cout << endl ;
    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> x(m);
    for(int i=0;i<m;i++)cin>>x[i];
    sort(x.begin(),x.end());
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    vector<int> l(m-1);
    int ans=x[m-1]-x[0];
    for(int i=1;i<m;i++){
        l[i-1]=x[i]-x[i-1];
    }
    sort(l.begin(),l.end(),greater<int>());
    for(int i=0;i<n-1;i++){
        ans-=l[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N - 1);
  for (int i = 0; i < N; ++i)
    cin >> A[i];
  for (int i = 0; i < N; ++i)
    cin >> B[i];
  for (int i = 0; i < N - 1; ++i)
    cin >> C[i];
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += B[A[i] - 1];
    if (i == 0)
      continue;
    if (A[i] == A[i - 1] + 1)
      ans += C[A[i - 1] - 1];
  }
  cout << ans << endl;
}

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

dic = {}
lst = [0] * (N+1)

for i in range(N-1):
  a, b = map(int,input().split())
  
  if not (a in dic.keys()):
    dic[a] = []
  
  dic[a].append(b)


for i in range(Q):
  p, x = map(int,input().split())
  lst[p] += x
  
for i in range(1,N+1):
  print(lst[i],end=' ')
  if i in dic.keys():
    tmp_lst = dic[i]
    for j in tmp_lst:
      lst[j] += lst[i]
    
print()

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)
	{
		cout << c << endl;
	}
	else if (b ==c)
	{
		cout << a << endl;
	}
	else
	{
		cout << b << endl;
	}

}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    string S, T;
    cin >> S >> T;
    ll cnt = 0;
    rep(i, 3) {
        if (S[i] == T[i]) cnt++;
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 1e9 + 7;
const int inf = 9e18;
const int N = 2e5 + 5;

void solve(){
    int i,j,k,sum=0,x;
    cin>>x;
    for(i=1;i<=x;++i){
        for(j=1;j<=x;++j){
            for(k=1;k<=x;++k){
                sum+=gcd(gcd(i,j),k);
            }
        }
    }
    cout<<sum;
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<vector>
using namespace std;
int n;
vector<int> e[111111];
int d[111111],sz[111111];
int fat[111111];
void dfs(int x){
	sz[x] = 1;
	for(vector<int>::iterator it = e[x].begin(); it!=e[x].end(); it++){
		int y = *it;
		if(y == fat[x])continue;
		d[y] = d[x] + 1;
		fat[y] = x;
		dfs(y);
		sz[x] += sz[y];
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	fat[1] = 1;
	dfs(1);
	int z = n;
	for(int i=(d[n]-1)/2; i>0; i--)
		z = fat[z];
	puts(n - sz[z] > sz[z] ? "Fennec" : "Snuke");
	return 0;
}

Measured memory_bytes: 11776
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

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

using namespace std;

template <class T>
T even(T n)
{
	return !(n % 2);
}
template <class T>
T div_three(T n)
{
	return !(n % 3);
}
template <class T>
T div_five(T n)
{
	return !(n % 5);
}

const int MIN = 200001;

int is_valid();
void cal_max_string();
void concatenate_min_bit();
int count_last_first_digit(int n);

int main() {
	int n;
	cin >> n;
	cout << count_last_first_digit(n) << endl;
    return 0;
}

int count_last_first_digit(int n) {
	int p, r = 0;
	vector<vector<int> > v(10, vector<int>(10, 0));
	
	for (int i = 1; i < n + 1; i++) {
		p = i;
		while (p/10 > 0) p /= 10;
		v[p][i % 10]++;
	}
	
	rep(i, 10) rep(j, 10) r += v[i][j] * v[j][i];
	
	return r;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b;

    scanf("%d %d", &a, &b);

    if (a == 13 && b == 1){
        puts("Bob");
    }
    else if (a == 1 && b == 13){
        puts("Alice");
    }
    else if (a < b){
        puts("Bob");
    }
    else if (a > b){
        puts("Alice");
    }
    else {
        puts("Draw");
    }

    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> v(N);
	for (int n = 0; n < N; n++) {
		cin >> v.at(n);
	}

	sort(v.begin(), v.end());

	double mean = (double)v.at(0);
	for (int n = 1; n < N; n++) {
		mean = ((double)v.at(n) + mean) / 2.0;
	}

	cout << mean << endl;

	return 0;
}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<vector<int>> dp(n);
	for(int i = 0; i < n;i++) dp[i].resize(3);
	vector<int> a(n), b(n), c(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(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2])<<endl;
	return 0;
}

Measured memory_bytes: 6912
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import itertools

def main():
  N, M, Q = map(int, input().split())
  all_num = [i for i in range(1, M+1)]
  q_kumi = []
  for i in range(Q):
    q_kumi.append(list(map(int, input().split())))

  ans = 0
  for com in list(itertools.combinations_with_replacement(all_num, N)):
    tmp_ans = 0
    if com != tuple(sorted(com)):
      continue
    for q in q_kumi:
      if com[q[1]-1] - com[q[0]-1] == q[2]:
        tmp_ans += q[3]
    ans = max(ans, tmp_ans)
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 21488
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
flush = sys.stdin.flush()

def solve():
    l = 0
    r = 17
    while r-l > 1:
        m = (l+r) >> 1
        M = 10**m
        print("?",M)
        flush
        ans = input()
        if ans == "Y":
            l = m
        else:
            r = m
    k = l
    A = 0
    for i in range(k+1)[::-1]:
        l = max(0,i-k+1)
        r = 10
        while r-l > 1:
            m = (l+r) >> 1
            M = (A+m*10**i)*10
            print("?",M)
            flush
            ans = input()
            if ans == "Y":
                r = m
            else:
                l = m
        A += l*10**i
    if A < 10**9:
        if A == 10000000:
            M = 10**9
            print("?",M)
            flush
            ans = input()
            if ans == "N":
                print("!",A+1)
                return
        else:
            print("!",A+1)
            return
    l = -1
    r = 9
    while r-l > 1:
        m = (l+r) >> 1
        M = 10**m+1
        print("?",M)
        flush
        ans = input()
        if ans == "Y":
            r = m
        else:
            l = m
    print("!",10**r)
    return
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39492
#include<bits/stdc++.h>
using namespace std;
using ldb = long double;

int n;
ldb arr[3000];
ldb dp[3000][3000];

ldb solve(int x, int nn){
    if(x == 0) return 1.00;
    if(nn == -1) return 0.0;
    
    if(dp[x][nn] != -1) return dp[x][nn];
    
    ldb answer = arr[nn]*solve(x-1, nn-1) + (1.00-arr[nn])*solve(x, nn-1);
    
    return dp[x][nn] = (ldb)answer;
}

int main(){
    cin >>n;
    
    for(int i=0;i<n;i++) 
        cin >>arr[i];
        
    for(int i=0;i<3000;i++){
        for(int j=0;j<3000;j++){
            dp[i][j] = -1;
        }
    }
    
    cout<<fixed<<setprecision(12)<<(ldb)solve((n+1)/2, n-1);
    
    return 0;
}

Measured memory_bytes: 144648
#include <stdio.h>
#include <limits.h>

int main(void) {
   
   int H,W,K;
   
   scanf("%d %d %d",&H,&W,&K);
   
   char S[H][W];
   int Ans[H][W];
   int i,j,k;
   int str = 1;
   
   for (i = 0; i < H; i++) {
      scanf("%s",S[i]);
      for (j = 0; j < W; j++) {
         if (S[i][j] == '#') {
            Ans[i][j] = str;
            str++;
         }
         else {
            Ans[i][j] = 0;
         }
      }
   }
   
   int Col[W];
   int col_num;
   
   for (i = 0; i < H; i++) {
      col_num = 0;
      for (j = 0;j < W; j++) {
         Col[j] = -1;
      }
      
      for (j = 0; j < W; j++) {
         if (Ans[i][j] != 0) {
            Col[col_num] = j;
            col_num++;
         }
      }
      
      if (col_num == 1) {
         for (k = 0; k < W; k++) {
            Ans[i][k] = Ans[i][Col[0]];
         }
      }
      else {
         
         for (k = 0; k < Col[0]; k++) {
            Ans[i][k] = Ans[i][Col[0]];
         }

         for (j = 1; j < col_num; j++) {
            for (k = Col[j - 1]; k < Col[j]; k++) {
               Ans[i][k] = Ans[i][Col[j - 1]];
            }
         }
         
         for (k = Col[col_num - 1]; k < W; k++) {
            Ans[i][k] = Ans[i][Col[col_num - 1]];
         }
         
      }
   }
   
   for (i = 0; i < H; i++) {
      if (Ans[i][0] == 0) {
         
         int row = i;
         
         while (Ans[row][0] == 0 && row < H) {
            row++;
         }
         
         if (row == H) {
            row = i;
            while (Ans[row][0] == 0 && row < H) {
               row--;
            }
         }
         
         for (j = 0; j < W; j++) {
            Ans[i][j] = Ans[row][j];
         }
   
      }
   }
   
   
   
   for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
         printf("%d ",Ans[i][j]);
      }
      printf("\n");
   }
   
   
   
   
   
   return 0;
}


Measured memory_bytes: 1152
def main():
    N = int(input())
    pl = tuple(map(float, input().split()))
    mid = (N + 1) // 2
    v = [0.0] * (mid + 1)
    v[0] = 1.0
    for i, p in enumerate(pl[:mid]):
        q = 1 - p
        t = 0.0
        for j, uu in enumerate(v[:i + 2]):
            v[j] = t * p + uu * q
            t = uu
    for i, p in enumerate(pl[mid:], mid):
        q = 1 - p
        t = v[i - mid + 1]
        for j, uu in enumerate(v[i - mid + 2:mid], i - mid + 2):
            v[j] = t * p + uu * q
            t = uu
        v[mid] += t * p
    print(v[mid])

main()


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

const int MOD = 1000000007;

vector<pair<int64_t, int64_t>> prime_factorize(int64_t n) {
    vector<pair<int64_t, int64_t>> ret;
    for (int64_t i = 2; i*i <= n; i++) {
        if (n % i != 0) continue;
        int64_t ex = 0;
        while (n % i == 0) {
            ex++;
            n /= i;
        }
        ret.push_back({i, ex});
    }
    if (n != 1) ret.push_back({n, 1});
    return ret;
}

int main() {
    int n;
    cin >> n;
    map<int64_t, int64_t> mp;
    for (int64_t i = 1; i < n+1; i++) {
        const auto &pf = prime_factorize(i);
        for (auto p : pf) {
            mp[p.first] += p.second;
        }
    }
    int64_t ans = 1;
    for(auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans *= itr->second + 1;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func lowerBound(a []int, x int) int {
	n := len(a)
	ok := n
	ng := -1
	for ok-ng > 1 {
		mid := (ok + ng) / 2
		if a[mid] >= x {
			ok = mid
		} else {
			ng = mid
		}
	}
	return ok
}

func main() {
	var s string
	var t string
	fmt.Scan(&s, &t)

	idxs := make([][]int, 256)
	for i := 0; i < len(s); i++ {
		idxs[s[i]] = append(idxs[s[i]], i)
	}

	n := int64(len(s))
	cur := int64(0)
	ng := false

	for i := 0; i < len(t); i++ {
		is := idxs[t[i]]
		if is == nil || len(is) == 0 {
			ng = true
			break
		}
		base := (cur / n) * n

		nidx := lowerBound(is, int(cur%n))
		if nidx == len(is) {
			cur = base + int64(is[0]) + n + 1
		} else {
			cur = base + int64(is[nidx]) + 1
		}
	}
	if ng {
		fmt.Println(-1)
	} else {
		fmt.Println(cur)
	}
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    string s,t;cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++){
        ans+=s[i]==t[i];
    }
    cout<<ans;
}


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

using namespace std;

int getArriveTime(int a,int b,int c){
  bool visited[60][60][2];
  memset(visited,false,sizeof(visited));
  int d = 0,st = 1,e = 0;
  for(int i = 0 ; ; i++,d++){
    if(i >= 60){ i %= 60; e++; }
    if(c == i && st){ return c+e*60; }
    if(visited[i][d][st]){ return -1; }
    visited[i][d][st] = true;
    if(d >= a && st == 1){ d = 0; st = 0; }
    if(d >= b && st == 0){ d = 0; st = 1; }
  }
  return -1;
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int res = getArriveTime(a,b,c);
  cout << (res >= 0 ? res : -1) << endl;
  return 0;
}

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

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


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

int main() {
  int N, A;
  cin >> N;
  int ans = 10000;
  for (int i=0; i < N; i++) {
    cin >> A;
    ans = min(ans, __builtin_ctz(A));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
flag =0 #yesフラグ
ext1 = N // 4
ext2 = N // 7

if ext1 == 0:
  print("No")
else:
  for i in range(ext1 +1):
    for j in range (ext2 +1):
      if i*4 + j*7 ==N:
        flag +=1
  print("Yes"if flag >0 else "No")

Measured memory_bytes: 3060
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M, K;
    scan(N, M, K);
    auto A = aryread();
    auto B = aryread();
    auto S = [0L] ~ B ~ [0L];
    foreach (i; 0 .. M)
    {
        S[i + 1] += S[i];
    }
    long as;
    long ans;
    foreach (i; 0 .. N + 1)
    {
        long ok = 0;
        long ng = M + 1;
        while (1 < (ng - ok))
        {
            long j = (ok + ng) / 2;
            if (S[j] <= K - as)
            {
                ok = j;
            }
            else
            {
                ng = j;
            }
        }
        dprint(i, ok);
        if (as + S[ok] <= K)
            ans = ans.max(i + ok);
        if (i < A.length)
            as += A[i];
    }
    writeln(ans);
}


Measured memory_bytes: 22936
<?php

function input() {
    return trim(fgets(STDIN));
}

function input_array() {
    return explode(' ', input());
}

list($N, $T) = input_array();

$routes = [];
for ($i = 0; $i < $N; $i++) {
    $routes[] = input_array();
}

$available_routes = array_filter($routes, function($route) use ($T) {
    return $route[1] <= $T;
});
usort($available_routes, function($a, $b) {
    return $a[0] <=> $b[0];
});

if ($available_routes === []) {
    echo "TLE\n";
} else {
    echo $available_routes[0][0] . "\n";
}

Measured memory_bytes: 4728
#include<iostream>
#include<cmath>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<iomanip>
#include<string>
#include<map>
#define PI 3.14159265
#define mod 998244353    
using namespace std;

 

void func(){
    long long n,ans = 0 , k ;
    cin >> n >> k ;
    long long arr[n] , dp[n] = {0};

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

    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);
    
    for(int i = 2 ; i < n ; ++i){
      long long mini = 1e9;
        for(int j = 1 ; j <= min(k , (long long)i) ; ++j)
          mini = min(mini , dp[i - j] + abs(arr[i] - arr[i - j])); 
        dp[i] = mini;
    }
  cout << dp[n - 1] << "\n";
}
int main(){
    int t = 1 , cnt = 0 ;
  // cin >> t;
    
    while(t--){
        
        func();
    }
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#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 all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X, Y, Z; cin >> X >> Y >> Z;
	int K; cin >> K;
	vector<int> A(X); rep(i, 0, X) {
		cin >> A[i];
	}
	vector<int> B(Y); rep(i, 0, Y) {
		cin >> B[i];
	}
	vector<int> C(Z); rep(i, 0, Z) {
		cin >> C[i];
	}
	sort(all(A), greater<int>());
	sort(all(B), greater<int>());
	sort(all(C), greater<int>());
	vector<int> AB(X*Y);
	rep(i, 0, X)rep(j, 0, Y) {
		AB[i*Y + j] = A[i] + B[j];
	}
	sort(all(AB), greater<int>());
	dump(AB);
	vector<int> ans(K*Z);
	int m = min(X*Y, K);
	rep(i, 0, m) {
		rep(j, 0, Z) {
			ans[i*Z + j] = AB[i] + C[j];
		}
	}
	sort(all(ans), greater<int>());
	rep(i, 0, K) { cout << ans[i] << endl; }

	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c, l, s;
  int ans[101][101];
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> ans[i][j];
      s += ans[i][j];
    }
    ans[i][c] = s;
    s = 0;
  }
  for (int j = 0; j <= c; j++) {
    for (int i = 0; i < r; i++) {
      l += ans[i][j];
    }
    ans[r][j] = l;
    l = 0;
  }
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j != 0) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3112
S = input()
N =input()
f = 0
if(len(S)+1==len(N)):
    for i in range(len(S)):
        if(S[i]!=N[i]):
            print("No")
            f = 1
            break
    if(f == 0):
        print("Yes")    
else:
    print("No")

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

#define sz(s)               (int)s.size()
using namespace std;
int main()
{
	long long l1, r1, l2, r2;
	cin >> l1 >> r1 >> l2 >> r2;
	if (l1*r1 > l2*r2) cout << l1*r1;
	else  if (l1*r1 <l2*r2) cout << l2*r2;
	else cout << l2*r2;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;cin>>n;
    vector<int> b(n-1);
    for(int i=0;i<n;i++)cin>>b[i];
    int ans = b[0];
    for(int i=0;i<n-1;i++){
        ans+=min(b[i-1],b[i]);
    }
    ans+=b[n-2];
    cout<<ans<<endl;
}

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

// Repeat
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
// Container Util
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

int main() {
    int A,B,C; cin >> A >> B >> C;
    map<int,int> mp;
    mp[A]++; mp[B]++; mp[C]++;

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5+45;

ll n,a[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    map <ll,ll> mapa;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        mapa[a[i]]++;
    }
    ll sol = 0;
    for(auto f : mapa){
        ll cnt = f.second;
        sol += (cnt*(cnt-1))/2;
    }
    for(int i = 1; i <= n; i++){
        ll x = a[i];
        ll ima = mapa[x];
        ll sol1 = sol;
        sol1 -= (ima*(ima-1))/2;
        ima--;
        sol1 += (ima*(ima-1))/2;
        cout << sol1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string a,b;cin>>a>>b;
  if((int)a.size()<(int)b.size()){
    P("LESS");
  }else if((int)a.size()>(int)b.size()){
    P("GREATER");
  }else{
    REP(i,(int)a.size()){
      if(a[i]>b[i]){
        P("GREATER");
        return 0;
      }else if(a[i]<b[i]){
        P("LESS");
        return 0;
      }
    }
    P("EQUAL");
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<n; ++i)
#define FOR(i, a, b) for(int i=a; i<b; ++i)
#define FORR(i, a, b) for(int i=b-1; i>=a; --i)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, z;
	cin>>x>>y>>z;
	cout<<(x-z)/(y+z)<<'\n';
	return 0;
}


Measured memory_bytes: 256