akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    int i, n, x;
    scanf("%d%d",&n,&x);
    long long ans = 0;
    int pre;
    scanf("%d",&pre);
    REP (i,n-1) {
        int a;
        scanf("%d",&a);
        int y = max(0,(pre+a)-x);
        ans += y;
        pre = max(0,a - y);
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> takoyaki(N);
    for(int i = 0; i < N; i++){
        cin >> takoyaki[i];
    }
    int sum = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            sum += takoyaki[i] * takoyaki[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  REP(i, N) {
    int a;
    cin >> a;
    A[i] = make_pair(a, i);
  }
  sort(ALL(A));
  REP(i, N) {
    cout << A[i].SE + 1 << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
/*input
58 23 42
*/

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

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con))) 
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)
 
using ll = long long;
using ss = stringstream;
using ul = unsigned long long;
 
template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) { 
  FH(it,s) 
    *it = tolower(*it); 
} 
 
inline void upper(string &s) { 
  FH(it,s) 
    *it = toupper(*it); 
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
} 

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n) 
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    int n, a, b;
    cin >> n >> a >> b;
    if((b - a) % 2 == 0) {
        cout << "Alice";
    }
    else {
        cout << "Borys";
    }
    nl;
    return 0;
}



Measured memory_bytes: 256
/*{{{*/
#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))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll k,a,b;
  cin >> k >> a >> b;
  FOR(i,a,b+1){
    if(i%k==0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  
  //cout << fixed << setprecision(10);
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
#define inf 1000000007

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x/gcd(x,y)*y;
}

int n,a[114514],b[114514],c[114514];
int dp[114514][5];

int rec(int i,int j){
	if(dp[i][j]>=0)return dp[i][j];
	int res;
	if(i==n){
		res=0;
	}
	else if(j==0){
		res=max(rec(i+1,1)+b[i],rec(i+1,2)+c[i]);
	}
	else if(j==2){
		res=max(rec(i+1,0)+a[i],rec(i+1,1)+b[i]);
	}
	else{
		res=max(rec(i+1,0)+a[i],rec(i+1,2)+c[i]);
	}
	return dp[i][j]=res;
}

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

Measured memory_bytes: 11904
import sys
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if (10000*i)+(5000*j)+(1000*k)==y:
            print("{} {} {}".format(i,j,k))
            sys.exit()
print("-1 -1 -1")


Measured memory_bytes: 2940
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  int ans=min(a,b);
  ans+=min(c,d);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 200000
#define mod1 1000000007
#define mod2 1000000009
#define mod3 998244353
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
ll a[N+5];
ll dp[2][N+5];

bool rec(ll player,ll n,ll k)
{
	bool ans = 1;
	if(dp[player][k]!=-1)
		return dp[player][k];
	for(ll i=1;i<=n;i++)
	{
		if(k>=a[i])
			ans =ans & rec((player+1)%2,n,k-a[i]);
	}
	dp[player][k] = !ans;
	return !ans;
}

bool fun(ll player, ll n, ll k){
	if(dp[player][k]!=-1){
		return dp[player][k];
	}
	bool ans = true;
	for(ll i=1;i<=n;i++){
		ans = ans & fun((player+1)%2, n,k-a[i]);
	}
	return dp[player][k] = !ans;
}

int main()
{
    IO
	clock_t begin = clock();
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<=k;i++)
    	dp[0][i] = dp[1][i] = -1;
    for(ll i=1;i<=n;i++)
    	cin>>a[i];
    bool final_ans = rec(1,n,k);
    // cout<<final_ans<<endl;
    if(final_ans==1)
    	cout<<"First";
    else
    	cout<<"Second";
    // cout<<double(clock() - begin)/CLOCKS_PER_SEC<<endl;
    return 0;
}

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

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

  for(int i=0; i<N; i++){
    cout << c[i] << endl;
  }
  
  return 0;
}


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

int adj[10][10];
int n, m;

int dfs(int now, int vis) {
    vis |= 1 << now;
    if (vis == (1 << n) - 1) return 1;
    
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        if (adj[now][i] && !(vis & (1 << i))) {
            ret += dfs(i, vis | (1 << i));
        }
    }
    return ret;
}

