akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    if(K <= X / D) {
        cout << abs(X - D * K) << endl;
    } else {
        ll mi = X - (X / D + 1) * D;
        ll ma = X - (X / D) * D;
        if((X / D) % 2 == 0) {
            if(K % 2 == 0) {
                cout << abs(ma) << endl;
            } else {
                cout << abs(mi) << endl;
            }
        } else {
            if(K % 2 == 0) {
                cout << abs(mi) << endl;
            } else {
                cout << abs(ma) << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3592
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int gauss(int x) {
    return x * (x + 1) / 2;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int limit = (n - 1) * (n - 2) / 2;
    if (k > limit)
        cout << -1, exit(0);
    int m = limit - k;
    cout << n - 1 + m << "\n";
    for (int i = 1; i < n; ++i)
        cout << i << " " << n << "\n";
    int l = 1, r = 2;
    while (m--) {
        cout << l << " " << r << "\n";
        r++;
        if (r == n)
            l++, r = l + 1;
    }
    return 0;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
l=[]
for i in range(M):
    l.append(list(map(int,input().split())))
for j in range(M):
    l[j].append(j)
l.sort(key=lambda x:(x[0],x[1]))

l[0].append(1)
for k in range(1,M):
    if l[k][0] == l[k-1][0]:
        l[k].append(l[k-1][3]+1)
    else:
        l[k].append(1)

l.sort(key=lambda x:x[2])

for m in range(M):
    s='00000' + str(l[m][0])
    t='00000' + str(l[m][3])
    print(s[len(s)-6:len(s)]+t[len(t)-6:len(t)])


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> x(N, vector<int>(D));

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> x.at(i).at(j);
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int tmp = 0;
      for (int k = 0; k < D; k++) {
        int d = x.at(i).at(k) - x.at(j).at(k);
        tmp += d * d;
      }

      int n = floor(sqrt(tmp));
      if (n * n == tmp) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}

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

int main() {
    ll n;
    cin >> n;
    ll x, y;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) x = i;
    }
    y = n / x;
    x--; y--;
    cout << x+y << endl;
    return 0;
}

Measured memory_bytes: 3592
n,a,b,c = map(int, input().split( ))
mod = 10**9+7
#n回～2nー1回
a_ab = pow(a+b,mod-2,mod)*a
prob = pow(a_ab,n,mod)

ans = prob*n
b_ab = pow(a+b,mod-2,mod)*b
for i in range(1,n):
    pre = prob
    prob *= (n+i)
    prob *= pow(i,mod-2,mod)
    prob *= b_ab
    prob %= mod
    ans += (prob-pre*b_ab)*(n+i)
    ans %=mod
prob = pow(b_ab,n,mod)
ans2 = prob*n
for i in range(1,n):
    pre = prob
    prob *= (n+i)
    prob *= pow(i,mod-2,mod)
    prob *= a_ab
    prob %= mod
    ans += (prob-pre*a_ab)*(n+i)
    ans %= mod
ans += ans2
ans *= pow(100-c,mod-2,mod)*100
ans%=mod
print(ans)


Measured memory_bytes: 40940
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;
#define PI 3.14159265359

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I a,b,x;
  cin >> a >> b >> x;
  I base = a * a;
  double y;
  double t;
  if (base * b / 2 < x){
    y = (2.0 * b) - (2.0 * x) / (1.0 * base);
    t = atan(y/a) * 1.0 / PI * 180;
  }else{
    y = x * 2.0 / (a * b * 1.0);
    t = atan(b/y) * 1.0 / PI * 180;
  }
  COUTDOUBLE(t,10);
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int gcd(int x,int y){
  if(x%y==0) return y;
  else gcd(y,x%y);
}

int main(void){
  int x,y;
  scanf("%d %d",&x,&y);
  printf("%d\n",gcd(x,y));
  return 0;
}


Measured memory_bytes: 2064
#include <iostream>

using namespace std;
int main(void){
  int i=0;
  int N;
  int V[50],C[50],VmC[50];
  int max = 0;
  cin >> N;


  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  for(int i=0;i<N;i++){
    VmC[i] = V[i]-C[i];
  }
  for(int i=0;i<N;i++){
    if(VmC[i] > 0)max += VmC[i];
  }

  cout << max;

}


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

int main() {
  long int A,B,C,K,ans;
  cin>>A>>B>>C>>K;
  if(A>=K)ans=K;
  else if(A+B>K)ans=A;
  else ans=A-(K-A-B);
  cout<<ans<<endl;
}


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c;
    
        if(a > b){
             d=a;
             a=b;
             b=d;
        }
        if(b>c){
             d=b;
             b=c;
             c=d;
        }
        if(a>b){
             d=a;
             a=b;
             b=d;
        }
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 3092
import java.util.*;

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

        String t = sc.next();
        StringBuilder ans = new StringBuilder();

        for(int i = 0; i < t.length(); i++){
            switch(t.charAt(i)){
                case 'P':
                    ans.append('P');
                    break;
                case 'D':
                    ans.append('D');
                    break;
                case '?':
                    if(i > 0 && t.charAt(i - 1) == 'P'){
                        ans.append('D');
                    }else if(i < t.length() - 1 && t.charAt(i + 1) == 'P'){
                        ans.append('D');
                    }else if(i > 0 && ans.charAt(i - 1) == 'P'){
                        ans.append('D');
                    }else if(i < t.length() - 1 && t.charAt(i + 1) == '?'){
                        ans.append('P');
                    }else if(i < t.length() - 1 && t.charAt(i + 1) == 'D'){
                        ans.append('P');
                    }else{
                        ans.append('D');
                    }

            }
        }

        System.out.println(ans);

    }
}


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

