akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++) 
#define ll long long

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    vector<vector<pair<int, int>>> xy(n);

    rep(i, 0, n) {
        cin >> a[i];
        rep(j, 0, a[i]) {
            int x, y;
            cin >> x >> y;
            xy[i].push_back(make_pair(x, y));
        }
    }

    int ans = 0;
    rep(bit, 1, (1<<n)) {
        bool ok = true;
        vector<bool> person(n);
        rep(i, 0, n) {
            person[i] = (bit >> i) & 1;
        }
        
        bool judge = false;
        int sum = 0;
        int count = 0;
        int trueman = 0;
        rep(i, 0, n) {
            if(person[i] == 1) {
                trueman++;
                sum += a[i];
                rep(j, 0, a[i]) {
                    if(person[xy[i][j].first-1] != xy[i][j].second) {
                        count = 0;
                        continue;
                    }
                    else {
                        count++;
                    }
                }
            }
        }

        if(count == sum) {
            ans = max(ans, trueman);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    n, a, b = list(map(int, input().split()))
    x = list(map(int, input().split()))
    e = 0
    for i in range(n - 1):
        e += min(abs(x[i + 1] - x[i]) * a, b)
    print(e)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14228
K,N=map(int,input().split())
#print(K,N)
A=list(map(int,input().split()))
#print(A)
#print(A[1:N])
#print(A[0:(N-1)])

D = max([i-j for i,j in zip(A[1:N], A[0:(N-1)])])
#print(D)
z = K - A[N-1] + A[0]
if z > D:
    D = z
print(K - D)


Measured memory_bytes: 26444
#include <stdio.h>
int main (){

int S[10000]; int T[500];
int n,q,i,j,count; count=0;
	scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&S[i]);
		}
	scanf("%d",&q);
		for(j=0;j<q;j++){
			scanf("%d",&T[j]);
		}
		
	for(j=0;j<q;j++){
		for(i=0;i<n;i++){
			if(S[i]==T[j]){
				count++;
				break;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1816
#include <algorithm>
#include <iostream>
#include <vector>
#include <iostream>
#include <cstdio>
#include <complex>
#include <utility>
#define X real()
#define Y imag()
#define EPS (1e-10)
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;
namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

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

double caliper(Poly p){
  int n = p.size();
  if(n <= 1) return 0;
  if(n == 2) return abs(p[0]-p[1]);

  int i = 0, j = 0;
  for(int k = 0; k < n; ++k){
    if(!(p[i] < p[k])) i = k;
    if(p[j] < p[k]) j = k;
  }
  
  double res = 0;
  int si = i, sj = j;
  while(i != sj || j != si){
    res = max(res, abs(p[i]-p[j]));
    if(cross(p[(i+1)%n]-p[i],p[(j+1)%n]-p[j]) < 0) i = (i+1)%n;
    else j = (j+1)%n;
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  Poly p;
  double x, y;
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    p.push_back(P(x,y));
  }
  printf("%.10lf\n", caliper(p));
  return 0;
}

Measured memory_bytes: 5460
n,x = map(int, input().split())
l = [int(input()) for _ in [0] * n]
l = sorted(l)
a = 0
for i in range(n):
    if 0 <= x - l[i]:
        x -= l[i]
        a += 1
    else:
        print(a)
        break
else:
    print(a + int(x/l[0]))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ld = long double;
int main()
{
    auto out = [](const ld y, const ld x, const ld sp) {
        const ld PI = 3.141592653589793;
        const ld F = 0.22451398828979266;
        const ld r1 = sqrt(sp / F / 5);
        const ld r2 = r1 * F / 0.5877852522924731;
        const ld theta = 0.1 * PI;
        for (int i = 0; i < 10; i++) {
            const ld s = theta * i * 2;
            const ld r = i % 2 == 0 ? r1 : r2;
            cout << fixed << setprecision(15) << x + r * cos(s) << " " << y + r * sin(s) << endl;
        }
    };
    int N;
    cin >> N;
    vector<ld> S(N);
    for (int i = 0; i < N; i++) { cin >> S[i]; }
    for (int i = 0; i < N; i++) {
        const ld y = (2 * (i / 10) + 1) * 500 - 5000;
        const ld x = (2 * (i % 10) + 1) * 500 - 5000;
        cout << i + 1 << endl;
        out(y, x, (i == 0 ? 1.5 * S[i] : (S[i] + S[i - 1]) * 0.5));
    }
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
    for (int i=0;i<M;i++){
      int A;
      cin >> A;
      N=N-A;
    }
  if (N>=0)cout << N << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

#include <sstream>
#include <istream>

using namespace std;

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



int main(){
	int a,b,c;

	cin >> a >> b >> c;
	if(a==b&&b==c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const int INF = 2e9 + 1;
int x[4] = {-1, 0, 1, 0};
int y[4] = {0, 1, 0, -1};
int dp[1010][1010];
struct node{
    int d;
    int nx;
    int ny;
};
bool operator< (const node &l, const node &r){
    return l.d > r.d;
};
void Main(){
    int h, w;
    cin >> h >> w;
    h += 2;
    w += 2;
    int sh, sw, gh, gw;
    cin >> sh >> sw >> gh >> gw;
    vector<string> s(h);
    string str = "";
    For(i,0,w) str += '#';
    s[0] = str;
    s[h-1] = str;
    For(i,1,h-1){
        cin >> s[i];
        s[i] = '#' + s[i] + '#';
    }
    For(i,0,h) For(j,0,w) dp[i][j] = INF;
    dp[sh][sw] = 0;
    priority_queue<node> que;
    node init;
    init.d = 0;
    init.nx = sh;
    init.ny = sw;
    que.push(init);
    while(!que.empty()){
        auto now = que.top();
        node to;
        que.pop();
        if(now.nx == gh && now.ny == gw) break;
        For(i,0,4){
            if(s[now.nx + x[i]][now.ny + y[i]] == '#'){
                continue;
            }
            if(dp[now.nx + x[i]][now.ny + y[i]] > now.d){
                dp[now.nx + x[i]][now.ny + y[i]] = now.d;
                to.d = now.d;
                to.nx =  now.nx + x[i];
                to.ny = now.ny + y[i];
                que.push(to);
            }
        }
        For(i, -2, 3){
            if(clamp(now.nx + i, 0, h-1) != now.nx + i) continue;
            For(j, -2, 3){
                if(clamp(now.ny + j, 0, w-1) != now.ny + j) continue;
                if(s[now.nx + i][now.ny + j] == '#') continue;
                if(dp[now.nx + i][now.ny + j] > now.d + 1){
                    dp[now.nx + i][now.ny + j] = now.d + 1;
                    to.d = now.d + 1;
                    to.nx =  now.nx + i;
                    to.ny = now.ny + j;
                    que.push(to);
                }               
            }
        }
    }
    /*For(i,0,h){
        For(j,0,w){
            cout << dp[i][j] << " \n"[j==w-1];
        }
    }*/
    if(dp[gh][gw] == INF) cout << -1 << endl;
    else cout << dp[gh][gw] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  double ax,bx,ay,by;
  cin >> ax >> ay >> bx >> by;
  cout << syo(5) << sqrt(pow(ax-bx,2.0)+pow(ay-by,2.0)) << endl;
}



Measured memory_bytes: 3280
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
void solve(){
  int n;cin>>n;vi a(n);vvi dp(n,vi(n,0));
  rep(i,0,n-1)cin>>a[i];
  per(i,n-1,0)
    rep(j,i,n-1){
      if(i==j)dp[i][j]=a[i];
      else{
        /*if((j-i+1)&1)*/dp[i][j]=max(a[i]-(i+1!=n?dp[i+1][j]:0),a[j]-(j-1!=-1?dp[i][j-1]:0));
        // else dp[i][j]=min(a[i]-(i+1!=n?dp[i+1][j]:0),a[j]-(j-1!=-1?dp[i][j-1]:0));
      }
    }
  cout<<dp[0][n-1];
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

inline ll gcd(ll a, ll b) {
  for (; a; swap(b %= a, a));
  return b;
}

signed main() {
    ll N;
    cin >> N;
    ll gcda = 0;
    rep(i, N) {
        ll a;
        cin >> a;
        gcda = gcd(a, gcda);
    }
    cout << (gcda%2 != 0 ? "first" : "second") << nl;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as np
def run():
    r1, c1, r2, c2 = map(int, read().split())
    mod = 10 ** 9 + 7

    def generate_inv(n, mod):
        """
        逆元行列
        n >= 2
        Note: mod must bwe a prime number
        """
        ret = [0, 1]
        for i in range(2, n + 1):
            next = -ret[mod % i] * (mod // i)
            next %= mod
            ret.append(next)
        return ret

    inv = generate_inv(10 ** 6 + 1, mod)



    def calc(i,j):
        ret = 0
        agg = 1
        for k in range(1, i+2):
            agg *= (j+k)%mod
            agg *= inv[k]
            agg %= mod
            ret += agg
        return ret


    ret = 0
    ret += calc(r2, c2)
    ret -= calc(r2, c1-1)
    ret -= calc(r1-1, c2)
    ret += calc(r1-1, c1-1)
    ret %= mod
    print(ret)

if __name__ == "__main__":
    run()

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

long long lmax(long long A,long long B){
	if(A>B)return A;
	else return B;
}

signed main() {
	int A,B,K;
	cin >>A>>B>>K;
	cout<<lmax(A-K,0)<<' '<<lmax(0,B-lmax(-A+K,0))<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final int NUM = 100;
	public static long dfs(long[][][] memo, int n, int low, int s){
		if(n == 0){
			return s == 0 ? 1 : 0;
		}else if(low > NUM){
			return 0;
		}
		
		if(memo[n][low][s] >= 0){
			return memo[n][low][s];
		}
		
		long ret = 0;
		for(int next = low; next <= NUM; next++){
			if(s - next < 0){
				break;
			}
			
			ret += dfs(memo, n - 1, next + 1, s - next);
		}
		
		return memo[n][low][s] = ret;
	}
	
	public static final int N = 10;
	public static final int SIZE = 1000;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long[][][] memo = new long[N + 1][NUM + 1][SIZE + 1];		
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= NUM; j++){
				for(int k = 0; k <= SIZE; k++){
					memo[i][j][k] = -1;
				}
			}
		}
		
		while(true){
			final int n = sc.nextInt();
			final int s = sc.nextInt();
			
			if(n == 0 && s == 0){
				break;
			}
			
			System.out.println(dfs(memo, n, 0, s));
		}
		
	}

}

Measured memory_bytes: 32040
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,i,s,t,l;
    cin>>n;
    for(i=sqrt(n);i>0;i--){
    if(n%i==0){
    t=i;
	l=n/i;
    s=1;
    while(l>=10){
    s++;
    l/=10;
    }
    cout<<s;
    return 0;
    }}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		if(a*a+b*b==c*c||a*a+c*c==b*b||c*c+b*b==a*a)
		printf("YES\n");
		else
		printf("NO\n");
	}
	return(0);
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n){
    cout << s[2*i];
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  int count=0;
  int Min=P.at(0);
  for(int i=0;i<N;i++){
    if(P.at(i)<=Min) count++;
    Min = min(P.at(i),Min);
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double eps=1e-8;
ll mod=1e9+7;
ll inf=1e9;
priority_queue<P> pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end() , l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower

  return R-L;
}

vector<ll> e[100000],v[100000];
ll n,m,a[100000],g[100000],cnt[100000],ans;
void dfs(ll p,ll c){
  if(g[p]!=-1)return;
  g[p]=c;
  v[c].push_back(a[p]);
  cnt[c]++;
  for(int i=0;i<(int)e[p].size();i++)dfs(e[p][i],c);
}

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0,x,y;i<m;i++)cin>>x>>y,e[x].push_back(y),e[y].push_back(x);
  memset(g,-1,sizeof(g));
  ll c=0;
  vector<ll> vv;
  for(int i=0;i<n;i++)
    if(g[i]==-1){
      dfs(i,c);
      sort(v[c].begin(),v[c].end());
      ans+=v[c][0];
      for(int j=1;j<(int)v[c].size();j++)vv.push_back(v[c][j]);
      c++;
    }
  sort(vv.begin(),vv.end());
  if(c==1)cout<<0<<endl;
  else if((int)vv.size()<c-2)cout<<"Impossible"<<endl;
  else{
    for(int i=0;i<c-2;i++)ans+=vv[i];
    cout<<ans<<endl;
  }
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, result = 0, sum = 0;
  string s;
  cin >> n >> s;
  rep(i, n) {
    if(s[i] == 'I') sum++;
    if(s[i] == 'D') sum--;
    if(result < sum) result = sum;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
from itertools import chain


def GCD(x, y):
    if y == 0:
        return x
    return GCD(y, x % y)


def prime_set(N):
    """
    Nまでの素数のsetを返す
    """
    if N < 4:
        return ({}, {}, {2}, {2, 3})[N]
    Nsq = int(N ** 0.5 + 0.5) + 1
    primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6)))
    for i in range(5, Nsq, 2):
        if i in primes:
            primes -= set(range(i * i, N + 1, i * 2))
    return primes


N = int(input())
A = list(map(int, input().split()))

g = 0
for a in A:
    g = GCD(g, a)


def is_coprime():
    U = 10 ** 6 + 1
    primes = prime_set(U)
    val = [0] * (U + 1)
    for a in A:
        if a == 1:
            continue
        if val[a]:
            return False
        val[a] = 1

    for p in primes:
        v = p
        cnt = 0
        while v < U:
            if val[v]:
                cnt += 1
            v += p
        if cnt >= 2:
            return False
    return True


if is_coprime():
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 126780
p = 1000000007
n = int(input())
A = list(map(int, input().split()))

ans = 1
cnt = [3 if i == 0 else 0 for i in range(n+1)]

for a in A:
    ans *= cnt[a]
    ans %= p
    cnt[a] -= 1
    cnt[a+1] += 1
print(ans)

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

int main()
{
  int n;
  while (scanf("%d", &n) != EOF){
    int cou = 0;

    for (int i = 0; i <= 9; i++){
      for (int j = 0; j <= 9; j++){
        for (int k = 0; k <= 9; k++){
          for (int l = 0; l <= 9; l++){
            if (i + j + k + l == n){
              cou++;
            }
          }
        }
      }
    }

  cout << cou << "\n";
  }

  return 0;
}

Measured memory_bytes: 1204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();

        //X[i]は、index i またはそれより西側にいる、西を向いている人の合計人数とする。
        int[] X = new int[N];
        X[0] = S[0] == 'W' ? 1 : 0;
        for (int i = 1; i < S.Length; i++)
        {
            X[i] = S[i] == 'W' ? X[i - 1] + 1 : X[i - 1];
        }

        int ans = (N - 1) - (X[N - 1] - X[0]);

        //index が iの人をリーダーとしてシミュレーションしてみる
        for (int i = 1; i < S.Length; i++)
        {
            //リーダーより西に居て西を向いている人数＋リーダーより東に居て東を向いている人数
            int val1 = X[i - 1];
            int val2 = (N - i - 1) - (X[N - 1] - X[i]);
            ans = Math.Min(ans, val1 + val2);
        }

        Console.WriteLine(ans);
    }
}


static class MathUtil
{
    public static T Max<T>(params T[] datas)
    {
        return datas.Max();
    }

    public static T Min<T>(params T[] datas)
    {
        return datas.Min();
    }

    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


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

typedef long long ll;
#define INF INT_MAX
#define MAXN 200005

int checkdiff(vector<pair<int,char>> v)
{
    int diff = INF;
    for(int i = 1 ; i < (int)v.size() ; i++){
        diff = min(v[i].first - v[i-1].first,diff);
    }
    return diff;
}



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

    string s;
    cin >> s;
    int len = s.length();
    for(int i = 0 ; i < len ; i++){
        s[i] = 'x';
    }
    cout << s << '\n';

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

const mod = 1e9 + 7

func intsHaveDuplicateElm(a []int) bool {
	m := make(map[int]bool, len(a))
	for _, aa := range a {
		if _, exists := m[aa]; exists {
			return true
		} else {
			m[aa] = true
		}
	}
	return false
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&bs[i])
	}

	if intsHaveDuplicateElm(as) || intsHaveDuplicateElm(bs) {
		fmt.Println(0)
		return
	}

	sort.Sort(sort.Reverse(sort.IntSlice(as)))
	sort.Sort(sort.Reverse(sort.IntSlice(bs)))

	aExists := make([]bool, n*m+1)
	for _, aa := range as {
		aExists[aa] = true
	}
	aGreater := make([]int, n*m+1)
	for _, aa := range as {
		aGreater[1]++
		aGreater[aa]--
	}
	for i := 2; i < len(aGreater); i++ {
		aGreater[i] += aGreater[i-1]
	}

	bExists := make([]bool, n*m+1)
	for _, bb := range bs {
		bExists[bb] = true
	}
	bGreater := make([]int, n*m+1)
	for _, bb := range bs {
		bGreater[1]++
		bGreater[bb]--
	}
	for i := 2; i < len(bGreater); i++ {
		bGreater[i] += bGreater[i-1]
	}

	calc := func(x int) int {
		if aExists[x] && bExists[x] {
			return 1
		} else if aExists[x] {
			return bGreater[x]
		} else if bExists[x] {
			return aGreater[x]
		} else {
			return aGreater[x]*bGreater[x] - (n*m - x)
		}
	}

	ans := 1
	for i := n * m; i >= 1; i-- {
		ans = ans * calc(i) % mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 17280
def BWstripper(S):
  BWarray=[]
  while (len(S) != 0):
    initial = S[0]
    tmp=""
    while (S[0] == initial):
      tmp+=S[0]
      S=S.lstrip(initial)
      if len(S) == 0:
        break
    BWarray.append(tmp)
  return BWarray
S=input()
stripped = BWstripper(S)
print(len(stripped)-1)

Measured memory_bytes: 3992
n,q = map(int, input().split())
tree = [set() for i in range(n+1)]
for _ in range(n-1):
  a,b = map(int, input().split())
  tree[a].add(b)
  tree[b].add(a)
lazy = [0]*(n+1)
cnt = 0

for _ in range(q):
  x,v = map(int, input().split())
  lazy[x] += v

que = [(1,0)]
while que:
  v,p = que.pop()
  for x in tree[v]:
    if x == p:
      continue
    lazy[x] += lazy[v]
    que.append((x,v))

print(" ".join(map(str,lazy[1:])))

Measured memory_bytes: 92416
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

typedef vector<int> VI;
typedef pair <int, int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

struct pI {
	int x, y;
};

LL detI(pI& a, pI& b, pI& c) {
	return a.x * 1LL * b.y + b.x * 1LL * c.y + c.x * 1LL * a.y - a.x * 1LL * c.y - b.x * 1LL * a.y - c.x * 1LL * b.y;
}

int ccwI(pI& a, pI& b, pI& c) {
	LL d = detI(a, b, c);
	return (d > 0) ? 1 : ((d < 0) ? -1 : 0);
}

double od(double a, double b, double c, double d) {
	return sqrt((a - c) * 1LL * (a - c) + (b - d) * 1LL * (b - d));
}


bool obliczOkrag(pI a, pI b, pI c, double& x, double& y, double& r) {
	if (ccwI(a, b, c) == 0) return false;
	double ma, mb;
	if (a.x == b.x) swap(b, c);
	if (b.x == c.x) swap(a, b);
	ma = ((b.y - a.y)*1.0) / (b.x - a.x);
	mb = ((c.y - b.y)*1.0) / (c.x - b.x);
	x = (ma * mb * (a.y - c.y) + mb * (a.x + b.x) - ma * (b.x + c.x)) / (2 * (mb - ma));
	y = (-1 / ma) * (x - (a.x + b.x) / 2.0) + (a.y + b.y) / 2.0;
	r = od(a.x, a.y, x, y);
	return true;
}

double minR, x, y, r;
int n, i, j, l;
pI tab[55];
const double eps = 1e-8;

void check() {
	int ok = 1;
	for (int k = 0; k < n; k++) if (od(tab[k].x, tab[k].y, x, y) > r + eps) ok = 0;
	if (ok) minR = min(minR, r);
}

int main() {
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d %d", &tab[i].x, &tab[i].y);
	minR = INF;
	for (i = 0; i < n; i++) for (j = i + 1; j < n; j++) {
		x = (tab[i].x + tab[j].x) / 2.0;
		y = (tab[i].y + tab[j].y) / 2.0;
		r = od(tab[i].x, tab[i].y, x, y);
		check();
	}
	for (i = 0; i < n; i++) for (j = i + 1; j < n; j++) for (l = j + 1; l < n; l++) {
		if (obliczOkrag(tab[i], tab[j], tab[l], x, y, r)) check();
	}
	printf("%.10lf\n", minR);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(H, W):
    if H % 3 == 0 or H % 3 == 0:
        return 0

    L = max(H, W)
    S = min(H, W)

    def f1(L, S):
        if (math.ceil(L/3) - L/3) < (L/3 - math.floor(L/3)):
            SL = math.ceil(L/3)
        else:
            SL = math.floor(L/3)
        A = SL * S

        L -= SL
        if L < S:
            L, S = S, L

        if L % 2 == 0 or S % 2 == 0:
            B = C = (L * S) // 2
        else:
            if (math.ceil(L/2) - L/2) < (L/2 - math.floor(L/2)):
                SL = math.ceil(L/2)
            else:
                SL = math.floor(L/2)
            B = SL * S
            C = (L-SL) * S
        return max([A, B, C]) - min([A, B, C])

    def f2(L, S):
        if (math.ceil(S/3) - S/3) < (S/3 - math.floor(S/3)):
            SL = math.ceil(S/3)
        else:
            SL = math.floor(S/3)
        A = SL * L

        S -= SL
        if L < S:
            L, S = S, L

        if L % 2 == 0 or S % 2 == 0:
            B = C = (L * S) // 2
        else:
            if (math.ceil(L/2) - L/2) < (L/2 - math.floor(L/2)):
                SL = math.ceil(L/2)
            else:
                SL = math.floor(L/2)
            B = SL * S
            C = (L-SL) * S
        return max([A, B, C]) - min([A, B, C])

    return min(f1(H, W), f2(H, W))


def main():
    H, W = read_int_n()

    print(slv(H, W))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5584
n = int(input())
a = 0
w = 0
t = 0
r = 0
l = []
for i in range(n):
    l.append(input())

print("AC x", l.count("AC"))
print("WA x", l.count("WA"))
print("TLE x", l.count("TLE"))
print("RE x", l.count("RE"))

Measured memory_bytes: 82596
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(); cout.tie()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl '\n'
#define len(a) a.length()
#define TIME cout << endl << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
#define f first
#define s second

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

const int Iinf = 1e9;
const long long LLinf = 1e18;
const double eps = 1e-6;
const long long mod = 998244353;

bool is_prime (ll a) {
    for (ll i = 2; i <= sqrt(a); i++)
        if (a % i == 0)
            return false;
    return true;
}

ll binpow (ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1LL)
			res = (res * a) % mod;
		a = (a * a) % mod;
		n >>= 1LL;
	}
	return res;
}

ll string_to_int (string s) {
    reverse(all(s));
    int pw = 1;
    int ans = 0;
    for (int i = 0; i < len(s); i++) {
        ans += (s[i] - '0') * pw;
        pw *= 10;
    }
    return ans;
}

ll div_up (ll x, ll y) {
    if (x == 0)
        return 0;
    return (x - 1) / y + 1;
}

int32_t main()
{
    boost;
    int n; cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x % 2 == 1 & i % 2 == 0)
            ans++;
    }
    cout << ans;
    return 0;
}

