akhauriyash/Code-Regression huggingface dataset:
<?php

while (TRUE) {
    fscanf(STDIN, "%d", $d);
    if (feof(STDIN)) {
        break;
    }
    $area = 0;
    for ($i = $d; $i < 600; $i += $d) {
        $area += $i * $i * $d;
    }
    echo (string) $area;
    echo PHP_EOL;
}

Measured memory_bytes: 6604
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<vector<int>> dp(n + 1, vector<int>(3));
	for (int i = 1; i <= n; i++) {
		dp[i][0] = max(dp[i - 1][1] + b[i - 1], dp[i - 1][2] + c[i - 1]);
		dp[i][1] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][2] + c[i - 1]);
		dp[i][2] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] + b[i - 1]);
	}
	cout << max({ dp[n][0], dp[n][1],dp[n][2] }) << endl;

	return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    if (n == 1) {
        puts("Hello World");
    }
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N,T;cin>>N>>T;
    vector<pair<int,int>>vec(N);
    REP(i,N){
        int a,b;cin>>a>>b;
        vec[i]={a,b};
    }
    sort(all(vec));
    int dp[N+1][T+3000];
  	REP(i,N+1)REP(j,T+3000)dp[i][j]=0;
    REP(i,N){
        REP(j,T){
            chmax(dp[i+1][j+vec[i].first],dp[i][j]+vec[i].second);
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    int ans=0;
    REP(i,N+1)REP(j,T+3000)chmax(ans,dp[i][j]);
    cout<<ans<<endl;
}

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

if b - a < 2 * k:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)
    for i in range(b - k + 1, b + 1):
        print(i)

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

int n,m;
vector <int>a(1000010,0);
vector<int64_t>done(1000010,0);
vector<int>flag(1000010,0);
void dfs(int k)
{
    flag.at(k)=1;
    if(a.at(k)==1)return;
    if(k==n){done.at(n)=1;return;}
    if(k>n)return;
    if(flag.at(k+1)==0)dfs(k+1);
    if(flag.at(k+2)==0)dfs(k+2);
    done.at(k)=done.at(k+1)+done.at(k+2);
  	if(done.at(k)>=1000000007)done.at(k)%=1000000007;
}

int main()
{
    cin>>n>>m;
    REP(i,m)
    {
        int x;
        cin>>x;
        a.at(x)=1;
    }
    dfs(0);
    cout<<done.at(0)%1000000007<<endl;
}


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

static const int N=100000;
static const int NIL=-1;

vector<int> G[N];
int color[N];

void paint(int u,int c){
    color[u]=c;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(color[v]==NIL) paint(v,c);
    }
}

int main(){
    int n,m,s,t,q;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    for(int i=0;i<n;i++) color[i]=NIL;

    int id=1;
    for(int i=0;i<n;i++){
        if(color[i]==NIL) paint(i,id++);
    }

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


Measured memory_bytes: 12088
let n = stdin.ReadLine() |>  int
let s = stdin.ReadLine() 
let c = [|for i in 0..(n-1) do yield s.[i]|]

let x = ( c
|>Array.pairwise
|>Array.map (fun (x,y) -> if x=y then 0 else 1)
|>Array.sum
)

x+1
|>stdout.WriteLine

Measured memory_bytes: 19924
#include <stdio.h>
#include <stdlib.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N;
	char S[202][202];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%s", &(S[i][1]));
	
	int j, k;
	list **adj = (list**)malloc(sizeof(list*) * (N + 1)), *d = (list*)malloc(sizeof(list) * N * (N - 1));
	for (i = 1; i <= N; i++) adj[i] = NULL;
	for (i = 1, k = 0; i < N; i++) {
		for (j = i + 1; j <= N; j++) {
			if (S[i][j] == '0') continue;
			d[k*2].v = j;
			d[k*2+1].v = i;
			d[k*2].next = adj[i];
			d[k*2+1].next = adj[j];
			adj[i] = &(d[k*2]);
			adj[j] = &(d[k*2+1]);
			k++;
		}
	}
	
	int dist[201] = {}, q[201], head, tail;
	list *p;
	dist[1] = 1;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		for (p = adj[q[head]]; p != NULL; p = p->next) {
			if (dist[p->v] == 0) {
				dist[p->v] = dist[q[head]] + 1;
				q[tail++] = p->v;
			} else if ((dist[p->v] + dist[q[head]]) % 2 == 0) break;
		}
		if (p != NULL) break;
	}
	if (head < tail) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int diam = dist[q[tail-1]];
	for (i = 2; i < N; i++) {
		for (j = 1; j <= N; j++) dist[j] = 0;
		dist[i] = 1;
		q[0] = i;
		for (head = 0, tail = 1; head < tail; head++) {
			for (p = adj[q[head]]; p != NULL; p = p->next) {
				if (dist[p->v] == 0) {
					dist[p->v] = dist[q[head]] + 1;
					q[tail++] = p->v;
				}
			}
		}
		if (diam < dist[q[tail-1]]) diam = dist[q[tail-1]];
	}
	
	printf("%d\n", diam);
	fflush(stdout);
	return 0;
}

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

