akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 200000
#define MOD 1000000007
using namespace std;

long long fac[200010];
long long inv[200010];

long long power(long long n, int t) {
	long long r = 1;
	while (t) {
		if (t & 1) r = (r * n) % MOD;
		n = (n * n) % MOD;
		t /= 2;
	}
	return r;
}

long long c(int a, int b) {
	if (a == 0 || b == 0) return 1;
	long long ret = 1;
	ret = fac[a + b];
	(ret *= inv[a]) %= MOD;
	(ret *= inv[b]) %= MOD;
	return ret;
}

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

	fac[1] = 1;
	for (int i = 2; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % MOD;
	}

	inv[N] = power(fac[N], MOD - 2);
	for (int i = N; i >= 2; --i) {
		inv[i - 1] = (inv[i] * i) % MOD;
	}

	int h, w, a, b;
	cin >> h >> w >> a >> b;

	long long ans = c(h - 1, w - 1);
	for (int i = 1; i <= b; ++i) {
		ans -= (c(w - i, a - 1) * c(i - 1, h - a - 1)) % MOD;
		if (ans < 0) ans += MOD;
	}
	cout << ans;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;

	if (a*b % 2 == 0) {
		cout << "Even" << endl;
		return 0;
	}
	else {
		cout << "Odd" << endl;
		return 0;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF 99999999 
using namespace std;
 
int main()
{
    double R; cin >> R;
    double PI = 3.14159265358979;
    printf("%.5f\n",2.0*PI*R);
}

Measured memory_bytes: 3792
#include <stdio.h>
#include <algorithm>
#include <tuple>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int s = 1 << 12;
int n, m, a[2010], b[2010], c[20], bin[2010];
int dp[s];
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", a + i, b + i);
		for (int j = 0; j < b[i]; j++)
			scanf("%d", c + j), bin[i] ^= 1 << (c[j] - 1);
	}
	for (int i = 0; i < s; i++)
		dp[i] = 1e9;
	dp[0] = 0;

	for (int i = 0; i < m; i++)
		for (int j = 0; j < s; j++)
			dp[j | bin[i]] = min(dp[j | bin[i]], dp[j] + a[i]);
	if (dp[(1 << n) - 1] == ((int)1e9))
		printf("-1\n");
	else
		printf("%d\n", dp[(1 << n) - 1]);
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

ll dfs_sub_tree_size(ll node, ll prev, const vector<vector<ll>>& edges, vector<ll>& sub_tree_size) {
	sub_tree_size[node] = 1;
	REPD(i, 0, edges[node].size()) {
		if (prev == edges[node][i]) continue;
		sub_tree_size[node] += dfs_sub_tree_size(edges[node][i], node, edges, sub_tree_size);
	}

	return sub_tree_size[node];
}

void dfs_subtraction(
		ll node, ll prev,
		const vector<vector<ll>>& edges,
		const vector<ll>& cs,
		const vector<ll>& sub_tree_size,
		vector<ll>& color_counts,
		vector<ll>& answers)
{
	ll color_count_in = color_counts[cs[node]];
	REPD(i, 0, edges[node].size()) {
		if (prev == edges[node][i]) continue;
		ll next = edges[node][i];
		ll next_color_count_in = color_counts[cs[node]];
		dfs_subtraction(next, node, edges, cs, sub_tree_size, color_counts, answers);
		ll node_remained = sub_tree_size[next] - (color_counts[cs[node]] - next_color_count_in);
		answers[cs[node]] -= node_remained * (node_remained + 1LL) / 2LL;
	}
	color_counts[cs[node]] = color_count_in + sub_tree_size[node];

	return;
}