/*

*/


Measured memory_bytes: 3596
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, r;
  cin >> n >> r;
  if (n>=10) { cout << r << endl; return; }
  cout << r + 100*(10-n) << endl;
  
}


Measured memory_bytes: 3552
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,L,x[300005],t[300005],l[300005],r[300005];
bool vis[300005];
long long ans=0;
int read()
{
	char c=getchar();
	int res=0,bj=1;
	while(c<'0'||c>'9'){if(c=='-') bj=-1;c=getchar();}
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res*bj;
}
int main()
{
	n=read(),L=read();ans=n+1;
	for(int i=1;i<=n;i++) x[i]=read();
	for(int i=1;i<=n;i++)
	{
		t[i]=read();
		ans+=t[i]/(L<<1);t[i]%=(L<<1);
	}
	for(int i=1;i<=n;i++)
	{
		if(!t[i])
		{
			ans--;vis[i]=1;
			continue;
		}
		l[i]=2*(L-x[i])>=t[i];r[i]=2*x[i]>=t[i];
		vis[i]=!(l[i]|r[i]);
	}
	ans-=l[n];
	int pos=n,num=0,sum=0;
	for(int i=1;i<n;i++)
	{
		if(vis[i]) continue;
		if(!l[i])
		{
			pos=i;
			break;
		}
		if(r[i]) num++;
		else
		{
			if(num) num--,ans--;
		}
	}
	sum=num,num=0;
	for(int i=n-1;i>=pos;i--)
	{
		if(vis[i]) continue;
		if(!r[i]) break;
		if(l[i]) num++;
		else
		{
			if(num) num--,ans--;
		}
	}
	printf("%lld\n",2ll*L*(ans-(sum+num)/2));
}

