akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int h, w;
int d[21][21];
int sy, sx, gy, gx;
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
bool contain(int y, int x){
   return (0 <= y && y < h && 0 <= x && x < w);
}
int ans = 11;

void dfs(int y, int x, int k){
    if(k > 10) return;

    rep(i, 0, 4){
        int nowy = y;
        int nowx = x;
        while(1){
            int nexty = nowy + dy[i];
            int nextx = nowx + dx[i];
            if(!contain(nexty, nextx)){
                break;
            }
            if(d[nexty][nextx] == 1 || d[nexty][nextx] == 3){
                if(d[nexty][nextx] == 3){
                    chmin(ans, k);
                    break;
                }
                d[nexty][nextx] = 0;
                // cout << y << " " << x << " " << k << " " << nowy << " " << nowx << " " << nexty << " " << nextx << endl;
                if(!(nowy == y && nowx == x)){
                    dfs(nowy, nowx, k + 1);
                }
                d[nexty][nextx] = 1;
                break;             
            }
            nowy = nexty;
            nowx = nextx;
        }
    }
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> w >> h;
        if(h == 0 && w == 0) break;
        rep(i, 0, h){
            rep(j, 0, w){
                cin >> d[i][j];
                if(d[i][j] == 2){
                    sy = i; sx = j;
                }
                if(d[i][j] == 3){
                    gy = i; gx = j;
                }
            }
        }
        ans = 11;
        dfs(sy, sx, 1);
        cout << (ans == 11 ? -1 : ans) << endl;
    }
}


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

using namespace std;

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

    int n = s.size();
    int k;
    cin >> k;

    vector<string> cds;
    for (int i = 0; i < n; i++) {
        for (int length = 1; length <= k && i + length <= n; length++) {
            cds.push_back(s.substr(i, length));
        }
    }

    sort(cds.begin(), cds.end());
    cds.resize(unique(cds.begin(), cds.end()) - cds.begin());

    cout << cds[k - 1] << endl;

    return 0;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n;
    cin >> n;
    vector<ll> x(n), y(n), h(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }
    // 中心座標(i, j)
    frep(i, 0, 100) {
        frep(j, 0, 100) {
            bool ok = true;
            // これに外れると不適
            ll tmp;
            rep(k, n) {
                if(h[k] > 0) {
                    tmp = h[k]+my_abs(x[k]-i)+my_abs(y[k]-j);
                }
            }
            // 条件に適合しているか確認
            rep(k, n) {
                ll a = 0;
                if(max(a, tmp-my_abs(x[k]-i)-my_abs(y[k]-j)) != h[k]) {
                    ok = false;
                }
            }
            if(ok) {
                cout << i << ' ' << j << ' ' << tmp << endl;
                return 0;
            }
        }
    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++)
    cin >> x[i];
  vector<int> s = x;
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++)
    if (x[i] < s[(n + 1) / 2])
      cout << s[(n + 1) / 2] << endl;
    else
      cout << s[(n + 1) / 2 - 1] << endl;

  return 0;
}


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

using namespace std;

int res;
int len;
char ch[10001];

int main() {
    scanf("%s", ch + 1);
    len = strlen(ch + 1);
    for(int i = 1; i <= len; i++) res += ch[i] - '0';
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
s=gets.chomp.split("").map(&:to_i).sort
n=s.size
c0=0
s.each do |si|
  if si==0
    c0+=1
  else
    break
  end
end
c1=n-c0
if c0==c1
  puts n
else
  puts [c0,c1].min*2
end


Measured memory_bytes: 9328
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int n;

    cin >> n;
    long long arr[n][10], arr2[n][11],num, arr3, arr4[n], prof, maxProf= -1000000000;

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

    for(int i=0; i<n; i++)
    {
        for(int j=0; j<11; j++)
        {
            cin >> arr2[i][j];
        }
    }
    for(int i=1; i<1024; i++)
    {
        num = i;
        prof=0;
        for(int k=0; k<n; k++)
        {
            arr4[k]=0;
        }
        for(int j=9; j>=0; j--)
        {
            arr3= num % 2;
            num = num/2;
            for(int k=0; k<n; k++)
            {
                if(arr[k][j]==arr3 && arr[k][j]==1)
                {
                    arr4[k]++;
                }
            }
        }
        for(int k=0; k<n; k++)
        {
            num = arr4[k];
            prof+=arr2[k][num];
        }
        if(maxProf<prof)
        {
            maxProf = prof;
        }

    }

    cout << maxProf;


    return 0;
}