int main(void){
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        adj[a - 1][b - 1] = adj[b - 1][a - 1] = 1;
    }
    cout << dfs(0, 0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

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

	vector<double> a(n, 0);
	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	double avg = sum / n;

	double abs_diff_min = 1000000;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		double abs_diff = abs(a[i] - avg);
		if (abs_diff < abs_diff_min) {
			ans = i;
			abs_diff_min = abs_diff;
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using namespace std;
using ii = long long;
int main()
{
    string a, b;
    cin >> a >> b;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    int mx = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (a[i - 1] != b[j - 1]) {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
            else {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            mx = max(mx, dp[i][j]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (dp[i][j] == mx) {
                string s;
                while (i > 0 && j > 0) {
                    if (dp[i - 1][j] == dp[i][j]) {
                        i--;
                    }
                    else if (dp[i][j - 1] == dp[i][j]) {
                        j--;
                    }
                    else {
                        assert(a[i - 1] == b[j - 1]);
                        s.push_back(a[i - 1]);
                        i--;
                        j--;
                    }
                }
                reverse(all(s));
                cout << s << "\n";
                return 0;
            }
        }
    }
}


Measured memory_bytes: 35584
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
#dprint = print
def dprint(*args):
   pass

N = list(map(int, input().split()))[0]
s = list(input())

l, r = 0, N-1
count = 0

while(l < r):
    dprint('l,r=', l, r)
    dprint('s=', s)
    while(l < r):
        if (s[l]=='W'):
            break
        l = l + 1
        dprint('l=', l)

    while(l < r):
        if (s[r]=='R'):
            break
        r = r - 1
        dprint('r=', r)

    if (l < r):
        s[l] = 'R'
        s[r] = 'W'
        count = count + 1
    
print(count)


Measured memory_bytes: 10808
using System;

namespace Atcoder
{
    class Program
    //    ABC128 A - Apple Pie
    {
        private static void Main(string[] args)
        {
            var ap = Console.ReadLine().Split(' ');
            double a = int.Parse(ap[0]);
            double p = int.Parse(ap[1]);

            double ans = Math.Floor(((a * 3 + p) / 2));
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//ld dis(ll a,ll b,ll c,ll d){return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll a(n) ;
	for(int i=0;i<n;i++){
		cin >> a.at(i) ;
		a.at(i)-- ;
	}
	vll ok(n,-1) ;
	ok.at(0) = 0 ;
	ll cnt = 0 ;
	ll p = 0 ;
	for(int i=0;i<k;i++){
		cnt++ ;
		p = a.at(p) ;
		if(ok.at(p)!=-1){
			k -= ok.at(p) ;
			cnt -= ok.at(p) ;
			k %= cnt ;
//			for(auto j:ok) cout << j << " " ; cout << endl ;
			for(int j=0;j<n;j++){
				if(ok.at(j)==k+ok.at(p)){
//					cout << cnt << " " << k << endl ;
					cout << j+1 << endl ;
					return 0 ;
				}
			}
		}else{
			ok.at(p) = cnt ;
		}
	}
	cout << p+1 << endl ;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i,n) {
		cin >> p[i];
		p[i]--;
	}
	int ans = 0;
	rep(i,n){
		if(i<n-1){
			if(p[i] == i){
				swap(p[i],p[i+1]);
				ans++;
			}
		}else{
			if(p[i] == i){
				swap(p[i],p[i-1]);
				ans++;
			}
		}
	}
	cout << ans << endl;
	
    return 0;
}



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

int main(){
  long long n;
  cin>>n;
  vector<long long> vec(n);
  long long minusnum=0;
  long long exit0=0;
  for(long long i=0; i<n; i++){
    cin>>vec[i];
    if(vec[i]<0){
      minusnum++;
      vec[i]=vec[i]*(-1);
    }else if(vec[i]==0){
      exit0=1;
    }
  }
  sort(vec.begin(),vec.end());
  long long sum=0;
  if(exit0==1||minusnum%2==0){
    for(long long i=0; i<vec.size(); i++){
      sum+=vec[i];
    }
  }else{
    sum -= vec[0];
    for(long long i=1; i<vec.size(); i++){
      sum+=vec[i];
    }
  }
  cout<<sum<<endl;
  return 0;
}





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

bool isPali(string s)
{
	int n=s.size();
	for(int i=0; i<s.size(); i++)
		if(s[i]!=s[n-i-1]) return 0;
	return 1;
}

int main()
{
	string s; cin>>s;
	int n=s.size();
	string s1=s.substr(0,(n-1)/2);
	string s2=s.substr(((n+3)/2)-1);
	if(isPali(s) && isPali(s1) && isPali(s2)) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
flg=0
ans=0
for i in  range(n):
  if s[i]=="A":
    flg=1
  elif s[i]=="B" and flg==1:
    flg=2
  elif s[i]=="C" and flg==2:
    ans=ans+1
    flg=0 
  else:
    flg=0
print(ans)

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

        long sum = a[0];
        for (int i = 1; i < n; i++)
        {
            sum = sum ^ a[i];
        }

        long[] answers = new long[n];
        for (long i = 0; i < n; i++)
        {
            answers[i] = sum ^ a[i];
        }

        Console.WriteLine(string.Join(" ", answers));
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 68112
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int n, i;
	int64_t a, min, max, sum;
	if (scanf("%d", &n) != 1) return 1;
	if (scanf("%"SCNd64, &a) != 1) return 1;
	min = max = sum = a;
	for (i = 1; i < n; i++) {
		if (scanf("%"SCNd64, &a) != 1) return 1;
		if (a < min) min = a;
		if (max < a) max = a;
		sum += a;
	}
	printf("%"PRId64" %"PRId64" %"PRId64"\n", min, max, sum);
	return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int X;
    cin >> X;
    vector<bool> dp(X + 1000, false);
    dp[0] = true;

    rep(i, X) {
        dp[i + 100] = (dp[i + 100] || dp[i]);
        dp[i + 101] = (dp[i + 101] || dp[i]);
        dp[i + 102] = (dp[i + 102] || dp[i]);
        dp[i + 103] = (dp[i + 103] || dp[i]);
        dp[i + 104] = (dp[i + 104] || dp[i]);
        dp[i + 105] = (dp[i + 105] || dp[i]);
    }
    if (dp[X]) {
        cout << 1 << '\n';
    } else {
        cout << 0 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
int N;
int DP[SIZE]={};
bool used[SIZE]={};
vint node[SIZE];
vint A;
int ans[SIZE]={};
void DFS(int now){
    used[now]=1;

    int a, b, c;
    int high=N+1, low=0;
    while(high-low>1){
        int mid=low+(high-low)/2;
        if(DP[mid]<A[now])
            low=mid;
        else
            high=mid;
    }
    a=high, b=A[now];
    c=DP[a];
    DP[a]=b;

    int left=0, right=N;
    while(right-left>1){
        int mid=(left+right)/2;
        if(DP[mid]==INF)
            right=mid;
        else
            left=mid;
    }
    ans[now]=left;


    for(int next:node[now]){
        if(used[next])
            continue;
        
        DFS(next);
    }
    DP[a]=c;
}
signed main(){
    cin>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        A.pb(a);
    }
    for(int i=0;i<N-1;i++){
        int u, v;
        cin>>u>>v;
        u--, v--;
        node[u].pb(v);
        node[v].pb(u);
    }

    if(N==2){
        if(A[0]<A[1]){
            cout<<1<<endl;
            cout<<2<<endl;
        }
        else{
            cout<<1<<endl;
            cout<<1<<endl;
        }
        return 0;
    }

    for(int i=0;i<SIZE;i++)
        DP[i]=INF;

    DFS(0);

    for(int i=0;i<N;i++)
        cout<<ans[i]<<endl;

    return 0;
}


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

int main() {

    int n, m;

    cin >> n >> m;

    int ch = min(n, m);

    int c = max(n, m);

    for(int i = 0; i < c; ++i)
        cout << ch;

    cout << endl;
    return 0;

}

Measured memory_bytes: 256
def index(L,x):
    return [i for i, l in enumerate(L) if l == x]
def check(S, T):
    now = 'a'
    for i in range(26):
        ind = index(S, now)
        if ind:
            x = ind[0]
            t = T[x]
            for i in ind:
                if  t != T[i]:
                    print('No')
                    exit()
        now = chr(ord(now)+1)
def main():
    S = input()
    T = input()
    check(S,T)
    check(T,S)
    print('Yes')
main()

Measured memory_bytes: 7588
import copy
n = int(input())
s = list(input())

def search_pattern(input_list):
    temp = copy.deepcopy(input_list)
    for i in range(2, n):
        if temp[i - 1] == 'S':
            if s[i - 1] == 'o':
                temp.append(temp[i - 2])
            else:
                if temp[i - 2] == 'S':
                    temp.append('W')
                else:
                    temp.append('S')
        else:
            if s[i - 1] == 'x':
                temp.append(temp[i - 2])
            else:
                if temp[i - 2] == 'S':
                    temp.append('W')
                else:
                    temp.append('S')

    if temp[n - 1] == 'S':
        if s[n - 1] == 'o':
            if temp[n - 2] != temp[0]:
                return -1
        else:
            if temp[n - 2] == 'S':
                if temp[0] == 'S':
                    return -1
            else:
                if temp[0] != 'S':
                    return -1
    else:
        if s[n - 1] == 'x':
            if temp[n - 2] != temp[0]:
                return -1
        else:
            if temp[n - 2] == 'S':
                if temp[0] == 'S':
                    return -1
            else:
                if temp[0] != 'S':
                    return -1

    if temp[0] == 'S':
        if s[0] == 'o':
            if temp[n - 1] != temp[1]:
                return -1
        else:
            if temp[n - 1] == 'S':
                if temp[1] == 'S':
                    return -1
            else:
                if temp[1] != 'S':
                    return -1
    else:
        if s[0] == 'x':
            if temp[n - 1] != temp[1]:
                return -1
        else:
            if temp[n - 1] == 'S':
                if temp[1] == 'S':
                    return -1
            else:
                if temp[1] != 'S':
                    return -1
    print("".join(temp))
    exit()

search_pattern(list("SS"))
search_pattern(list("SW"))
search_pattern(list("WS"))
search_pattern(list("WW"))

print("-1")

Measured memory_bytes: 5272
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
   n,m = map(int,input().split())
   print("Yes" if n == m else "No")
    
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 5684
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int n,m;cin>>n>>m;
  int ans=0;
  vector<int>s(m),c(m);
  vector<int>num(n,11);
  
  for(int i=0;i<m;i++){
    cin>>s.at(i)>>c.at(i);
  }
  for(int i=0;i<m;i++){
    if(num.at(s.at(i)-1)==11 || num.at(s.at(i)-1)==c.at(i)){
      num.at(s.at(i)-1)=c.at(i);
    }
    else{
      ans=-1;
    }
  }
  
  if(ans==-1){
    cout<<-1;
  }
  else if(num.at(0)==0 &&n!=1)
    cout<<-1;
  else if(num.at(0)==11 && n==1)
    cout<<0;
  else{
    for(int i=0;i<n;i++){
      if(num.at(i)==11 && i!=0){
        num.at(i)=0;
      }
      if(num.at(i)==11 && i==0){
        num.at(i)=1;
      }
    }
    if(n==1 && num.at(0)==0){
      cout<<0;
    }
    else{
      for(int i=0;i<n;i++){
        cout<<num.at(i);
      }
    }
  }
      
}
  
    


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

int a, b;

void solve() {
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	string res = "Draw";
	if (a > b) res = "Alice";
	if (a < b) res = "Bob";
	cout << res << endl;
}

signed main() {
	srand(time(NULL));
	int T = 100;
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

a, b, x = map(int, input().split())
MOD = int(1e9+7)

if x < a:
    res = x % MOD
else:
    k = (x-b) // (a-b)
    res = (x + b*k)
    res %= MOD
print(res)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int x=max(h,w);
  if(n%x==0)cout << n/x << endl;
  else cout << n/x+1 << endl;
} 
    

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  string s;
  cin>>s;
  regex r("A[a-z]+C[a-z]+");
  if(regex_match(s,r))cout<<"AC";
  else cout<<"WA";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[10][10];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>h>>w;
    rep(i,h)rep(j,w)cin>>s[i][j];
    ll lim=-1;
    rep(i,h){
        fl=false;
        rep(j,w){
            if(s[i][j]=='#'&&!fl){
                fl=true;
                if(lim>j){
                    Cout("Impossible");
                    return 0;
                }
            }
            if(s[i][j]=='#')lim=j;
        }
    }
    ll st=0;
    rep(i,h){
        fl=false;
        rrep(j,st,w){
            if(s[i][j]=='#'&&fl){
                Cout("Impossible");
                return 0;
            }
            if(s[i][j]=='.'&&!fl)fl=true,st=j;
            if(j==w-1&&!fl)st=w-1;
        }
    }
    Cout("Possible");
    return 0;
}


Measured memory_bytes: 256
import Data.List( sort)
main = do
    abc <- return . map (read::String->Integer) . words =<< getLine
    let abc' = sort abc
	a' = abc'!!0
	b' = abc'!!2
	c' = abc'!!1
    print $ a' * c' * (b' - 2*floor (fromIntegral b'/2))

Measured memory_bytes: 508
#include<stdio.h>


int main(){
	int n;
	int id[4000],cid;
	long long int price,num,sale[4000];
	bool f;
	int i,j,idcount;
	while(scanf("%d",&n),n){

		f=true;
		idcount=0;

		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&cid,&price,&num);
			for(j=0;j<idcount;j++){
				if(id[j]==cid){
					sale[j]=sale[j]+price*num;
				}
			}

			if(j==idcount){
				id[idcount]=cid;
				sale[idcount]=price*num;
				idcount++;
			}

		}



		for(i=0;i<idcount;i++){
			if(sale[i]>=1000000){
				printf("%d\n",id[i]);
				f=false;
			}
		}
		if(f!=false)printf("NA\n");
	}
	return 0;
}

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