Measured memory_bytes: 8720
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ld l;std::cin >> l;
  ld a = l/3;
  ld ans = a*a*a;
  std::cout << fixed << setprecision(20) << ans << '\n';

  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void)
{
  int num1,num2;
  double add,sub,mul,ans1,ans;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d %d",&num1,&num2);
  
  add = (double)num1 + (double)num2;
  sub = (double)num1 - (double)num2;
  mul = (double)num1 * (double)num2;
  
  ans1 = fmax(add,sub);
  ans = fmax(ans1,mul);
  
  printf("%d",(int)ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>



template<class T> struct AdjMat { //adjacency matrix
  using size_t = std::size_t;
  size_t n; T e; std::vector<std::vector<T>> dat;
  AdjMat() {}
  AdjMat(size_t n, T e) : n(n), e(e), dat(n, std::vector<T>(n, e)) {}
  void init(size_t n) { this->n = n; dat.resize(n); for(size_t i=0;i<n;++i) dat[i].assign(n, e); }
  auto& operator[](size_t i) { return dat[i]; }
  void wf() { // WarshallFloyd
    for(size_t k=0; k<n; ++k) for(size_t i=0; i<n; ++i) for(size_t j=0; j<n; ++j) {
      if(dat[i][k] == e || dat[k][j] == e) continue;
      T t = dat[i][k] + dat[k][j];
      if(dat[i][j] == e || t < dat[i][j]) dat[i][j] = t;
    }
  }
  auto begin() { return dat.begin(); }
  auto end() { return dat.end(); }
};



#include <iostream>

void abc143_e() {
  using namespace std;
  int N, M;
  long long L;
  cin >> N >> M >> L;
  AdjMat<long long> g(N, 0);
  for(int i=0;i<M;++i) {
    int A, B, C;
    cin >> A >> B >> C;
    --A; --B;
    g[A][B] = C;
    g[B][A] = C;
  }

  g.wf();
  for(auto& v : g) for(auto& e : v) e = (e != g.e && e <= L ? 1 : g.e);
  g.wf();

  int Q; cin >> Q;
  for(int i=0;i<Q;++i) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    cout << g[s][t]-1 << '\n';
  }
}

signed main() {

  abc143_e();

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		int h,w;
           cin>>h>>w;
           vst a(h);
           rep(i,0,h)cin>>a[i];
           map<char,int> cnt;
           rep(i,0,h){
            rep(j,0,w)cnt[a[i][j]]++; 
           }
           int p=0,q=0,r=0;
           for(auto v:cnt){
             if(v.second%4==1)p++;
             else if(v.second%4==2)q++;
             else if(v.second%4==3)r++;
           }
           if(h%2==0&&w%2==0){
             Yes(p==0&&q==0&&r==0);
           }
           else if(h%2==0){
             Yes(p==0&&r==0&&q<=(h/2));
           }
           else if(w%2==0){
             Yes(p==0&&r==0&&q<=(w/2));
           }
           else{
            while(r){
              r--;
              p++;
              q++;
            }
             Yes(p==1&&q<=(h/2+w/2));
           }
}



Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n, r, p, c;
	int *before, *after;
	while(cin >> n >> r && n){
		before = new int[n];
		after = new int[n];
		for(int i=0; i<n; i++) before[i]=n-i, after[i]=n-i;
		for(int i=0; i<r; i++){
			cin >> p >> c;
			for(int i=0; i<c; i++) after[i] = before[p-1+i];
			for(int i=0; i<p-1; i++) after[c+i] = before[i];
			for(int i=0; i<n; i++) before[i]=after[i];
		}
		cout << after[0] << endl;
		delete[] after;
		delete[] before;
	}
	return 0;
}