using namespace std;

int main() {
  int x;
  cin >> x;
  if (x % 2 == 0) {
    cout << 0.5000000000 << endl;
  } else {
    cout << 1 - (x - 1.0) / 2 / x << endl;
  }
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
#define ll long long
ll mod = 1000000000+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    ll T;
    T=1;
    //cin>>T;
    start:
    while(T--)
    {
        int n;
        cin>>n;
        if(n%1000==0){cout<<0<<endl;goto start;}
        cout<<1000-(n%1000)<<endl;
        
    }
    return 0;
}



Measured memory_bytes: 3648
import heapq

N,Q = map(int, input().split())

node = [0]*N
edge = [[] for _ in range(N)]
color = [0]*N

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

stack = [0]
while stack:
    s = stack.pop()
    color[s] = 1
    for t in edge[s]:
        if color[t]==0:
            stack.append(t)
            node[t] += node[s]
    color[s]=2

print(*node)

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

int main(){
    int N, M, tmp;
    long long ans=0;
    cin >> N >> M;
    priority_queue<int, vector<int>> desc;
    for(int i=0; i<N; i++){
	cin >> tmp;
	desc.push(tmp);
    }

    for(int i=0; i<M; i++){
    	tmp = desc.top();
    	desc.pop();
    	tmp >>= 1;
    	desc.push(tmp);
    }

    while(!desc.empty()){
    	ans += desc.top();
    	desc.pop();
    }

    cout << ans << endl;
}



Measured memory_bytes: 892
n = gets.to_i
hs = Hash.new(0)

n.times do
  s = gets.chomp
  hs[s] += 1
end

puts "AC x %d" % [hs["AC"]]
puts "WA x %d" % [hs["WA"]]
puts "TLE x %d" % [hs["TLE"]]
puts "RE x %d" % [hs["RE"]]


Measured memory_bytes: 14332
#include <iostream>
using i64 = long long;

