akhauriyash/Code-Regression huggingface dataset:
// uva 796
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

static const int FAIL = -1;

struct Edge{
  int src, dst;
  Edge(int s, int d) : src(s), dst(d) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void traverse(const Graph &G, int n, int d[], int p[], int l[], int &time)
{  
  d[n] = l[n] = ++time;
  FOR(e, G[n]){
    if(!d[e->dst]){
      p[e->dst] = e->src;
      traverse(G, e->dst, d, p, l, time); 
      l[e->src] = min(l[e->src], l[e->dst]); 
    }
    else if(p[e->src] != e->dst)
      l[e->src] = min(l[e->src], d[e->dst]); 
  }
  return ;
}

Edges findBridge(const Graph &G)
{// G is not allowed parallel edge
  const int size = G.size();
  int d[size], p[size], l[size], time = 0;
  Edges B;
  fill(d, d + size, false);
  fill(p, p + size, FAIL);
  REP(i, size){
    if(d[i])continue;
    traverse(G, i, d, p, l, time);
  }
  REP(i, size){
    if(p[i] != FAIL && d[i] == l[i])
      B.push_back(Edge(p[i], i));
  }
  return B;
}

bool cmp(const Edge &a, const Edge &b)
{
  if(a.src != b.src)return a.src < b.src;
  return a.src > b.dst;
}

#include <set>
#include <utility>
int main(void)
{
  int n, m;

  while (cin >> n >> m) {
    Graph g(n);
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(Edge(a ,b));
      g[b].push_back(Edge(b, a));
    }
    cout << findBridge(g).size() << endl;
    
  }
  
  // while(cin >> node){
  //   int src, edge, dst, cnt = 0;
  //   char c;
  //   set< pair<int, int> > S, T;
  //   Graph G(node);
  //   REP(i, node){
  //     cin >> src >> c >> edge >> c;
  //     REP(j, edge){
  //       cin >> dst;
  //       if(S.count(make_pair(src, dst))){
  //         T.insert(make_pair(src, dst));
  //       }
  //       else{
  //         G[src].push_back(Edge(src, dst));		  
  //         G[dst].push_back(Edge(dst, src));
  //       }
  //     }
  //   }
  //   Edges B = findBridge(G), R;
  //   FOR(e, B){
  //     //if(T.count(make_pair(e->src, e->dst)))continue;
  //     R.push_back(Edge(min(e->src, e->dst), max(e->src, e->dst)));
  //   }
  //   sort(ALL(R), cmp);
  //   cout << R.size() << " critical links" << endl;
  //   FOR(e, R)
  //     cout << e->src << " - " << e->dst << endl;
  //   cout << endl;
  // }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL t[110];
LL x[110];
int p[110];
int main()
{
	 int n;
	 while(~scanf("%d",&n))
	 {
	 	LL sum=0;
	 	for(int i=1;i<=n;i++)
	 	{
	 		scanf("%lld",&t[i]);
	 		sum+=t[i];
		 }
		 int m;
		 scanf("%d",&m);
		 for(int i=0;i<m;i++)
		 {
		 	scanf("%d %lld",&p[i],&x[i]);
		 	LL ans=sum-t[p[i]]+x[i];
		 	printf("%lld\n",ans);
		 }
		 return 0;
	 }
 } 

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
 
    char ch;
    int sum[26]={0};
    
    for(int i=0;cin>>ch;i++){
        if('a'<= ch&&ch<='z')
        sum[ch-'a']++;
        else if('A'<=ch&&ch<='Z')
        sum[ch-'A']++;
    }
    
    for(char i='a';i<='z';i++)
    cout<<i<<" "<<":"<<" "<<sum[i-'a']<<endl;

}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ll tmp1 = 0, tmp2 = 0;
    while (tmp1 < a) {
      tmp1 += c;
    }
    while (tmp2 < b) {
      tmp2 += d;
    }
    cout << n - max(tmp1/c, tmp2/d) << endl;
}


Measured memory_bytes: 3092
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n;cin>>n;
    n=(n/200);
    cout<<8-(n-2)<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3644
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean second = true;
		for (int i=0;i<n;i++) {
			int a = sc.nextInt();
			if (a%2!=0) {
				second=false;
			}
		}
		System.out.println(second ? "second" : "first");
	}

}