Measured memory_bytes: 1196
n,k = map(int,input().split())
p = list(map(int,input().split()))

c=0
x=0
m=sum(p[0:k])
z=m
for i in range(1,n-k+1):
#  print(z,p[i-1],p[i+k-1])
  z=z-p[i-1]+p[i+k-1]
#  print(m,z)
  if m<z:
    m=z
    x=i
#print(x)
for i in range(x,x+k):
#  print(p[i])
  c+=((p[i]*(p[i]+1))/2)/p[i]
print(c)

Measured memory_bytes: 25060
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World";
    }else{
        int a,b;
        cin>>a>>b;
        cout<<a+b;
    }
    return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int num;
    num = 100*a+10*b+c;
    if(num%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	string str;
	vector<int> alpha('z'-'a'+1,50);
	for (int i = 0; i < n; ++i) {
		cin >> str;
		map<int,int> counter;
		for (int j = 0; j < str.length(); ++j) {
			++counter[(int)str[j]-'a'];
		}

		for (int j = 0; j < ('z'-'a'+1); ++j) {
			alpha[j] = min(alpha[j],counter[j]);
		}
	}
	string res = "";
	for (int i = 0; i < ('z'-'a'+1); ++i) {
		for (int j = 0; j < alpha[i]; ++j) {
			res += (char)('a' + i);
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
N=input()
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])
if A+B+C+D==7: print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B+C-D==7: print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A+B-C+D==7: print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A+B-C-D==7: print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A-B+C+D==7: print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A-B+C-D==7: print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A-B-C+D==7: print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B-C-D==7: print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    sort(a, a + 3);

    int ans = 0;

    ans += a[2] - a[1];
    a[0] += a[2] - a[1];
    a[1] += a[2] - a[1];
    // printf("%d\n", ans);
    // for(int i = 0; i < 3; i++){
    //     printf("%d ", a[i]);
    // }
    // puts("");
    if ((a[2] - a[0]) % 2 == 0){
        ans += (a[2] - a[0]) / 2;
    }else {
        ans += (a[2] - a[0]) / 2 + 2;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
A = list(input())
B = list(input())
C = list(input())

next = A.pop(0)
while True:
    if next == 'a':
        if len(A) == 0:
            print('A')
            exit()
        else:
            next = A.pop(0)
    elif next == 'b':
        if len(B) == 0:
            print('B')
            exit()
        else:
            next = B.pop(0)        
    elif next == 'c':
        if len(C) == 0:
            print('C')
            exit()
        else:
            next = C.pop(0)


Measured memory_bytes: 3060
program main
	implicit none
	integer :: N, M
	integer, allocatable :: T(:), P(:), X(:)
	integer :: S, i
	
	read(*, *) N
	allocate(T(1:N))
	read(*, *) T
	read(*, *) M
	allocate(P(1:M), X(1:M))
	do i = 1, M
		read(*, *) P(i), X(i)
	end do
	
	S = sum(T)
	do i = 1, M
		write(*, *) S + X(i) - T(P(i))
	end do
	
end program main

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

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
  mint val;
  mint sz;
};

struct F {
  mint a;
  mint b;
};

S op(S l, S r) {
  return {l.val + r.val, l.sz + r.sz};
};

S e() {
  return {0, 0};
}

S mapping(F f, S s) {
  return {f.a * s.val + f.b * s.sz, s.sz};
}

F composition(F g, F f) {
  return {f.a * g.a, f.b * g.a + g.b};
}

F id() {
  return {1, 0};
}

using lseg = lazy_segtree<S, op, e, F, mapping, composition, id>;

int main() {
  int N, Q; cin >> N >> Q;
  vector<S> v;
  for (int i = 0; i < N; i++) {
    int t; cin >> t;
    v.push_back(S{t, 1});
  };
  auto s = lseg(v);
  while (Q--) {
    int q; cin >> q;
    if (q == 0) {
      int l, r, b, c; cin >> l >> r >> b >> c;
      s.apply(l, r, {b, c});
    } else {
      int l, r; cin >> l >> r;
      cout << s.prod(l, r).val.val() << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 19488
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=1<<18;


int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    vector<ll> f(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<n;i++) cin>>f[i];
    sort(a.begin(),a.end());
    sort(f.begin(),f.end(),greater<ll>());

    ll ub=100100100100100;
    ll lb=-1;

    while(ub-lb>1){
        ll med=(ub+lb)/2;
        ll cnt=0;
        for(ll i=0;i<n;i++){
            if(med<a[i]*f[i]) cnt+=a[i]-med/f[i];
        }
        if(cnt>k){
            lb=med;
        }else{
            ub=med;
        }
    }

    ll cnt=0;
    for(ll i=0;i<n;i++){
        cnt+=a[i]-lb/f[i];
    }

    cout<<ub<<endl;
 
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

bool ok(int left, int mid, int l, int m) {
   bool flag = false;
   if ((mid-left)&1) {
      if (l != m) flag = true;
   } else {
      if (l == m) flag = true;
   }
   return flag;
}

int query(int x) {
   cout << x << endl;
   string s;
   cin >> s;
   if (s == "Male") {
      return 0;
   } else if (s == "Female") {
      return 1;
   } else {
      exit(0);
   }
}

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

   int left = 0, right = n;
   int mid = (left+right)/2;
   int l = query(left), m = query(mid);

   rep (i, 0, 18) {
      // 矛盾の判定
      if (ok(left, mid, l, m)) { // 矛盾無し
         left = mid;
         l = m;
      } else { // 矛盾有り
         right = mid;
      }
      mid = (left + right) / 2;
      m = query(mid);
   }

   return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    double d; cin >> d;
    printf("%.12f\n", max(sqrt(2)*d, (int)d + 1.0));
    return 0;
}

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

#define INF 1000000

int n;
int *p;
int **m;

void mchain();

int main(){
  int i;

  scanf("%d",&n);

  p = (int *)malloc((n+1) * sizeof(int));
  m = (int **)malloc((n+1) * sizeof(int *));
  
  for(i=0; i<n; i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  
  for(i=0; i<n+1; i++){
    m[i] = (int *)malloc((n+1) * sizeof(int));
  }

  mchain();
  printf("%d\n",m[1][n]);
  
  for(i=0; i<n+1; i++)
    free(m[i]);
  free(m);
  free(p);
  return 0;
}

void mchain(){
  int i,j,k,l;
  int q;
  
  for(i=1; i<=n; i++)
    m[i][i] = 0;

  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i+l-1;
      m[i][j] = INF;

      for(k=i; k<j; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j]>q)
	  m[i][j] = q;
      }
    }
  }
}



Measured memory_bytes: 2104