int main() {
  int n, l;
  string str[100], work;

  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }
  for (int j = 0; j < n - 1; j++) {
    for (int k = 0; k < n - 1 - j; k++) {
      if (str[k].compare(str[k + 1]) > 0) {
        work = str[k];
        str[k] = str[k + 1];
        str[k + 1] = work;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << str[i];
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n,k;
  cin >> n >> k; 
  int num=1;
  REP(i,n) {
    if(num<k) num*=2;
    else num+=k;
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 3592
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const S = input[1];

  if(N%2 !== 0){
    console.log('No');
    return;
  }

  const pre = S.slice(0, N/2);
  const suf = S.slice(N/2, N);
  if(pre !== suf){
    console.log('No');
    return;
  }

  console.log('Yes');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import math
n = int(input())
x = [int(i) for i in input().split()]
y = [int(j) for j in input().split()]
p_1 = p_2 = p_3 = p_m = 0

for i in range(n):
	diff = math.fabs(x[i]-y[i])
	p_1 += diff
	p_2 += diff*diff
	p_3 += diff*diff*diff
	if p_m < diff:
		p_m = diff
	
p_2 = math.sqrt(p_2) 
p_3 = math.pow(p_3, 1/3)

print('%.5f\n%.5f\n%.5f\n%.5f'% (p_1, p_2, p_3, p_m))

Measured memory_bytes: 7820
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

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

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------
void call(int n){
    int i = 1;
    CHECK_NUM:
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    INCLUDE3:
    if ( x % 10 == 3 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    x /= 10;
    if ( x ) goto INCLUDE3;
    END_CHECK_NUM:
    if ( ++i <= n ) goto CHECK_NUM;

    cout << endl;
}
void solve() {
    int n;
    read(n);
    call(n);
}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 3132
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    num = 10**9 + 7
    if n == 1:
        print(0)
    else:
        ans = 10**n -2*9**n + 8**n
        ans %= num
        print(ans)
main()


Measured memory_bytes: 85912
a, b = map(int, input().split())

a_min = -(-a*100//8)
a_max = int((a+1)*100/8)-1
b_min = -(-b*100//10)
b_max = int((b+1)*100/10)-1

if a_max >= b_min and b_max >= a_min:
    print(max([a_min, b_min]))
else:
    print(-1)

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

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  using P = pair<Int, Int>;
  vector<P> v;
  for(Int i=0;i<n;i++){
    Int a,b;
    cin>>a>>b;
    v.emplace_back(a,b);
  }
  sort(v.begin(),v.end());

  vector<Int> a,b;
  for(Int i=0;i<n;i++){
    if(a.empty()||a.back()!=v[i].first){
      a.emplace_back(v[i].first);
      b.emplace_back(v[i].second);
    }else{
      b.back()+=v[i].second;
    }  
  }

  //for(Int i=0;i<n;i++) cout<<i<<":"<<a[i]<<" "<<b[i]<<endl;

  vector<Int> c(b.size());
  partial_sum(b.begin(),b.end(),c.begin());

  // [l,r]
  auto get=[&](Int l,Int r){
    if(l) return c[r]-c[l-1];
    return c[r];
  };

  if(0){
    Int ans=0;
    for(Int i=0;i<(Int)a.size();i++)
      for(Int j=i;j<(Int)a.size();j++)
	chmax(ans,get(i,j)-(a[j]-a[i]));
    
    cout<<ans<<endl;
  }
  
  Int ans=0,l=0,r=0;
  for(Int i=0;i<(Int)a.size();i++){
    while(l<i&&a[l+1]-a[l]>=b[l]) l++;
    chmax(ans,get(l,i)-(a[i]-a[l]));
    
    chmax(r,l);
    while(r+1<i){
      while(r+1<i&&a[r+1]-a[l]<=get(l,r)) r++;
      if(a[r+1]-a[l]>=get(l,r)) l=r+1;
      else break;
    }
    chmax(ans,get(l,i)-(a[i]-a[l]));
  }
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 23880
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
  int main(){
 lint n;
 cin>>n;
 M mp;
 lint x=n;
 rep(i,sqrt(n)+1){
        if(x==1)break;
        if(x%(i+2)==0){
            mp[i+2]++;
            x/=(i+2);
              i--;
        }
 }
 if(primary(x))mp[x]++;
 lint ans=0;
 for(auto x:mp){
     lint h=x.second;
     lint j=1;
     while(h-j>=0){
         ans++;
         h-=j;
         j++;
     }
 }
 cout<<ans<<endl;
  }
      
      
    

  
          
  

Measured memory_bytes: 3724
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;

    int to_x = x2 - x1;
    int to_y = y2 - y1;

    to_y *= -1;

    x3 = x2 + to_y;
    y3 = y2 + to_x;
    x4 = x1 + to_y;
    y4 = y1 + to_x;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    const ll unf=1e18;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0) cout<<a-b<<endl;
    else cout<<b-a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;

vector<P> v;

int32_t main(){_

   cin>>n;
   v.resize(n);

   for (int i = 0; i < n; ++i)
   {
      cin>>v[i].S>>v[i].F;
   }

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

   int pre = 0;
   for (int i = 0; i < n; ++i)
   {
      pre += v[i].S;
      if(pre > v[i].F){
         cout<<"No";
         return 0;
      }
   }
   
   cout<<"Yes";

   return 0;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int num2 = sc.nextInt();
        if(num%2==1&&num2%2==1)
        {
            System.out.println("Odd");
        }
        else
        {
            System.out.println("Even");
        }
    }
}


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


int main() {

  int N, K;
  string S;
  cin >> N >> K >> S;

  // 0 が何個、1 が何個ならんでいるかを保持する配列
  vector<int> v;
  
  // 今見ている数 1 or 1
  int current = 1;
  
  // 今見ている数が何個並んでいるか
  int count = 0;

  for (int i = 0; i < N; i++) {
    if (S[i] == (char) '0' + current) {
      count++;
    } else {
      v.push_back(count);
      current = 1 - current;
      count = 1;
    }
  }
  // 最後の分
  if (count != 0) {
    v.push_back(count);
  }

  // 1-0-1-0-1 と 1 を最後にする
  if (v.size() % 2 == 0){
    v.push_back(0);
  }

  int answer = 0;
  int add = 2 * K + 1;

  for (int i = 0; i < v.size(); i += 2) {
    int tmp = 0;
    int left = i;
    int right = min(i + add, (int) v.size());
    for (int j = left; j < right; j++) {
      tmp += v[j];
    }
    answer = max(answer, tmp);
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 1020
# coding: utf-8

N, X = (int(x) for x in input().split())
m = list(int(input()) for i in range(N))

m = sorted(m)
total = 0 #お菓子の個数

for i in range(N):
    X -= m[i]
    total += 1

while X >= m[0]:
    X -= m[0]
    total += 1

print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
int main()
{
  string s;
  cin >> s;

  int a = 0, b = 0;
  re(i, s.size()) {
    if (s[i] == 'A') {
      a = i;
      break;
    }
  }
  reverse(s.begin(), s.end());
  re(i, s.size()) {
    if (s[i] == 'Z') {
      b = s.size() - i;
      break;
    }
  }

  cout << b - a << endl;

  return 0;
}


Measured memory_bytes: 640