akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;

    ll ans = 0;

    vector<ll> num(k, 0);
    for (int i = 1; i <= n; i++){
        // num[n % i]++;
        num[i % k]++;
    }
    for (int a = 0; a < k; a++){
    // for (int a = 1; a <= k; a++){
        int b = (k - a) % k;
        int c = (k - a) % k;
        if ((b+c) % k != 0) continue;
        // todo: duplicate?
        ans += num[a] * num[b] * num[c];
    }

    cout << ans << endl;

    return 0;
}





















Measured memory_bytes: 1792
N=int(input())
A=list(map(int,input().split()))
listB=list()
for  k in range(N):
    listB.append(0)
for i in range(0,N-1):
       listB[A[i]-1]=listB[A[i]-1]+1
for j in range(0,N):
       print(listB[j])


Measured memory_bytes: 32368
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

/* Union-Find-Tree */
/* 必ず要素数をコンストラクタに入れること */
template <class T = long long>
class Union_Find {
  using size_type = std::size_t;
  using _Tp = T;
public:

  vector<_Tp> par;
  vector<_Tp> rnk;

  // 親の根を返す。値の変更は認めない。
  const _Tp & operator[] (size_type child) {
    find(child);
    return par[child];
  }

  Union_Find (size_type n) {
    par.resize(n), rnk.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rnk[i] = 0;
    }
  }

  // 木の根を求める
  _Tp find(_Tp x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  // xとyの属する集合を併合
  void merge(_Tp x, _Tp y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }

  // xとyが同じ集合に属するか否か
  bool same(_Tp x, _Tp y) {
    return find(x) == find(y);
  }
};

struct Edge {
  int a, b, cost;
  bool operator<(const Edge& o) const { return cost < o.cost; }
  bool operator>(const Edge& o) const { return cost > o.cost; }
};

int Kruskal(vector<Edge>& graph, int graphNodeNum) {
  int totalCost = 0;
  sort(graph.begin(), graph.end()); // const だとgraphをsortできない。
  Union_Find<long long> uf(graphNodeNum);
  for (auto edge : graph) {
    if (!uf.same(edge.a, edge.b)) {
      totalCost += edge.cost;
      uf.merge(edge.a, edge.b);
    }
  }
  return totalCost;
}

int main() {
  int v, e;
  cin >> v >> e;
  vector<Edge> graph;
  for (int i = 0; i < e; ++i) {
    Edge edge;
    cin >> edge.a >> edge.b >> edge.cost;
    graph.push_back(edge);
  }

  cout << Kruskal(graph, v) << endl;
}



Measured memory_bytes: 4556
class Union_Find:
  def __init__(self,n=0):
    self.vertices=n
    self.mother=[-1 for i in range(self.vertices)]
    self.size_temp=[1 for i in range(self.vertices)]
  
  def root(self,x):
    normalize_v=[]
    while x!=-1:
      normalize_v.append(x)
      y=x
      x=self.mother[x]
    for i in normalize_v[:-1]:
      self.mother[i]=y
    return y
  
  def union(self,x,y):
    root_x=self.root(x)
    root_y=self.root(y)
    if root_x!=root_y:
      self.mother[root_x]=root_y
      self.size_temp[root_y]+=self.size_temp[root_x]
  
  def find(self,x,y):
    if self.root(x)==self.root(y):
      return True
    else:
      return False
  
  def size(self,x):
    return self.size_temp[self.root(x)]



n,m,k=map(int,input().split())
uf=Union_Find(n)
friend=[0 for i in range(n)]
block=[[] for i in range(n)]

for i in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  friend[a]+=1
  friend[b]+=1
  uf.union(a,b)

for i in range(k):
  a,b=map(lambda x:int(x)-1,input().split())
  block[a].append(b)
  block[b].append(a)

r=""
for i in range(n):
  size=uf.size(i)
  size-=friend[i]
  for j in block[i]:
    if uf.find(i,j):
      size-=1
  r+=str(size-1)+" "
print(r[:-1])
  

Measured memory_bytes: 31728
# -*- coding: utf-8 -*-

num = raw_input().split()

num[0] = int(num[0])
num[1] = int(num[1])

if num[0]+num[1] > num[0]-num[1]:
    if num[0]+num[1] > num[0]*num[1]:
        print num[0]+num[1]
    else:
        print num[0] * num[1]
else :
        if num[0]-num[1] > num[0]*num[1]:
            print num[0]-num[1]
        else:
            print num[0] * num[1]