Measured memory_bytes: 48652
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, ans = 0; cin >> N;
    rrep (i, 1, N) {
        if (i % 2 == 0) continue;
        int tmp = 0;
        rrep (j, 1, i) if (i % j == 0) tmp++;
        if (tmp == 8) ans++;
    }
    cout << ans << endl;
}

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

const int mod = 1e9 + 7;
int C[2005][2005];

void init(int n,int m)
{
	for(int i = 0;i <= n;++i)
	{
		C[i][0] = 1;
		for(int j = 1;j <= m && j <= i;++j)
			C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
	}
}

int main()
{
	int N;
	scanf("%d",&N);
	
	ll ans = 0;
	int B=N / 3;
	init(2000,2000);
	for(int i = 1;i <= B;++i)
	{
		ans = (ans + C[N-2*i-1][i-1]) % mod;
	}
	return printf("%lld",ans),0;
} 

Measured memory_bytes: 17572
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
	std::io::Read::read_to_string(
		&mut std::io::stdin(),
		&mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
	let mut get = || stdin.next().unwrap();
	macro_rules! get {
		() => (get().parse::<i64>().unwrap());
		($t:ty) => (get().parse::<$t>().unwrap());
	}
    
	let n = get!(usize);
	let mut xs = vec![];
	xs.push(0);
	for _ in 0..n {
		xs.push(get!());
	}
	xs.push(0);
	let mut all = 0;
	for i in 0..xs.len()-1 {
		all += (xs[i] - xs[i+1]).abs();
	}
	for i in 1..n+1 {
		let ans = all
				- (xs[i] - xs[i-1]).abs()
				- (xs[i] - xs[i+1]).abs()
				+ (xs[i+1] - xs[i-1]).abs();
		println!("{}", ans);
	}
}

Measured memory_bytes: 7292
import java.util.Scanner;

public class Main {

	public static void main( String[] args ) {	
          
		Scanner input = new Scanner (System.in);
		
		
		int a = input.nextInt();
		
		int b = input.nextInt();
		
		int sum = a+b;
		
		if (sum%2==0) {
			
			System.out.println(sum/2);
		}
		else {
			System.out.println("IMPOSSIBLE");
		}
		
		input.close();
		
	} 
	
}


Measured memory_bytes: 35348
import sys
from itertools import accumulate

readline = sys.stdin.readline
INF = 10 ** 9
h, w, k = map(int, readline().split())
s = [readline() for _ in range(h)]

ans = INF
for bit in range(2**h-1):
    cut = bin(bit).count('1')
    group = 0
    peace = [[0] * (bin(bit).count('1') + 1) for _ in range(w)]

    for i in range(w):
        group = 0
        for j in range(h):
            if s[j][i] == '1':
                peace[i][group] += 1
            if bit >> j & 1:
                group += 1

    if any(max(col) > k for col in peace):
        continue
    current = [0] * (bin(bit).count('1') + 1)
    for i in range(w):
        current = list(map(sum, zip(current, peace[i])))
        if max(current) > k:
            cut += 1
            current = peace[i]
    if ans > cut:
        ans = cut