int main() {
    i64 n;
    std::cin >> n;
    i64 c = 100;
    for (int i = 1; ; i++) {
        c = c + c / 100;
        if (c >= n) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    return 0;
}


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

const ll MOD=1000000007;

int main(){
    int K,A,B;
    cin>>K>>A>>B;
    bool flag=false;
    for(int i=A;i<B+1;i++){
        if(i%K==0){
            flag=true;
        }
    }
    if(flag){
        cout<<"OK"<<endl;
    }
    else{
        cout<<"NG"<<endl;
    }
}

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

using namespace std;
using ll = long long;

const long long INF = 1LL << 60;

int main() {
    int n; cin >> n;
    vector<ll> h(n);
    vector<ll> dp(n);

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

    fill(dp.begin(), dp.end(), INF);

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
import sys
N, M = map(int, input().split())
A = [list(map(str, input())) for _ in range(N)]
B = [list(map(str, input())) for _ in range(M)]
for i in range(N - M + 1):
    for j in range(N - M + 1):
        OK = True
        for k in range(M):
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    OK = False
                    break
            if not OK:
                break
        if OK:
            print('Yes')
            sys.exit()
print('No')

Measured memory_bytes: 9220
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;
#define lol long long


int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		bool OK = true;
		for (int j = i; j >= 0; j--) {
			if (H[i] < H[j]) {
				OK = false;
			}
		}
		if (OK) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if ((abs(a - b) <= d&&abs(b - c) <= d)||abs(a-c)<=d) {
		puts("Yes");
	}
	else {
		puts("No");
	}
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    static Scanner scanner;

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

        int N=gi();
        int K=gi();
        String S=gs();
        List<Integer> l=new ArrayList<Integer>();
        long ans=0;
        boolean f=true;
        boolean sf=true;
        if(S.charAt(0)=='0') {
        	f=false;
        	sf=false;
        }
        int tmp=0;
        for (int i=0;i<N;i++) {
            char c=S.charAt(i);
        	if(f) {
        		if(c=='0') {
        			l.add(tmp);
        			tmp=1;
        			f=false;
        		} else {
        			tmp++;
        		}
        	} else {
        		if(c=='1') {
        			l.add(tmp);
        			tmp=1;
        			f=true;
        		} else {
        			tmp++;
        		}
        	}
        }
        l.add(tmp);

        long ta=0;
        if (sf) {
            for (int i=0; i<Math.min(2*K+1, l.size());i++) {
            	ta+=l.get(i);
            }
            ans=ta;
            for (int i=2*K+1; i<l.size();i+=2) {
            	ta+=l.get(i);
            	if(i+1<l.size())ta+=l.get(i+1);
            	ta-=l.get(i-(2*K+1));
            	ta-=l.get(i-(2*K));
            	ans=Math.max(ta, ans);
            }
        } else {
        	for (int i=0; i<Math.min(2*K, l.size());i++) {
            	ta+=l.get(i);
            }
            ans=ta;

            for (int i=2*K; i<l.size();i+=2) {
            	ta+=l.get(i);
            	if(i+1<l.size())ta+=l.get(i+1);
            	if(i-(2*K+1)>=0)ta-=l.get(i-(2*K+1));
            	ta-=l.get(i-(2*K));
            	ans=Math.max(ta, ans);
            }
        }

        System.out.println(ans);
    }

    // 文字列として入力を取得
    public static String gs() {
         return scanner.next();
    }

    // intとして入力を取得
    public static int gi() {
         return Integer.parseInt(scanner.next());
    }

    // longとして入力を取得
    public static long gl() {
         return Long.parseLong(scanner.next());
    }

    // doubleとして入力を取得
    public static double gd() {
         return Double.parseDouble(scanner.next());
    }
}

Measured memory_bytes: 41720
#include <stdio.h>

int main(void)
{
    int N,K,i,j;
    long double P_kitai1[200002],P_kitai2[200002],max=0;

    scanf("%d %d",&N,&K);
    for(i=0; i<N; i++){
        scanf("%Lf",&P_kitai1[i]);
        P_kitai1[i] = (P_kitai1[i]+1)/2;
        //printf("P[%d] = %Lf\n",i, P_kitai1[i]);
    }

    //N-K+1回調べる

    P_kitai2[0]=0;
    for(i=0; i<K; i++){
        P_kitai2[0] += P_kitai1[i];
        //printf("%Lf\n",P_kitai2[0]);
    }
	max = P_kitai2[0]; 

    //printf("\n\n");

    if(N != 1){
        for(i=1; i<N-K+1; i++){
            P_kitai2[i] = P_kitai2[i-1];
            //printf("P_kitai2[%d] = P_kitai2[%d-1] = %Lf\n",i,i,P_kitai2[i]);
            //printf("P_kitai2[%d] - P_kitai1[%d] = %Lf - %Lf\n",i,i-1,P_kitai2[i],P_kitai1[i-1]);
            P_kitai2[i] -= P_kitai1[i-1];
            //printf("P_kitai2[%d] + P_kitai1[%d] = %Lf - %Lf\n",i,i+K-1,P_kitai2[i],P_kitai1[i+K-1]);
            P_kitai2[i] += P_kitai1[i+K-1];

            if(max < P_kitai2[i]){
                max = P_kitai2[i];
                //printf("max = %Lf\n\n",max);
            }
        }
    }
/*
    for(i=0; i<N-K+1; i++){
        P_kitai2[i] = 0;
        for(j=i; j<K+i; j++){
            P_kitai2[i]+=P_kitai1[j];
        }
        if(max < P_kitai2[i]){
            max = P_kitai2[i];
        }
    }
*/
    printf("%.12Lf\n",max);

    return 0;
}


Measured memory_bytes: 6400
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""


input:
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0

output:
0
0
1
1
1
0
1
1

