akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n, pos;
	ArrayList<Integer> Pre = new ArrayList<>();
	ArrayList<Integer> In = new ArrayList<>();
	ArrayList<Integer> Post = new ArrayList<>();
	
	//入力
	public void input() {
		int k;
		n = sc.nextInt();
		//先行順巡回
		for(int i=0; i<n; i++) { k = sc.nextInt(); Pre.add(k); }
		//中間順巡回
		for(int i=0; i<n; i++) { k = sc.nextInt(); In.add(k); }
	}
	
	//後行順に出力
	public void solve() {
		pos = 0;
		rec( 0, Pre.size() );
		for(int i=0; i<n; i++) {
			if(i==0) System.out.print( Post.get(i) );
			else System.out.print(" "+Post.get(i));
		}
		System.out.println();
	}
	
	//木の修復
	public void rec(int l, int r) {
		if(l >= r) return;
		int root = Pre.get(pos++);
		int m = In.indexOf(root);
		rec(l, m);
		rec(m+1, r);
		Post.add(root);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.solve();
	}
}



Measured memory_bytes: 26356
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll 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;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

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

int main(){
  COMinit();
  ll N,M,ans=0;
  cin>>N>>M;
  
  ll DP[N+1];
  REP(i,N+1){
    DP[i]=COM(N,i)*fac[i]%MOD*COM(M,i)%MOD*COM(M-i,N-i)%MOD*fac[N-i]%MOD*COM(M-i,N-i)%MOD*fac[N-i]%MOD;
    if(i%2==0) ans+=DP[i];
    else ans-=DP[i];
    ans%=MOD;
  }
  
  if(ans<0) ans+=MOD;
  co(ans);
  return 0;
}

Measured memory_bytes: 127044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_c>
問題文============================================================
 XXXX年のCODE FESTIVALには、世界中から高橋君を含めて N+1 人の参加者が集まりました。
 
 高橋君の都市と他の N 人の都市の時刻の差を調べてみたところ、i 番目の人の都市との時刻の差は Di 時間でした。
 ただし 2 つの都市について、片方の都市で 0 時の瞬間にもう一方の都市で d 時であるようなとき、
 これらの都市の時刻の差は min(d,24−d) であるものとします。
 ここで、時刻の表記には 24 時間表記を用いるものとします。
 つまり、例えば高橋君の都市で 0 時の瞬間には i 番目の人の都市は Di 時または 24−Di 時のいずれかとなります。
 
 高橋君は次に、N+1 人のうちの全ての 2 人組についてその人の都市どうしの時刻の差を書き出し、
 それらの時刻の差のうちの最小値を s としました。
 
 s として考えられる最大値を求めて下さい。
=================================================================

解説=============================================================