Measured memory_bytes: 384
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vi = vector<ll>;
using vii = vector<ii>;
using vvi = vector<vi>;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

ll calculark(ll nact, vi const& pos, vi const& neg) {
	ll ktot = 0;
	if (nact < 0) {
		//Solo parejas pos, neg

		if (pos.size() > 0 && neg.size() > 0) {
			ll idx2 = pos.size() - 1;
			//ll idx1 = neg.size() - 1;
			ll idx1 = 0;
			while (idx1 < neg.size() && neg[idx1] * pos[idx2] > nact) ++idx1;

			while (idx2 >= 0) {
				ktot += (neg.size() - idx1);
				--idx2;
				//++idx1;
				while (idx2 >= 0 && idx1 < neg.size() && neg[idx1] * pos[idx2] > nact) ++idx1;
				//if (idx2 >= 0 && (idx1 == neg.size() || neg[idx1] * pos[idx2] > nact)) --idx1;
			}
		}
	}

	else {
		ktot += ((ll) pos.size()) * neg.size();

		if (pos.size() > 1) {
			ll idx2 = pos.size() - 1;
			ll idx1 = pos.size() - 2;

			while (idx1 >= 0 && pos[idx1] * pos[idx2] > nact) --idx1;
			while (idx2 > 0) { //COMPROBAR 
				if (idx1 == idx2) --idx1;
				ktot += (idx1 + 1);
				--idx2;
				if(idx1 == -1) ++idx1;
				while (idx1 < idx2 && pos[idx1] * pos[idx2] <= nact) ++idx1;
				if (idx1 == idx2 || pos[idx1] * pos[idx2] > nact) --idx1;
			}
		}


		if (neg.size() > 1) {
			ll idx2 = neg.size() - 1;
			ll idx1 = neg.size() - 2;

			while (idx1 >= 0 && neg[idx1] * neg[idx2] > nact) --idx1;
			while (idx2 > 0 && idx2 > idx1) { //COMPROBAR 
				if (idx1 == idx2) --idx1;
				ktot += (idx1 + 1);
				--idx2;
				if (idx1 == -1) ++idx1;
				while (idx1 < idx2 && neg[idx1] * neg[idx2] <= nact) ++idx1;
				if (idx1 == idx2 || neg[idx1] * neg[idx2] > nact) --idx1;
			}
		}
	}
	return ktot;
}

ll busBin(ll nini, ll nfin, vi const& pos, vi const& neg, ll k) {
	if (nini >= nfin) return nini;
	else {
		ll mitad = (nini + nfin - 1) / 2;

		if (calculark(mitad, pos, neg) >= k) return busBin(nini, mitad, pos, neg, k);
		else return busBin(mitad + 1, nfin, pos, neg, k);
	}
}

bool res() {
	ll n , k;
	cin >> n >> k;
	if (!cin) return false;
	vi pos, neg;

	for (int i = 0; i < n; ++i) {
		int num;
		cin >> num;
		if (num >= 0) pos.push_back(num);
		else neg.push_back(num);
	}

	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	reverse(neg.begin(), neg.end());

	ll INF = 1000000000000000000LL;

	ll sol = busBin(-INF, INF, pos, neg, k);

	cout << sol << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 2548
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  char op;           //文字入力
  while(true){
  cin>>a>>op>>b;
  if(op=='+'){
      cout<<(a+b)<<endl;
  }
  if(op=='-'){
      cout<<(a-b)<<endl;
  }
  if(op=='*'){
      cout<<(a*b)<<endl;
  }
  if(op=='/'){
      cout<<(a/b)<<endl;
  }
          if(op=='?'){
      break;
  }
}

}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

vector< vector<int> >P;

vector<int> VC;

map< pair<int, int>, int > M;

int c_max = 0;

void dfs( int v, int c ) {

    int color = 0;

    for ( int i = 0; i < P[v].size(); i++ ) {
        int next = P[v][i];
        
        color++;
        if ( color == c ) { color++; }

        if ( VC[ M[make_pair( v, next )] ] > 0 ) {  color--; continue; }
        VC[ M[make_pair( v, next )] ] = color;
        c_max = max( c_max, color );
        dfs( next, color );
    }
}

int main() {

    int N;
    cin >> N;
    
    P.resize(N);
    VC.resize(N, 0);

    for ( int i = 0; i < N-1; i++ ) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        P[a].push_back(b);
        P[b].push_back(a);

        M[make_pair(a,b)] = i;
        M[make_pair(b,a)] = i;
    }

    dfs( 0, 0 );

    cout << c_max << endl;
    for ( int i = 0; i < N-1; i++ ) {
        cout << VC[i] << endl;
    }




    return 0;
}

