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

int gcd(int a,int b){
    int c;
    if(a<b){
        a+=b;
        b=a-b;
        a-=b;
    }
    while(b!=0){
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
 
int main(){
    int data0,data1;
    int answer;
    while(cin>>data0>>data1){
        answer=gcd(data0,data1);
        cout<<answer<<" "<<data0/answer*data1<<endl;
    }
}

Measured memory_bytes: 3040
#include "stdio.h"
int main(void)
{
	int num[10000],i,j,k,tmp;
	for(i=0;;i++){
		scanf("%d",&num[i]);
		if(i%2 != 0){
			if(num[i]==0 && num[i-1]==0){
				tmp = i;
				break;
			}
		}
	}
	for(i=0;i<tmp-1;i++){
		for(j=0;j<num[i];j++){
			for(k=0;k<num[i+1];k++){
				if(j==0 || j==num[i]-1 || k==0 || k==num[i+1]-1)
					printf("#");
					else
					printf(".");	
			}
			printf("\n");
		}
		printf("\n");
		i++;
	}
	return 0;
}


Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

void trace(vector<int>& a) {
    for (int i = 0; i < a.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
}

void bubbleSort(vector<int>& a) {
    int n = a.size();
    int count = 0;
    for (int i = 0; i < n; i++) {
        bool swapped = false;
        for (int j = n - 1; j >= i + 1; j--) {
            if (a[j - 1] > a[j]) {
                swap(a[j - 1], a[j]);
                swapped = true;
                count++;
            }
        }
        if (!swapped) {
            break;
        }
    }
    trace(a);
    cout << count << endl;
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bubbleSort(a);
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

typedef long long ll;
#define fi first
#define se second




using namespace std;

int main(){
  
  int ans;
  int A, B;
  
  
  
  cin>>A>>B;
  
  ans = A + B;
  
  if( ans > 23 ) ans -= 24;
  
   
  cout<<ans<<endl;
  
  return 0;
}

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

using namespace std;

int main(void)
{
    int N;
    vector<int> lower;

    cin >> N;

    /* first number */
    int before;
    cin >> before;

    for (int i = 0; i < N - 1; i++)
    {
        int h;
        cin >> h;
        if (h <= before)
        {
            lower.push_back(1);
        }
        else
        {
            lower.push_back(0);
        }
        before = h;
    }

    if (lower.size() == 0)
    {
        cout << "0" << endl;
        return 0;
    }

    int max = 0;
    int count = 0;
    for (int i = 0; i < lower.size(); i++)
    {
        if (lower[i] == 1)
        {
            count++;
        }
        else
        {
            if (max < count)
            {
                max = count;
            }
            count = 0;
        }
    }

    if (max < count)
    {
        max = count;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 892
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
b = [0 for i in range(n)]
count = 0
for i in range(n):
    if x - a[i] == 0:
        count += 1
        x -= a[i]
        b[i] = 1
    elif x - a[i] > 0 and i != n-1:
        count += 1
        x -= a[i]
        b[i] = 1
    """
    else:
        if x != 0 and i == n-1:
            if count > 0:
                print(count-1)
                print("aaaaa")
                exit()
            else:
                print(0)
                exit()
        elif x == 0:
            print(count)
            exit()
        else:
            print(count)
        exit()
    print(b)
    """
print(count)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
map<int, ll> a;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    ll tmp;
    scanf("%lld", &tmp);

    a[i] = tmp;
  }

  vector<int> idx;

  for (auto &e : a) {
    idx.push_back(e.first);
  }

  ll ans = 0LL;

  for (int i = 0; i < idx.size(); ++i) {
    {  // about idx[i];
      ll commit = a[idx[i]] / 2LL;
      ans += commit;
      a[idx[i]] -= 2LL * commit;

      // printf("idx[i]: %d, commit: %d\n", idx[i], commit);
    }

    {  // about idx[i] and idx[i] + 1 (if idx[i] + 1 exist)
      int next_target = idx[i] + 1;
      if (a.find(next_target) != a.end()) {
        ll commit = min(a[idx[i]], a[next_target]);

        ans += commit;

        a[idx[i]] -= commit;
        a[next_target] -= commit;
        // printf("idx[i]: %d, next_target: %d, commit: %d\n", idx[i], next_target, commit);
      }
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 9084
#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;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, y;
    cin >> n >> y;
    y /= 1000;
    rep(i, 0, 20001){
        rep(j, 0, 20001){
            int tmp = i * 10 + j * 5;
            int k = y - tmp;
            if(0 <= k && i + j + k == n){
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                ios_base::sync_with_stdio(false);
                cin.tie(NULL);
                lli t,n,i,j,b,a,q,m;
                cin>>n;
                vector<lli> v(n);
                rep(i,n-1)cin>>v[i];
                map<lli,lli> mp;
                rep(i,n)mp[v[i]]++;
                rep(i,n)cout<<mp[i+1]<<endl;

            }



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

int main() {
  string a, b;
  cin >> a >> b;
  int x = stoi(a+b);
  
  for(int i = 1; i <= 1000; i ++){
    if ( x == i*i){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  ll x;
  cin >> x;
  ll ans = 0, a = 100;
  while (a < x) {
    a += a / 100;
    ans++;
  }
  cout << ans << endl;
  return(0);
}


Measured memory_bytes: 3556
import itertools
import math


N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

pairs = list(itertools.permutations(A, N))

ans = 0
for p in pairs:
    x1, y1 = p[0]
    for i in range(1, N):
        x2, y2 = p[i]
        ans += math.hypot(x1-x2, y1-y2)
        x1, y1 = x2, y2

ans /= len(pairs)
print(ans)


Measured memory_bytes: 46316
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int main()
{
	int n=read(),s=0;while(n--)s+=read()&1;
	puts((s&1)?"NO":"YES");return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: OakenSh1eld
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ld a, b, x; cin>>a>>b>>x;
	ld y = 2.000000*x / (a*b), ans;
	if (y > a) {
		ld z = (2.000000*x - a*a*b) / (a*a);
		b-=z;
		ans = 180.000000/acos(-1) * atan(b/a);
	}else ans = 180.000000/acos(-1) * atan(b/y);
	cout<<setprecision(9);
	cout<<fixed<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

double pi = 3.1415926535897932384626433;

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

    double time = 60*h + m;

    double pos_a = (time  / (60.0 * 12.0)) * 360.0;
    double pos_b = (m / 60.0) * 360.0;

    double r = abs(pos_a - pos_b);
    r = min(r, 360.0 - r) * (pi/180.0);
    double ans = a*a + b*b - (2.0 * a * b)*cos(r);

    printf("%.10f\n", sqrt(ans));
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

int main(){
    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


void solve(std::vector<long long> H, std::vector<long long> M, long long K){
  long long ret = (H[1]-H[0]) * 60 + (M[1] - M[0]) - K;
  cout << ret << endl;
}

int main(){
    std::vector<long long> H(2);
    std::vector<long long> M(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&H[i]);
        scanf("%lld",&M[i]);
    }
    long long K;
    scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
    return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a=0,b=0,ba=0;
    int ans=0;
    rep(i,n){
        string s;
        cin>>s;
        int m=s.size();
        rep(i,m-1)if(s[i]=='A'&&s[i+1]=='B')++ans;
        if(s[0]=='B'&&s[m-1]=='A')++ba;
        else if(s[0]=='B')++b;
        else if(s[m-1]=='A')++a;
    }
    //cerr<<a<<" "<<b<<" "<<ba<<endl;
    if(a>0&&b>0){
        ans+=min(a,b)+ba;
    }
    else if(a>0){
        ans+=ba;
    }
    else if(b>0)ans+=ba;
    else ans+=max(0,ba-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
const int INF = 1001001001;
const ll LINF = 1e18;
const ll mod = 1e9 + 7;

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

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}

ll C(ll n, ll k, vl f) {
    ll a = f[n]; // = n!
    ll b = f[n-k]; // = (n-k)!
    ll c = f[k]; // = k!
    
    ll bc = (b * c) % mod;
    
    return (a * inv(bc)) % mod;
}

int main() {
    ll N, M; cin >> N >> M;
    auto f = prime_factor(M);
    
    vl F(101010, 0); F[0] = 1;
    for(ll i = 1; i < F.size(); i++) F[i] = (F[i - 1] * i) % mod;
    
    ll ret = 1;
    for(auto it = f.begin(); it != f.end(); it++){
        if(it->second != 0){
            ret *= C(N - 1 + it->second, min(N - 1, it -> second), F) % mod;
            ret %= mod;
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  string a,b;
  cin>>a>>b;
  for(int i=0;i<b.size();i++){
  cout<<a.at(i)<<b.at(i);
  }
  if(a.size()==b.size()){}
  else{
    cout<<a.at(a.size()-1);
  }
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int cnt2 = 0, cnt4 = 0, cnt1 = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;

        if(a % 2)
            cnt1++;
        else if(a % 4 == 0)
            cnt4++;
        else
            cnt2++;
    }

    if(cnt1 - cnt4 == 1){
        if(cnt2)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    else if(cnt4 >= cnt1)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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

void	Move(int x1, int y1, int x2, int y2, vector<string> &S) {
	int m;
	if (x1>x2) m=-1;
	else m=1;
	while (x1 != x2) {
		S.push_back(to_string(x1)+' '+to_string(y1)+' '
				+to_string(x1+m)+' '+to_string(y1));
		x1 += m;
	}
	if (y1>y2) m=-1;
	else m=1;
	while (y1 != y2) {
		S.push_back(to_string(x1)+' '+to_string(y1)+' '
				+to_string(x1)+' '+to_string(y1+m));
		y1 += m;
	}
}

int	main() {
	int H, W;
	cin >>H >>W;
	vector<vector<int> > a(H, vector<int> (W, 0));
	// Read Data into 2D Array
	for (int i=0; i<H; i++)
		for (int j=0; j<W; j++)
			cin >> a.at(i).at(j);
	bool flag=false;
	int x0=0;
	int y0=0;
	if (1==a.at(x0).at(y0)%2) flag=true;
	vector<string> S(0);
	for (int i=1; i<H*W; i++) {
		int x=i/W;
		int y=i%W;
		if (1==x%2) y=W-y-1;
		if (flag) Move(x0+1, y0+1, x+1, y+1, S);
		if (1==a.at(x).at(y)%2) flag=!flag;
		x0=x;
		y0=y;
	}
	cout <<S.size() <<endl;
	if (0!=S.size()) {
		for (int i=0; i<S.size(); i++) {
			cout << S.at(i) << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 11892
import math
n = 1000001
rn = round(math.sqrt(n)) + 1
tbl = [True for i in range(n)]
tbl[0], tbl[1] = False,False
for i in range(4,n,2):
    tbl[i] = False
for i in range(3,rn,2):
    if tbl[i]:
        for j in range(i*2,n,i):
            tbl[j] = False
n = int(input())
while 1:
    print(sum(tbl[:n+1]))
    try: n = int(input())
    except EOFError:break


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


int main() {
  int N,i,j,ans=0,M=0;
  cin>>N;
  vector<int> A(N),a(1000001);
  for(i=0;i<N;i++){
    cin>>A[i];
    a[A[i]]++;
    M=max(A[i],M);
  }
  sort(A.begin(), A.end());
  for(i=0;i<N;i++){
    if(a[A[i]]==1)ans++;
    for(j=2;A[i]*j<=M;j++)a[A[i]*j]=0; 
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8004
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ii a[n];
	forn(i,0,n) cin>>a[i].S>>a[i].F;
	sort(a,a+n);
	
	ll tot=0;
	forn(i,0,n){
		tot+=a[i].S;
		if(tot>a[i].F){ cout<<"No\n"; exit(0); }
	}
	cout<<"Yes\n";
	
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 1000000;
  for (int i = a[0]; i <= a[n-1]; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (i - a[j])*(i - a[j]);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
}

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

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<int> a(n);
    for (int &i: a) scanf("%d", &i);
    priority_queue<int> pq;
    for (int i: a) pq.push(i);
    for (int i=0; i<m && !pq.empty(); i++) {
        int l = pq.top();
        // printf("%d\n", l);
        // if (l==0) break;
        pq.pop();
        l = l>>1;
        if (l) pq.push(l);
    }
    long long sm = 0;
    while (!pq.empty()) {
        sm += pq.top();
        pq.pop();

    }
    printf("%lld\n", sm);
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  vector<ll> asum(n + 1, 0), bsum(m + 1, 0);
  repz(i, 1, n + 1) { asum[i] = asum[i - 1] + a[i - 1]; }
  repz(i, 1, m + 1) { bsum[i] = bsum[i - 1] + b[i - 1]; }
  // rep(i, n + 1) { debug(asum[i]); }
  // rep(i, m + 1) { debug(bsum[i]); }
  ll res = 0;
  rep(i, n + 1) {
    if (k - asum[i] < 0) continue;
    ll temp = upper_bound(ALL(bsum), k - asum[i]) - bsum.begin();
    res = max(temp + i - 1, res);
    // cout << temp << endl;
  }
  cout << res << endl;
  ret;
}


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

p = [m[0][0]]
for i in range(n):
    p.append(m[i][1])

INF = 1 << 60
dp = [[INF] * n for _ in range(n)]

for i in range(n):
    dp[i][i] = 0

for x in range(1, n):
    for i in range(n - x):
        j = i + x
        for k in range(i, j):
            dp[i][j] = min((dp[i][j], dp[i][k] + dp[k + 1][j] + p[i] * p[k + 1] * p[j + 1]))

print(dp[0][-1])


Measured memory_bytes: 5720
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC116A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadInt;
            var b = ReadInt;
            var c = ReadInt;

            Console.WriteLine(a * b / 2);


        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

const long long INF = 1e18;

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    if(!a[0]) fin(0);
    ll ans = 1;
    rep(i,n){
        if(INF/ans+100<a[i])fin(-1);
        ans *=a[i];
        if (ans> INF)fin(-1);
    }
    fin(ans);

}
/*
int main() {
    int n;
    cin >> n;
    ull ans=1;
//    int cnt=0;
    ull ref = pow(10,18);

    ull realans=10;
    rep(i,n){
        ull tmp;
        ull oldans = ans;
        cin>>tmp;
        ans *=tmp;
        if(ans>ref){
            realans = 2;
        }
        if(tmp==0){
            realans=0;
            break;
        }
        if (ans/tmp != oldans) {
            realans=2;
            //ここにbreakを入れてたのがミス！！！！！！！！！！！！
        }
    }

    switch(realans){
        case 2:
            cout<<-1<<endl;
            break;
        case 0:
            cout<<0<<endl;
            break;
        case 10:
            cout<<ans<<endl;
            break;

    }
    return 0;
}
*/


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

typedef long long ll;
const ll mo=1e9+7;
const int maxn=100010;
char s[maxn];
int n;
ll f[maxn][4],g[maxn][4];
ll powmod(ll a,ll b)
{
	if (b<0)	return 0;
	ll ans=1;
	while (b)
	{
		if (b&1)	ans=(ans*a)%mo;
		a=(a*a)%mo;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++)
	{
		for (int k=0;k<4;k++)
			f[i][k]=f[i-1][k];
		if (s[i]=='A')	f[i][0]++;
		if (s[i]=='B')	f[i][1]++;
		if (s[i]=='C')	f[i][2]++;
		if (s[i]=='?')	f[i][3]++;
	}
	for (int i=n;i>=1;i--)
	{
		for (int k=0;k<4;k++)
			g[i][k]=g[i+1][k];
		if (s[i]=='A')	g[i][0]++;
		if (s[i]=='B')	g[i][1]++;
		if (s[i]=='C')	g[i][2]++;
		if (s[i]=='?')	g[i][3]++;
	}
	int sum=f[n][3];
	ll ans=0;
	for (int i=2;i<n;i++)
	if (s[i]=='B' || s[i]=='?')
	{
		if (s[i]=='B')
		{
			ans=(ans+f[i-1][0]*g[i+1][2]%mo*powmod(3,sum)%mo)%mo;
			ans=(ans+f[i-1][3]*g[i+1][2]%mo*powmod(3,sum-1)%mo)%mo;
			ans=(ans+f[i-1][0]*g[i+1][3]%mo*powmod(3,sum-1)%mo)%mo;
			ans=(ans+f[i-1][3]*g[i+1][3]%mo*powmod(3,sum-2)%mo)%mo;
		}	else
		{
			ans=(ans+f[i-1][0]*g[i+1][2]%mo*powmod(3,sum-1)%mo)%mo;
			ans=(ans+f[i-1][3]*g[i+1][2]%mo*powmod(3,sum-2)%mo)%mo;
			ans=(ans+f[i-1][0]*g[i+1][3]%mo*powmod(3,sum-2)%mo)%mo;
			ans=(ans+f[i-1][3]*g[i+1][3]%mo*powmod(3,sum-3)%mo)%mo;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long max_a = 0;
  long max_b = 0;
  long min_a = 0;
  long min_b = 0;
  
  long A,B,X;
  cin >> X;
  
  A = 0;
  B = 0;
  for(;;){
    max_a++;
    min_a--;
    max_b++;
    min_b--;

    for(;B<max_b;B++){
      if(pow(A,5)-pow(B,5)==X) break;
    }
    for(;A>min_a;A--){
      if(pow(A,5)-pow(B,5)==X) break;
    }
    for(;B>min_b;B--){
      if(pow(A,5)-pow(B,5)==X) break;
    }
    for(;A<max_a;A++){
      if(pow(A,5)-pow(B,5)==X) break;
    }
    if(pow(A,5)-pow(B,5)==X) break;
  }
  
  
  
  cout << A << ' ' << B << endl;
  return 0;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> t(h);
  for(auto&& l:t) cin>>l;
  int n=h*w;
  constexpr int INF = 1000000000;
  vector<vecint> m(n, vecint(n, INF));
  for(auto&& i:irange(0,n)) m[i][i] = 0;
  for(auto&& i:irange(0,h-1)) {
    for(auto&& j:irange(0,w)) {
      if (t[i][j] == '.' && t[i+1][j] == '.') {
        m[i*w+j][(i+1)*w+j] = 1;
        m[(i+1)*w+j][i*w+j] = 1;
      }
    }
  }
  for(auto&& i:irange(0,h)) {
    for(auto&& j:irange(0,w-1)) {
      if (t[i][j] == '.' && t[i][j+1] == '.') {
        m[i*w+j][i*w+j+1] = 1;
        m[i*w+j+1][i*w+j] = 1;
      }
    }
  }
  for(auto&& k:irange(0,n)) {
    for(auto&& i:irange(0,n)) {
      for(auto&& j:irange(0,n)) {
        m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
      }
    }
  }
  int mx = 0;
  for(auto&& i:irange(0,n)) {
    for(auto&& j:irange(0,n)) {
      if (m[i][j] < INF) mx = max(mx, m[i][j]);
    }
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define LL long long
#define mod 1000000007
#define INF (0x3f3f3f3f)
using namespace std;
char s[30],b[26];
int f;
int main() {
  cin>>s;
  for(int i=0;s[i];i++) {
    b[s[i]-'a']=1;
  }
  int l=strlen(s);f=1;
  if(l<26) {
  for(int i=0;i<26;i++)
    if(b[i]==0) {s[l]=i+'a'; s[l+1]='\0';break; }
   } else {
     f=0;
     for(int i=0;i<26;i++) b[i]=0;
     b[s[25]-'a']=1;
     for(int i=24;i>=0;i--) {
       if(s[i]<s[i+1]) {
         int j=s[i]-'a';
         for(;j<26;j++) if(b[j]) break;
         s[i] = j+'a'; s[i+1]='\0'; f=1; break;
       }
       b[s[i]-'a'] = 1;
     }
   }

  if(!f) cout<<-1<<endl;
  else cout<<s<<endl;

  return 0;
}

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

namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();

            bool checkX = false;
            bool checkY = false;

            if (s.Contains('W') && s.Contains('E')) checkX = true;
            if (!s.Contains('W') && !s.Contains('E')) checkX = true;
            if (s.Contains('N') && s.Contains('S')) checkY = true;
            if (!s.Contains('N') && !s.Contains('S')) checkY = true;

            if (checkX && checkY) Console.WriteLine("Yes");
            else Console.WriteLine("No");

            
            
		}

	}
}

Measured memory_bytes: 2904
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ccs
{
    class Program
    {
        static void Main( string[] args ) {
            var abcd = Console.ReadLine().Split( ' ' ).Select( x => Int32.Parse( x ) ).ToArray();

            var sx = abcd[0];
            var sy = abcd[1];
            var tx = abcd[2];
            var ty = abcd[3];

            var ans = "";
            Int32 px=sx, py=sy;

            //first time
            {
                //go

                while (ty != py++)
                    ans += "U";
                while (tx != px++)
                    ans += "R";

                --px;--py;
                //back
                while (sy != py--)
                    ans += "D";

                while (sx != px--)
                    ans += "L";
                ++px;++py;

            }

            //second time
            {

                //go
                --px; ans += "L";
                while (ty + 1 != py++)
                    ans += "U";

                while (tx != px++)
                    ans += "R";

                --px;--py;

                --py; ans += "D";


                //back
                ++px; ans += "R";
                while (sy-1 != py--)
                    ans += "D";

                while (sx != px--)
                    ans += "L";
                ++px;++py;
                ++py; ans += "U";
            }
            Console.WriteLine( ans );
        }
    }
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		++cnt[a[i]];
	}
	vector<pair<int, int>> vp;
	for (auto p : cnt) {
		vp.emplace_back(p.first, p.second);
	}
	if (N % 3 != 0) {
		puts(vp.size() == 1 ? "Yes" : "No");
		return 0;
	}
	if (vp.size() == 1) {
		puts(vp[0].first == 0 ? "Yes" : "No");
		return 0;
	}
	int sz = N / 3;
	if (vp.size() == 3) {
		puts(vp[0].second == sz && vp[1].second == sz && vp[2].second == sz && (vp[0].first ^ vp[1].first ^ vp[2].first) == 0 ? "Yes" : "No");
		return 0;
	}
	if (vp[0].second > vp[1].second) swap(vp[0], vp[1]);
	puts(vp[0].second == sz && vp[1].second == sz * 2 && vp[0].first == 0 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define pb push_back
#define SZ(x) ((int)x.size())
#define fi first
#define se second
#define mp make_pair
const int N=100010;
int n,m;
vector<int> e[N];
bool vis[N];
int dfn[N],cnt;
int dfs(int la,int x){
	dfn[x]=++cnt;vis[x]=1;
	int count=0;
	ref(i,0,SZ(e[x])-1){
		int y=e[x][i];
		if(vis[y]){
			if(y!=la&&dfn[y]<dfn[x]){
				cout<<x<<" "<<y<<endl;
				count++;
				continue;
			}
			continue;
		}else
		count+=dfs(x,y);
	}
	if(!la)return 0;
	if(count%2==0){
		cout<<la<<" "<<x<<endl;
		return 1;
	}else{
		cout<<x<<" "<<la<<endl;
		return 0;
	}
}
int main(){
	cin>>n>>m;
	if(m%2!=0){
		cout<<"-1"<<endl;
		return 0;
	}
	ref(i,1,m){
		int x,y;cin>>x>>y;
		e[x].pb(y);e[y].pb(x);
	}
	dfs(0,1);
}

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

int main() {
	long long s,m=1e9,t;
	cin>>s; t=(m-s%m)%m;
	printf("0 0 %lld 1 %lld %lld\n", m,t,(s+t)/m);
	return 0;
}

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

typedef long long ll;

static const ll INF=1000000000000000;

int main(){
    int N;
    cin >> N;
    ll a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=1;i<N;i++){
        a[i]+=a[i-1];
    }
    ll ans=INF;
    for(int i=0;i<N-1;i++){
        ans=min(ans,abs(a[i]-(a[N-1]-a[i])));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	ss := make([]int, n)
	tt := make([]int, m)

	dp := make([][]int, n+1)

	for i := 0; i < n; i++ {
		dp[i] = make([]int, m+1)
		ss[i] = getNextInt(scanner)
	}
	dp[n] = make([]int, m+1)
	for i := 0; i < m; i++ {
		tt[i] = getNextInt(scanner)
	}
	dp[0][0] = 1
	for i := 0; i <= n; i++ {
		for ii := 0; ii <= m; ii++ {
			if i == 0 || ii == 0 {
				dp[i][ii] = 1
				continue
			}
			dp[i][ii] += dp[i][ii-1]
			dp[i][ii] = mint(dp[i][ii])
			dp[i][ii] += dp[i-1][ii]
			dp[i][ii] = mint(dp[i][ii])
			if ss[i-1] != tt[ii-1] {
				dp[i][ii] -= dp[i-1][ii-1]
				dp[i][ii] = mint(dp[i][ii])
			}

		}
	}
	fmt.Fprintln(writer, dp[n][m])

	writer.Flush()
}
func mint(a int) int {
	return ((a % 1000000007) + 1000000007) % 1000000007
}


Measured memory_bytes: 34048
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration


int main() {
	int A;
	cin>>A;
	cout<<(A/500)*1000+((A%500)/5)*5;

	return 0;
}


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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<pair<int, int>> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i].first >> a[i].second;
  sort(a.begin(), a.end());
  int i = 0, ans = 0;
  while (K > 0)
    ans = a[i].first, K -= a[i].second, i++;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  std::set<int> solved;
  std::map<int, int> chaled;
  int ac = 0;
  int pena = 0;
  for (size_t i = 0; i < m; ++i) {
    int p;
    char buf[4];
    scanf("%d %s", &p, buf);
    std::string s = buf;

    if (solved.count(p)) continue;
    if (s == "WA") {
      ++chaled[p];
    } else {
      pena += chaled[p];
      ++ac;
      solved.insert(p);
    }
  }
  printf("%d %d\n", ac, pena);
}


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

int main(void)
{
	int i,j;
	int n;
	char a[9],b[9],c[9];
	int x,y;
	int r[4];
	
	scanf("%d ",&n);

	for(i=0;i<n;i++)
	{
		x = 0;
		y = 0;

		for(j=0;j<9;j++)
		{
			a[j] = 0;
			b[j] = 0;
			c[j] = 0;
		}

		scanf("%s %s ",a,b);
		
		for(j=0;j<8;j++)
		{
			if(a[j]=='m')
			{
				if(j != 0)
				{
					x += (a[j-1]-'0')*1000;
				}else{
					x += 1000;
				}
			}
			
			if(a[j]=='c')
			{
				if(j != 0 && a[j-1]-'0' <= 9)
				{
					x += (a[j-1]-'0')*100;
				}else{
					x += 100;
				}
			}
			
			if(a[j]=='x')
			{
				if(j != 0 && a[j-1]-'0' <= 9)
				{
					x += (a[j-1]-'0')*10;
				}else{
					x += 10;
				}
			}
			
			if(a[j]=='i')
			{
				if(j != 0 && a[j-1]-'0' <= 9)
				{
					x += (a[j-1]-'0');
				}else{
					x += 1;
				}
			}
		}
			
		for(j=0;j<8;j++)
		{
			if(b[j]=='m')
			{
				if(j != 0)
				{
					y += (b[j-1]-'0')*1000;
				}else{
					y += 1000;
				}
			}
			
			if(b[j]=='c')
			{
				if(j != 0 && b[j-1]-'0' <= 9)
				{
					y += (b[j-1]-'0')*100;
				}else{
					y += 100;
				}
			}
			
			if(b[j]=='x')
			{
				if(j != 0 && b[j-1]-'0' <= 9)
				{
					y += (b[j-1]-'0')*10;
				}else{
					y += 10;
				}
			}
			if(b[j]=='i')
			{
				if(j != 0 && b[j-1]-'0' <= 9)
				{
					y += (b[j-1]-'0');
				}else{
					y += 1;
				}
			}
		}
			
			r[0] = (x+y)/1000;
			if(r[0]>1)
			{
			  printf("%d",r[0]);
			}
			if(r[0]!=0)
			{
				printf("m");
			}
			
			r[1] = (x + y - r[0]*1000)/100;
			if(r[1]>1)
			{
				printf("%d",r[1]);
			}
			if(r[1]!=0)
			{
				printf("c");
			}
			
			r[2] = (x + y - r[0]*1000 -r[1] * 100) / 10;
			if(r[2]>1)
			{
				printf("%d",r[2]);
			}
			if(r[2]!=0)
			{
				printf("x");
			}
			
				r[3] = x + y - r[0]*1000 - r[1] *100 - r[2] *10;
			if(r[3]>1)
			{
				printf("%d",r[3]);
			}
			if(r[3]!=0)
			{
				printf("i");
			}
			
			printf("\n");
		}
	return 0;
}

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

using namespace std;

void solve(long N, vector<long> a) {
  long on = 1;
  rep(i, N) {
    on = a[on - 1];
    if (on == 2) {
      cout << (i + 1) << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main(){
  // int 3E4
  // long 2E9
  // long long 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<long> a(N);
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  solve(N, move(a));
  return 0;
}


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

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

  char arare[n];

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

  int type_arare = 3;
  for(i=0; i<n; i++)
  {
      if(arare[i] == 'Y'){
            type_arare = type_arare+1;
        }
  }

  if(type_arare == 3) {
      cout << "Three" << endl;
      }
  else {
      cout << "Four" << endl;
      }

}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans=0;
    REP(i,s.size()){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout << ans << endl;
}


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

using namespace std;

vector<bool> b(20, 0);

bool ok(int i) {
    while (i) {
        if (b.at(i % 10)) return false;
        i /= 10;
    }
    return true;
}

int main() {
    int n, k, d;
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        cin >> d;
        b.at(d) = 1;
    }
    for (int i = n; ; ++i) {
        if (ok(i)) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math
def a():
    n = int(input()) % 10
    if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        print('hon')
    elif n == 3:
        print('bon')
    else:
        print('pon')




def b():
    k = int(input())
    s = input()
    if len(s) <= k:
        print(s)
    else:
        print(s[:k] + '...')

def c():
    a, b, h, m = map(int, input().split())
    deg = abs(360 * m / 60 - 360 * (h / 12 + m / 720))
    print(pow(pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(math.radians(deg)), 0.5))
    
    


# def d():


c()

Measured memory_bytes: 9544
import itertools
r = 110000
s = int(r*0.5)
p = [1] * r
p[0] = 0
for i in range(1,s):
	if p[i]:
		p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
		
while 1:
	N,P = map(int,raw_input().split())
	if N == -1: break
	i = N + 1
	prime = [0]*25
	j = 0
	while j < 25:
		if p[i-1] == 1:
			prime[j] = i
			j += 1
		i += 1
	wa = sorted([sum(comb) for comb in itertools.combinations(prime,2)] + [2*a for a in prime])
	print wa[P-1]

Measured memory_bytes: 9020
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main(){
	int r,c;
	cin >> r >> c;
	vector<vector<char>> grid(r, vector<char> (c));
	for(int i = 0; i < r; i++)
	{
		for(int j = 0; j < c; j++)
			cin >> grid[i][j]; 
	}
	vector<vector<long long>> dp(r, vector<long long> (c));
	dp[0][0]=1;
	for(int i = 0; i < r; i++)
	{
		for(int j = 0; j < c; j++)
		{
			if(i==0 && j==0)
				continue;
			if(grid[i][j] == '#')
				continue;
			if(i > 0 )
				dp[i][j] += dp[i-1][j];
			dp[i][j] %= mod;
			if( j > 0)
				dp[i][j] += dp[i][j-1];
			dp[i][j] %= mod;

		}
	} 
	cout <<  dp[r-1][c-1] << endl;


	return 0;
}

Measured memory_bytes: 9088
import sys

n = int(input())

if n == 0:
    print("0")
    sys.exit(0)

sum = 0
ans = ""

count = 0
d = 1

while n != sum:
    mod = (n - sum) % (d * 2)
    # print("count/d/mod %d/%d/%d" % (count, d, mod))

    if mod != 0:
        ans = "1" + ans
        sum += d * (1 if count % 2 == 0 else -1)
    else:
        ans = "0" + ans

    count += 1
    d *= 2

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int W, H, x, y, r;
	r>0;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if(x+r<=W && y+r<=H && 0<x && 0<W && 0<y && 0<H){
		printf("Yes\n");
	}else if(x+r<=W && y-r>=H && 0<x && 0<W && 0>y && 0>H){
		printf("Yes\n");
	}else if(x-r<=W && y+r<=H && 0>x && 0>W && 0<y && 0<H){
		printf("Yes\n");
	}else if(x-r>=W && y-r>=H && 0>x && 0>W && 0>y && 0>H){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> dp(N + 1, 0);
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        dp[a] = -1;
    }

    dp[0] = 1;
    ll mod = 1e9 + 7;
    for (int i = 0; i < N; i++) {
        if (dp[i] == -1)
            continue;

        if (i + 1 <= N && dp[i + 1] != -1) {
            dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
        }
        if (i + 2 <= N && dp[i + 2] != -1) {
            dp[i + 2] = (dp[i + 2] + dp[i]) % mod;
        }
    }

    cout << dp[N] << endl;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
 
import java.util.*;
 
public class Main {
	int H,W,N;
	int[] a,b;
	long[] cnt;
	HashSet<Long> color,used;
 
	public void solve() {
		H = nextInt();
		W = nextInt();
		N = nextInt();
 
		color = new HashSet<Long>();
 
		a = new int[N];
		b = new int[N];
		cnt = new long[10];
		cnt[0] = (long)(H - 2)* (W - 2);
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
			b[i] = nextInt();
			color.add(a[i] * (long)1e9 + b[i]);
		}
		
		used = new HashSet<Long>();
		
		for(int i = 0;i < N;i++){
			
			for(int py = -2;py <=0;py++){
				for(int px = -2;px <=0;px++){
					int j = 0;
					boolean f = false;
					if(a[i] + py <= 0 || b[i] + px <= 0 || a[i] + py > H || b[i] + px > W)continue;
					if(used.contains((a[i] + py) * (long)1e9 + (b[i] + px)))continue;
					used.add((a[i] + py) * (long)1e9 + (b[i] + px));
					for(int y = 0;y < 3;y++){
						for(int x = 0;x < 3;x++){
							int ny = a[i] + py + y;
							int nx = b[i] + px + x;
							
							if(ny > H || nx > W || ny <= 0 || nx <= 0){
								f = true;
								break;
							}
						}
						if(f)break;
					}
					if(f)continue;
					for(int y = 0;y < 3;y++){
						for(int x = 0;x < 3;x++){
							
							int ny = a[i] + py + y;
							int nx = b[i] + px + x;
							if(color.contains(ny * (long)1e9 + nx)){
								j++;
							}
						}
					}
					cnt[j]++;
				}
			}
		}
		for(int i = 1;i <= 9;i++){
			cnt[0] -= cnt[i];
		}
 
		for(int i = 0;i < 10;i++){
			out.println(cnt[i]);
		}
 
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 102632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;

  string s = to_string(n);

  ll d = s.back() - '0';

  set<ll> hon = {2, 4, 5, 7, 9};
  set<ll> pon = {0, 1, 6, 8};

  string ans = "hon";
  if (d == 3) {
    ans = "bon";
  } else if (pon.find(d) != pon.end()) {
    ans = "pon";
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3696