================================================================
*/
ll solve(){
    ll ret = INF;
    ll N; cin >> N;
    vector<ll> D(N);
    for(auto& in:D) cin >> in;
    sort(D.begin(),D.end());
    vector<ll> t; t.push_back(0);
    for(int i = 0; i < N;i++){
        if(i%2 == 0){
            t.push_back(D[i]);
        }else{
            t.push_back(24-D[i]);
        }
    }
    for(int i = 0; i <= N;i++){
        for(int j = i+1; j <= N;j++){
            ret = min(ret,abs(t[i]-t[j]));
        }
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

int main() {
	int times, plusNum;
    cin >> times >> plusNum;
    
    int ans = 1;
    for(int i = 0; i < times; i++) {
    	if(ans < plusNum) {
        	ans *= 2;
        } else {
        	ans += plusNum;
        }
    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
K = int(input())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

ans = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      ans += gcd(gcd(i, j), k)

print(ans)


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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

ll N,W;
vl w,v,dp;
const ll INF = 1e11+1;

void min_ele(ll &a, ll b){
    a = min(a,b);
}

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin>>N>>W;
    w.resize(N+1);v.resize(N+1);
    dp.resize(1000*N+1, INF);
    Fo(i,1,N+1)cin>>w[i]>>v[i];
    dp[0] = 0;
    Fo(i,1,N+1){
        for(ll j=1000*N-v[i]; j>=0; j--){
            min_ele(dp[j+v[i]], dp[j]+w[i]);
        }
    }
    ll val = INF;
    for(ll i=1000*N; i>=0; i--){
        if(dp[i]<=W){
            cout<<i<<endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
x,y,z = map(int,input().split())
a = (x-z)/(y+z)
if a<1:
    print(0)
    exit()
else:
    ans=0
    for i in range(1,10**6):
        if y*i+z*(i+1)<=x:
            ans+=1
        else:
            print(ans)
            exit()
    print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	static String original;
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int R = reader.nextInt();
		String ans = "";

		if (R < 1200) {
			ans = "ABC";
		} else if (R < 2800) {
			ans = "ARC";
		} else {
			ans = "AGC";
		}

		System.out.print(ans);
	}


}

Measured memory_bytes: 22740
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        ArrayList<Integer> A = new ArrayList<>();
        HashMap<Integer,Integer> count = new HashMap<>();
        for(int i=0; i<N; i++){
            int a = scanner.nextInt();
            A.add(a);
            count.putIfAbsent(a, 0);
            int current = count.get(a);
            count.put(a, current + 1);
        }
        long allpair = 0;
        for(int i:count.keySet()){
            int val = count.get(i);
            if(val>0){
                allpair += (long)val*((long)val-1)/2;
            }
        }
        for(int i=0; i<A.size(); i++){
            int num = A.get(i);
            if(count.get(num)>1){
                System.out.println(allpair - (count.get(num)-1));
            }else{
                System.out.println(allpair);
            }
        }
    }
}

Measured memory_bytes: 131088
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, a[111111] = {0}, b[111111], acc[111111];

  std::cin >> N;

  for (int i = 1; i <= N; i ++)
    std::cin >> a[i];

  N += 2;

  for (int i = 0; i < N - 1; i ++)
    b[i] = std::abs(a[i + 1] - a[i]);

  acc[0] = 0;

  for (int i = 0; i < N; i ++)
    acc[i + 1] = acc[i] + b[i];

  for (int i = 0; i < N - 2; i ++) {
    assert(i + 2 < N);
    assert(i + 2 < N);
    
    std::cout << acc[N - 1] - (acc[i + 2] - acc[i]) + std::abs(a[i + 2] - a[i]) << std::endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <array>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9 + 7);
const ll INF = LLONG_MAX;
const ll MAX_N = ll(3e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    string s;
    cin >> s;
    int cnt=0, l=0, r=s.size()-1;
    for(;l<=r;l++,r--){
        if(s[l]==s[r]){
            if(s[l]=='w' || s[l]=='i')continue;
            cnt++;
        }
        else{
            if(s[l]=='(' && s[r]==')' || s[l]==')' && s[r]=='(')continue;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3188
#include<iostream>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail;

void enqueue(P x){
  Q[tail] = x; 
  tail = (tail+1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head+1) % LEN;
  return x;
}

int main(){
  int q, n;
  scanf("%d %d", &n, &q);

  for(int i=0; i<n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  int sum=0, elaps=0;
  P u;
  head = 0;
  tail = n;
  while(true){
    u = dequeue();
    if(u.t <= q){
      sum += u.t;
      printf("%s %d\n", u.name, sum);
      elaps++;
      if(elaps == n) break;
    }else{
      u.t -= q;
      sum += q;
      enqueue(u);
    }
  }
  
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);


    ll n;
    cin>>n;
    ll min = n-1;
    for(ll i = 2;i*i<n+1;i++)
    {
        ll x = n/i;
        if(x*i != n)continue;
        else
        {
            if(min>x+i-2)min = x+i-2;
        }
    }

    cout<<min<<endl;

    return 0;
}

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

int main(){
  string s;
  int ret;
  cin >> s;
  if("SAT"==s) ret=1;
  else if("FRI"==s) ret=2;
  else if("THU"==s) ret=3;
  else if("WED"==s) ret=4;
  else if("TUE"==s) ret=5;
  else if("MON"==s) ret=6;
  else ret=7;
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

void Zalg(const string &s, vector<int> &Z){
  int n = (int)s.size();
  Z.clear(); Z.resize(n);
  Z[0] = n;
  int i = 1, len = 0;
  while(i < n){
    while(i+len < n && s[i+len] == s[len]) len++;
    Z[i] = len;
    if(len == 0){ i++; continue; }
    int j = 1;
    while(i+j < n && Z[j] < len - j){
      Z[i+j] = Z[j];
      j++;
    }
    i += j; len -= j;
  }
}

int main(int argc, const char * argv[]) {
  int N; cin >> N;
  string S; cin >> S;
  
  vector<int> Z;
  int ans = 0;
  for(int i=0; i<S.size(); i++){
    Zalg(S.substr(i), Z);
    for(int i=0; i<Z.size(); i++){
      if(Z[i] <= i) ans = max(ans, Z[i]);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	string s; cin >> s;
	if (stoi(s.substr(5, 2)) >= 5) cout << "TBD" << endl;
	else cout << "Heisei" << endl;
}

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


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;


int main(void)	
{
	ll n;
	ll mod;
	cin >> n >> mod;
	string s;
	cin >> s;
	if (mod == 2 || mod == 5) {
		ll sum = 0;
		rep(i, n) {
			if ((s[i]-'0') % mod == 0) {
				sum += i + 1;
			}
		}
		cout << sum << endl;
		return 0;
	}
	else 
	{
		map<ll, ll> m;
		ll current = 0;
		ll sum = 0;
		ll shift = 1;
		rep(i, n) {
			ll d = s[n - 1 - i] - '0';
			(current += (d * shift) % mod)  %= mod;
			if (current == 0) sum++;
			shift *= 10;
			shift %= mod;
			sum += m[current];
			m[current]++;
		}
		cout << sum << endl;
		return 0;
	}
}



Measured memory_bytes: 1028
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>

using namespace std;

class c_doubly
{
private:

public:
    c_doubly();
    void f_input();
};

c_doubly::c_doubly()
{
    
}

void c_doubly::f_input()
{
    int n;
    int n_key;
    int i;
    string s;
    list<int>d_doubly;
    
    cin >> n;
   
    for (i = 0; i < n; ++i){
        cin >> s;
        if (s == "insert"){
            cin >> n_key;
            d_doubly.push_front(n_key);
        }else if(s == "delete"){
            cin >> n_key;
            list<int>::iterator it = d_doubly.begin(); 
            while( it != d_doubly.end() )
            {
	            if( *it == n_key )
	                {
                        d_doubly.erase(it);
                        break;
                    }
                ++it;
            }
        }else if(s == "deleteFirst"){
            d_doubly.pop_front();
        }else if(s == "deleteLast"){
            d_doubly.pop_back();
        }
    }
    
    /*
    i = 1;
    list<int>::iterator it = d_doubly.begin(); 
    while( it != d_doubly.end() ) 
    {
        if (i != d_doubly.size()){
            cout << *it << " ";
            ++i;
        }else{
            cout << *it << endl;    
        }
        ++it;
    }
    */
    n = d_doubly.size();
    list<int>::iterator it = d_doubly.begin(); 
    //cout << "n: " << n << endl;
    for ( i = 0; i < n; ++i){
        if (i == n-1){
            cout << *it << endl;
        }else{
            cout << *it << " ";          
        }
        ++it;  
    }
}

int main(){
    
    c_doubly doubly01;
    doubly01.f_input();
    
    return 0;
}

Measured memory_bytes: 34300
import math
import sys
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b)
a,b=map(int,input().split())
c=euclid(a,b)
if c==1:
  print(1)
  sys.exit()
print(len(factorization(c))+1)

Measured memory_bytes: 3188
s = map(lambda i: (ord('z') - ord(i) + 1) % 26, raw_input())
n = len(s)
k = int(raw_input())

for i in range(n):
    if s[i] <= k:
        k -= s[i]
        s[i] = 0

s[-1] -= k

s = map(lambda i: (26 - i) % 26 + ord('a'), s)
s = ''.join(map(chr, s))

print s


Measured memory_bytes: 6756
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
constexpr ll mod = 1000000007;

int main() {
    int n, m, c[20], dp[60001];
    cin >> n >> m;
    for (int i = 0; i < m; i++)cin >> c[i];
    for (int i = 1; i <= n; i++)dp[i] = n;
    for (int i = 0; i < n; i++)for (int j = 0; j < m; j++)dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1);
    cout << dp[n] << endl;
}



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

def divisor(n):
    fac = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0: 
            fac.append(i)
            if i*i != n: fac.append(n//i)
    return sorted(fac)

ans = len(divisor(n-1))-1
lst = divisor(n)
for i in lst:
    tmp = n
    if i == 1: continue
    while tmp%i == 0: tmp //= i
    if tmp%i == 1: ans += 1

print(ans)

Measured memory_bytes: 3316
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
b=list(map(int,input().split()))
c=list(map(int,input().split()))
sum=0
for i in range(n):
    sum+=b[a[i]]
    if(a[i]==a[i-1]+1 and i>0):
        #print(a[i]+1,a[i])
        sum+=c[a[i]-1]
print(sum)


Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	string s,t; cin>>s>>t;
	cout<<t+s;

	return 0;
}

Measured memory_bytes: 3596
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


M1, _ = read_ints()
M2, _ = read_ints()
if M1 != M2:
    print(1)
else:
    print(0)


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

namespace IPT1_7A
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                //?????????????????\??? m f r
                string[] in_num = Console.ReadLine().Split(' ');
                int m = int.Parse(in_num[0]);
                int f = int.Parse(in_num[1]);
                int r = int.Parse(in_num[2]);
                //????????? -1 ????????\?????????
                if ((m + f + r) == -3) break;
                // m or f -1 -> F
                if ((m == -1) || (f == -1)) Console.WriteLine("F");
                // m + f >= 80 -> A
                else if ((m + f) >= 80) Console.WriteLine("A");
                // m + f >= 65 -> B
                else if ((m + f) >= 65) Console.WriteLine("B");
                // m + f >= 50 -> C
                else if ((m + f) >= 50) Console.WriteLine("C");
                // m + f >= 30 -> D 
                //  r >= 50 -> C
                else if ((m + f) >= 30)
                {
                    if (r >= 50) Console.WriteLine("C");
                    else Console.WriteLine("D");
                }
                // -> E
                else Console.WriteLine("F");
            }
        }
    }
}

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

int main(){
    ll N,M;
    cin >> N;
    cin >> M;

    vector<bool> result(N, false);
    vector<ll> wacount(N, 0);

    rep(i,M){
        ll idx;
        string r;
        cin >> idx;
        cin >> r;
        idx -= 1;
        if(r=="WA"&&!result[idx]) wacount[idx]+=1;
        else result[idx] = true;
    }
    ll score=0;
    ll penalty=0;
    rep(i,N){
        if(result[i]){
            score+=1;
            penalty+= wacount[i];
        }
    }

    cout << score << " " << penalty << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include "string"
#include "vector"

using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, sum = 0;
ll A[500000] = {}, B[500000] = {}, ruiseki[500000] = {}, dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = false, check2 = false;

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

int main() {

	//Code Line
	cin >> S >> T;
	if (S[0] == T[0])sum++;
	if (S[1] == T[1])sum++;
	if (S[2] == T[2])sum++;
	cout << sum << endl;

	return 0;}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<climits>//上限値
// #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


void printVector(const std::vector<double>& vec) {
	for (double value : vec) {
		std::cout << value << " ";
	}
	std::cout << std::endl;
}


int main(){
	ll n;
	ll a;
	ll ans = 1;
	ll hairetu[100001];
	std::cin >> n;
	for ( ll i = 0 ; i < n ; i++ ) {
		std::cin >> a;
		if (a == 0) {
			std::cout << 0 << '\n';
			return 0;
		}
		hairetu[i] = a;
	}

	for ( ll i = 0 ; i < n ; i++ ) {
		if(log10(ans) + log10(hairetu[i] + 1)> 19){
			std::cout << -1 << '\n';
			return 0;
		}
		ans = ans * hairetu[i];
		if(ans > 1000000000000000000){
			std::cout << -1 << '\n';
			return 0;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


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

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

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

int main() {
  int A, B;
  std::cin >> A >> B;

  if((A + B) % 2 == 0) std::cout << (A + B) / 2 << '\n';
  else std::cout << "IMPOSSIBLE" << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int t, n, s, f;
	int i;
	int sum;

	while(1) {
		scanf("%d", &t);
		if(!t)
			break;
		scanf("%d", &n);

		for(i = 0, sum = 0; i < n; i++) {
			scanf("%d %d", &s, &f);
			sum += f - s;
		}

		if(sum >= t)
			printf("OK\n");
		else
			printf("%d\n", t - sum);
	}

	return 0;
}

Measured memory_bytes: 1040
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int N;
	cin>>N;
	set<int> A;
	vector<int> eat;
	rep(i,N){
		int a;
		cin>>a;
		if(A.find(a)==A.end())A.insert(a);
		else eat.push_back(a);
	}
	int ans=0;
	sort(All(eat));
	if(eat.size()==0) ans=N;
	else if(eat.size()%2==1) ans=A.size()-1;
	else ans=A.size();
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

int main() {
    int n;
    int m;
    cin >> n >> m;
    if(n==m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,ans;
	cin>>s;
	if(s=="Sunny")ans="Cloudy";
	else if(s=="Cloudy")ans="Rainy";
	else if(s=="Rainy")ans="Sunny";
	cout<<ans<<endl;
}

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<int> a(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        a[i] -= 1;
    }

    set<int> lighten;
    int ans = -1;
    int l = 0;
    for (int i = 0; i < N; ++i) {
        l = a[l];
        if (l == 1) {
            ans = i + 1;
            break;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3752
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int N, W;
	cin >> N >> W;
	vector<int[2]> objects(N);

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

	vector<ull> dp(val_sum + 1, W + 1);
	dp[0] = 0;

	for(int i = 1; i <= N; ++i) {
		auto cur = dp;
		for(int j = 1; j <= val_sum; ++j) {
			int v = objects[i - 1][1];
			int w = objects[i - 1][0];
			if(j >= v && dp[j - v] <= W) {
				cur[j] = min(cur[j], dp[j - v] + w);
			}
		}
		dp = cur;
	}
	int ans = 0;
	for(int i = 1; i <= val_sum; ++i) {
		if(dp[i] <= W) {
			ans = i;
		}
	}
	cout << ans << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 1E5 + 10;

int n, m;
ll K;
int s[MAXN];
int b[MAXN], t[MAXN];

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &s[i]);
	for (int i = n; i > 1; --i)
		s[i] -= s[i - 1];
	scanf("%d%lld", &m, &K);
	for (int i = 1; i <= n; ++i)
		b[i] = i;
	for (int t, i = 0; i < m; ++i){
		scanf("%d", &t);
		swap(b[t], b[t + 1]);
	}
	for (; K; K >>= 1){
		if (K & 1){
			for (int i = 2; i <= n; ++i)
				t[i] = s[b[i]];
			copy_n(t + 2, n - 1, s + 2);
		}
		for (int i = 2; i <= n; ++i)
			t[i] = b[b[i]];
		copy_n(t + 2, n - 1, b + 2);
	}

	ll sum = s[1];
	printf("%lld\n", sum);
	for (int i = 2; i <= n; ++i)
		printf("%lld\n", sum += s[i]);
	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >>W >>H >>x >>y >>r;
    if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


class UnionFind{
  public:
  vector<int> par;
  UnionFind(int N) : par(N,-1) {}
  bool unite(int x,int y){
    x = root(x),y = root(y);
    if(x == y)return false;
    if(par[x] > par[y])swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool find(int x,int y){
    return root(x) == root(y);
  }
  int root(int x){
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  
  int n,m;
  cin >> n >> m;
  vector<ll> v(n);
  ll res = 0;
  rep(i,n)cin >> v[i],res += v[i];
  UnionFind uf(n);
  rep(i,m){
    int x,y;cin >> x >> y;
    uf.unite(x,y);
  }
  map<int,priority_queue<ll>> mp;
  rep(i,n)mp[uf.root(i)].push(v[i]);
  priority_queue<ll> que;
  for(auto au : mp){
    while(au.second.size() > 1){
      que.push(au.second.top());
      au.second.pop();
    }
  }
  if(uf.size(0) == n){
    cout << 0 << "\n";
    return 0;
  }
  if(que.size() < n-(n-1-m)*2){
    cout << "Impossible\n";
    return 0;
  }
  rep(i,n-(n-1-m)*2){
    res -= que.top();
    que.pop();
  }
  cout << res << "\n";



  return 0;
}

Measured memory_bytes: 15408
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<time.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	//srand(time(NULL));
	int N,M,s[190000],t[190000];
	vint adj[601];
	ld cost[601];
	int bc[601];
	scan(N>>M);
	fill(bc,bc+N,-1);
	rep(i,M){
		scan(s[i]>>t[i]);
		s[i]--; t[i]--;
		adj[s[i]].push_back(t[i]);
	}
	cost[N-1]=0;
	brep(i,N-1){
		ld ncsum=0;
		ld ncmax=0;
		int ncmaxv=-1;
		rep(j,adj[i].size()){
			int v=adj[i][j];
			ncsum+=cost[v];
			if(ncmax<cost[v]){
				ncmaxv=v;
				ncmax=cost[v];
			}
		}
		ncsum/=adj[i].size();
		cost[i]=ncsum+1;
		if(adj[i].size()>1) bc[i]=ncmaxv;
	}
	ld ans=cost[0];
	rep(k,N-1){
		if(bc[k]>=0){
			ld nowcost[601];
			nowcost[N-1]=0;
			brep(i,N-1){
				ld ncsum=0;
				rep(j,adj[i].size()){
					int v=adj[i][j];
					if(i==k&&bc[k]==v) continue;
					ncsum+=nowcost[v];
				}
				if(i==k) ncsum/=((int)adj[i].size()-1);
				else ncsum/=adj[i].size();
				nowcost[i]=ncsum+1;
			}
			ans=min(ans,nowcost[0]);
		}
	}
	prin(setprecision(11)<<ans);
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int d[n];
	int i,j;
	for( i=0; i<n; i++ ){
		cin >> d[i];
	}
	int ans = 0;
	for( i=0; i<n-1; i++ ){
		for( j=i+1; j<n; j++ ){
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define COUNT 10000
int main() {
	int n, i, max, min;
	int a[COUNT];
	long int sum;
	max = -1000000;
	min = 1000000;
	sum = 0;
	cin >> n;

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



		if (a[i] < min) {
			min = a[i]; 
		}
	    if (a[i] > max) {
			max = a[i];
		}

	}
	
		cout << min << " " << max << " " << sum << endl;

	
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>

int main()
{
	int a, b, c, x;
	std::cin >> a >> b >> c >> x;

	int cnt = 0;
	for( int i = 0; i <= a; i++ ) {
		for( int j = 0; j <= b; j++ ) {
			for( int k = 0; k <= c; k++ ) {
				int t = 500 * i + 100 * j + 50 * k;
				if( t == x ) {
					cnt += 1;
				}
			}
		}
	}

	std::cout << cnt << std::endl;
	return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
   priority_queue<P,V<P>,greater<P>> q;
   int n;
   cin>>n;
   V<ll> a(n),ans(n,0);
   for(int i=0;i<n;i++){
       cin>>a[i];
       q.emplace(-a[i],i);
   }
   q.emplace(0,-1);
   ll ma2=0,cnt=0;
   queue<ll> tmp;
   while(q.size()){
       auto p=q.top();
       if(p.fi==0)break;
       while(q.size()&&(q.top().fi<=p.fi||p.se<=q.top().se)){
       tmp.push(-q.top().fi);
       q.pop();
       }
       ans[p.se]+=(-p.fi+q.top().fi)*cnt;
       while(tmp.size()){
           ans[p.se]+=tmp.front()+q.top().fi;
           tmp.pop();
           cnt++;
       }
   }
   for(int i=0;i<n;i++)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 7104
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll D; cin >> D;
  if(D == 25)cout << "Christmas";
  if(D == 24)cout << "Christmas Eve";
  if(D == 23)cout << "Christmas Eve Eve";
  if(D == 22)cout << "Christmas Eve Eve Eve";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

const int N=1005;
const int MOD=1e9+7;
 
 
int32_t main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && a==c)
  {
  	cout<<"Yes"<<endl;
  }
  else
  {
  	cout<<"No";
  }
  
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int D, N;
  cin >> D >> N;
  int base = 1;
  for (int i = 0; i < D; i++) base *= 100;
  if (N < 100) {
    cout << base * N << endl;
  } else { // N=100
    cout << base * (N+1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int a = 1;
    for(int i = 0; i < n - 1; i ++) {
      if(s.charAt(i) != s.charAt(i + 1)) {
        a ++;
      }
    }
    System.out.println(a);
  }
}


Measured memory_bytes: 26068
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	long long a[110];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int co = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
					if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) {
						co++;
					}
				}
			}
		}
	}
	cout << co << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;

// ModInt begin

ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
struct ModInt {
    ll v;
    ModInt(ll a = 0) : v(((a%MOD) + MOD) % MOD) {}
    ModInt  operator+ ( const ModInt& b ) const {return (v + b.v) % MOD;}
    ModInt  operator- ( const ModInt& b ) const {return (v - b.v + MOD) % MOD;}
    ModInt  operator* ( const ModInt& b ) const {return (v * b.v) % MOD;}
    ModInt  operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, MOD-2)) % MOD;}
};

bool    operator==(ModInt  a, ModInt b) {return a.v == b.v;}
ModInt& operator+=(ModInt& a, ModInt b) {return a = a + b;}
ModInt& operator-=(ModInt& a, ModInt b) {return a = a - b;}
ModInt& operator*=(ModInt& a, ModInt b) {return a = a * b;}
ModInt& operator/=(ModInt& a, ModInt b) {return a = a / b;}
ostream& operator<<(ostream& out, ModInt  a) {return out << a.v;}
istream& operator>>(istream& in,  ModInt& a) {
    ll v; in >> v;
    a = ModInt(v);
    return in;
}

// ModInt end

ModInt fact[200010];

ll comb(int n, int r) {
    if(n < r) return 0;
    ModInt ret = fact[n];
    ret /= fact[n-r];
    ret /= fact[r];
    return ret.v;
}

signed main() {
    fact[0] = 1;
    rep(i,1,200010) fact[i] = fact[i-1] * i;

    int h, w, a, b; cin >> h >> w >> a >> b;
    ModInt ans = 0;
    repq(i,1,w-b) {
        ModInt va = comb(h-a+b+i-2, b+i-1);
        ModInt vb = comb(w-b-i+1+a-2, a-1);
        ans += va * vb;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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


  //input
  ll D;
  cin >> D;
  vl c(26);
  rep(i, 26) cin >> c[i];


  //preparation
  vpl C(26);
  rep(i,26) C[i] = pl (c[i], i);
  sort(all(C), greater<pl>());


  //output
  bool b=0;
  rep(i, D) {
    ll day=i;
    day%=17;
    if(day>=8 and b) day+=9;
    if(day==16) b=1;
    if(day==25) b=0;
    cout << C[day].second+1 << newl;
  }


  return 0;
}

Measured memory_bytes: 3624
N = int(input())
a = list(map(int, input().split()))
p = [t for t in a if t >= 0]
m = [t for t in a if t < 0]
p.sort(reverse = True)
m.sort()
l = []
if N == 2:
  print(max(a) - min(a))
  print(max(a), min(a))
  exit(0)
if len(p) == 0:
  u = m.pop()
  v = m.pop()
  l.append((u, v))
  p.append(u - v)
if len(m) == 0 and len(p) >= 2:
  u = p.pop()
  v = p.pop()
  l.append((u, v))
  m.append(u - v)
while len(p) >= 2:
  u = m.pop()
  v = p.pop()
  l.append((u, v))
  m.append(u - v)
while len(m):
  t = p[0]
  u = m.pop()
  l.append((t, u))
  p[0] = t - u
print(p[0])
for res in l:
  print(*res)

Measured memory_bytes: 20356
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

cnt = 0
k, l = 0, 0
for i in itertools.permutations(list(range(1,n+1))):
    cnt += 1
    if i == p:
        k = cnt
    elif i == q:
        l = cnt

if p == q:
    print(0)
else:
    print(abs(k-l))


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>

using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
int main()
{
    int n,year,month,day;
    long long int count;
    scanf("%d\n",&n);
    REP(i,n)
    {
        scanf("%d %d %d\n",&year,&month,&day);
        count=(year/3-(year%3==0))*590;
        if(year%3==0)
        {
            count+=390+(month-1)*20+day;
        }
        else
        {
            if(year%3==2)count+=195;
            int st=1;
            while(st<month)
            {
                if(st%2==0)count+=19;
                else count+=20;
                st++;
            }
            count+=day;
        }
        printf("%lld\n",196471-count);
    }
    return 0;
}


Measured memory_bytes: 3132