int solve() {
	ll N;
	cin >> N;

	vector<ll> cs(N);
	REPD(i, 0, N) cin >> cs[i], --cs[i];
	vector<vector<ll>> edges(N);
	ll a, b;
	REPD(i, 1, N) {
		cin >> a >> b;
		--a, --b;
		edges[a].emplace_back(b);
		edges[b].emplace_back(a);
	}

	vector<ll> sub_tree_size(N);
	dfs_sub_tree_size(0, -1, edges, sub_tree_size);

	vector<ll> answers(N, N * (N + 1LL) / 2LL);
	vector<ll> color_counts(N);
	dfs_subtraction(0, -1, edges, cs, sub_tree_size, color_counts, answers);

	REPD(i, 0, N) {
		ll node_remained = N - color_counts[i];
		answers[i] -= node_remained * (node_remained + 1LL) / 2LL;
	}

	REPD(i, 0, N) cout << answers[i] << endl;

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 45412
using System;

namespace AtCoderGrandContest036
{
    class Program
    {
        static void Main(string[] args)
        {
            long S = Convert.ToInt64(Console.ReadLine());
            long m = (int)1e9;
            long x1 = 0;
            long y1 = 0;
            long x2 = m;
            long y2 = 1;
            long x3 = 0;
            long y3;

            if (S % m == 0)
                y3 = S / m;
            else
            {
                y3 = S / m + 1;
                x3 = (S / m + 1) * m - S;
            }

            if (x1 * y2 + x2 * y3 + x3 * y1 - y1 * x2 - y2 * x3 - y3 * x1 != S)
                throw new Exception("Not Equal");

            Console.WriteLine($"{x1} {y1} {x2} {y2} {x3} {y3}");
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B;

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

  if( A+B >= 10 )
    std::cout << "error" << std::endl;
  else
    std::cout << A+B << std::endl;

  return 0;
}

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

int main(){
    int health_first = 0;
    int health_sec = 0;
    int strength_first = 0 ;
    int strength_sec = 0;
    cin >> health_first >> strength_first >> health_sec >> strength_sec;
    while(health_first>0&& health_sec>0){
        health_sec = health_sec-strength_first;
        if(health_sec<=0){
            cout << "Yes";
            return 0;
        }

        health_first = health_first-strength_sec;
        if(health_first<=0){
            cout << "No";
            return 0;
        }

    }
    return 0;
}

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

int n,m;
vector<vector<int>> G(100005,vector<int>(0));
vector<int> color(100005,0);

void dfs(int u,int c){
    if(color[u]>0) return;
    color[u]=-1;
    for(int i=0;i<G[u].size();i++){
        if(color[G[u][i]]==0){
            dfs(G[u][i],c);
        }
    }
    color[u]=c;
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for(int i=0;i<n;i++){
        dfs(i,i+1);
    }

    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int a,b;
        cin>>a>>b;
        if(color[a]==color[b]) cout<<"yes";
        else cout<<"no";
        cout<<endl;
    }
}
    
    


Measured memory_bytes: 13352
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    vector<int> AS(N), BS(N);
    int asum = 0;
    rep(i, N) AS[i] = (asum += A[i]);
    reverse(all(B));
    int bsum = 0;
    rep(i, N) BS[i] = (bsum += B[i]);
    reverse(all(BS));
    int ans = 0;
    rep(i, N) {
        ans = max(ans, AS[i] + BS[i]);
    }
    output(ans);
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n) {
        ans = __gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}
#define ONE_CLOCK 0.000000425

inline unsigned long long get_cycle() {
  unsigned int low, high;
  __asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
  return ((unsigned long long int)low) | ((unsigned long long int)high << 32);
}

class Timer {
 public:
  unsigned long long start_time;
  Timer() { start_time = get_cycle(); }
  inline int get_time() {
    return get_cycle() * ONE_CLOCK - start_time * ONE_CLOCK;
  }
};
int main() {
  Timer timer;
  GI2(N, M);
  vector<vector<int>> G(N);
  FOR(i, M) {
    GI2(u, v);
    G[u - 1].push_back(v - 1);
  }
  GI2(S, T);
  vector<vector<int>> dist(N, vector<int>(3));
  queue<pair<int, int>> q;
  q.push(pair<int, int>(S - 1, 0));
  while (timer.get_time() < 1800) {
    if (!q.empty() && q.size() < 100000000) {
      pair<int, int> p = q.front();
      q.pop();
      int v = p.first;
      int d = p.second;
      if (v == T - 1 && d % 3 == 0) {
        print(d / 3);
        return 0;
      }
      for (int x : G[v]) {
        if (dist[x][(d + 1) % 3] == 0) {
          q.push(pair<int, int>(x, d + 1));
          dist[x][(d + 1) % 3] = 1;
        }
      }
    }
  }
  print(-1);
  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N, A, B, C, X;
  while(cin >> N >> A >> B >> C >> X, N) {
    i64 cnt = 0;
    vector<i64> Y(N);
    rep(q, 0, N) cin >> Y[q];
    rep(q, 0, N) {
      i64 y = Y[q];
      if(q != 0) {
        X = (A * X + B) % C;
        cnt++;
      }
      while(X != y) {
        if(cnt >= 10001) {
          cnt = -1;
          break;
        }
        X = (A * X + B) % C;
        cnt++;
      } 
      if(cnt >= 10001) {
        cnt = -1;
        break;
      }
      if(cnt == -1) {
        break;
      }
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3060
import java.util.*;

public class Main{
    
    static final int MOD = 1_000_000_007;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        long[] x = new long[n];
        long[] y = new long[m];
        
        for(int i=0; i<n; i++) x[i] = sc.nextLong();
        for(int i=0; i<m; i++) y[i] = sc.nextLong();
        
        System.out.println(calc(x) * calc(y) % MOD);
    }
    
    public static long calc(long[] z){
        long res = 0;
        for(int i=0; i<z.length; i++){
            res =  (res + (2*i-z.length+1)*z[i]) % MOD;
        }
        return res;
    }
}


Measured memory_bytes: 92820
<?php
fscanf(STDIN, "%d", $x);

while (true) {
    $limit = ceil(sqrt($x));
    $prime = true;
    for ($i = 2; $i < $limit; $i++) {
        if ($x % $i == 0) {
            $prime = false;
            break;
        }
    }
    if ($prime) {
        break;
    }
    $x++;
}

echo $x;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
void dfs(int node, vector<int> adj[], int dp[], bool vis[])
{
	vis[node] = true;
	for(int i=0;i < adj[node].size();i++)
	{
		if(!vis[adj[node][i]])
			dfs(adj[node][i], adj, dp, vis);
			
		dp[node] = max(dp[node],1 + dp[adj[node][i]]);
	}
}
void addEdge(vector<int>adj[], int u, int v)
{
	adj[u].push_back(v);
}
int LongestPath(vector<int>adj[], int n)
{
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i,adj,dp,vis);
	int ans = 0;
	for(int i=1;i<=n;i++)
		ans = max(ans,dp[i]);
		
	return ans;
}
int main()
{
	int n, m;
	cin>>n>>m;
	vector<int>adj[n+1];
	for(int i=0;i<m;i++)
	{
		int u, v;
		cin>>u>>v;
		addEdge(adj,u,v);
	}
	cout<<LongestPath(adj,n);
	return 0;
}

Measured memory_bytes: 9600
// AOJ Volume 1 Problem 0102

#include <stdio.h>
#include <string.h>


int main(void)
{
	int data[11][11];
	int i, j;
	int n;

	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		memset(data, 0, sizeof(data));
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%d", &data[i][j]);
				data[i][n] += data[i][j];
				data[n][j] += data[i][j];
			}
		}
		for (j = 0; j < n; j++){
			data[n][n] += data[n][j];
		}

		for (i = 0; i <= n; i++){
			for (j = 0; j <= n; j++){
				printf("%5d", data[i][j]);
			}
			printf("\n");
		}
	}
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n;
    cin >> n;
    vector<ll> x(n);
    for (ll i=0;i<n;++i){
        ll a;
        cin >> a;
        x[i]=a;
    }
    vector<bool> flag(n);
    for (ll i=0;i<n;++i){
        flag[i]=false;
    }
    ll s=1;
    for (ll i=0;i<n;++i){
        s=x[s-1];
        if (flag[s-1]==true){
            cout << -1 << endl;
            return 0;
        }
        flag[s-1]=true;
        if (s==2){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1152
import math
while True:
  n=int(input())
  if n==0:
    break
  s=[int(0) for i in range(n)]
  s[:]=(int(x) for x in input().split())
  
  m=sum(s)/n
  a2=0
  for i in range(n):
    a2+=(s[i]-m)**2
  a2/=n
  print('{:.05f}'.format(math.sqrt(a2)))




Measured memory_bytes: 5712
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL  INF=1<<31;



int main(){
     string a[4]={"dream","erase","dreamer","eraser"};
     string s;
     cin>>s;
     reverse(s.begin(),s.end());
     for(int i=0;i<4;++i){
          reverse(a[i].begin(),a[i].end());
     }
     bool ans=false;
     LL j=0;
     bool aaa=true;
     while(aaa){
          bool ans2=false;
          for(int i=0;i<4;++i){
               
               if(i<2){
                    string d=s.substr(j,5);
                    if(d==a[i]){
                         j+=5;
                    ans2=true;
                    }
                    continue;
               }
               else if(i==3){
                    string d=s.substr(j,6);
                    if(d==a[i]){
                         j+=6;
                    ans2=true;
                    }
                    continue;

               }
               else {
                    string d=s.substr(j,7);
                    if(d==a[i]){
                         j+=7;
                    ans2=true;
                    }
                    continue;
               }
          }
          LL uuu=s.size();

          if(!ans2){
               aaa=false;
               break;
          }
          else if(j>=uuu-1){
               ans=true;
               break;
          }
          
     }
     if(ans)cout<<"YES"<<endl;
     else cout<<"NO"<<endl;
}
   

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 100010;
int n, per[N], sz[N], cur;
ll dis[N];
map<ll,int> mp;
vector<pii> ans;
void fail() {
  puts("-1");
  exit(0);
}
struct edge {
  int la,b;
} con[N << 1];
int tot, fir[N];
void add_edge(int from,int to) {
  con[++tot] = (edge) {fir[from], to};
  fir[from] = tot;
}
ll sum[N], cal[N];
void dfs(int pos,int fa) {
  sum[pos] = cal[pos] = 0;
  for (int i = fir[pos]; i; i = con[i].la) {
    if (con[i].b == fa) continue;
    dfs(con[i].b, pos);
    sum[pos] += sum[con[i].b] + sz[con[i].b];
  }
}
void fsd(int pos,int fa) {
  cal[pos] += sum[pos];
  for (int i = fir[pos]; i; i = con[i].la) {
    if (con[i].b == fa) continue;
    cal[con[i].b] += cal[pos] - sum[con[i].b] - sz[con[i].b] + (n - sz[con[i].b]);
    fsd(con[i].b, pos);
  }
}
int main() {
  read(n);
  rep (i, 1, n) read(dis[i]);
  rep (i, 1, n) mp[dis[i]] = i;
  rep (i, 1, n) per[i] = i;
  sort(per + 1, per + n + 1, [=](int a,int b) -> bool {
      return dis[a] < dis[b];
    });
  rrp (i, n, 2) {
    ++ sz[per[i]];
    ll tmp = dis[per[i]] - n + 2 * sz[per[i]];
    if (!mp.count(tmp)) fail();
    sz[mp[tmp]] += sz[per[i]];
    ans.push_back(pii(mp[tmp], per[i]));
    add_edge(mp[tmp], per[i]);
  }
  dfs(per[1], 0);
  fsd(per[1], 0);
  rep (i, 1, n) if (cal[i] != dis[i])
    fail();
  rep (i, 0, (int)ans.size()-1) {
    printf("%d %d\n", ans[i].fir, ans[i].sec);
  }
  return 0;
}


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

int dp[100010][3];
int main()
{
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        if (t[i] == 'r') dp[i][2] = p;
        if (t[i] == 's') dp[i][0] = r;
        if (t[i] == 'p') dp[i][1] = s;

        int pos;
        for (pos=i+k;pos<n;pos+=k){
            dp[pos][0] = max(dp[pos-k][1],dp[pos-k][2]);
            dp[pos][1] = max(dp[pos-k][0],dp[pos-k][2]);
            dp[pos][2] = max(dp[pos-k][0],dp[pos-k][1]);
            if (t[pos] == 'r') dp[pos][2] += p;
            if (t[pos] == 's') dp[pos][0] += r;
            if (t[pos] == 'p') dp[pos][1] += s;
        }
        pos -= k;
        ans += max(dp[pos][0], max(dp[pos][1], dp[pos][2]));
    } // rspsrrpsrps

    cout << ans << endl;
}


Measured memory_bytes: 1664
N,M,X=[int(s) for s in input().split()]
Book=[[int(s) for s in input().split()] for _ in range(N)]
INF=10**7

ans=set()
ans.add(INF)

for n in range(2**N):
  #Bit全探索
  Xls=[0 for i in range(M)]
  cost=0
  for i in range(N):
    if ((n>>i)&1)==1:
      cost+=Book[i][0]
      for b in range(M):
        Xls[b]+=Book[i][b+1]
    if min(Xls)>=X:
      ans.add(cost)
if min(ans)==INF:
  print(-1)
else:
  print(min(ans))

Measured memory_bytes: 9196
/// kAAzuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define MAX 500000
#define K 30
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
int k,a,b,ans;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin >> k >> a >> b;
int mx = k+1;
if(b>=a){
int   lef = (k-a+1);
   if(lef>1){
      ans = (b-a)*(lef/2);
      ans+=a;
      if(lef%2)ans++;
   }
   //cout << ans << endl;
}
cout << max(ans,mx) << endl;

return 0;}
///....