Measured memory_bytes: 18944
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
t = [int(input()) for i in range(D)]

last = {}
for i in range(1,27):
    last[i] = 0

satisfaction = 0
for d in range(1,D+1):
    satisfaction += s[d-1][t[d-1]-1]
    last[t[d-1]] = d
    for i in range(1,27):
        satisfaction -= c[i-1]*(d-last[i])
    print(satisfaction)


Measured memory_bytes: 68504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,ans=0;
    cin>>n;
    for(int i=1,t,y;i<=n;i++) {
	int x=gi();
	if(i==1) t=-1,++ans;
	else if(x!=y) {
	    if(t==-1) t=(x>y);
	    else if(t!=(x>y)) t=-1,++ans;
	}
	y=x;
    }
    cout<<ans;
    return 0;
}

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

int main(){
    int ten_sum;

    while(cin >> ten_sum, ten_sum != 0){
        int sum = 0;
        for(int i=1; i<=9; i++){
            int tmp;
            cin >> tmp;
            sum += tmp;
        }

        cout << ten_sum-sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
char t[100009];
int vis[100009];
int ans=0,r,s,p,n,k;
int main()
{
    cin>>n>>k>>r>>s>>p;
    for(int i=1;i<=n;i++){
        cin>>t[i];
        if(i-k>0&&vis[i-k]&&t[i]==t[i-k])continue;
        if(t[i]=='r')ans+=p;
        if(t[i]=='s')ans+=r;
        if(t[i]=='p')ans+=s;
        vis[i]=1;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int ans = 0, r = 0;
    for(int i = 0; i < 3; ++i){
        if(S[i] == 'S'){
            ans = max(ans, r);
            r = 0;
        }
        else{
            ++r;
        }
    }
    ans = max(ans, r);
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll ans = (N % 2 == 0) ? N : N * 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	init_C(3100000);
	long long ret=0;
	for(int i=b;i<=3*b/2;i++){
		int A=i;
		int B=3*b-i*2;
		int C=a-1-B;
	//	printf("%d %d %d\n",A,B,C);
		if(B<0||C<0)continue;
		ret=(ret+Comb(A+B+C,A+B)*Comb(A+B,A))%mod;

	}
	for(int i=b;i<=(3*b-1)/2;i++){
		int A=i;
		int B=3*b-1-i*2;
		int C=a-1-B;
	//	printf("%d %d %d\n",A,B,C);
		if(B<0||C<0)continue;
		ret=(ret+Comb(A+B+C,A+B)*Comb(A+B,A))%mod;
	}
	ret=(ret+mod-a*Comb(b-1+a-1,a-1)%mod)%mod;
	printf("%lld\n",ret);
}

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

int main(){
    using namespace std;
    int N; cin >> N;
    string s; cin >> s;

    for (int i = 0; i < s.size(); i++)
    {
        s[i] = (char) ((int) s[i] + N);
        if(s[i]>'Z') s[i] -= 26;
    }
    cout << s << endl;
}


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

int bfs(vector<string> &maze, vector<vector<int> > &moving_count, int i, int j, int H, int W){
    if (maze[i][j] == '#'){
        return 0;
    }
    vector<int> dx(4);
    dx[0] = 1;
    dx[1] = 0;
    dx[2] = -1;
    dx[3] = 0;
    vector<int> dy(4);
    dy[0] = 0;
    dy[1] = 1;
    dy[2] = 0;
    dy[3] = -1;
    queue<pair<int,int> > que;
    que.push(pair<int,int> (i,j));
    moving_count[i][j] = 0;
    while(que.size() != 0){
        pair<int,int> p = que.front();
        que.pop();
        rep(a,4){
            int nx = p.second + dx[a];
            int ny = p.first + dy[a];
            if (0 <= nx && nx < W && 0 <= ny && ny < H && maze[ny][nx] == '.' && moving_count[ny][nx] == 150){
                que.push(pair<int,int>(ny,nx));
                moving_count[ny][nx] = moving_count[p.first][p.second] + 1;
            }
        }
        /*rep(k,moving_count.size()){
            rep(l,moving_count[k].size()){
                cout << moving_count[k][l] << " ";
            }
        }
        cout << endl;*/
    }
    int num_max = 0;
    rep(k,moving_count.size()){
        rep(l,moving_count[k].size()){
            if (moving_count[k][l] != 150){
                num_max = max(moving_count[k][l], num_max);
            }
        }
    }
    return num_max;
}

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> maze(H);
    rep(i,H){
        cin >> maze[i];
    }
    int ans = 0;
    rep(i,H){
        rep(j,W){
            vector<vector<int> > moving_count(H,vector<int>(W));
            rep(k,H){
                rep(l,W){
                    moving_count[k][l] = 150;
                }
            }
            int ans_sub = bfs(maze, moving_count, i, j, H, W);
            ans = max(ans, ans_sub);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

const double pi=3.1415;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
}
int main()
{
   int n,m;
   cin>>n>>m;
   vector<int>cnt(n,0);
   vector<int>h(n);
   rep(i,n)cin>>h[i];
   int a,b;
   rep(i,m){
   	cin>>a>>b;
   	a--;b--;
   	if(h[a]>h[b])cnt[b]++;
   	else if(h[b]>h[a])cnt[a]++;
   	else{cnt[a]++;cnt[b]++;}
   }
   int ans=0;
    rep(i,n)if(cnt[i]==0){ans++;}
   cout<<ans;
}


Measured memory_bytes: 4052
//Face Produces Unhappiness
//Naru
#include<iostream>
using namespace std;

char West[100001];

int main() {
  int N, K;
  cin >> N >> K;
  for(int i=1; i<=N; i++) {
    cin >> West[i];
  }
  //違うところ調べる
  int diff = 0;
  for(int i=1; i<=N-1; i++) {
    if(West[i] != West[i+1]) diff++;
  }
  //計算
  int ans = diff;
  int cnt = 0;
  while(cnt < K) {
    if(ans <= 0) break;
    ans--;
    if(ans <= 0) break;
    ans--;
    if(ans <= 0) break;
    cnt++;
  }
  cout << N-1-ans << endl;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   ll x, y;
   cin >> x >> y;
   ll ans = 1;
   while (1) {
      x *= 2;
      if (x > y) break;
      ans++;
      // debug(x)
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
import sys
def euclid(data):
    a=data[0]
    for b in data[1:]:
        if(b<a):
            a,b=b,a
        while(1):
            r=b%a
            if(r==0):
                break
            else:
                b=a
                a=r
    return a


S_l,T_l=map(int,input().split())
S=input()
T=input()

lcm=S_l*T_l//euclid([S_l,T_l])
dS=lcm//S_l
dT=lcm//T_l

llcm=dS*dT//euclid([dS,dT])
ddS=llcm//dS
ddT=llcm//dT

i=0
while(ddS*i < S_l and ddT*i < T_l):
    if(S[ddS*i]!=T[ddT*i]):
        print(-1)
        sys.exit(0)
    i+=1
print(lcm)

Measured memory_bytes: 3316
def main():
    from collections import deque
    N, M = (int(i) for i in input().split())
    G = [[] for _ in range(N)]
    deg = [0]*N
    for _ in range(M):
        a, b = (int(i) for i in input().split())
        G[a-1].append(b-1)
        deg[b-1] += 1

    dist = [10**6]*(N)

    def topological_sort():
        """
        deg[i] := 頂点iの入次数
        グラフ入力時に計算
        """
        que = deque()
        for i in range(N):
            if deg[i] == 0:
                que.append(i)
                dist[i] = 0

        while que:
            u = que.popleft()
            for v in G[u]:
                deg[v] -= 1
                if deg[v] == 0:
                    que.append(v)
                    dist[v] = dist[u] + 1

    topological_sort()

    print(max(dist))


if __name__ == '__main__':
    main()


Measured memory_bytes: 88996
#include<bits/stdc++.h>
#include<vector>
#include<cstring>
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int a[300];
int b[100003];
int main()
{
 int n,m;
 cin>>n>>m;
 cout<<n-(m-1)<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_9_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            string target = ReadSt();
            int res = 0;

            while (true)
            {
                string[] line = ReadStAr();

                if (line[0].Equals("END_OF_TEXT")) break;
                res += line.Count(x => String.Compare(x, target, true) == 0);
            }

            Console.WriteLine(res.ToString());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 17044
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

s = rls()
ans = ["" for i in s]
idx = 0
for i in s:
    if(i == "B"):
        idx -= 1
        if(idx == -1):
            idx += 1
        else:
            ans[idx] = ""
    else:
        ans[idx] = i
        idx += 1
print(pli(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n;
pair<int,int> a[100010];
vector<int> dict;

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
}

void solve() {
    sort(a,a+n);
    int ans = 0;
    int l = 1, r = 1e9;
    multiset<int> st;
    multiset<int> left,right;
    for (int i = 0; i < n; i++) {
        l = max(l,a[i].fi);
        r = min(r,a[i].se);
        left.insert(a[i].fi);
        right.insert(a[i].se);
        st.insert(a[i].se);
    }
    for (int i = 0; i < n; i++) {
        left.erase(left.find(a[i].fi));
        right.erase(right.find(a[i].se));
        ans = max(ans, max(0,*right.begin() - *left.rbegin() + 1) + a[i].se - a[i].fi + 1);
        left.insert(a[i].fi);
        right.insert(a[i].se);
    }
    for (int i = 0; i < n - 1; i++) {
        st.erase(st.find(a[i].se));
        ans = max(ans, max(0,r - a[i].fi + 1) + max(0,*st.begin() - l + 1));
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	ll n, y; cin >> n >> y;
	ll m10000 = -1, m5000 = -1, m1000 = -1;

	for (ll i = 0; i <= n; i++)
	{
		for (ll j = 0; j <= n-i; j++)
		{
			ll k = n - i - j;
			if (i * 10000 + j * 5000 + k * 1000 == y)
			{
				m10000 = i;
				m5000 = j;
				m1000 = k;
			}
		}
	}

	cout << m10000 << " " << m5000 << " " << m1000 << endl;
}

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

using namespace std;

int N, R, L;
set<pair<int, int> >  TeamInfo;
int TotalScoreOfTeam[100001];
int TotalTime[100001];


void solve(int id, int score) {
	set<pair<int, int> >::iterator it;

	it = TeamInfo.find(make_pair(-TotalScoreOfTeam[id], id));
	if ( it != TeamInfo.end()) {
		TeamInfo.erase(it);
	}
	TotalScoreOfTeam[id] += score;
	TeamInfo.insert(make_pair(-TotalScoreOfTeam[id], id));
}

int main() {
	int d, t, x, preTime;

	memset(TotalTime, 0, sizeof(TotalTime));
	memset(TotalScoreOfTeam, 0, sizeof(TotalScoreOfTeam));
	TeamInfo.clear();
	preTime = 0;

	cin >> N >> R >> L;
	for (int i = 0; i < N; ++i) {
		TeamInfo.insert(make_pair(0, i + 1));
	}
	for (int i = 0; i < R; ++i) {
		cin >> d >> t >> x;
		
		TotalTime[TeamInfo.begin()->second] += t - preTime;
		solve(d, x);
		preTime = t;
	}
	TotalTime[TeamInfo.begin()->second] += L - preTime;

	cout << max_element(TotalTime + 1, TotalTime + N + 1) - TotalTime << endl;

	return 0;
}



Measured memory_bytes: 8568
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n; cin >> n;
	deque<int> d;
	Rep(n){
		int a; cin >> a;
		int i = lower_bound(d.begin(), d.end(), a) - d.begin();
		if(i == 0){
			d.push_front(a);
		}else{
			d[i-1] = a;
		}
	}
	cout << d.size() << endl;
}


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

using namespace std;

int main(){
    long double a,b,h,m;

    long double kakudo;

    long double result;

    cin>>a>>b>>h>>m;

    m/=5;
    h+=m/12;
    long double wariai=(h-m);
    /*if(wariai>=6){
        wariai-=6;
    }*/

    kakudo=3.141592653589793238462643*abs(wariai)/6;
    //cout<<cos(kakudo)<<endl;

    result=sqrt(a*a+b*b-(2*a*b*cosl(kakudo)));

    cout<<setprecision(20)<<result<<endl;


}

Measured memory_bytes: 4164
#include <stdio.h>
#include <string.h>
int main(void){

    char S[1001],T[1001];
    scanf("%s",S);
    scanf("%s",T);

    int count, i, j, S_len, T_len, min;
    S_len = strlen(S);
    T_len = strlen(T);
    min = T_len;

    for(i=0; i<=(S_len-T_len); i++){
        count = 0;
        for(j=0; j<T_len; j++){
            if(T[j] != S[j+i]) count++;
        }
        if(min>count){
            min = count;
        }
    }

    printf("%d",min);

    return 0;
}

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

int main(){
    string S;cin>>S;
    if(S=="Sunny")cout<<"Cloudy"<<endl;
    else if(S=="Cloudy")cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n)cin >> l[i];
    sort(ALL(l));
    ll ans = 0;
    for(ll  a=0; a<l.size(); ++a){
        for(ll b=a+1; b<l.size(); ++b){
            ll low = upper_bound(l.begin()+b, l.end(), l[b]-l[a])-l.begin();
            ll high = lower_bound(l.begin()+b, l.end(), l[b]+l[a])-l.begin()-1;
            ll plus = high-low+1;
            if(a<=high&&a>=low)plus--;
            if(b<=high&&b>=low)plus--;
            ans += max(plus, (ll)0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int a[n] = {0};
    int i = 0;
    while(i < n - 1)
    {
        int x;
        cin >> x;
        a[x - 1]++;
        i++;
    }
    for(int i = 0; i < n; i++)
    {
        cout << a[i] << "\n";
    }
}

Measured memory_bytes: 4416
import fractions

N = int(input())
A = list(map(int,input().split()))
l = [0] * (N+1)
r = [0] * (N+1)

for i in range(1, N+1):
    l[i] = fractions.gcd(l[i-1], A[i-1])
for i in range(1, N+1):
    r[N-i] = fractions.gcd(r[N-i+1], A[N-i])

ans = 0
for i in range(N):
    kouyaku = fractions.gcd(l[i], r[i+1])
    ans = max(ans, kouyaku)

print(ans)

Measured memory_bytes: 16148
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto x : mp) {
        if (x.se%2 == 1) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    a,b,c = map(int,ipt().split())
    k = int(ipt())
    t = 0
    while a >= b:
        t += 1
        b *= 2
    while b >= c:
        t += 1
        c *= 2
    if k >= t:
        print("Yes")
    else:
        print("No")

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 74920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int a,b,c;

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

	cin >>a >> b >> c;

	if(a > b){
		swap(a,b);
	}	
	if(a > c){
		swap (a,c);
	}

	if(b > c){
		swap(b,c);
	}

	cout << a * b /2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 2005;

int n;
char str[MAXN];
int sz[MAXN];
vector<int> gph[MAXN];

void getsz(int x, int p){
	sz[x] = (str[x] == '1');
	for(auto &i : gph[x]){
		if(i == p) continue;
		getsz(i, x);
		sz[x] += sz[i];
	}
}

pi solve(int x, int p){
	pi ret(0, 0);
	vector<pi> ans;
	for(auto &i : gph[x]){
		if(i != p){
			auto r = solve(i, x);
			r.first += sz[i];
			r.second += sz[i];
			ret.second += r.second;
			ans.push_back(r);
		}
	}
	for(auto &i : ans){
		if(i.first >= ret.second - i.second){
			ret.first = max(ret.first, i.first - ret.second + i.second);
		}
	}
	return ret;
}

int main(){
	scanf("%d",&n);
	scanf("%s", str + 1);
	for(int i=0; i<n-1; i++){
		int s, e; scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	int ret = 1e9;
	for(int i=1; i<=n; i++){
		getsz(i, -1);
		auto ans = solve(i, -1);
		if(ans.first == 0 && ans.second % 2 == 0){
			ret = min(ret, ans.second / 2);
		}
	}
	if(ret > 1e8) ret = -1;
	cout << ret << endl;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N;
  double s,ans;
  vl A;
  cin >> N;
  REP(i,N){
		int x;
		cin >> x;
		A.push_back(x);
	}
  s = 0;
  REP(i,N){
    s = s+(double)1/A[i];
  }
  ans = 1/s;
  cout << setprecision(13) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_b

#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 MAX 100000
#define NIL -1
#define MOD 998244353

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll N;
    cin >> N;
    
    ll temp[MAX];
    rep(i, N) {
        temp[i] = 0;
    }
    
    bool flag = false;

    rep(i, N) {
        ll a;
        cin >> a;
        if(i==0&&a!=0) {
            flag = true;
        }
        temp[a]++;
    }
 
    ll root = temp[0];
    if (root != 1 || flag) {
        print(0);
        return 0;
    }
    
    ll ans = root;
    rep(i, N) {
        rep(j, temp[i+1]) {
            ans = ans * temp[i] % MOD;
        }
    }
    
    print(ans);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e3 + 20;
const ll mod = 1e9 + 7;
int s[maxn], t[maxn];
ll dp[maxn][maxn];
ll num[maxn][maxn];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &s[i]);
	for (int i = 1; i <= m; i++)
		scanf("%d", &t[i]);
	ll ans = 1;
	for (int i = 0; i <= 2010; i++)
		num[0][i] = num[i][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i] == t[j]) {
				dp[i][j] = num[i - 1][j - 1] % mod;
				ans = (ans + dp[i][j]) % mod;
			}
			num[i][j] = (num[i - 1][j] + num[i][j - 1] - num[i - 1][j - 1] + dp[i][j] + mod) % mod;
		}
	}
	printf("%lld\n", ans%mod);
	//system("pause");
}

Measured memory_bytes: 98176
import java.io.*;

public class Main {
           public static void main (String args[]){

           BufferedReader reader = new BufferedReader (new InputStreamReader (System.in));
           String line;

           try {
                   line = reader.readLine();
                   int number = Integer.parseInt(line);
                   if (number<1200){
                         System.out.println("ABC");
                  } else {
                        System.out.println("ARC");
                 }
                 }catch (IOException e){
                    System.out.println(e);
                 }catch (NumberFormatException e){
                     System.out.println("数字のみ");
                  }
}
}

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

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

    if(str[0] == 'R' && str[1] == 'R' && str[2] == 'R'){
        cout << 3 << endl;
    }else if((str[0] == 'R' && str[1] == 'R') || (str[1] == 'R' && str[2] == 'R')){
        cout << 2 << endl;
    }else if(str[0] == 'S' && str[1] == 'S' && str[2] == 'S'){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
using System.Linq;
using System.Collections.Generic;
using System;

public class PL
{
    public int t { get; set; }
    public int h { get; set; }
}
public class VM
{
    public int t { get; set; }
    public int zan { get; set; }
    public int tmax { get; set; }
}
public class hello
{
    public static void Main()
    {
        var pLs = new List<PL>();
        var q = new Queue<int>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        foreach (var x in Enumerable.Range(0, n)) q.Enqueue(x);
        var vm = new VM { t = int.Parse(line[1]),  tmax = int.Parse(line[3]) };
        for (int i = 0; i < n; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            pLs.Add(new PL { t = int.Parse(line2[0]), h = int.Parse(line2[1]) });
        }
        var ans = PlayGame(q, pLs, vm);
        Console.WriteLine(ans);
    }
    public static int PlayGame(Queue<int> q, List<PL> p, VM vm)
    {
        while (true)
        {
            var a = q.Dequeue(); q.Enqueue(a);
            if (p[a].t == 0 && p[a].h == 0) return a + 1;
            if (p[a].t == 0)
            {
                p[a].h--;
                vm.t -= (1 + vm.zan);
                if (vm.t < 0) return a + 1;
                p[a].t += (1 + vm.zan);
                vm.zan = 0;
            }
            else
            {
                p[a].t--;
                vm.t++;
                if (vm.t > vm.tmax) return a + 1;
                vm.zan++;
                if (vm.zan == 9) { vm.zan = 0;  }
            }
        }
    }
}

Measured memory_bytes: 10528
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int Q;
    cin >> Q;
    while (Q-- > 0) {
        int c, a, n, ans = 0;
        cin >> c >> a >> n;
        // 1 1 1
        for (int i = 0; i <= n; i++) {
            // 2 1 0
            for (int j = 0; j <= (a - i); j++) {
                // 3 0 0
                for (int k = 0; k <= (c - i - 2 * j) / 3; k++) {
                    int c_ = i + 2 * j + 3 * k,
                        a_ = i + j,
                        n_ = i;
                    if (c_ <= c && a_ <= a && n_ <= n) ans = max(ans, i + j + k);
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a == 1 || b == 1)
    {
        if (a == 2 || b == 2)
        {
            cout << 3 << endl;
        }
        else
        {
            cout << 2 << endl;
        }
    }
    else
    {
        cout << 1 << endl;
    }
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*
int dx[4]={-1,0,1,0};//四方に移動
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a=A;
    ll b=B;
    if (a==0 || b==0) {return 0;}
    if (a<0) {a=-a;}
    if (b<0) {b=-b;}
    while(b>0) {
        ll c=a%b;
        a=b;
        b=c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while(b!=0) {
        int t=b;
        b=a%b;
        a=t;
    }
    return a;
}

//入力はすべて正とする
bool is_prime(int n) {//素数判定o(√n)
    for (int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return n!=1;//1の場合は例外
}

vector<ll> divisor(ll n){//約数の列挙o(√n)
    vector<ll> res;
    for(ll i=1;i*i<=n;i++) {
        if(n%i == 0){
        res.push_back(i);
        if(i!=n/i)res.push_back(n/i);
        }
    }
    return res;
}//vector<ll>k=divisor(n);rep(i,k.size())cout<<k[i]<<endl;//のように使う

map<ll,ll> prime_factor(ll n){//素因数分解o(√n)
    map<ll,ll>res;    
    for(ll i=2;i*i<=n;i++) {
        while (n%i==0) { 
            ++res[i];
            n/=i;
        }
    }
    if (n!=1)res[n]=1;
    return res;
}//map<ll,ll> k=prime_factor(n);for(auto i=k.begin();i!=k.end();i++){cout<<i->first<<" "<<i->second<<endl;}//みたいに使う

vector<ll> prime_list(ll n){//n以下の素数を全て見つける
    vector<ll> is_prime(n);//is_prime[i]が1ならiは素数
    for(ll i=2;i<=n;i++)is_prime[i]=1;//最初はみんな素数かも
    for(ll i=2;i*i<=n;i++){//素数の整数倍を消していく(√nまで)
        if(is_prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    is_prime[j]=0;                
                }
            }
        }
    }return is_prime;
}vector<ll>k=prime_list(n);REP(i,n){if(k[i])cout<<i<<endl;}のように使う
*/
/*--------------------------------------------*/


int main(){
    int d,n;cin>>d>>n;
    cout<<(n==100?(int)((101)*pow(100,d)):(int)(n*pow(100,d)))<<endl;
}




Measured memory_bytes: 384
class Dice
  attr_accessor :a, :b, :c, :d, :e, :f

  def initialize(aaa, bbb, ccc, ddd, eee, fff)
    @a = aaa
    @b = bbb
    @c = ccc
    @d = ddd
    @e = eee
    @f = fff
  end

  def opposite(nnn)
    if nnn == a
      f
    elsif nnn == b
      e
    elsif nnn == c
      d
    elsif nnn == d
      c
    elsif nnn == e
      b
    elsif nnn == f
      a
    end
  end

  def spin(char)
    aa = @a
    bb = @b
    cc = @c
    dd = @d
    ee = @e
    ff = @f

    if char == 'E'
      @a = dd
      @c = aa
      @d = ff
      @f = cc
    elsif char == 'N'
      @a = bb
      @b = ff
      @e = aa
      @f = ee
    elsif char == 'S'
      @a = ee
      @b = aa
      @e = ff
      @f = bb
    elsif char == 'W'
      @a = cc
      @c = ff
      @d = aa
      @f = dd
    end
  end
end

a, b, c, d, e, f = gets.split.map(&:to_i)
dice = Dice.new(a, b, c, d, e, f)
q = gets.to_i
v = []

q.times do
  top, front = gets.split.map(&:to_i)
  found = false
  e_or_w = false

  until found
    if e_or_w
      dice.spin('E')
    else
      dice.spin('W')
    end
    e_or_w = !e_or_w

    3.times do
      dice.spin('S')
      if dice.a == top && dice.b == front
        found = true
        v << dice.c
        break
      elsif dice.a == front && dice.b == top
        found = true
        v << dice.opposite(dice.c)
        break
      end
    end
  end
end

v.each do |i|
  p i
end



Measured memory_bytes: 6884
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define watch(x)		cerr << #x << " = " << x << "\n"
#else
#define watch(x)		42
#endif

mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int dig(int n)
{
	int d=0;

	while(n != 0)
	{
		d++;
		n /= 10;
	}

	return d;
}

int32_t main()
{
	c_p_c();

	int n; cin>>n;

	int a[n];

	int mx = 1e18;

	int ans = 1;

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

	}

	sort(a, a+n);

	for (int i = 0; i < n; ++i)
	{
		// cout << ans << '\n';

		if(ans == -1)
			continue;

		if(ans != 0 && a[i] > ceil(mx/ans))
		{
			ans = -1;
		}else
			ans *=a[i];
	}

	if(ans > mx)
		ans = -1;


	cout << ans;
	
	return 0;
}

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

typedef long long int lli;

long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
typedef pair<int,int> pii;
typedef vector<int> vi;
void solve(){
  string s;
  cin>>s;
  int n = s.length();
  vi ans(n+1);
  for(int i = 0;i<n;i++){
    if(s.at(i)=='<')
    ans[i+1] = max(ans[i+1],ans[i]+1);
  }

  for(int i = n-1;i>=0;i--){
    if(s.at(i)=='>'){
      ans[i] = max(ans[i],ans[i+1]+1);
    }
  }
  lli tot = 0;
  for(int i = 0;i<=n;i++){
    tot+=ans[i];
  }
  cout<<tot;
  
}

int main(){
  solve(); 
}

Measured memory_bytes: 2820