Measured memory_bytes: 2568
n = gets.to_i
arr = gets.split(" ").map(&:to_i)

m = 1000
c = 0
(n - 1).times do |i|
  if arr[i] > arr[i + 1]
    m += c * arr[i]
    c = 0
  elsif arr[i] < arr[i + 1]
    c += m / arr[i]
    m = m % arr[i]
  end
end

p m + c * arr[-1]

Measured memory_bytes: 14400
#include<iostream>
using namespace std;
int a[100];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int k=1;k<=m;k++){
		for(int i=0;i<n-1;i++){
			if(a[i]%k>a[i+1]%k){
				int tmp=a[i];
				a[i]=a[i+1];
				a[i+1]=tmp;
			}
		}
	}
	for(int i=0;i<n;i++)cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;
using ll = long long;
static ll dp[101][2];

int main(){
	ios_base::sync_with_stdio(false);
	int n, p;
	cin >> n >> p;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for(int i = 0; i < n; ++i){
		dp[i + 1][0] = dp[i][0];
		dp[i + 1][1] = dp[i][1];
		if(a[i] % 2 == 0){
			dp[i + 1][0] += dp[i][0];
			dp[i + 1][1] += dp[i][1];
		}else{
			dp[i + 1][0] += dp[i][1];
			dp[i + 1][1] += dp[i][0];
		}
	}
	cout << dp[n][p] << endl;
	return 0;
}



Measured memory_bytes: 256
// E - Multiplication 4
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int vpop(vector<int>& v){int x=v.back();v.pop_back();return x;}

int main(){
	int N, K; cin>>N>>K;
	vector<int> P, M;
	rep(i, N){
		int a; cin>>a;
		if(a < 0) M.push_back(a);
		else P.push_back(a);
	}

	sort(P.begin(), P.end());
	sort(M.rbegin(), M.rend());

	vector<int> p, m;
	while(int(p.size() + m.size()) < K){
		if(P.size() > 0 && M.size() <= 0) p.push_back(vpop(P));
		else if(P.size() <= 0 && M.size() > 0) m.push_back(vpop(M));
		else if(P.back() < -M.back()) m.push_back(vpop(M));
		else p.push_back(vpop(P));
	}

	if(m.size()%2){
		int mi, pi;
		mi = (p.size() * M.size() > 0)? vpop(M): 1;
		pi = (m.size() * P.size() > 0)? vpop(P): -1;
		if(mi < 0 && pi >=0){
			if(abs((ll)p.back() * pi) < abs((ll)m.back() * mi)){ p.pop_back(); m.push_back(mi); }
			else{ m.pop_back(); p.push_back(pi); }
		}
		else if (mi < 0){ p.pop_back(); m.push_back(mi); }
		else if (pi >= 0){ m.pop_back(); p.push_back(pi); }
		else{
			while(m.size() > 0) p.push_back(vpop(m));
			while(P.size() > 0) p.push_back(vpop(P));
			while(M.size() > 0) p.push_back(vpop(M));
			sort(p.begin(), p.end(), [](int x, int y){ return abs(x) < abs(y); });
			while((int)p.size() > K) p.pop_back();
		}
	}

	ll ans = 1;
	int mod = 1'000'000'007;
	for(int a:p) ans = ans * a % mod;
	for(int a:m) ans = ans * a % mod;
	cout<< (ans+mod)%mod <<endl;
}


Measured memory_bytes: 5728
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

int used[100005];