Measured memory_bytes: 256
#include<stdio.h>
char a[100008];
int main()
{
	int n;
	while(~scanf("%d",&n)){
        scanf("%s",a);
        char p=a[0];
        int s=1;
        for(int i=1;i<n;i++){
            if(a[i]!=p){
                s++;
                p=a[i];
            }
        }
        printf("%d\n",s);
	}
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int pn;
int pri[200000];

int use[300000];

int main()
{
  int n;
  long long i,now,ii;

  memset(use,0,sizeof(use));
  for(i=3;i<300000;i+=2)use[i] = 1;
  pn = 1;
  pri[0] = 2;
  for(i=3;i<300000;i+=2){
    if(use[i]){
      pri[pn] = i;
      pn++;
      now = i*i;
      ii = 2*i;
      for(;now<300000;now+=ii)use[now] = 0;
    }
  }
  //for(i=0;i<pn;i++)printf("%d\n",pri[i]);
  while(scanf("%d",&n)!=EOF){
    if(!n)break;
    printf("%d\n",upper_bound(pri,pri+pn,n+n)-lower_bound(pri,pri+pn,n+1));
  }
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#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 rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#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 NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    ll csum[n];
    csum[0] = a[0];
    rep(i, n - 1) csum[i + 1] = csum[i] + a[i + 1];
    bool can_be[n]; //i -> i+1 になれるか

    rep(i, n - 1) {
        if (csum[i] * 2 >= a[i + 1]) can_be[i] = true;
        else can_be[i] = false;
    }
    can_be[n - 1] = true;

    int cant = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (!can_be[i]) {
            cant = i + 1;
            break;
        }
    }

    cout << n - cant << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
long long ruijou(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b%2==1){
            c*=a;
        }
        a*=a;
        b/=2;
    }
    return c;
}
int main(void){
    long long N,P,i,ans=1;
    cin>>N>>P;
    if(N==1){
        cout<<P<<endl;
        return 0;
    }
    long long a=2,b=N,c=1;
    while(b>0){
        if(b%2==1){
            c*=a;
        }
        if(a>10000000&&b>1){
            cout<<1<<endl;
            return 0;
        }
        a*=a;
        b/=2;
        
    }
    for(i=1;ruijou(i,N)<P+1;i++){
        if(P%ruijou(i,N)==0){
            ans=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define ui64 unsigned long long
#define eps 1e-6
using namespace std;
 
int main() {
	// your code goes here
	long double X,Y,res;
	cin>>X>>Y;
	res = Y/X;
	printf("%llu\n", (ui64)log2(res)+1); 
	//the sequence with max len will be of this form: X*(1,2,4,8,.. 2^k)
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  vector<int>id;
  if(n%2)
  {
    rep(i,n/2+1)
    {
      id.push_back(n-i*2-1);
    }
    rep(i,n/2)
    {
      id.push_back(i*2+1);
    }
  }
  else
  {
    rep(i,n/2)
    {
      id.push_back(n-i*2-1);
    }
    rep(i,n/2)
    {
      id.push_back(i*2);
    }
  }
  rep(i,n)
  {
    cout<<a[id[i]]<<" ";
  }
cout<<endl;
  return 0;

}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 2019;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int l, r;
  cin >> l >> r;
  ll ans = 1e9;
  int end_loop = min(r, l + MOD);
  rep(i, l, end_loop) {
    rep(j, i + 1, end_loop + 1) ans = min(((ll)i * j) % MOD, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b, c;

    cin >> a >> b >> c;

    c -= (a - b);

    cout << max(0, c) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
#define x second
#define y first
#define M st.size()
typedef complex<double> point;
pair<int,int> a[100000];
vector<int> st;
bool ccw(point a,point b,point c){
  b-=a;
  c-=a;
  c*=conj(b);
  if(c.imag()<=0)return true;  
  return false;
}

void check(int i){
 while(M>=2){
      int s=st[M-2];
      int e=st[M-1];
      point S=point(a[s].x,a[s].y);
      point E=point(a[e].x,a[e].y);
      point N=point(a[i].x,a[i].y);
      if(ccw(S,E,N))break;
      st.pop_back();
    }
 st.push_back(i);
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;
  sort(a,a+n);
  for(int i=0;i<n;i++)check(i);
  for(int i=n-2;i>=0;i--)check(i);
  st.pop_back();
  cout<<M<<endl;
  for(int i=M;i>0;i--)cout<<a[st[i%M]].x<<' '<<a[st[i%M]].y<<endl;
  return 0;
}

Measured memory_bytes: 2456
# import numpy as np
import sys
import math
input = sys.stdin.readline

N = int(input())

if N == 0:
    print(0)
    sys.exit()
elif N == 1:
    print(0)
    sys.exit()
elif N % 2 == 1:
    print(0)
    sys.exit()

res = 0

temp = 10

while N >= temp:
    res += N // temp
    temp *= 5

print(res)


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

using namespace std;

const int N = 3000 + 77;
int n;
long double P[N] , dp[N] , A;
int main(){
   dp[0] = 1;
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int i = 1;i <= n;++ i){
      cin >> P[i];
      for(int j = i;j >= 0;-- j){
         dp[j] = dp[j] * (1 - P[i]) + (j == 0 ? 0 : dp[j - 1] * P[i]);
      }
   }
   for(int i = 0;i <= n;++ i)
      if(i > n - i)
         A += dp[i];
   cout << fixed << setprecision(10) << A;
   return 0;
}


Measured memory_bytes: 384
function Main(input) {
	input = input.split(" ");
	console.log(`${input[2]} ${input[0]} ${input[1]}`);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    int q;
    cin >> q;
    for (int ii = 0; ii < q; ii++)
    {
        string X, Y;
        cin >> X >> Y;
        int x = X.size();
        int y = Y.size();
        int dp[x + 1][y + 1];
        memset(dp, 0, sizeof(dp));
        for (int i = 0; i < x; i++)
        {
            for (int j = 0; j < y; j++)
            {
                if (X[i] == Y[j])
                {
                    dp[i + 1][j + 1] = max({dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1]});
                }
                else
                {
                    dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
                }
            }
        }
        cout << dp[x][y] << endl;
    }
}



Measured memory_bytes: 7060
import System.IO (isEOF)
import Data.Ratio ((%))
import Data.List.Split (splitOn)

main = do
    quit <- isEOF
    if quit then return () else do
        input >>= return . solve >>= output
        main

input :: IO ([Integer],Integer,Integer)
input = do
    line <- getLine
    let
        ns = map read $ splitOn "," line
        [l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2] = ns
    return ([l1,l2,l3,l4,l5,l6,l7,l8,l9,l10],v1,v2)

output :: Integer -> IO ()
output = print

solve :: ([Integer],Integer,Integer) -> Integer
solve (ls,v1,v2) = spanOf (map fromIntegral ls) d1
    where
    d1 = (fromIntegral v1) * t
    t = (sum ls) % (v1 + v2)

    spanOf :: [Rational] -> Rational -> Integer
    spanOf ls d = spanOf' ls d 1
        where
        spanOf' (l:ls) d n
            | d <= l = n
            | otherwise = spanOf' ls (d-l) (n+1)

Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll dp[101][101];
ll a[102];
ll solve(ll le,ll ri){
	if(dp[le][ri]!=-1)return dp[le][ri];
	ll num=1e18;
	for(int i=le+1;i<ri;i++){
		num=min(num,solve(le,i)+solve(i,ri)+a[le]*a[ri]*a[i]);
	}
	return dp[le][ri]=num;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)dp[i][i+1]=0;
    for(int i=0;i<n;i++){
    	cin>>a[i]>>a[i+1];
    }
    cout << solve(0LL,n) <<endl;
    return 0;
}



Measured memory_bytes: 3244
#include <stdio.h>

int main()
{

  int x, y, n;

  /* input 2numbers */
  scanf("%d%d", &x, &y);

  /* running Euclidean algorithm */
  while(y > 0){
    n = y;
    y = x%y;
    x = n;
  }

  /* output Greatest Common Divisor */
  printf("%d\n",x);

  return 0;
}

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

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

  if(n >= 10){
    cout << r << endl;
  } else{
  
    cout << r + 100 * (10 - n) << endl;
    
  }
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define me(a,b) memset(a,b,sizeof(a))
int main(){
	ll n,m;
	cin>>n>>m;
	cout<<n*m/__gcd(n,m)<<endl;
	return 0;
}

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

struct edge {
  string Name;
  int weight, deep;
  bool operator<(const edge& e) const {
    return(weight > e.weight);
  }
};

int main()
{
  int n;
  while(cin >> n, n) {
    list< edge > edges;
    int ALL = 0;
    for(int i = 0; i < n; i++) {
      edge e;
      cin >> e.Name >> e.weight >> e.deep;
      ALL += e.weight;
      edges.push_back(e);
    }
    edges.sort();
    while(!edges.empty()) {
      for(list< edge >::iterator it = edges.begin(); ; ++it) {
        if(ALL - it -> weight <= it -> deep) {
          cout << it -> Name << endl;
          ALL -= it -> weight;
          edges.erase(it);
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define N 100101
#define forn(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define F first
#define S second
int main()
{
         boost;
         int arr[3];
         forn(i,3)
         cin>>arr[i];
         sort(arr,arr+3);
         int ans=0;
         for(int i=1;i>=0;i--)
         {
               ans+=abs(arr[i]-arr[i+1]);
         }
         
         cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
#ifdef _DEBUG
	printf( "debug\n" );
#endif
	for ( int i = 1; i < 10; i++ ) {
		for ( int j = 1; j < 10; j++ ) {
			printf( "%dx%d=%d\n", i, j, i * j);
		}
	}
	return 0;
}

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

#define Rep(i,n) for(int i=0;i<(n);i++)
#define For(i,n1,n2) for(int i=(n1);i<(n2);i++)
#define REP(i,n) for(ll i=0;i<(n);i++)
#define RREP(i,n) for(ll i=(n-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(n1);i<(n2);i++)
#define put(a) cout<<(a)<<"\n";
#define all(a)  (a).begin(),(a).end();
#define SORT(a) sort((a).begin(),(a).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int a,b,c,d;

int main(){
    cin >> a >> b >> c >> d;
    put(min(a,b)+min(c,d));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;
signed main() {
    int d,t,s;
    cin >> d>> t>> s;
    if(s*t<d) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define nn 65536*48
#define mod 998244353
ll s;ll g=1e18;
int main(){
	cin>>s;srand(time(0));//s=g-0;
	ll k=1e9;k--;
	if(s==g){
		cout<<0<<" "<<0<<" "<<1000000000<<" "<<0<<" "<<0<<" "<<1000000000<<"\n";
		exit(0);
	}
	else if(s==g-1){
			ll x1=k,y2=1e9,x2=1,y1=s-x1*y2;
			assert(x1*y2+x2*y1==s);
				cout<<0<<" "<<y1<<" "<<x1<<" "<<0<<" "<<x1+x2<<" "<<y2<<"\n";
				exit(0);
	}
			ll x1=k,y2=s/k,x2=1,y1=s%k;
			assert(x1*y2+x2*y1==s);
				cout<<0<<" "<<y1<<" "<<x1<<" "<<0<<" "<<x1+x2<<" "<<y2<<"\n";
				exit(0);
	
	return 0;
}

Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i
count = 0
A.downto(0) do |num500|
  B.downto(0) do |num100|
    C.downto(0) do |num50|
      if num500 * 500 + num100 * 100 + num50 * 50 == X
        count += 1
      end
    end
  end
end
puts count

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
int h,w;

bool outframe(int y,int x){
	if(x<0 || x>=w || y<0 || y>=h)return true;
	else return false;
}

int main(){
	cin>>h>>w;
	string s[h];
	int dt[h][w];
	char ch;
	rep(i,h){
		s[i]="";
		rep(j,w){
			cin>>ch;
			s[i]+=ch;
			if(ch=='#')dt[i][j]=-1;
			else dt[i][j]=0;
		}
	}
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#')continue;
			rep(k,8){
				if(outframe(i+dy[k],j+dx[k]))continue;
				if(s[i+dy[k]][j+dx[k]]=='#')dt[i][j]++;
			}
			s[i][j]=(char)(dt[i][j]+'0');
		}
	}
	rep(i,h){
		rep(j,w)cout<<s[i][j];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
ll c(ll a,ll b,ll p){
    if (b==0)return 1;
    else if (b%2==0) {
        ll d=c(a,b/2,p);
        return (d*d)%p;
    }
    else return (a*c(a,b-1,p))%p;
}
int n,a,b,i;
ll r=1,y=1,m=1e9+7;
int main(){
    scanf("%d%d%d",&n,&a,&b);
    r=c(2,n,m);
    r--;
    for(i=a;i>0;i--)y=(y*i)%m;
    y=c(y,m-2,m);
    for(i=n-a+1;i<=n;i++)y=(i*y)%m;
    r-=r-y<0?y-m:y;
    y=1;
    for(i=b;i>0;i--)y=(y*i)%m;
    y=c(y,m-2,m);
    for(i=n;i>n-b;i--)y=(i*y)%m;
    r-=r-y<0?y-m:y;
    printf("%lld",r);
    return 0;
}

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

using namespace std;
int n, k, c, d1[200000], d2[200000], i, j;
string s;


int main() {
    scanf(" %d %d %d", &n, &k, &c);
    cin >> s;
    i=0;
    j=0;
    while(j<k) {
        if (s[i] == 'x') i++;
        else {
            d1[j] = i;
            j++;
            i = i + c+1;
        }
    }
    i=n-1;
    j=k-1;
    while(j>=0) {
        if (s[i] == 'x') i--;
        else {
            d2[j] = i;
            j--;
            i = i - (c+1);
        }
    } 
    for (i=0;i<k;i++) {
        if (d1[i] == d2[i]) printf("%d\n", d1[i]+1);
    }
    return 0;
}

Measured memory_bytes: 3332
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  string s1 = s.substr(0, 1), s2 = s.substr(1, 1), s3 = s.substr(2, 1);
  int maxCount = 0;
  int count = 0;
  string rainy = "R";
  if(s1 == rainy) {
    count++;
  }
  if(s2 == rainy) {
    count++;
  } else {
    maxCount = count;
    count = 0;
  }
  if(s3 == rainy) {
    count++;
  } else {
    maxCount = count > maxCount ? count : maxCount;
    count = 0;
  }
  int result = count > maxCount ? count : maxCount;
  // 出力
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3588
def main
  gets
  arr = gets.split(" ").map(&:to_i)
  def arr.[](n)
    super(n - 1)
  end
  arr.each_with_index{|item, idx|express(arr,idx + 1)}
end
def express(arr, idx)
  exp = ["node #{idx}: key = #{arr[idx]},"]
  exp << "parent key = #{arr[idx / 2]}," if idx != 1
  exp << "left key = #{arr[idx * 2]}," if idx * 2 <= arr.size
  exp << "right key = #{arr[idx * 2 + 1]}," if idx * 2 < arr.size
  puts (exp.join(" ") + " ")
end
main

Measured memory_bytes: 6108
#include <iostream>
#include <vector>
int main() {
    int n;
    std::cin >> n;
    int array[n] = {};
    for (int i = 0; i < n;i++) {
        std::cin >> array[i];
    }

    int criteria = array[n-1];
    std::vector<int> small_numbers;
    std::vector<int> large_numbers;
    int replace_num = -1;
    for (int i = 0; i < n-1;i++) {
        /*
        if (array[i] < criteria) {
            small_numbers.push_back(array[i]);
        } else if (array[i] > criteria) {
            large_numbers.push_back(array[i]);
        }
        */

        if (array[i] <= criteria) {
            replace_num++;
            int tmp = array[replace_num];
            array[replace_num] = array[i];
            array[i] = tmp;
        }
    }
    int tmp1 = array[replace_num+1];
    array[replace_num+1] = criteria;
    array[n-1] = tmp1;

    /*
    for (int i = 0; i < small_numbers.size(); i++) {
        std::cout << small_numbers[i] << " ";
    }

    std::cout << "[" << criteria << "] ";

    for (int i = 0; i < large_numbers.size(); i++) {
        std::cout << large_numbers[i];
        if (i != large_numbers.size() - 1) {
            std::cout << " ";
        } else {
            std::cout << std::endl;
        }
    }*/
    for (int i = 0; i < n; i++) {
        if (i == replace_num+1) {
            std::cout << "[";
        }
        std::cout << array[i];
        if (i == replace_num+1) {
            std::cout << "]";
        }

        if (i != n-1) {
            std::cout << " ";
        } else {
            std::cout << std::endl;
        }
    }

}



Measured memory_bytes: 3500
N=int(input())
a=1
b=1
c=1

for i in range(N):
    a=(a*10)%(10**9+7)
for j in range(N):
    b=(b*8)%(10**9+7)
for k in range(N):
    c=(c*9)%(10**9+7)

ans=(a+b-2*c)%(10**9+7)

print(ans)


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

using namespace std;

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

  for (int i = 1; i <= M; ++i) {
    cout << i << " ";

    if (N & 1) { 
      cout << N-i+1 << endl;
    } else {
      if (i*4 > N) {
        cout << N-i << endl;
      } else {
        cout << N-i+1 << endl;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3684
n = int(input())
S = list(input())
R, G, B = set(), set(), set()
for i in range(n):
    if S[i] == 'R':
        R.add(i)
    if S[i] == 'G':
        G.add(i)
    if S[i] == 'B':
        B.add(i)
cnt = len(R)*len(G)*len(B)
for r in R:
    for g in G:
        if 2*g-r in B:
            cnt -= 1
        if 2*r-g in B:
            cnt -= 1
        if (r+g) % 2 == 0 and (r+g)//2 in B:
            cnt -= 1
print(cnt)


Measured memory_bytes: 68600
n,k=map(int,input().split())

class SegmentTree:
    def __init__(self,n,ele):

        self.ide_ele = ele

        self.num =2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num


    #####segfunc######
    #クエリに応じて変える
    def segfunc(self,x,y):
        return max(x,y)

    def init(self,init_val):
        #set_val
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self,k,x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res

st=SegmentTree(300001,0)
dp=[0]*n
for i in range(n):
    a=int(input())
    dp[i]=max(dp[i],st.query(max(0,a-k),min(300000,a+k)+1)+1)
    st.update(a,dp[i])
    dp[i]=max(dp[i],st.query(0,300001))
print(dp[n-1])

Measured memory_bytes: 166468
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
 
n, k = map(int, input().split())
a = [int(item) - 1 for item in input().split()]
visited = [0] * n
 
v = 0
visited[0] = 1
pre = [0]
loop = []
start = False
while True:
    v = a[v]
    if visited[v] == 1:
        start = True
    if visited[v] == 2:
        break
    if not start:
        pre.append(v)
    else:
        loop.append(v)
    visited[v] += 1 
 
if k < len(pre):
    print(pre[k] + 1)
    exit()
k -= len(pre)
print(loop[k % len(loop)] + 1)

Measured memory_bytes: 31052