using static Input;
using static Util;
class Program
{
    static int N;
    static void INPUT()
    {
        N = NextInt();
    }
    static void OUT()
    {
        var a = N / 2 + N % 2;

        Console.WriteLine((float)(a) / N);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
        N = 3;
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 11220
import math
from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)
cut = []
for k in range(N):
  cut.append(K*A[k]//S)

length = []
for k in range(N):
  length.append([A[k] / (cut[k]+1), k])

length.sort(key = lambda x: x[0], reverse=True)

def nibun_insert(lis, item):
  end = len(lis)
  start = 0
  now = (end+start)//2
  while end > start+1:
    if lis[now][0] > item[0]:
      start = 0 + now
      now = (now + end)//2
    else:
      end = 0 + now
      now = (now + start)//2
  lis.insert(now+1, item)
  return lis

C = sum(cut)
res = K - C
length = length[:res+1]
length = deque(length)
for _ in range(res):
  a = length.popleft()
  cut[a[1]] += 1
  a[0] = a[0]*cut[a[1]]/(cut[a[1]]+1)
  if a[0] <= length[-1][0]:
    continue
  elif a[0] >= length[0][0]:
    length.appendleft(a)
  else:
    length = nibun_insert(length, a)
  length.pop()

print(math.ceil(length.popleft()[0]))

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    string s;cin>>s;
    map<char,ll>a;
    rep(i,n)a[s[i]]++;
    sort(all(s));
    s.erase(unique(all(s)),s.end());
    ll ans=1;
    int m=s.size();
    rep(i,s.size()){
        ans*=(a[s[i]]+1);
        ans%=MOD;
    }
    cout<<(ans-1)%MOD<<endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;


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


Measured memory_bytes: 3168
package main

import (
	"fmt"
)

func main() {
	var b string

	fmt.Scan(&b)

	switch b {
	case "A":
		fmt.Print("T")
	case "C":
		fmt.Print("G")
	case "G":
		fmt.Print("C")
	case "T":
		fmt.Print("A")
	}

}


Measured memory_bytes: 1764
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i = 0; i < (n); i++)
#define rint(n) scanf("%lld", &(n))
#define wint(n) printf("%lld\n", (n))

using namespace std;

signed main() {
  int n, q;
  rint(n);
  int S[n];
  dotimes(i, n)
    rint(S[i]);
  rint(q);
  int r = 0;
  dotimes(i, q) {
    int x;
    rint(x);
    int a = 0, b = n;
    while (a < b) {
      int c = a + (b - a) / 2;
      if (x < S[c])
        b = c;
      else if (x > S[c])
        a = c + 1;
      else {
        r++;
        break;
      }
    }
  }
  wint(r);
  return 0;
}



Measured memory_bytes: 3516
def erase(line)
  (1..9).each do |i|
    5.downto(3).each do |j|
      line.gsub!(/#{i.to_s}{#{j}}/, '0'*j)
    end
  end
  line
end

def sum(board)
  board.flat_map{ |l| l.split('') }.map(&:to_i).reduce(:+)
end

def fall(board)
  ret = @h.times.map{ '00000' }
  5.times do |i|
    idx = @h - 1
    (@h - 1).downto(0) do |j|
      if board[j][i] != '0'
        ret[idx][i] = board[j][i]
        idx -= 1
      end
    end
  end
  ret
end

def solve(board)
  loop do
    score = sum(board)
    board.map!{ |l| erase(l) }
    board = fall(board)
    break if score == sum(board)
  end
  sum(board)
end

while (@h = gets.to_i) != 0
  board = @h.times.map{ gets.chomp.delete(' ') }
  score = sum(board)
  puts score - solve(board)
end

Measured memory_bytes: 10676
list=[]
for i in range(5):
   x=int(input())
   if x==0:
      break
   else:
      list.append(x)

for i in range(len(list)):
   y=list[i]
   a=1000-y
   b=a//500
   c=a%500
   d=c//100
   e=c%100
   f=e//50
   g=e%50
   h=g//10
   i=g%10
   j =i//5
   k=i%5
   sum=b+d+f+h+j+k
   print(str(sum))
     



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int K, A, B;
  cin >> K >> A >> B;
  
  if (A % K == 0 || B % K == 0 || (A / K + 1) * K <= B) {
    cout << "OK";
  }
  
  else {
    cout << "NG";
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long> a;
    vector<long> b;
    vector<long> c;
    long totala = 0;
    long totalb = 0;
    for(int i = 0;i < n;++i){
        int da;
        cin >> da;
        a.push_back(da);
        totala += da;
    }
    for(int i = 0;i < n;++i){
        int db;
        cin >> db;
        b.push_back(db);
        totalb += db;
    }
    for(int i = 0;i < n;++i){
        c.push_back(a[i] - b[i]);
    }
    if(totala < totalb){
        cout << -1 << endl;
        return 0;
    }
    sort(c.begin(),c.end());
    long tl1 = 0;
    int lp;
    for (lp = 0; lp < n; ++lp) {
        if(c[lp] < 0)tl1 -= c[lp];
        else break;
    }
    long tl2 = 0;
    for (int i = 0; i < n; ++i) {
        if(tl1 <= tl2){
            cout << i + lp << endl;
            return 0;
        }
        else{
            if(c[n - 1 - i] > 0){
                tl2 += c[n - 1 - i];
                if(tl1 <= tl2){
                    cout << i + 1 + lp << endl;
                    return 0;
                }
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
}







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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main(){
	int X,Y;
	cin >> X>>Y;

	int a,b;
	if((2*X-Y)%3==0&& 2*X-Y>=0) a =(2*X-Y)/3;
	else{
		cout<<0<<endl;
		return 0;
	}
	if((2*Y-X)%3==0 && 2*Y-X>=0) b =(2*Y-X)/3;
	else{
		cout<<0<<endl;
		return 0;
	}
	COMinit();

    // 計算例
    cout << COM(a+b, a) << endl;

}


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

int main() {
    long long N;
    cin >> N;

    for (long long i = (long long)floor(sqrt(N)); i >= 1; --i) {
        if (N % i == 0) {
            cout << i + (N / i) - 2 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int x;
    int tot=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        tot+=(x&1);
    }
    if(tot&1)
        cout<<"NO";
    else
        cout<<"YES";

} 


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;


int main() {
  string S;
  int w;
  cin >> S;
  cin >> w;
  string ans="";
  for(int i=0;i<S.length();i+=w){
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
     #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
            #define ll long long
            #define pal pair<double,int>
            #define ppa pair<int,pa>
            #define ssa pair<string,int>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     //priority_queue<int, vector<int>, greater<int> > que;
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
string itos( int i ) {
ostringstream s ;
s << i ;
return s.str() ;
}

int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
double distans(double x1,double y1,double x2,double y2){
	double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
	return sqrt(rr);
	
}
            //----------------kokomade tenpure------------
 

    signed  main(){
    	string s;
    	cin>>s;
    	
    	vector<int> ve;
    	for(int i=0;i<s.length();i++){
    		if(s[i]=='1') ve.pb(1);
    		else if(s[i]=='0') ve.pb(0);
    		else{
    			if(ve.size()>0){
    				ve.pop_back();
    			}
    		}
    	}
    	for(int i=0;i<ve.size();i++) cout<<ve[i];
    	cout<<endl;
  
  //  	printf("%.10f\n",ans[n-1]);
    	return 0;
    }

Measured memory_bytes: 384
import itertools
import sys

def main():
    N, M, R = map(int, sys.stdin.readline().split())
 
    r = [i - 1 for i in map(int, sys.stdin.readline().split())]
 
    d = [[float('inf')]*N for _ in range(N)]
 
    for _ in range(M):
        a, b, c = map(int,sys.stdin.readline().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c
 
    for a in range(N):
        d[a][a] = 0
 
    res = float('inf')
 
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][k]+d[k][j] < d[i][j]:
                    d[i][j] = d[i][k]+d[k][j]
 
    for perm in itertools.permutations(r):
        a = 0
        for i in range(len(perm)-1):
            a += d[perm[i]][perm[i+1]]
        res = min(a, res)
 
    print(res)
 
if __name__ == '__main__':
    main()

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

def main():
    n, k, c = map(int, input().split())
    s = input()

    left = getleft(s, n, c)
    right = list(reversed(getleft(s[::-1], n, c)))

    if n == 1:
        print(1)
        return

    for i in range(n):
        if i == 0:
            canrest = (right[i + 1][0] >= k)
        elif i == n - 1:
            canrest = (left[i - 1][0] >= k)
        else:
            if left[i - 1][0] + right[i + 1][0] >= k + 1:
                canrest = True
            elif (left[i - 1][0] + right[i + 1][0] >= k) and (left[i - 1][1] + right[i + 1][1] >= c - 1):
                canrest = True
            else:
                canrest = False
        if not canrest:
            print(i + 1)

def getleft(s, n, c):
    left = [None for i in range(n)]
    x = 0
    d = 10 ** 9
    for i in range(n):
        if s[i] == "o":
            if d >= c:
                x += 1
                d = 0
            else:
                d += 1
        else:
            d += 1
        left[i] = (x, d)
    return left

if __name__ == "__main__":
    main()


Measured memory_bytes: 46252
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

const int N = 100005;
int a, b, q;
ll s[N], t[N], dd;

int main() 
{
	cin >> a >> b >> q;
	for(int i = 1; i <= a; i++)
	{
		cin >> s[i];
	}
	for(int i = 1; i <= b; i++)
	{
		cin >> t[i];
	}
	s[0] = s[1];
	t[0] = t[1];
	s[a + 1] = s[a];
	t[b + 1] = t[b];
	while(q--) 
	{
		cin >> dd;
		int cnt1 = upper_bound(s + 1, s + a + 1, dd) - s;
		int cnt2 = upper_bound(t + 1, t + b + 1, dd) - t;
		cnt1 = a - cnt1 + 1;
		cnt2 = b - cnt2 + 1;
		ll res = 0;
		ll ans1 = abs(dd - s[a - cnt1]);
		ll ans2 = abs(dd - s[a - cnt1 + 1]);
		ll res1 = abs(s[a - cnt1] - t[b - cnt2]);
		ll res2 = abs(s[a - cnt1 + 1] - t[b - cnt2]);
		res = min(ans1 + res1, ans2 + res2);
		ans1 = abs(dd - s[a - cnt1]);
		ans2 = abs(dd - s[a - cnt1 + 1]);
		res1 = abs(s[a - cnt1] - t[b - cnt2 + 1]);
		res2 = abs(s[a - cnt1 + 1] - t[b - cnt2 + 1]);
		ll tmp1 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp1);
		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1]);
		ll tmp2 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp2);
		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1 + 1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1 + 1]);
		ll tmp3 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp3);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
int main(){
  int n,i,a=0,b;
  char s[100010];
  scanf("%d %s",&n,s);
  for(i=0;s[i];i++){
    if(s[i]=='(')a++;
    else         a--;
    if(a<0){
      b++;
      a=0;
    }
  }
  for(i=0;i<b;i++)printf("(");
  printf("%s",s);
  a=b=0;
  while(n--){
    if(s[n]==')')a++;
    else         a--;
    if(a<0){
      b++;
      a=0;//printf("%d\n",n);
    }
  }
  for(i=0;i<b;i++)printf(")");
  printf("\n");
  return 0;
}
      


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    ll N;
    cin >> N;

    ll cnt = 1;
    ll acc = 26;
    if (acc > N) {
        cout << (char)('a'+N-1) << endl;
        return 0;
    }
    while (true)
    {
        cnt++;
        ll a = pow(26, cnt);
        if (acc+a >= N) break;
        acc += a;
        
    }
    
    vector<char> name(cnt); 

    ll now = acc+1;
    REP(i, cnt) {
        int t = 0;
        REP(_, 26) {
            ll a = pow(26, (cnt-1)-i);
            if (now+a-1 >= N) {
                break;
            }
            t++;
            now += a;
        }
        name[i] = (char) ('a' + t);
    }

    for (char c : name) {
        cout << c ;
    }
    cout << endl;
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    string s; cin >> s;
    ll sum = 0;
    for(int i = 0; i < (int)s.size(); i++){
        sum += s[i] - '0';
    }
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3756
import time, random
now = time.time()

d = int(input())
clst = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
last = [0 for _ in range(26)]

def score_minus(d, q):
    minus = 0
    for i, (c, ls) in enumerate(zip(clst, last)):
        if i == q:
            continue
        minus += c * (d + 1 - ls)
    return minus

def check(t):
    def score_minus(d):
        minus = 0
        for c, ls in zip(clst, last):
            minus += c * (d - ls)
        return minus
        
    last = [0 for _ in range(26)]
    ans = 0
    for d, num in enumerate(t, start = 1):
        ans += s[d - 1][num - 1]
        last[num - 1] = d
        ans -= score_minus(d)
    return ans
    
t_lst = []
for i in range(d):
    tmp = -10 ** 10
    for q in range(26):
        tmp_score = s[i][q] - score_minus(i, q)
        if tmp_score > tmp:
            tmp = tmp_score
            max_q = q
    last[max_q] = i
    t_lst.append(max_q + 1)

ans = check(t_lst)

while time.time() - now < 1.9:
    d_change = random.randint(0, d - 1)
    q_change = random.randint(1, 26)
    old_d = t_lst[d_change]
    if old_d == q_change:
        continue
    t_lst[d_change]  = q_change
    ans_tmp = check(t_lst)
    if ans_tmp > ans:
        ans = ans_tmp
    else:
        t_lst[d_change] = old_d

for t in t_lst:
    print(t)


Measured memory_bytes: 9808
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}

double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}

int main(){
    double r,x,y;
    int n;
    cin >> r >> x >> y >> n;

    VP p(n);
    vector<double> area(n);
    p[0] = P(0, r);
    for(int i=0; i<n; i++){
        double ratio;
        cin >> ratio;
        area[i] = r*r*PI*ratio/100;
        if(i != n-1){
            double angle = 2*PI*ratio/100;
            p[i+1] = p[i] /P(cos(angle), sin(angle));
        }
    }

    vector<int> ans(n);
    for(int i=0; i<n; i++){
        double changed = area[i];
        VP tri{P(0, 0), p[(i+1)%n], p[i]};
        changed -= getarea(tri);
        VP tri2{P(x, y), p[(i+1)%n], p[i]};
        changed += getarea(tri2);
        ans[i] = changed/area[i]*100;
    }
    for(int i=0; i<n-1; i++){
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3624
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6+50
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

X, Y = map(int, input().split())
if (X+Y)%3 != 0:
  print(0)
else:
  m = (X+Y)//3
  a = (2*Y-X)//3
  print(cmb(m,a, mod))


Measured memory_bytes: 127940
n, y = map(int, input().split())

ans = [-1, -1, -1]

for a in range(n+1):
    for b in range(n-a+1):
        if (a*10000 + b*5000 + (n-a-b)*1000) == y:
            ans = [a, b, n-a-b]
print(*ans)

Measured memory_bytes: 3060
object Main extends App {
    val scan = new java.util.Scanner(System.in)
    val n = scan.next().toInt
    
    val graph: Dijkstra.Graph = Array.fill(n)(List())

    for (_ <- 1 to n) {
      val u, k = scan.next().toInt
      graph(u) = (1 to k).toList
                .map(_ => Dijkstra.Edge(scan.next().toInt, scan.next().toInt))
    }

    Dijkstra.shortest_path(graph, 0,n-1).zip(0 until n)
      .map(t => t._2.toString ++ " " ++ t._1.get.toString)
      .foreach(println(_))
}

object Dijkstra {
    case class Edge(to: Int, cost: Long)
    type Edges = List[Edge]
    type Graph = Array[Edges]
    
    def shortest_path(graph: Graph, start: Int, goal: Int): Array[Option[Long]] = {
        val pq = new collection.mutable.PriorityQueue[(Long, Int)]
        val cost: Array[Option[Long]] = Array.fill(graph.length)(None)
        cost(start) = Some(0L)
        pq += ((cost(start).get, start))
        while (pq.nonEmpty) {
            val current_edge = pq.dequeue()
            // if (current_edge._2 < current_edge._1) continue
            if (!cost(current_edge._2).map(_ < current_edge._1).getOrElse(false)){
                for (tmp <- graph(current_edge._2)) {
                    val sumCost = current_edge._1 + tmp.cost
                    if (cost(tmp.to).map(_ > sumCost).getOrElse(true)) {
                        cost(tmp.to) = Some(sumCost)
                        pq += ((cost(tmp.to).getOrElse(Long.MaxValue), tmp.to))
                    }
                }
            }
        }
        cost
    }
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll town[6];CLR(town,0);
  ll ans=0;
  town[0]=n;
  ll a[5];
  rep(i,0,5)cin>>a[i];
  ll mi=*min_element(a,a+5);
  printf("%lld",(ll)ceil((lb)n/mi)+4);






  return 0;
}


Measured memory_bytes: 512
n,d=map(int, input().split())
a=[list(map(int,list(input().split()))) for i in range(n)]

dist=0
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        for k in range(d):
            dist+=(a[i][k]-a[j][k])**2
        dist=dist**0.5
        if(dist.is_integer()==True):
            ans+=1
        dist=0
print(ans)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll a,b;
    cin >> a >> b;
    vector<ll> h(n);
    for(i = 0;i < n;++i){
        cin >> h.at(i);
    }
    ll sup = 1e9;
    ll inf = 0;
    while(sup-inf > 1){
        ll mid = (sup+inf)/2;
        ll tmp = 0;
        for(i = 0;i < n;++i){
            ll spare = h.at(i)-mid*b;
            if(spare <= 0) continue;
            else tmp += (spare-1)/(a-b) + 1;
        }
        if(tmp > mid) inf = mid;
        else sup = mid;
    }
    cout << sup << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int n, d;
int p[15][25];

int main(void)
{
	cin >> n >> d;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= d; j++) cin >> p[i][j];
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			int sum = 0;
			for(int k = 1; k <= d; k++){
				sum += (p[i][k]-p[j][k]) * (p[i][k]-p[j][k]);
			}
			for(int k = 0; k < 10000; k++){
				if(sum == k*k){
					ans++;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int D;
  cin>>D;
  int c[26];
  int s[D][26];
  int Tans[D];
  for(int i=0;i<26;i++){
    cin>>c[i];
  }
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin>>s[i][j];
    }
  }
  for(int i=0;i<D;i++){
    cout<<rand()%26+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

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

long long h[100010];
long long dp[100100];

int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    for(int i = 0; i < 100100;++i){
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= k;++j){
            chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1792
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;

int main()
{
    speed;
    ll t,i,j,a,b,c,d=0,e=0,ans=0;
    cin>>a>>c;
    cin>>b>>d;
    cin>>e;
    if(a<0 && b<0)
    {
        for(i=0;i<e;i++)
        {
            a=a-c;
            b=b-d;
            if(a<=b)
            {
                ans=1;
                break;
            }
        }
    }
    else if(a>0 && b<0)
    {
        for(i=0;i<e;i++)
        {
            a=a-c;
            b=b-d;
            if(a<=b)
            {
                ans=1;
                break;
            }
        }
    }
    else
    {
        for(i=0;i<e;i++)
        {
            a=a+c;
            b=b+d;
            if(a>=b)
            {
                ans=1;
                break;
            }
        }
    }
    //cout<<a<<b<<endl;
    if(ans==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 3636
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

bool getCuts(int k,int mx,vector<int> &arr) {

    for(auto i: arr) {
        if(i<=mx) continue;

        int x= ceil(i/mx);
        k-=x;
    }
    return k>=0;
}

int main() {
    fastIO;
    int n,k; cin>>n>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    int l=1,h=*max_element(arr.begin(),arr.end());

    while(l<h) {
        int m= (l+h)/2;
        bool b= getCuts(k,m,arr);

        if(b) h=m;
        else l=m+1;
    }
    cout<<l;
    return 0;
}

Measured memory_bytes: 3980
#!/usr/bin/perl

my ($s,$t) = split(/\s+/,<STDIN>);
my ($a,$b) = split(/\s+/,<STDIN>);
my ($u) = split(/\s+/,<STDIN>);

if( $s eq $u ){
  $a = $a - 1;
} else {
  $b = $b - 1;
}
print "$a $b\n";

exit(0);


Measured memory_bytes: 512
using System;
using System.Linq;
public class Test
{
	public static void Main(){
		
		int n = int.Parse(Console.ReadLine());
		
		for (int k=0;k<n;k++){
		
			String hen = Console.ReadLine();
			String[] henkari = hen.Split(' ');
			int[] HEN = new int[3];
			for(int i =0 ;i < 3 ;i++){
				HEN[i] = int.Parse(henkari[i]);
			}
			int max = HEN.Max();
			if( Math.Pow(max, 2) ==(Math.Pow(HEN[0], 2) + Math.Pow(HEN[1], 2) + Math.Pow(HEN[2], 2) - Math.Pow(max, 2))){
				Console.Write("YES\n");			
			}else{
				Console.Write("NO\n");
			}
		}
	}
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

ll a , b , mx = 1 ;

int main() {

    cin >> a >> b ;
    for( ll i = 1 ; i * i <= b ; i++ ){
        if( b % i == 0 ){
            if( i * a <= b ){
                mx = max( i , mx ) ;
            }
            if( b / i * a <= b ){
                mx = max( b / i , mx ) ;
            }
        }
    }

    cout << mx << "\n" ;



    return 0 ;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d",&n);
    char s[n];
    char t[n];
    scanf("%s%s",s,t);
    m= ( 2 * n);

    int i;

    for(i = 0; i < n; i++){
        printf("%c%c",s[i],t[i]);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//


ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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





int main() {
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s==u){
    a--;}
  else{b--;}
  cout<<a<<" "<<b<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define PI pair<int,int>
#define ff first
#define ss second
#define MOD 1000000007
int32_t main()
{
    boost;
   /* #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
	*/
    int n,tmp;
    cin>>n;
    int ans[n+1];

    for(int i=1;i<=n;i++)
    {
    	cin>>tmp;
    	ans[tmp]=i;
    }
    for(int i=1;i<=n;i++)
    	cout<<ans[i]<<" ";
    cout<<endl;
}



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

int main(){
    int N;
    int d[100002];

    cin >> N;
    for(int i=0;i<N;i++) cin >> d[i];
    sort(d, d+N);
    cout << d[N/2] - d[N/2 - 1] << "\n";

    return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

long long MAX = 1e18;

int main() {
int x, y, i, j;
cin >> x >> y;
for(i = 0; i <= 100; i++){
    for(j = 0; j <= 100; j++){
        if(i+j == x && 2*i+4*j == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
}
cout << "No" << endl;

return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
ll n,x,m;
int cnt,cnt2;
int ha[100005];
map<int,int> pre;
int main(){
	cin>>n>>x>>m;
	ll now=x;
	pre[x]=1;ha[1]=x;
	for(int i=2;i<=2*m+1;i++) {
		now = now * now % m;
		if (pre.find(now) != pre.end()) {
			cnt = i-1;
			cnt2=pre[now]-1;
			break;
		} else
			pre[now] = i, ha[i] = now;
	}
	ll ans=0;
	for(int i=1;i<=min(n,(ll)cnt2);i++) ans+=ha[i];
	ll ans2=0;
	for(int i=1;i<=((n-cnt2)<0?0:cnt-cnt2);i++) ans2+=ha[i+cnt2];
	ans2=ans2*(max(0ll,(n-cnt2)/(cnt-cnt2)));
	for(int i=1;i<=max(0ll,(n-cnt2)%(cnt-cnt2));i++) ans+=ha[i+cnt2];
	cout<<ans+ans2<<endl;
	return 0;
}


Measured memory_bytes: 6064
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll ans=0;
ll s;
int main(){
	ll n;
	scanf("%lld",&n);
	while(n--){
		scanf(" %s",&s);
		if(s<100)ans++;
		else ans--;
		if(ans<0){
			puts("NO");
			return 0;
		}
	}
	puts(ans?"NO":"YES");
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  ll orig = n;
  bool all9 = true;
  ll ans = 0;
  while(n > 0) {
    int cur = n%10;
    if(n >= 10) {
      if(cur != 9) all9 = false;
      ans += 9;
    } else {
      if(all9) ans += n;
      else     ans += n-1;
    }
    n /= 10;
  }
  if(orig < 10) cout << orig << "\n";
  else cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int m;
  cin>>m;
  cout << 24 - m +24<< endl;
  return 0;
}



Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

ans = 0
cnt = 0
for i in range(N-1):
#  print (i, cnt, ans, H[i], H[i+1], H[i] > H[i+1])
  if H[i] >= H[i+1]:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
ans = max(ans, cnt)
print (ans)

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

vector<string> result;

void add(int len){
  if(len==1){
    result={"a"};
  }else{
    vector<string> tmp;
    tmp=result;
    result.clear();
    for(string pre: tmp){
      int maxchar=0;
      for(int i=0; i<len-1; i++){
        maxchar=max(maxchar,(pre[i]-'a'));
      }
      for(int j=0; j<maxchar+2; j++){
        result.push_back(pre+(char)((int)'a'+j));
      }
    }
  }
  return;
}

int main(){
  int N; cin >> N;
  for(int i=0; i<N; i++){
    add(i+1);
  }
  for(auto s : result){
    cout << s << endl;
  }
}

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

int main(){
  ll x;
  cin>>x;
  ll ans = (x/500)*1000;
  x = x%500;
  ans = ans + (x/5)*5;
  cout<<ans;
  
  
  
  
  return 0;}


Measured memory_bytes: 3640