int main(){
    rep(i,100005){
        used[i]=-1;
    }
    ll n;
    int x,m;
    cin >> n>> x>> m;
    bool lp=1;
    int cnt=0;
    vector<ll> temp;
    temp.push_back(x);
    ll A=x;
    used[x]=0;
    int repeat_start=0;
    while(lp){
        cnt++;
        A=A*A%m;
        //cerr<<A<<' ';
        temp.push_back(temp[temp.size()-1]+A);
        if(used[A]!=-1){
            lp=0;
            repeat_start=used[A];
            cnt=cnt-repeat_start;
        }
        used[A]=cnt;
        if(cnt==n-1){
            //cerr<<endl;
            cout<<temp[temp.size()-1]<<endl;
            return 0;
        }
    }
    ll ans=0;
    ans+=temp[repeat_start];
    n-=repeat_start+1;
    ans+=(temp[temp.size()-1]-temp[repeat_start])*(n/cnt);
    ans+=(temp[repeat_start+n%cnt]-temp[repeat_start]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4244
import sys

N=int(input())
A=list(map(int,input().split()))
div_flg=False
inc_flg=False
dec_flg=False
ans=0

if N==1:
  print(1)
  sys.exit()
  
for i in range(N):
  if inc_flg:
    if i==N-1:
      break
    if A[i]<=A[i+1]:
      continue
    else:
      inc_flg=False
      div_flg=False
  elif dec_flg:
    if i==N-1:
      break
    if A[i]>=A[i+1]:
      continue
    else:
      dec_flg=False
      div_flg=False
  else:
    if i==0:
      ans+=1
      div_flg=True
    elif i==N-1:
      if not div_flg:
        ans+=1
      break
    if A[i]==A[i+1]:
      if not div_flg:
        ans+=1
      div_flg=True
      continue
    elif A[i]<A[i+1]:
      if not div_flg:
        ans+=1
      inc_flg=True
      continue
    elif A[i]>A[i+1]:
      if not div_flg:
        ans+=1
      dec_flg=True
      continue
print(ans)

Measured memory_bytes: 20168
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll gcd(ll c, ll d)
{
  ll r = c % d;
  while (r != 0)
  {
    c = d;
    d = r;
    r = c % d;
  }
  return d;
}

int main()
{
  ll a, b, c, d;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  ll range = b - a + 1;
  ll hoge = range - ((b / c) - ((a - 1) / c));
  ll fuga = range - ((b / d) - ((a - 1) / d));
  ll piyo = c * d / gcd(c, d);
  ll piyopiyo = range - ((b / piyo) - ((a - 1) / piyo));
  printf("%lld\n", hoge + fuga - piyopiyo);
}

Measured memory_bytes: 128
#include<iostream>
#include <string.h>
#include <math.h> 
#include <algorithm>
#include<cstdlib>
typedef long long ll;
using namespace std;


int main()
{
    ll n,p,ans = 1;
    cin >> n >> p;

    for(ll i = 2; i*i <= p; i++)
    {
        //if(IsPrime(i) == true){
        int cnt = 0;
        while(p % i == 0)
        {
            cnt++; 
            p /= i;
        }  
        for(int j = 0; j < cnt/n; j++)
        {
            ans *= i;
        }  
        
    }
    if(n == 1) ans *= p;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: putc;
using io :: print;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define ll long long
void gi(int &sum){
    sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(!flag) sum = -sum;
}
const int p = 1e9+7;
int cnt[27];
int n;
char s[101000];
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	rep(i,1,n) cnt[s[i]-'a'+1]++;
	int ans = 1;
	rep(i,1,26) ans = 1ll*ans*(cnt[i]+1)%p;
    ans--;
    if(ans == -1) ans += p;
    printf("%d\n",ans);
    return 0;
}

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

int main(){
    int a, b, ans = 0;
    cin >> a >> b;

    for(int i = a; i <= b; i++){
        if(i/10000 == i%10 && i/1000%10 == i/10%10){
            ans++;
            // cout << i << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define fr(a,b) for(ll i=a;i<b;i++)

int32_t main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin>>n;
    ll ans=1000;
    while (n>ans)
    {
        ans+=1000;
    }
    cout<<ans-n<<endl;
return 0;
}

Measured memory_bytes: 3620
/*
???????????????????¨??????§??????????????°??????????????????
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int LEN=101; //???????????§??????

class stack {
	int data[LEN]; 
	int top;
public:
	stack(): top(0){};
	void push(int);
	int pop();
	bool isEmpty();
	bool isFull();
	int get_top(){	return top;	}
};
void stack::push(int num){
	if( isFull() )
		return;
	
	data[top+1]=num;
	top++;
}
int stack::pop(){
	if( isEmpty() )
		return 0;

	top--;
	return data[top+1];
}
bool stack::isEmpty(){
	return top==0;
}
bool stack::isFull(){
	return	top==LEN-1;
}




int main(){

	
	stack s;

	char oper[110];

	int a, b; 

	while( scanf("%s", &oper) !=EOF ) {



		
		switch( oper[0] ){
			case '+':
				a=s.pop();
				b=s.pop();
				s.push( b+a );
				break;

			case '-':
				a=s.pop();
				b=s.pop();
				s.push( b-a );
				break;
				
			case '*':
				a=s.pop();
				b=s.pop();
				s.push( b*a );
				break;

			default:
				s.push(atoi(oper));
		}


			

		

	}

	cout<<s.pop()<<endl;



	

}

	

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

using namespace std;

#define ll long long int
#define MOD 1000000007
#define mt make_tuple
#define eb emplace_back
#define error(args...){string _s = #args; replace(_s.begin(),_s.end(),',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args){cerr<<*it<<" = "<<a<<endl; err(++it,args...);}



int main()
{
    ll t,i,j,k,l,n,m;
    vector<ll> V;
    cin>>k>>l>>j;
    V.push_back(j);
    V.push_back(k);
    V.push_back(l);
    sort(V.begin(),V.end());
    cout<<min(V[2]-V[0],V[2]+V[1]-2*V[0]);
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
Vs = gets.split.map(&:to_i)
Cs = gets.split.map(&:to_i)
ans = 0

N.times{|x|
    if (Vs[x] > Cs[x]) then
        ans = ans + Vs[x] - Cs[x]
    end
}

puts ans


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

int main(){
    int a;
    int b;
    int k;
    int count=0;
    int ans;

    cin >> a >> b >> k;
    for(int i=100; i>=1; i--){
        if(a%i==0 && b%i==0){
            count++;
            if(count==k){
                ans = i;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
    int a,b;
  	string str;
    cin >> a >> b;
  	if(a > b){
      for (int i = 0; i < a; i++) {
       
        str = str + to_string(b);
      }
    }else{
      for (int i = 0; i < b; i++) {
        str = str + to_string(a);
      }
    }
    cout << str << endl;
}

Measured memory_bytes: 256
use std::cmp::max;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let nm:Vec<i64> = read_vec();
    let n = nm[0];
    let m = nm[1];

    let ans = if n == 1 && m == 1{
        1
    } else if n == 1 || m == 1{
        let x = max(n,m); 
        x -2
    } else {
        (n - 2) * (m - 2)
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    string s[n];
    rep(i,n) cin >> s[i];
    int a = 0;
    int w = 0;
    int t = 0;
    int r = 0;
    rep(i,n){
        if(s[i]=="AC") a++;
        if(s[i]=="WA") w++;
        if(s[i]=="TLE") t++;
        if(s[i]=="RE") r++;
    }
    cout <<"AC x "<<a<< endl; 
    cout <<"WA x "<<w<< endl; 
    cout <<"TLE x "<<t<< endl; 
    cout <<"RE x "<<r<< endl; 

    return 0;
}


Measured memory_bytes: 6736
s=list(input())
n=len(s)
a=0
ans=0
i=0
while i < n-1:
    if s[i]=='A':
        a+=1
        i+=1
    elif s[i]=='B' and s[i+1]=='C':
        ans+=a
        i+=2
    else:
        a=0
        i+=1
print(ans)

Measured memory_bytes: 4840
X,Y=map(int, input().split())

MOD = 10**9 + 7
def prepare(n, MOD):

    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs
if (X+Y)%3!=0:
    print(0)
else:
    #最初に行き方を決めて、使う移動方法の個数を求めて、重複組み合わせ
    #決め打ちしてから n:2x+yの移動　m:x+2yの移動
    n = (2*X-Y)//3
    m = (2*Y-X)//3

    if n<0 or m<0:
        print(0)
        exit()


    fac, invs = prepare((n+m), MOD)


    print(fac[n+m]*invs[n]*invs[m]%MOD)


Measured memory_bytes: 55852
#include <bits/stdc++.h>
#include <regex>
#define ll long long int
#define yorn(f) cout << ((f) ? "Yes" : "No") << endl
#define YORN(f) cout << ((f) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

string replace(string s, string x, string y) {
    string::size_type pos = 0;
    while ((pos = s.find(x, pos)) != std::string::npos)
    {
        s.replace(pos, x.size(), y);
        pos += y.size();
    }
    return s;
}

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

    cout << replace(s, ",", " ") << endl;

    return 0;
}

Measured memory_bytes: 3528
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
e=[[] for _ in range(h*w+1)]
dp=[0]*(h*w+1)
for i in range(h):
  for j in range(w):
    e[a[i][j]]=(i,j)
for i in range(1,h*w+1-d):
  dp[i+d]=dp[i]+abs(e[i+d][0]-e[i][0])+abs(e[i+d][1]-e[i][1])
q=int(input())
for _ in range(q):
  l,r=map(int,input().split())
  print(dp[r]-dp[l])

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


int main()
{
    ll n, tmp;
    cin >> n;
    ll a[n+1]={0};
    for (int i=2;i<=n;i++)
    {
        cin >> tmp;
        a[tmp]++;
    }
    for (int i=1;i<=n;i++)
        cout << a[i] << endl;
}


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

using ll = long long;
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int n, a, b, c;
   cin >> n >> a >> b >> c;
   vector<int> d(n);
   for (int i = 0; i < n; i++) {
      cin >> d[i];
   }
   sort(d.begin(), d.end(), greater<int>());
   int cal = c, sum = a;
   double Max = 0;
   for (int i = 0; i < n; i++) {
      Max = max(Max, (double)cal / sum);
      cal += d[i];
      sum += b;
   }
   printf("%d\n", (int)Max);

   return 0;
}


Measured memory_bytes: 3276
import java.util.*;
import java.math.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);

      long a = sc.nextLong();
      BigInteger A = BigInteger.valueOf(a);
      BigDecimal AA = new BigDecimal(A);

      Double b = sc.nextDouble();
      BigDecimal B = BigDecimal.valueOf(b);

      BigDecimal res = AA.multiply(B);
    
      System.out.println(res.toBigInteger().toString());
  }
}

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

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

  int count = 0;
  int light = 1;
  bool flag = false;
  for(int i = 0; i < n; ++i) {
      light = a.at(light-1);
      count++;
      if (light == 2) {
          flag = true;
          break;
      }
  }
  cout << (flag ? count : -1) << endl;
}

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

int main(){
  string o, e;
  cin >> o >> e;
  int l = o.size() + e.size();
  int o_i = 0, e_i = 0;
  for(int i=0; i<l;i++){
    if(i % 2 == 0){
      cout << o.at(o_i++);
    }
    else{
      cout << e.at(e_i++);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
m1 = 0
for i in range(n):
    if i % 2 == 0:
        m1 += a[i]
    else:
        m1 -= a[i]
ans = str(int(m1))
neighbor = m1
for i in range(n-1):
    m = 2 * (a[i]-neighbor/2)
    ans += " " +str(int(m))
    neighbor = m
print(ans)

Measured memory_bytes: 14024
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{

	const int mod = 1000000007;
	static void Main(string[] args)
	{
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		int N = int.Parse(Console.ReadLine());
		var H = Console.ReadLine().Split().Select(int.Parse).ToArray();
		string ans = "Yes";
		if (H.Length != 1)
		{
            for(var i = 1; i < N; i++)
			{
				if (H[i - 1] > H[i])
				{
					H[i]++;

				}
				if (H[i] < H[i - 1])
				{
					ans = "No";
					break;
				}
				
			}
		}

		Console.WriteLine(ans);

		Console.Out.Flush();
	}
}

Measured memory_bytes: 26204
a, b, c, d = map(int, input().split())
if abs(a-c) <= d:
    print('Yes')
    exit()
l = [a, b, c]
l.sort()
if l[2] - l[1] <= d and l[1] - l[0] <= d:
    print("Yes")
else:
    print('No')

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

static const int N = 100;

int main()
{
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i - 1] >> p[i];
    }

    for (int i = 1; i <= n; i++)
    {
        m[i][i] = 0;
    }
    for (int l = 2; l <= n; l++)
    {
        for (int i = 1; i <= n - l + 1; i++)
        {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j - 1; k++)
            {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3132
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



n = II()
p = tuple(MI())
q = tuple(MI())

l = list(permutations(list(range(1,n+1))))
print(abs(l.index(p)-l.index(q)))


Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N,A,B;cin>>N>>A>>B;

  int ans=min(N*A,B);
  cout<<ans;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);

  ll n;
  cin >> n;
  vector<ll> v;
  ll n2 = n;
  for (ll p = 2; p * p <= n2; p++)
  {
    if (n2 % p == 0)
      v.push_back(p);
    while (n2 % p == 0)
      n2 /= p;
  }
  if (n2 != 1)
    v.push_back(n2);

  ll ans = n;
  for (auto p : v)
  {
    ans /= p;
    ans *= p - 1;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3164
N,M,X,Y=input().split()
X=int(X)
Y=int(Y)
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.append(X)
y.append(Y)
if max(x)<min(y):
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
N, M, X, Y =(int(x) for x in input().split(" "))

x = max([int(x) for x in input().split(" ")])
y = min([int(x) for x in input().split(" ")])

if y<=x or Y<=X or y <= X or x >= Y:
    print("War")
else:
    print("No War")


Measured memory_bytes: 3060
'use strict'

const main = (input) => {
    const str = input.split('\n')[0].split('')
    const obj = {}
    new Set(str).forEach(v => {
        obj[v] = 0
    })
    str.forEach(v => {
        obj[v]++ 
    })

    for(let v in obj){
        if(obj[v] % 2 !== 0){
            console.log('No')
            return
        }
    }
    console.log('Yes')
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7500
1
2
3
4
5
6
7
8
9
10
11
a, b, c, x = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
            cnt += 1 if i * 500 + j * 100 + k * 50 == x
        end
    end
end
 
puts cnt

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define P(r) do{for(auto i:r){cout<<i<<' ';}cout<<'\n';}while(0)
const int MOD = 1000000007;
int POW2(int n)
{
    int ans = 1;
    for (int i = 0; i < n; i++) ans = (ans * 2) % MOD;
    return ans;
}
int main()
{
    int N; cin >> N;
    int C[100001] = {};
    REP(i, N) {
        int a; cin >> a;
        C[a]++;
    }
    if (N % 2 == 0) { // 3 1 1 3
        for (int i = 1; i <= N - 1; i+=2) {
            if (C[i] != 2) {
                goto FAIL;
            }
        }
        cout << POW2(N / 2) << endl;
    } else { // 4 2 0 2 4
        if (C[0] != 1) goto FAIL;
        for (int i = 2; i <= N - 1; i+=2) {
            if (C[i] != 2) {
                goto FAIL;
            }
        }
        cout << POW2((N - 1) / 2) << endl;
    }
    return 0;
FAIL:
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main(int argc, char const *argv[]){

	for (int i = 1; i <= 9; ++i){
		for (int j = 1; j <= 9; ++j){
					std::cout << i << "x" << j << "=" << i*j << std::endl;
				}		
	}

	return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <locale>
#include <algorithm>

using namespace std;

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

	int r, D, x;
	cin >> r >> D >> x;

	for (int i=1; i<=10; i++) {
		x = r*x-D;
			cout << x << endl;
	}
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    // pair<red, blue>
    map<pair<string,string>, ll> m;
    reverse(s.begin(), s.begin()+n);
    rep(bit, 1<<n) {
        string red = "", blue = "";
        rep(i, n) {
            if (bit & (1 << i)) red += s[i];
            else blue += s[i];
        }
        m[{red, blue}]++;
    }

    ll ans = 0;
    rep(bit, 1<<n) {
        string red = "", blue = "";
        rep(i, n) {
            if (bit & (1 << i)) red += s[i+n];
            else blue += s[i+n];
        }
        ans += m[{blue, red}];
    }
    cout << ans << endl;
}


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

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

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.erase(k) << "..." << endl;
  }

  return 0;
}


Measured memory_bytes: 3524
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

//??°?????????????????°

void function()
{
    //??¢??°
}
 
int main(){
    int max1 = 0;
    int max2 = 0;
    int max3 = 0;
    for (int i = 0; i < 10; i++){
    	int a;
		cin >> a;
		if(a >= max1){
		max3 = max2;
		max2 = max1;
		max1 = a;
		}else if(a >= max2){
			max3 = max2;
			max2 = a;
		}else if(a >= max3){
			max3 = a;
		}
    }
    cout << max1 << endl << max2 << endl << max3 << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#define NUM_INTERVAL 10
int main() {
	double L[NUM_INTERVAL], v1, v2;
	double total, cross_over, d;
	int i;
	while (scanf(
			" %lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
			&L[0], &L[1], &L[2], &L[3], &L[4], &L[5], &L[6], &L[7], &L[8],
			&L[9], &v1, &v2) != EOF) {
		total = cross_over = d = 0.0;
		for (i = 0; i < NUM_INTERVAL; i++) {
			total += L[i];
		}
		cross_over = v1 * total / (v1 + v2);
		for (i = 0; i < NUM_INTERVAL; i++) {
			d += L[i];
			if (cross_over <= d)
				break;
		}
		printf("%d\n", i + 1);
	}
	return 0;
}

Measured memory_bytes: 624
#include<stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))

int main(){
	long n,i;
	long long a,s;
	long long ans,cmp=0;
	char op,f;
	scanf("%ld",&n);
	scanf("%lld",&a);
	f=0;
	s=0;
	ans=a;
	for(i=0;i<n-1;i++){
		scanf(" %c",&op);
		scanf("%lld",&a);
		if(f==0 && op=='-'){
			ans-=a;
			f=1;
			s=0;
		}else if(f==1 && op=='+'){
			s+=a;
		}else if(f==1 && op=='-'){
			if(s-a<=a-s){
				ans+=a-s;
				s=0;
				f=2;
			}else{
				cmp=ans+a-s;
				ans+=s-a;
				f=3;
				s=0;
			}
		}else if(f==3){
			cmp+=a;
			if(op=='+'){
				s+=a;
			}else{
				if(s-a<=a-s){
					ans+=a-s;
					s=0;
					f=4;
				}else{
					cmp=max(cmp,ans+a-s);
					ans+=s-a;
					s=0;
				}
			}
		}else{
			ans+=a;
			cmp+=a;
		}
	}
	if(s>0){
		ans+=s;
	}
	if(f>=3){
		ans=max(ans,cmp);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  cout << (N + X - 1) / X * T << endl;
}

Measured memory_bytes: 3616
def papers_please(a_list:list) -> str:
    approved_list = []      
    for x in a_list:
        if x % 2 == 0:
            if x % 3 == 0 or x % 5 == 0:
                approved_list.append("APPROVED")
            else:
                approved_list.append("DENIED")
        else:
            approved_list.append("APPROVED")
    if "DENIED" in approved_list:
        return("DENIED")
    else:
        return("APPROVED")

n = int(input())
a_list = list(map(int, input().split()))
print(papers_please(a_list))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
priority_queue< double,vector<double>,greater<double> > pq;
int n;double v[1011];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lf",&v[i]),pq.push(v[i]);
	for(int i=1;i<n;i++)
	{
		double a,b;
		a=pq.top(); pq.pop();
		b=pq.top(); pq.pop();
		pq.push((a+b)/2.0);
	}
	printf("%.14lf",pq.top());
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int64 N, W;

int main(void){
	cin >> N >> W;
	vector<int64> dp(112345, INF_LL);
	dp[0] = 0;
	int64 res = 0;
	REP(i, N){
		int64 w, v;
		cin >> w >> v;
		for(int32 j = 112344;j >= 0;j--){
			if(dp[j]+w <= W){
				chmin(dp[j+v], dp[j]+w);
				chmax(res, j+v);
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int n[b];
  int s=0;
  for(int i=0;i<b;i++)
  {
    cin>>n[i];
    s=s+n[i];
  }
  if(s>=a)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279


void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main(void){
	int n;
	scanf("%d", &n );
	int a[n];
	for(int i=0;i<n;i++)	scanf("%d", &a[i]);
	int ans=a[0];
	for(int i=1;i<n;i++){
      ans = gcd(ans, a[i]);
    }
	
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 512
n,k=map(int,input().split())
a=list(map(int,input().split()))
inf=10**9+7
now=0
cnt=[0]*n
cntlast=0
plus=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            if i<j:
                cnt[j]+=1
            plus+=1
print((k*sum(cnt)+plus*(k-1)*k//2)%inf)

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    Stream io;
    
    string s;
    io.read(s);
    string s1 = s.substr(0, 5);
    string s2 = s.substr(6, 7);
    string s3 = s.substr(14);
    cout << s1 << ' ' << s2 << ' ' << s3;
    return 0;
}

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

int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; i++) {
		if (A & 1) --A;
		B += A >> 1; A >>= 1;
		swap(A, B);
	}
	if (K & 1) swap(A, B);
	cout << A << ' ' << B << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N,X,T;
    cin >> N >> X >> T;
    int times = N/X;
    int ans;
    if(N%X==0){
        ans=times*T;
    } else{
        ans=(times+1)*T;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3192
#include <stdio.h>
#include <algorithm>
#define x first
#define y second
using namespace std;

/*struct point{
    int x, y;
    bool usado = false;
};*/

int n, a, b;
pair<int, int> blue[120], red[120];
bool usado[120];

/*bool compare(point a, point b){
    /*if(a.x < b.x){
        return true;
    } else if(a.x == b.x){
        return a.y < b.y;
    } else {
        return false;
    }
    return (a.x < b.x && a.y < b.y);
}*/

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d %d", &a, &b);
        red[i].x = a;
        red[i].y = b;
    }
    for(int i=0; i<n; i++){
        scanf("%d %d", &a, &b);
        blue[i].x = a;
        blue[i].y = b;
    }

    sort(red, red+n);
    sort(blue, blue+n);
    int cont =0;


    for(int i=n-1; i>=0; i--){
        int maxi = 9999;
        int idx = -1;
        for(int j=0; j<n; j++){
            if(red[i].x < blue[j].x && red[i].y < blue[j].y && !usado[j] && maxi > blue[j].y){
                idx = j;
                maxi = blue[j].y;
            }
        }
        if(idx != -1){
            cont +=1;
            usado[idx] = true;
            //printf("%d %d y %d %d\n", red[i].x, red[i].y, blue[idx].x, blue[idx].y);
        }

    }
    printf("%d\n", cont);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

ULL F[10000001];
ULL P[10000001]={};
ULL D[10000001];

int main() {
 ULL N; cin>>N;
 F[1]=1; P[1]=1; D[1]=1;
 for(UL i=1;i<=N;i++){
  if(P[i]) continue;
  for(UL j=1;j*i<=N;j++){
   if(P[j]!=i) D[j]=F[j];
   F[j*i]=F[j]+D[j];
   D[j*i]=D[j];
   P[j*i]=i;
  }
 }
 ULL ans=0;
 for(UL i=1; i<=N; i++) ans+=i*F[i];
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 237864
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>
 
#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
 
const int INF = 10000000;
using namespace std;
typedef long long  ll;
 
/** Problem1129 : Hanafuda Shuffle **/
int main()
{
    vector<int> card;
    int n, r, p, c;
     
    while (cin >> n >> r, n||r) {
        card.clear();
        rep(i, n)
            card.push_back(n-i);
         
        rep(k, r) {
            cin >> p >> c;
            vector<int> tmp;
            rep(i, c)
                tmp.push_back(card[i+p-1]);
            rep(i, p-1)
                tmp.push_back(card[i]);
            REP(i, p+c-1, n) {
                tmp.push_back(card[i]);
            }
            card = tmp;
        }
        cout << card[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
/*
Main AC Solution(Zobiest Hash)
*/

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

const int MN = 100;
const int MH = TEN(9);

mt19937 gen;
void reseed(ll seed) {
    gen = mt19937(seed);
    for (int i = 0; i < 10000; i++) {
        gen(); // skip
    }
}

ll rand_int(ll l, ll r) { //[l, r]
    using D = uniform_int_distribution<ll>;
    assert(l <= r);
    return D(l, r)(gen);
}

string rand_lower_string(int n, int up = 26) {
    string s = "";
    for (int i = 0; i < n; i++) {
        s += 'a' + rand_int(0, up-1);
    }
    return s;
}

template<class T> void myshuffle(T &v) {
    shuffle(begin(v), end(v), gen);
}

template<uint MD>
struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v{0} {}
    ModInt(ll _v) : v{normS(_v % MD + MD)} {}
    explicit operator bool() const { return v != 0; }
    static uint normS(uint x) { return (x < MD) ? x : x - MD; };
    static M make(uint x) { M m; m.v = x; return m; }
    static M inv(const M& x) { return x.pow(MD - 2); }
    M operator+(const M& r) const { return make(normS(v + r.v)); }
    M operator-(const M& r) const { return make(normS(v + MD - r.v)); }
    M operator*(const M& r) const { return make(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * inv(r); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
};
using Mint = ModInt<TEN(9)+7>;

using P = pair<Mint, Mint>; // 0101, all

P make(int l, int r, V<int> &v) {
    int mi = TEN(9) + TEN(4);
    for (int i = l; i < r; i++) {
        mi = min(mi, v[i]);
    }
    for (int i = l; i < r; i++) {
        v[i] -= mi;
    }
    int other = 0;
    Mint c01 = Mint(1), c01self = Mint(1);
    int p = l;
    while (p < r) {
        if (v[p] == 0) {
            other++;
            p++;
            continue;
        }
        int q = p;
        while (q < r && v[q]) q++;
        P ch = make(p, q, v);
        c01 *= ch.first;
        c01self *= (ch.first + ch.second);
        p = q;
    }
    Mint self01 = Mint(2).pow(mi) * c01;
    Mint selfall = Mint(2).pow(other) * c01self + self01 - Mint(2) * c01;
    return P(self01, selfall);
}

int main() {
    int n;
    cin >> n;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    P p = make(0, n, a);
    cout << p.second.v << endl;
    return 0;
}


Measured memory_bytes: 256