print(ans)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 074_arc_a / Link: https://abc062.contest.atcoder.jp/tasks/arc074_a?lang=en  ----- */
/* ------問題------

縦 H ブロック、横 W ブロックの板チョコがあります。 すぬけ君は、この板チョコをちょうど 3 つのピースに分割しようとしています。 ただし、各ピースはブロックの境目に沿った長方形でなければなりません。

すぬけ君は、3 つのピースの面積 (ブロック数) をできるだけ均等にしようとしています。 具体的には、3 つのピースの面積の最大値を Smax、最小値を Smin としたとき、Smax−Smin を最小化しようとしています。 Smax−Smin の最小値を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL H, W;

LL ans = 0LL;

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

	cin >> H >> W;

	ans = LINF;
	FOR(k, 0, 2) {
		swap(H, W);
		FOR(i, 1, W) {
			LL a = i;
			LL b = (W - i) / 2;
			LL c = W - a - b;

			LL Sx = a*H;
			LL Sy = b*H;
			LL Sz = c*H;
			ans = min(ans, max({ Sx, Sy, Sz }) - min({ Sx, Sy, Sz }));

			LL w = W - a;
			LL bb = H / 2;
			LL cc = H - bb;
			Sy = bb*w;
			Sz = cc*w;
			ans = min(ans, max({ Sx, Sy, Sz }) - min({ Sx, Sy, Sz }));

		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

void dfs(vector<vector<int>> &graph, int s, vector<int> &dp){
    if (dp[s]!=-1)
        return;
    int ans = 0;
    for (int i=0;i<graph[s].size();i++){
        dfs(graph,graph[s][i],dp);
        ans = max(ans, 1 + dp[graph[s][i]]);
    }
    dp[s] = ans;
    return;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n,vector<int>(0)); // directed graph
    for (int i=0;i<m;i++){
        int u,v;
        cin >> u >> v;
        graph[u-1].push_back(v-1);
    }
    vector<int> dp(n,-1); // length of the path starting from this node
    vector<bool> visited(n,false);
    for (int i=0;i<n;i++){
        if (dp[i]!=-1)
            continue;
        dfs(graph, i, dp);
    }
    int ans = 0;
    for (int i=0;i<n;i++){
        ans = max(ans, dp[i]);
    }
    cout << ans << "\n";
}


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

int main() {

    int N,L;
    cin>>N>>L;
    vector<string> S(N);
    for (int i = 0; i < N; ++i) {
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    for (int i = 0; i < N; ++i) {
        cout<<S[i];
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
S = [list(map(int,input().split()))[1:] for _ in range(M)]
P = list(map(int,input().split()))

ans = 0
for i in range(1<<N):
  for j, k in enumerate(S):
    if sum(1 for kj in k if (i>>(kj-1) & 1))%2 != P[j]:
      break
    if j == len(S)-1:
      ans += 1

print(ans)

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

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

  ll A; cin >> A;
  ll B; cin >> B;
  ll ans;
  for (int i = 1; i <= B; i++) {
    if ((A * i) % B == 0) {
      ans = A * i;
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll n;
ll ans;

int main(){

cin >> n;

vector<ll> a(n*3);

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

sort(a.rbegin(), a.rend());

for(int i=1; i<n*2; i+=2){
    ans += a[i];
}
cout << ans << endl;

return 0;

}















Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T 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;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> multi_vector(size_t a){return vector<T>(a);}template<class T, class... Ts>auto multi_vector(size_t a, Ts... ts){return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  deque<ll> b;
  rep(i, 0, N){
    ll B;
    cin >> B;
    b.push_back(B);
  }
  deque<ll> ans;
  rem(i, N-1, -1){
    rem(j, i, -2){
      if(j == -1){
        cout << -1 << rt;
        return 0;
      }
      if(j+1 == b[j]){
        b.erase(b.begin() + j, b.begin() + j+1);
        ans.push_front(j+1);
        break;
      }
    }

  }
  for(auto&& i : ans){
    cout << i << rt;
  }
}

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

using namespace std;

int stamina = 1e9 * 3;

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<int> vil(n);
    
    for (int i = 0; i < n; ++i)
        cin >> vil[i];
    
    for (int j = 1; j <= 100; ++j)
    {
        int tmp = 0;
        
        for (int k = 0; k < n; ++k)
            tmp += (j - vil[k]) * (j - vil[k]);
        
        stamina = min(stamina, tmp);
    }
    
    cout << stamina;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxn = 1e5;
const ll mod = 1e9 + 7;
 
ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
 
const int siz = 5e5+20;
ll fact[siz], inv[siz];
void pre(){
	fact[0] = 1;
	inv[0] = pow(fact[0], mod-2);
	for(int i=1;i<siz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}
 
int spf[10];
void sieve(){
    spf[1]=1;
    for(int i=2;i<mxn;i++) spf[i]=i;
    for(int i=4;i<mxn;i+=2) spf[i]=2;
    for(int i=3;i*i<mxn;i++){
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;

    ll ans = 0;

    for(int i=1;i<n;i++){ 
        if(n%i==0) ans+= (n/i)-1;
        else ans+=(n/i);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

const int Maxn = 100005;

int n, k;
int a[Maxn];
vector <int> neigh[Maxn];
int ans;

int Traverse(int v, int p)
{
    int res = 0;
    for (int i = 0; i < neigh[v].size(); i++) {
        int u = neigh[v][i];
        if (u == p) continue;
        res = max(res, Traverse(u, v));
    }
    res++;
    if (res == k && p != 1) { ans++; return 0; }
    return res;
}

int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    if (a[1] != 1) { ans++; a[1] = 1; }
    for (int i = 2; i <= n; i++)
        neigh[a[i]].push_back(i);
    for (int i = 0; i < neigh[1].size(); i++)
        Traverse(neigh[1][i], 1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12288
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int N = A - B;
	int M = C - N;
	if (M > 0) {
		cout << C - N << endl;
	}
	else {
		cout << '0' << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a[10][10];
  rep(i,1,10){
    a[i][1]=i;
    a[1][i]=i;
  }
  rep(i,2,10){
    rep(j,2,10) a[i][j]=i*j;
  }
  int x;
  cin>>x;
  int check=0;
  rep(i,1,10){
    rep(j,1,10){
      if(a[i][j]==x){
        check++;
        break;
      }
    }
  }
  cout<<(check?"Yes":"No");
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

using namespace std;

int main(){
    int n;
    cin>>n;
    float sum=0;
    vector<float> v(n);
    for (int i=0; i<n; i++) {
        cin>>v[i];
        sum += 1/v[i];
    }
    sum = 1/sum;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	int red[a],green[b];
	fo0(i,a){
		cin>>red[i];
	} 
	fo0(i,b){
		cin>>green[i];
	}
	int d[c];
	fo0(i,c){
		cin>>d[i];
	}
	sort(red,red+a);
	reverse(red,red+a);
	sort(green,green+b);
	reverse(green,green+b);
	int ans=0;
	vi v;
	fo0(i,x){
		v.push_back(red[i]);
	}
	fo0(i,y){
		v.push_back(green[i]);
	}
	sort(all(v));
	sort(d,d+c);
	reverse(d,d+c);
	int j=0;
	fo0(i,v.size()){
		if(v[i]<d[j] and j<c){
			v[i]=d[j];
			j++;
		}
	}
	for(auto i: v){
		ans+=i;
	}
	cout<<ans;
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 4852
def chk(l):
  s=0
  for r in l:
    s+=r
    if (s<0)|(s>9):
      return False
  return True
def nml(l):
  ln=len(l)
  for i in range(1,ln):
    if l[-i]==2:
      l[-i]=-1
      l[-i-1]+=1
  if l[0]==10:
    return True
  return False


a=[1]
for i in range(int(input())-1):
  while True:
    if len(a)==1:
      a[0]+=1
      if a[0]==10:
        a=[1,-1]
    else:
      a[-1]+=1
      if nml(a):
        a=[1]+[-(j==0) for j in range(len(a))]
    if chk(a):
      break
rt=""
ss=0
for i in a:
  ss+=i
  rt+=str(ss)
print(rt)

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

using namespace std;

typedef long long ll;

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int g = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        g = gcd(g, a[i]);
    }
    if (k % g || *max_element(a.begin(), a.end()) < k) {
        cout << "IMPOSSIBLE";
    } else {
        cout << "POSSIBLE";
    }
    return 0;
}

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

int main(void) {
  int n, a[3]; cin >> n >> a[0] >> a[1] >> a[2];
  int ans[n], x[n][2];
  
  for(int i = 0;i < n;i++) {
    char s[3]; cin >> s; 
    for(int j = 0;j < 2;j++) { x[i][j] = s[j] - 'A'; } 
  }
  
  for(int i = 0;i < n;i++) {
    if( a[ x[i][0] ] == 0 && a[ x[i][1] ] == 0 ) { cout << "No\n"; return 0; }
    else if( a[ x[i][0] ] == 0 ) { a[ x[i][0] ]++; a[ x[i][1] ]--; ans[i] = x[i][0]; }
    else if( a[ x[i][1] ] == 0 ) { a[ x[i][1] ]++; a[ x[i][0] ]--; ans[i] = x[i][1]; }
    else {
      if( i < n - 1 && ( x[i][0] == x[i + 1][0] || x[i][0] == x[i + 1][1] ) ) {
        a[ x[i][0] ]++; a[ x[i][1] ]--; ans[i] = x[i][0];
      } else { a[ x[i][1] ]++; a[ x[i][0] ]--; ans[i] = x[i][1]; }
    }
  }
  
  cout << "Yes\n"; for(int i = 0;i < n;i++) { cout << (char)( ans[i] + 'A' ) << endl; }
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
const ll ll_inf = ll(1e9) * ll(1e9);
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
    ll x;
    cin >> x;

    if (x == 1){
        cout << 0;
    }
    else {
        cout << 1;
    }
    


    return 0;
}


Measured memory_bytes: 3616
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin>>n;
    map<int,int> mp;
    set<int> st;
    forn(i,n){
        int x;
        cin>>x;
        st.insert(x);
        mp[x]++;
    }
    ll a=0,b=0;
    for(auto it=st.rbegin();it!=st.rend();it++){
        if(mp[*it]>=4&&a==0){
            a=*it;
            b=*it;
            break;
        }else if(mp[*it]>=2){
            if(a==0)a=*it;
            else{
                b=*it;
                break;
            }
        }
    }
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 12900
#include <iostream>
using namespace std;
int main(void){
	char x[1001];
	string s;
	while(1){
		cin >> s;
		for(int a = 0; a < s.size();a++){
			x[a] = s.at(a);
		}
		if(x[0] == '0') break;
		int sum = 0;
		for(int i = 0; i < s.size(); i++){
			sum += (x[i] - '0');
		}
		cout << sum <<endl;
	}
	return 0;
}



Measured memory_bytes: 3160
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<vector>
#include<queue>
#include<math.h>
#include<stdlib.h>
#include<algorithm>

typedef long long int ll;

using namespace std;

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

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    double x1, y1, x2, y2;
    double x, y;
    cin>>x1>>y1>>x2>>y2;
    x = pow((x1-x2), 2.0);
    y = pow((y1-y2), 2.0);
    cout<<setprecision(10)<<sqrt(x + y)<<endl;

    return 0;
}



Measured memory_bytes: 3288
#include <iostream>

using namespace std;

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

    long long int Q, H, S, D;
    cin >> Q >> H >> S >> D;

    S = min(S, min(4 * Q, 2 * H));

    long long int cost = 0;
    int N;
    cin >> N;
    if (N % 2 == 0) {
        cost = N / 2 * min(2 * S, D);
    } else {
        cost = S + (N - 1) / 2 * min(2 * S, D);
    }

    cout << cost << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

const int MAXN = 100000;
int dp[MAXN+1];
int h[MAXN+1];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) {
        cin >> h[i];
        dp[i] = INT_MAX;
    }

    dp[1] = 0;
    for (int s = 1; s < N; ++s) {
        for (int j = 1; j <= K; ++j) {
            if (N < s+j) {
                j = K+1;
            } else {
                dp[s+j] = min(dp[s+j], dp[s] + abs(h[s] - h[s+j]));
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int de(char d, char f, char g){
    int a=d-'0',b=f-'0',c=g-'0';
    return 100*a+10*b+c;
}
int main(void){
   string s;
   cin>>s;
   int ans=1000;
   for(int i=0;i<s.size()-2;i++){
       int tmp=abs(de(s[i],s[i+1],s[i+2])-753);
      // cout<<de(s[i],s[i+1],s[i+2]) <<endl;
       if(ans>tmp) ans =tmp;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>

using namespace std;


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

	if (( s[6] == '3' || s[6] == '4')) {
			cout << "Heisei" << endl;
	}
	else if (s[6] == '1' || s[6] == '2') {
		if (s[5] == '0') {
			cout << "Heisei" << endl;
		}
		else { cout << "TBD" << endl; }
	}
	else {
		cout << "TBD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool judge(int p1, int p2, int p3){
	if (p1 <= p2&&p2 <= p3 || p3 <= p2&&p2 <= p1){
		return true;
	}
	else return false;
}
int main(){
	int n;
	int ans=0;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++){
		cin >> p[i];
	}
	for (int i = 1; i < n - 1; i++){
		if (judge(p[i - 1], p[i], p[i + 1])){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <string>
#include <iostream>
using namespace std;
map<string,int> table;
int main()
{
    string word, frequent, longest;
    size_t N=0;
    while (cin >> word)
    {
        table[word]++;
        if(table[word]>N)
        {
            N=table[word];
            frequent=word;
}
            if(word.size()>longest.size())
                longest=word;
    }
        cout<<frequent<<" "<<longest<<endl;
    }


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

int main() {
    int N;
    int i;
    int A;
    double Ai = 0;

    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d", &A);
        Ai += (double) 1 / A;
    }
    printf("%f\n", (double)1 / Ai); 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=1LL;
  cin >> n;
  string s;cin>>s;
  n*=2;
  vi lr(n);
  ll flag=0;
  REP(i,n){
    if (s[i]=='B') flag=i%2;
    if (s[i]=='W') flag=1LL-i%2;
    lr[i]=flag;//0がL
  }


  ll Lnum=0;
  REP(i,n){
    if (lr[i]==0)Lnum+=1;
    if (lr[i]==1){
      ans*=Lnum;
      ans%=MOD;
      Lnum--;
    }
  }

  REP(i,n/2){
    ans*=(ll)(i+1);
    ans%=MOD;
  }
  if (Lnum!=0)ans=0;

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

Measured memory_bytes: 2180
while True:
    m, n_min, n_max = map(int, input().split())
    if m == 0 and n_min == 0 and n_max == 0:
        break
    P = [int(input()) for _ in range(m)]
    ans = [0, 0]
    for i in range(n_min, n_max+1):
        # print("i: {}, P[i-1]: {}, P[i]: {}".format(i, P[i-1], P[i]))
        ans[0] = max(P[i - 1] - P[i], ans[0])
        if ans[0] == P[i - 1] - P[i]:
            ans[1] = i
    print(ans[1])



Measured memory_bytes: 5620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int w = sc.nextInt();

        int last = w;
        for (int i = 1; i <= 10; i++) {
            last = r * last - D;
            System.out.println(last);
        }
    }
}

Measured memory_bytes: 21712
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int n, m, s, t;
vector<long> u(100005);
vector<long> v(100005);
vector<long> a(100005);
vector<long> b(100005);
vector<vector<pair<long, long>>> graph(100005);

void dijkstra(long s, vector<long> &dist, bool isYen) {
  priority_queue<pair<long,long>, vector<pair<long, long>>, greater<>> queue;
  queue.push(make_pair(0, s));
  while (!queue.empty()) {
    pair<long, long> p = queue.top();
    queue.pop();
    long start = p.second;
    long d = p.first;
    if (d > dist.at(start)) {
      continue;
    }
    for (auto e : graph.at(start)) {
      long end = e.first;
      long train = e.second;
      long cost = isYen ? a.at(train) : b.at(train);
      if (dist.at(end) > d + cost) {
        dist.at(end) = d + cost;
        queue.push(make_pair(dist.at(end), end));
      }
    }
  }
}

int main() {
  cin >> n >> m >> s >> t;
  for (int i=1; i<=m; i++) {
    cin >> u.at(i) >> v.at(i) >> a.at(i) >> b.at(i);
  }

  for (int i=1; i<=m; i++) {
    graph.at(u.at(i)).push_back(make_pair(v.at(i), i));
    graph.at(v.at(i)).push_back(make_pair(u.at(i), i));
  }

  vector<long> dist1(n+1);
  vector<long> dist2(n+1);  
  for (int i=1; i<=n; i++) {
    dist1.at(i) = LONG_MAX;
    dist2.at(i) = LONG_MAX;
  }
  dist1.at(s) = 0;
  dist2.at(t) = 0;

  dijkstra(s, dist1, true);
  dijkstra(t, dist2, false);

  vector<long> dvec(n+1);
  dvec.at(n) = dist1.at(n) + dist2.at(n);
  for (int i=n-1; i>=1; i--) {
    dvec.at(i) = dist1.at(i) + dist2.at(i);
    dvec.at(i) = min(dvec.at(i), dvec.at(i+1));
  }
  long init = 1;
  for (int i=1; i<=15; i++) {
    init *= 10;
  }
  for (int i=1; i<=n; i++) {
    cout << init-dvec.at(i) << endl;
  }
}


Measured memory_bytes: 14848
program atcoder
    implicit none
    integer :: A, B, C, X, i, j, k, counter

    read *, A, B, C, X
    counter = 0
    do i = 0, A
        do j = 0, B
            do k = 0, C
                if(X == 500*i + 100*j + 50*k) then
                    counter = counter + 1
                end if
            end do
        end do
    end do
    print '(i0)', counter
    stop

end program atcoder


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
 string s,t;
  cin>>s>>t;
  //////
  int n,m;
  n=s.size();
  m=t.size();
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  //cout<<s<<t<<endl;
  bool ans=true;
  if(t<=s){
   ans=false; 
  }
  
 
  
  
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from sys import stdin
rs = stdin.readline
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    n = ri()
    A = ril()
    h = 0
    ans = 0
    for a in A:
        dh = max(h-a, 0)
        h = a + dh
        ans += dh
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31468
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 223;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int g[N][N];

void solve(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            g[i][j] = __gcd(i, j);
        }
    }
    ll s = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int k = 1; k <= n; k++){
                s += g[g[i][j]][k];
            }
        }
    }
    cout << s;
}

int main(){
    #ifdef KAZAKH
        //freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int x;
  cin >> x;
  if(x < 1200){
cout << "ABC" << endl;
  }else{
cout << "ARC" << endl;

  }
    return 0;
}


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

int main () {
  int a[5] ;
  for(int i = 0 ; i < 5 ; i++ ) cin >> a[i] ;
  int k ;
  cin >> k ;
  bool ans = true ;
  if(a[4] - a[0] > k ) ans = false ;
  if(ans) cout << "Yay!" << endl ;
  else cout << ":(" << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll l[87];

ll lucas(int n) {
	if(l[n] != 0) {
		return l[n];
	}
	if(n == 0) {
		l[0] = 2;
		return 2;
	} else if(n == 1) {
		l[1] = 1;
		return 1;
	} else {
		l[n] = lucas(n - 2) + lucas(n - 1);
		return l[n];
	}
}
int main(void) {
	int n;
	cin >> n;
	cout << lucas(n) << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
int main(){
    dou r;
    std::cin >> r;
    std::cout << keta(10)<<2*r*pi << std::endl;
}


Measured memory_bytes: 3812
H, W, A, B = [int(x) for x in input().split()]
ans = [[0 for _ in range(W)] for _ in range(H)]
for i in range(B):
    ans[i] = [int(not ans[i][j]) for j in range(W)]
for i in range(A):
    for j in range(H):
        ans[j][i] = int(not ans[j][i])
for row in ans:
    for val in row:
        print(val, end='')
    print('')    


Measured memory_bytes: 120800
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define Fast ios_base::sync_with_stdio(0), cin.tie(0)
#define ll long long
const int MAX = 55555;
int prime[MAX];
int used[MAX];
bool is_prime[MAX];
int k = 0;
int n;
int t = 0;
int ans[60];
void init(){
	for(int i=2;i<MAX;i++){
		if(is_prime[i]==0){
			prime[k++] = i;
		}
		for(int j=0;j<k&&prime[j]*i<MAX;j++){
			is_prime[prime[j]*i] = 1;
			if(i%prime[j]==0)break;
		}
		
	}
}


int main(){
	init();
	for(int i=0;i<k;i++){
		if(prime[i]%10==7)
			ans[t++] = prime[i];
		if(t>56)break;
	}
	cin>>n;
	for(int i=0;i<n-1;i++)cout<<ans[i]<<' ';
	cout<<ans[n-1]<<endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<climits>
#include<cmath>

int main(){
	int n, k;
	std::vector<int> hList;
	std::vector<long long> dpList;

	std::cin>>n>>k;
	hList.resize(n);
	dpList.resize(n, LLONG_MAX);

	for(int i=0; i<n; i++)
		std::cin>>hList[i];
	
	dpList[0]= 0;

	for(int i=0; i<n-1; i++){
		for(int j=1; j<=k; j++){
			if(i< n-j)
				dpList[i+j]= std::min(dpList[i]+std::abs(hList[i]- hList[i+j]), dpList[i+j]);
		}
	}


	std::cout<< dpList[n-1]<<std::endl;

	return 0;
	
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


const ll MOD = 1e9+7;


signed main(){
    ll n;
    cin >> n;
    ll a[n],b[n],sum_a = 0,sum_b = 0,cnt1 = 0,cnt2 = 0;
    rep(i,0,n){
        cin >> a[i];
        sum_a += a[i];
    }
    rep(i,0,n){
        cin >> b[i];
        sum_b += b[i];

        if(a[i] < b[i]){
            cnt2 += ceil((double)(b[i] - a[i])/2.0);
        }
        else if(a[i] > b[i]){
            cnt1 += a[i] - b[i];
        }
    }

    if(cnt1 <= sum_b - sum_a && cnt2 <= sum_b - sum_a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


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

string N;
ll dp[1010101][5][2];
int K;

ll solve(int i, int k, int b) {
    ll& ret = dp[i][k][b];

    if (i >= N.size()) {
        return (k == K);
    }
    if (ret != 1e18) return ret;

    int x = N[i] - '0';
    ret = 0;

    // 一番上の桁
    if (i == 0) {

        // 自由度trueで下の桁へ
        ret += solve(i+1, 1, true) * (x - 1) + solve(i+1, 0, true);

        // 自由度falseで下の桁へ
        return ret += solve(i+1, 1, false);
    }
    else {
        // 自由度true
        if (b) {
            //
            return ret += solve(i+1, k, b) + solve(i+1, k+1, b) * 9;
        }
        else {
            // 0だったら
            if (x == 0) {
                ret += solve(i+1, k, b);
            }
            else {
                ret += solve(i+1, k+1, b) + solve(i+1, k, !b) + solve(i+1, k+1, !b) * (x - 1);
            }
        }
    }
    return ret;
}

int main() {
    cin >> N >> K;
    rep(i, N.size()+1) rep(j, K+1) rep(b, 2) dp[i][j][b] = 1e18;

    cout << solve(0, 0, false) << endl;
}


Measured memory_bytes: 256
# 正解データ
tramps = {
    "S": [0] * 13,
    "H": [0] * 13,
    "C": [0] * 13,
    "D": [0] * 13
}
# print(tramps)

# 持っているカード
n = int(input())

for i in range(n):
    kind, num = input().split()
    tramps[kind][int(num) - 1] = 1

for i in ["S", "H", "C", "D"]:
    for j in range(13):
        tramp = tramps[i][j]
        if tramp == 0:
            print("{} {}".format(i, j+1))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[10000000];
int main() {

	ll i, j, k, l, test, n;
	cin >> k;
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	l = 0;
	for (i = 0; i < n; i++) {
		l += a[i];
	}
	if (l > k) cout << -1;
	else cout << k - l;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#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++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    int N;
    const string V = "aiueo";

    while (cin >> N, N) {
        vector<string> S(N);
        rep(i, N) cin >> S[i];

        for (int k=1; k<=50; k++) {
            set<string> vis;
            bool ok = true;
            for (auto s : S) {
                s = 'a' + s;
                string tmp;
                for (int i=1; i<s.size(); i++) {
                    if (V.find(s[i-1]) != string::npos) tmp += s[i];
                    if (tmp.size() == k) break;
                }
                if (vis.count(tmp)) {
                    ok = false;
                    break;
                }
                vis.insert(tmp);
            }
            if (ok) {
                cout << k << endl;
                goto next;
            }
        }
        cout << -1 << endl;
        next:;
    }
}

Measured memory_bytes: 3168