"""

import sys


class UnionFind(object):
    __slots__ = ('size', 'rank', 'p_list')

    def __init__(self, size):
        self.size = int(size)
        self.rank = [0] * self.size
        self.p_list = [i for i in range(self.size)]

    def _find(self, x):
        if x != self.p_list[x]:
            self.p_list[x] = self._find(self.p_list[x])
        return self.p_list[x]

    def same(self, x, y):
        return self._find(x) == self._find(y)

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p_list[y] = x
        else:
            self.p_list[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def union(self, x, y):
        self.link(self._find(x), self._find(y))


def action(cmd):
    for _, each in enumerate(cmd):
        cmd, ele_1, ele_2 = map(int, each)
        if cmd == 0:
            case.union(ele_1, ele_2)
        elif cmd == 1:
            if case.same(ele_1, ele_2):
                print('1')
            else:
                print('0')
    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    ele_num, cmd_num = map(int, _input[0].split())
    cmd_list = map(lambda x: x.split(), _input[1:])

    case = UnionFind(size=ele_num)

    ans = action(cmd_list)

Measured memory_bytes: 16628
MOD = 10**9+7
# dp[i][j] := Sの後ろからi桁を13で割った余りがjとなるようなものの個数
S = input()
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
mul = 1
l = len(S)
for i in range(l):
    x = S[-(i+1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= MOD
    else:
        k = int(x) # これしか選ぶ余地なし
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= MOD
    mul = mul * 10 % 13
print(dp[len(S)][5])


Measured memory_bytes: 62300
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

char res[32];

bool ok(int n, string S) {
  int us = 0;
  for (int i = 0; i <= (int)S.size(); ++i) {
    char ch = res[i];
    char sh = i < (int)S.size() ? S[i] : '\0';
    if (i >= n) {
      for (int t = 25; t >= 0; --t) {
        if (!(us & (1 << t))) {
          ch = t + 'a';
          break;
        }
      }
    }
    if (ch > S[i]) return true;
    if (ch < S[i]) return false;
    us |= 1 << (ch - 'a');
  }
  return false;
}

int main() {
  string S;
  cin >> S;
  if (S == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }

  int us = 0;
  for (int i = 0; ; ++i) {
    for (int c = 0; c < 27; ++c) {
      if (c > 0 && (us & (1 << (c-1)))) continue;
      res[i] = (c == 0 ? '\0' : (c - 1 + 'a'));
      if (ok(i + 1, S)) {
        if (c == 0) {
          puts(res);
          return 0;
        }
        us |= 1 << (c - 1);
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


import sys
input = sys.stdin.readline

from decimal import Decimal
a, b, c = list(map(int, input().split()))
def sq(x):
    x=Decimal(x**2)
    return x
#print(a**(1/2),b**(1/2),c**(1/2))
if c-a-b>0 and 2*(a*b+b*c+c*a)<sq(a)+sq(b)+sq(c):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5076
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;



int main(int argc, char const *argv[])
{
    
    
    ll h;
    cin >> h;
    
    ll cnt = 0;
    while(h > 1){
        cnt++;
        h /= 2;
    }

    ll res = pow(2, cnt+1) - 1;


    cout << res << endl;

    



    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
import math
from fractions import Fraction as frac

MOD = 1e9 + 7

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

def solve(case_no):
    n = int(input())
    cnt=0
    for i in range(n):
    	a,b = map(int,input().split())
    	if a==b:
    		cnt += 1
    		if cnt == 3:
    			print("Yes")
    			exit()
    	else:
    		cnt=0
    print("No")
    	

t = 1
# t = int(input())
for i in range(1, t + 1):
    solve(i)


Measured memory_bytes: 10448
#include <stdio.h>

int main(void){
  int kai,ban;
  scanf("%d %d",&kai,&ban);
  if(ban == 100){
    ban = 101;
  }
  for(int i = 0;i < kai;i++){
    ban = ban * 100;
  }
  printf("%d",ban);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,coun=0,coun2=0,coun3=0,coun4=0;
    string s;
    cin>>t;
    while(t--)
    {
        cin>>s;
        if(s[0]=='A')
        {
            coun++;
        }
        if(s[0]=='W')
        {
            coun2++;
        }
        if(s[0]=='R')
        {
            coun3++;
        }
        if(s[0]=='T')
        {
            coun4++;
        }
    }
    cout<<"AC x "<<coun<<endl;
    cout<<"WA x "<<coun2<<endl;
    cout<<"TLE x "<<coun4<<endl;
    cout<<"RE x "<<coun3<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <math.h>

using namespace std;

long long int lnln(long long int N, long long int X) {
	if (N == 0) return 1;
	if (X == 1) return 0;
	else if (X <= pow(2,N+1) - 2) return lnln(N-1, X-1);
	else if (X == pow(2,N+1) - 1) return pow(2, N);
	else if (X >= pow(2,N+1) && X <= pow(2,N+2) - 4) return pow(2, N) + lnln(N-1, X-pow(2,N+1)+1);
	else if (X == pow(2,N+2) - 3) return pow(2,N+1) - 1;
	else return 0;
}

int main(void) {
	long long int N, X;
	cin >> N >> X;
	cout << lnln(N, X) << endl;

}



Measured memory_bytes: 256
#gcdか....
def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

N = int(input())
aA = sorted(set(int(_) for _ in input().split()))
b = aA[0]
for a in aA[1:]:
    b = fgcd(a,b)
print(b)


Measured memory_bytes: 19728
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
//#define int long long
using namespace std;
int a;
int main()
{
	cin>>a;
	cout<<a+a*a+a*a*a;
 } 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;

const ll inf = 1e17;
const ll N = 1e6+10;
const ll bits = 62;
const ll mod = 1e9+7;

int main(){

   ll n,m;
   cin>>n>>m;

   priority_queue<ll,vector<ll>>pq;

   ll temp;

   for(int i=0;i<n;i++){
      cin>>temp;

      pq.push(temp);
   }
   

   while(m){
      ll top = pq.top();
      pq.pop();
      top/=2;
      pq.push(top);
      m--;
   }

   ll ans = 0;

   while(!pq.empty()){
      ans += pq.top();
      pq.pop();
   }

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

Measured memory_bytes: 1400
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  s <- getLine
  let s' = if last s == 's'
        then s ++ "es"
        else s ++ "s"
  putStrLn s'



Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S,T;
  string M;

  cin >> N;
  cin >> S >> T;

  // cout << "=======" << endl;

  for (int i; i<N; i++) {
    cout << S.at(i) << T.at(i);
  }
  cout << endl;


}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i).unshift(nil)

ans = 0
hash = Hash.new { |h, k| h[k] = 0 }
1.upto(N) do |idx|
  ans += hash[idx - A[idx]]
  hash[idx + A[idx]] += 1
end

puts ans


Measured memory_bytes: 47084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<string> vs;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int h,w,n;

bool finish(vs const& g){
    rep(i,h)rep(j,w)if(g[i][j]!='.')return false;
    return true;
}

int erase(vs &g){
    static bool exist[30][30];
    rep(i,h)rep(j,w)exist[i][j]=g[i][j]!='.';
    rep(i,h)rep(j,w){
        int ni;
        for(ni=i; ni<h && g[i][j]==g[ni][j]; ni++);
        if(ni-i >= n){
            for(int ii=i;ii<ni;ii++)exist[ii][j]=false;
        }
        int nj;
        for(nj=j; nj<w && g[i][j]==g[i][nj]; nj++);
        if(nj-j >= n){
            for(int jj=j;jj<nj;jj++)exist[i][jj]=false;
        }
    }

    int res=0;
    rep(i,h)rep(j,w){
        if(!exist[i][j] && g[i][j]!='.'){
            g[i][j]='.';
            res++;
        }
    }
    return res;
}

void drop(vs &g){
    rep(j,w){
        int top=h-1;
        for(int i=h-1;i>=0;i--){
            if(g[i][j]!='.'){
                g[top--][j] = g[i][j];
            }
        }
        while(top>=0)g[top--][j]='.';
    }
}

bool solve(vs const& g){
    rep(i,h)rep(j,w-1){
        vs ng=g;
        swap(ng[i][j],ng[i][j+1]);
        drop(ng);
        while(erase(ng))drop(ng);
        if(finish(ng))return true;
    }
    return false;
}

int main(){
    cin>>h>>w>>n;
    vs g(h);
    rep(i,h)cin>>g[i];
    puts(solve(g) ? "YES" : "NO");
}

Measured memory_bytes: 1184
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // codeforces
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") // yandex

#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

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

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

void solve() {
	int x;
    sc(x);
    x /= 200;
    cout << 10 - x << endl;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

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

int main() {
	int x, t, n;
	int ans;
	cin >> n >> x>> t;
	
	ans = n / x;
	if(n%x != 0)ans++;
	cout << ans*t << endl;
	return 0;
}

Measured memory_bytes: 3160
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum as = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

void main()
{
    writeln(as[readln.chomp.to!int-1]);
}

Measured memory_bytes: 256
while true
    n = gets.to_i
    break if n == 0

    lines = []
    n.times{
        line = gets.chomp
        lines << [line.count('.'), line[-1]]
    }

    stack = []
    (n - 1).downto(0){|i|
        level, number = lines[i]
        case number
        when "+"
            sum = 0
            until stack.empty? || stack[-1][0] != level + 1
                l, x = stack.pop
                sum += x
            end
            stack << [level, sum]
        when "*"
            product = 1
            until stack.empty? || stack[-1][0] != level + 1
                l, x = stack.pop
                product *= x
            end
            stack << [level, product]
        else
            stack << [level, number.to_i]
        end
    }
    puts stack[0][1]
end



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

N = int(input().split()[0])
b_list = list(map(int, input().split()))
w_list = b_list[:]

# 引いていく方法で考える
is_ok = True
ans_list = []

# 深さ優先探索か？
# 候補が複数ある場合が考えられる
while w_list:
    kouho_list = [i for i, w in enumerate(w_list) if w == i + 1]
    if not kouho_list:
        is_ok = False
        break

    # 右側から処理すると順序が変わらないので、
    # 右側から抜いていく
    kouho_list = list(reversed(kouho_list))
    ans_list.append(w_list.pop(kouho_list[0]))

if is_ok:
    ans_list = [str(x) for x in reversed(ans_list)]
    ans = "\n".join(ans_list)
else:
    ans = -1
print(ans)


Measured memory_bytes: 3064
n = int(input())
a = [int(m) for m in input().split()]
ans = 0
tmp = 0
for i in range(1, n):
    if a[i - 1] == a[i]:
        tmp += 1
    else:
        tmp += 1
        ans += tmp // 2
        tmp = 0
tmp += 1
ans += tmp // 2
print(ans)

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

struct Problem {
public:

	UL G[502][502];
	bool Save[502][502];
	bool S[502][502] = {};

	void BFS(UL x, UL y, UL d = 0) {
		queue<pair<pair<UL, UL>, UL>> Q;
		Q.push({ {x, y}, d });
		while (Q.size()) {
			UL x = Q.front().first.first;
			UL y = Q.front().first.second;
			UL d = Q.front().second;
			Q.pop();
			if (G[x][y] <= d && Save[x][y] == S[x][y]) continue;
			G[x][y] = d;
			Save[x][y] = S[x][y];
			if (S[x][y]) d++;
			Q.push({ {x-1, y}, d });
			Q.push({ {x+1, y}, d });
			Q.push({ {x, y-1}, d });
			Q.push({ {x, y+1}, d });
		}
	}

	void Solve() {
		UL N; scanf("%d", &N);

		rep(i, N) rep(j, N) S[i + 1][j + 1] = true;
		rep(i, N + 2) rep(j, N + 2) { G[i][j] = 10000; Save[i][j] = S[i][j]; }
		rep(i, N + 2) {
			G[0][i] = G[N + 1][i] = 0;
			G[i][0] = G[i][N + 1] = 0;
		}
		rep(x, N) rep(y, N) {
			UL tmp = 10000;
			tmp = min(tmp, x);
			tmp = min(tmp, y);
			tmp = min(tmp, N - 1 - x);
			tmp = min(tmp, N - 1 - y);
			G[x + 1][y + 1] = tmp;
		}

		UL ans = 0;

		rep(i, N * N) {
			UL P; scanf("%d", &P);
			UL x = (P - 1) % N + 1;
			UL y = (P - 1) / N + 1;
			UL d = G[x][y];
			ans += G[x][y];
			S[x][y] = false;
			BFS(x, y, d);
		}

		printf("%d", ans);
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


Measured memory_bytes: 4656
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int MAX_N = 200000;

template <typename T>
class BIT{
private:
	vector<T> bit; //[1, n]
public:
	BIT(){
		bit = vector<T>(MAX_N + 1, 0);
	}
	T sum(int i){
		if(i == 0) return 0;
		assert(1 <= i and i <= MAX_N and "invalid argument");
		T s = 0;
		while(i > 0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i, int x){
		assert(1 <= i and i <= MAX_N and "invalid argument");
		while(i <= MAX_N){
			bit[i] += x;
			//bit[i] = max(bit[i], x);
			i += i & - i;
		}
	}
};

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

	vector<long long> origin(n);
	vector<pair<long long, int>> a(n);
	rep(i,n){
		cin >> origin[i];
		origin[i] -= k;
		a[i] = make_pair(origin[i], i);
	}
	rep(i,n - 1) a[i + 1].first += a[i].first;
	sort(all(a));

	map<int,int> m;
	rep(i,a.size()) m[ a[i].second ] = i;

	//rep(i,n){ cout << a[i].first << ' ' ; } cout << endl;

	long long ans = 0;
	long long t = 0;
	BIT<long long> bit;
	rep(i,n){
		long long p = distance(a.begin(), lower_bound(all(a), make_pair(t, - 1)));
		ans += n - p;
		t+=origin[i];

		ans -= bit.sum(MAX_N) - bit.sum(p);
		bit.add(m[i] + 1, 1);
	}
	cout << ans << endl;
}


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

int main()
{
	int S;
	int h,m,s;

	while(1)
	{
	cin >> S;

	if( S >= 0 && S < 86400)
		break;
	}

	h = S / 3600;
	S = S - h * 3600;
	m = S / 60;
	s = S - m * 60;

	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <iostream>
using namespace std;
using int64 = long long int;
const int64 MOD = 1000000007;

int64 mod_pow(int64 A, int64 k) {
  int64 res = 1;
  for(; k>0; k>>=1) {
    if(k & 1) (res *= A) %= MOD;
    (A *= A) %= MOD;
  }
  return res;
}

int64 dp[100010];
int main() {
  int N, M; cin >> N >> M;

  dp[0] = 1;
  for(int i=0; i<N; i++) {
    dp[i+1] = dp[i] - (i-M < 0 ? 0 : dp[i-M]);
    (dp[i+1] += MOD) %= MOD;
    // fprintf(stderr, "dp[%d] = %lld\n", i+1, dp[i+1]);
    (dp[i+1] += dp[i]) %= MOD;
  }

  int64 ans = mod_pow(2, N);
  int64 sub = (dp[N] - dp[N-M] + MOD) % MOD;
  (ans += MOD - sub) %= MOD;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3868
N = int(input())
B = list(map(int, input().split()))

sum = 0
if N==2:
    sum += B[0]+B[0]
else:
    sum += B[0]
    for i in range(N-2):
        sum += min([B[i], B[i+1]])
    sum += B[N-2]
print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int 			long long int
#define ld 				long double
#define ff 				first
#define ss 				second
#define P 				pair<int,int>
#define pb 				push_back
#define mod             1000000007
#define inf             1e18
#define endl			'\n'
const int N = 1e5 + 5; //change it when needed
int n;
map<int, list<int>>gr;
int cache[N][2];
int dp(int u, int constraint, int par = -1) {
	int &ans = cache[u][constraint];
	if(ans!=-1)return ans;
	ans=0;
	int w1 = 1; //ita also act as 1st base case that is with constrint

	for (auto ch : gr[u]) {
		if (ch != par)
			w1 = (w1 * dp(ch, 0, u)) % mod;
	}
	ans = (ans + w1) % mod;
	if (!constraint) {
		//that is we can also paint children with our choice
		int w2 = 1; //base case 2
		for (auto ch : gr[u]) {
			if (ch != par)
				w2 = (w2 * dp(ch, 1, u)) % mod;
		}
		ans = (ans + w2) % mod;
	}
	return ans;
}
void solve() {
	cin >> n;
	//dp[u][0]==node u without any constraint//it can be painted
	//both the color.
	//if the constrint is set then we can only paint it white;
	for (int i = 1; i <= n - 1; i++) {
		int u, v;
		cin >> u >> v;
		gr[u].pb(v);
		gr[v].pb(u);
	}
	memset(cache, -1, sizeof(cache));
	cout << dp(1, 0);
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 24064
import numpy as np
N=int(input())
B=list(map(int,input().split()))
A=np.zeros(N,dtype="int64")

A[0]=B[0]
A[N-1]=B[N-2]

for i in range (1,N-1):
  A[i]=min(B[i-1],B[i])
print(sum(A))


Measured memory_bytes: 12396
program poll
  implicit none
  integer :: n, i, a(200000) = 0, m
  character(10) :: s(200000)
  read(*,*) n
  do i = 1, n
    read(*,*) s(i)
  end do
  call quick_sort(s(1:n))
  a(1) = 1
  do i = 2, n
    if (s(i) == s(i-1)) then
      a(i) = a(i-1)+1
    else
      a(i) = 1
    end if
  end do
  m = maxval(a(1:n))
  do i = 1, n
    if (a(i) == m) write(*,'(a)') trim(s(i))
  end do
contains
  subroutine swap(a,b)
    character(10), intent(inout) :: a, b
    character(10) :: c
    c = a
    a = b
    b = c
  end
  recursive subroutine quick_sort(a)
    character(10), intent(inout) :: a(:)
    integer :: n, l, r
    character(10) :: p
    n = size(a)
    l = 1
    r = n
    p = a((n+1)/2)
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      call swap(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program poll

Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int l = 0, r = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == ')'){
			if(r == 0) l++;
			else r--;
		}else{
			r++;
		}
	}
	
	for(int i = 0;i < l;i++){
		cout << "(";
	}
	cout << s;
	for(int i = 0;i < r;i++){
		cout << ")";
	}
	cout << endl;
 	
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split('\n')
	const slime = input[1].split('')
  
    const nakayoshiSlime = slime.reduce((accr, current) => {
      if (accr.length === 0 || accr[accr.length - 1] !== current) {
        accr.push(current)
      }
      return accr
    }, [])
    
    console.log(nakayoshiSlime.length)
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    if(i*10000>y)break;
    for(int j=0;j<=n;j++){
      if(n-i-j<0)break;
      if(i*10000+j*5000+(n-i-j)*1000==y){
	cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
	return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int max = 0;
        for (int i = 0; i < n; i++) {
            max += (a[i] - (-100))*(a[i]-(-100));
        }
        int min=max;
        for (int i = -100; i <101 ; i++) {
            int sum=0;
            for (int j = 0; j <n ; j++) {
                sum+=(a[j] - (i))*(a[j]-(i));


            }
            if (sum<min) {
                min=sum;
            }
        }
        System.out.println(min);

    }
}

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

int main() {
    int n;
    string S;
    cin >> n >> S;
    if(n%2==1){
        cout << "No" << endl;
        return 0;
    } else if(S.substr(0,n/2)==S.substr(n/2,n/2)){
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    int n;
    cin>>n;
    int A[n];
    map<int,int>mp;
    for(int  i=0; i<n; i++){
        cin>>A[i];
        mp[A[i]]++;
    }
    int odd=0,even=0;
    for(auto p:mp){
        if(p.second%2==0)even++;
        else odd++;
    }
    if(even%2==1)cout<<even+odd-1<<endl;
    else cout<<even+odd<<endl;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,X;
  cin>>A>>B>>C>>X;
  X=X/50;
 int sum=0;
  for(int i=0;i<=A;i++){
  for(int j=0;j<=B;j++){
  for(int k=0;k<=C;k++){
  if(10*i+2*j+k==X)
        sum++; 
  }
  
  }
  
  }   cout<<sum<<endl;
    

     return 0;
      }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s, t;
  cin >> s >> t;
  t = t.substr(0, s.size());
  if(s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<iostream>
int main()
{
    int k;
	char s[128];
	int sl;
    // 整数の入力
    scanf("%d", &k);
    scanf("%s", s);
	sl = strlen(s);

	if (k >= sl) {
		printf("%s\n",s);
	}else{
		s[k] = '.';
		s[k+1] = '.';
		s[k+2] = '.';
		s[k+3] = '\0';


		printf("%s\n",s);
	}
    // 出力

    return 0;
}


Measured memory_bytes: 3688
def main():
    A,B,C=map(int,input().split())
    K=int(input())
    cnt = 0
    for b in range(10):
        if A >= B:
            cnt += 1
            B *= 2
    for c in range(10):
        if B >= C:
            cnt += 1
            C *= 2
    if cnt <= K:
        print('Yes')
    else:
        print('No')
main()

Measured memory_bytes: 9176
#include <stdio.h>

int main() {
    int M[2], D[2];

    for (int i = 0; i < 2; i++) {
        scanf("%d %d", &M[i], &D[i]);
    }

    if (M[0] != M[1]) {
        printf("%d\n", 1);
        return 0;
    } else {
        printf("%d\n", 0);
        return 0;
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
using namespace std;
int main(void){
    ll n,k; cin>>n>>k;
    vl a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    vvl dp(n+1,vl(k+1,0));
    dp[0][0] = 1;
    for(int i=1;i<=n;++i){
        ll t = 0;
        for(int j=0;j<=k;j++){
            if(j <= a[i-1]) t += dp[i-1][j];
            else t += (dp[i-1][j]-dp[i-1][j-a[i-1]-1]);
            if(t < 0) t += 1000000007;
            t %= 1000000007;
            dp[i][j] = t;
        }
    }cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 80256
import numpy as np


def main():
    N, M, K = map(int, input().split())
    A = np.array([0] + [int(i) for i in input().split()])
    B = np.array([0] + [int(i) for i in input().split()])

    A.cumsum(out=A)
    B.cumsum(out=B)

    ans = 0
    j = M
    for i in range(N + 1):
        if A[i] > K:
            break
        while B[j] + A[i] > K:
            j -= 1
        ans = max(ans, i + j)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 53720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <math.h>
#include <bitset>
#include <fstream>
#define int long long
using namespace std;
signed main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    n--;
    for (int i=0;i<=n;i++){
        if ((n - i) % 2 != 0) continue;
        int have = (n - i) / 2;
        int l = a + i*c;
        int r = a + i*d;
        l -= (d - c) * (have);
        r += (d - c) * have;
        if (b >= l && b <= r){
            cout << "YES" << endl;
            return 0;
        }
        l = a - i*d;
        r = a - i*c;
        l -= (d - c) * (have);
        r += (d - c) * have;
        if (b >= l && b <= r){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)

int main()
{
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i, N) cin >> x[i];
  rep(i, M) cin >> y[i];

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  int maxX = x[N - 1];
  int minY = y[0];

  if (maxX < minY)
  {
    if (X < Y && X < minY && maxX < Y)
    {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

Measured memory_bytes: 256