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

struct edge {int /*from**/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

string s,t,ans,tmp;

signed main(){
    cin >> s >> t;
    int a = s.length();
    int b = t.length();
    ans="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    for(int i=0;i<a;i++){
        bool rullonz = false;
        for(int j=0;j<b;j++){
            if(s[i+j]!=t[j]&&s[i+j]!='?'){rullonz = false;break;}
            if(j==b-1){
                rullonz = true;
                //printf("%d %d\n",i,j);
            }
        }
        if(rullonz){
            //printf("%d\n",i);
            tmp = s;
            tmp.replace(i,b,t);
            for(int k=0;k<a;k++){
                if(tmp[k]=='?') tmp[k] = 'a';
            }
            if(ans>tmp) ans = tmp;
        }
    }
    if(ans=="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") printf("UNRESTORABLE\n");
    else cout << ans << endl;
    return 0;
}

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

using namespace std;

long long module(long long x, long long m){
    while(x >= m) x -= m;
    return x;
}

long long mul(long long a, long long b, long long mod){
    if(b == 0) return 0;
    long long res = mul(module(a + a, mod), b / 2, mod);
    if(b & 1) res = module(res + a, mod);
    return res;
}

long long pow(long long a, long long b, long long mod){
    if(b == 0) return 1;
    long long res = pow(mul(a, a, mod), b / 2, mod);
    if(b & 1) res = mul(res, a, mod);
    return res;
}

long long inv(long long a, long long mod){
    return pow(a, mod - 2, mod);
}


int main(){
    int N;
    const long long P = 10000000019;
    while(cin >> N){
        long long X = 0;
        for(int i = 0; i < N; i++){
            int ope;
            long long Y;
            cin >> ope >> Y;
            if(ope == 1){
                X = (X + Y + P) % P;
            }else if(ope == 2){
                X = (X - Y + P) % P;
            }else if(ope == 3){
                X = mul(X, abs(Y), P);
                if(Y < 0) {
                    X = (-X + P) % P;
                }
            }else{
                X = mul(X, inv(abs(Y), P), P);
                if(Y < 0) {
                    X = (-X + P) % P;
                }
            }
            //cout << X << endl;
        }
        if(X > INT_MAX){
            X = X - P;
        }
        cout << X << endl;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n+2);
    rep(i,n+1) cin >> a[i];
    b[0] = 0;
    rep(i,n) cin >> b[i+1];
    b[n+1] = 0;
    ll sum = 0;
    for (int i = n; i >= 0; i--) {
        ll subst = min(a[i],b[i+1]+b[i]);
        if (b[i+1] < subst) b[i] = b[i] - (subst-b[i+1]);
        sum += subst;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<((b*10+c)%4==0?"YES":"NO")<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1000100;
vector<int> g;
int n,k,x,y,a[N],b[N*2],ne[N*2],fi[N],only_child[N];
bool f[N];
void out(){
	for (int i=1; i<=n; i++) printf("%d ",f[i]); printf("\n");
	for (int i=1; i<=n; i++) printf("%d ",only_child[i]); printf("\n");
}
void add(int x,int y){
	b[++k]=y; ne[k]=fi[x]; fi[x]=k;
}
void dfs(int x,int fa){
	for (int j=fi[x]; j; j=ne[j])
	if (b[j]!=fa){
		dfs(b[j],x);
		if (a[b[j]]>=a[x]) continue;
		if (!f[b[j]]&&!f[x]) only_child[x]=b[j],f[x]=1;
		else if (!f[b[j]]&&f[x]) only_child[x]=0;
	}
}
void myrotate(int fa,int x){
	if (!fa) return;
	if (only_child[fa]==x){
		f[fa]=0;
		only_child[fa]=0;
	}
	if (a[fa]<a[x]&&!f[x]&&!f[fa]){
		f[x]=1;
		only_child[x]=fa;
	}
}
void calc(int x,int fa){
	myrotate(fa,x);
	if (f[x]) g.push_back(x);
	for (int j=fi[x]; j; j=ne[j])
	if (b[j]!=fa) calc(b[j],x);
	myrotate(x,fa);
}
void read(int &x){
	x=0;
	char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}
int main(){
//	freopen("3.in","r",stdin);
//	freopen("3rr.out","w",stdout);
	read(n);
	for (int i=1; i<=n; i++) read(a[i]);
	for (int i=1; i<n; i++){
		read(x); read(y);
		add(x,y); add(y,x);
	}
	dfs(1,0);
	calc(1,0);
	sort(g.begin(),g.end());
	for (unsigned int i=0; i<g.size(); i++) printf("%d ",g[i]);
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;
    int d=c/a;
    cout<<d*b<<endl;

    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(){
  int a,b,c,d;
  int tmp;
  scanf("%d %d %d %d",&a,&b,&c,&d);

  while(1){
    tmp= c-b;
    if(tmp<=0){
      printf("Yes\n");
      return 0;
    }
    c = tmp;
    tmp = a-d;
    if(tmp<=0){
      printf("No\n");
      return 0;
    }
    a = tmp;
  }

  return 0;
}

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

int main() {
  string s1,s2;
  cin >> s1 >> s2 ;

  if (s1 == s2) {
    cout << "=" << endl;
  }
  else if (s1 < s2) {
    cout << "<" << endl;
  }
  else {
    cout << ">" << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){
    int N,i,s=0,L[200];
    std::cin>>N;
    for(i=0;i<N*2;++i)std::cin>>L[i];
    std::sort(L,L+i);
    for(i=0;i<N*2;i+=2)s+=L[i];
    std::cout<<s;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n=0 ,i ,x ;
    scanf("%d",&n);

    for (i=1 ;i<n+1 ;i++){
        x=i;
        if ((x%3)==0){
            printf(" %d",i);
        } else while(1){
            if ((x%10)==3){
                printf(" %d",i);
                break;
            }
            x/=10;
            if (!x) break;
        }
    }

    printf("\n");
    return 0;
}

Measured memory_bytes: 600
import itertools

n = int(input())
a = list(map(int,input().split()))

su = sum(a)
ruisekiwa = list(itertools.accumulate(a))
ruisekiwa.pop()
ans = 10**99

for i in ruisekiwa:
  ans = min(ans,abs(su - 2*i))
  
print(ans)



Measured memory_bytes: 24168
N, A, B = [int(n) for n in input().split(" ")]

cnt = 0

for n in range(1,N+1):
  temp = 0
  temp += n%10
  temp += int(n/10)%10
  temp += int(n/10/10)%10
  temp += int(n/10/10/10)%10
  temp += int(n/10/10/10/10)%10
  if temp >= A and temp <= B:
    cnt += n

print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> p(m);
	vector<ll> y(m);
	vector<pair<ll, ll>> a(m), b(m);
	rep(i, m) {
		cin >> p[i] >> y[i];
		a[i] = make_pair(y[i], i);
	}
	
	sort(a.begin(), a.end());

	map<ll, ll> mp;
	int c[100001] = {};

	rep(i, m) {
		mp[a[i].first] = ++c[p[a[i].second]];
	}

	rep(i, m) {
		cout << setw(6) << setfill('0') << right << p[i];
		cout << setw(6) << setfill('0') << right << mp[y[i]] << endl;
	}

	return 0;
}

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

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

	int i = 0, x;
	while (++i <= n)
	{
		x = i;
		if (x % 3 == 0) 
		{
			cout << " " << i;
			continue;
		}
		while (x)
		{
			if (x % 10 == 3) 
			{
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 1160
program main
  implicit none
  integer i, N, K
  character(50) S
  read(*, *) N, K
  read(*, *) S
  if (S(K:K) == 'A') then
    S(K:K) = 'a'
  end if
  if (S(K:K) == 'B') then
    S(K:K) = 'b'
  end if
  if (S(K:K) == 'C') then
    S(K:K) = 'c'
  end if

  write(*,'(A)') S
end program main


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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];
void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}
ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}
//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}

set<ll> s;
void dfs(ll x)
{
    s.insert(x);
    if(x>323456669)
        return;
    if(x%10>0)
        dfs(x%10-1+x*10);
     if(x%10<9)
        dfs(x%10+1+x*10);

        dfs(x*10+x%10);
}
int main() {
    FAST
int k;
    cin>>k;
    k--;
    for(int i=1;i<=9;i++)
        dfs(i);
    while(k--)
        s.erase(s.begin());
    cout<<*s.begin()<<endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=305*2,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n;
int a[N],b[N];
int cnt=0,tot=0;
int dp[N][N][N];
vector <int> v;
int main(){
	n=read();
	For(i,1,n*2){
		a[i]=read();
		if (a[i]!=-1)
			b[a[i]]=1;
	}
	For(i,1,n){
		if (a[i*2-1]==-1&&a[i*2]==-1)
			cnt++,tot+=2;
		else if (a[i*2-1]==-1)
			tot+=2,v.pb(a[i*2]);
		else if (a[i*2]==-1)
			tot+=2,v.pb(a[i*2-1]);
	}
	For(i,1,n*2)
		if (!b[i])
			v.pb(i);
	sort(v.begin(),v.end());
	v.pb(0);
	reverse(v.begin(),v.end());
	dp[0][0][0]=1;
	For(i,1,tot)
		For(j,0,tot)
			For(k,0,tot){
				int val=dp[i-1][j][k];
				if (!val)
					continue;
				if (!b[v[i]]){
					Add(dp[i][j+1][k],val);
					if (j>0)
						Add(dp[i][j-1][k],val);
					if (k>0)
						Add(dp[i][j][k-1],(LL)val*k%mod);
				}
				else {
					Add(dp[i][j][k+1],val);
					if (j>0)
						Add(dp[i][j-1][k],val);
				}
			}
	int ans=dp[tot][0][0];
	For(i,1,cnt)
		ans=(LL)ans*i%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 872704
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long T = scan.nextLong();
        List<Pair> zero_list = new ArrayList<>();
        List<Pair> non_zero_list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            long a = scan.nextLong();
            long b = scan.nextLong();
            Pair p = new Pair(a, b);
            if (a == 0) {
                zero_list.add(p);
            } else {
                non_zero_list.add(p);
            }
        }

        zero_list.sort(new ZeroPairComparator());
        long[] z = new long[zero_list.size()+1];
        for (int i = 0; i < zero_list.size(); i++) {
            z[i + 1] = Math.min(z[i] + zero_list.get(i).b + 1, T + 1);
        }
        TreeMap<Long, Integer> zero_tree = new TreeMap<>();
        for (int i = 0; i < z.length; i++) {
            zero_tree.put(z[i], i);
        }

        non_zero_list.sort(new NonZeroPairComparator());
        long[] dp = new long[41];
        Arrays.fill(dp, T+1);
        dp[0] = 0;
        int len = non_zero_list.size();
        for (int i = 0; i < len; i++) {
            long[] next_dp = new long[41];
            Arrays.fill(next_dp, T+1);
            Pair p = non_zero_list.get(i);
            for (int j = 40; 0 <= j; j--) {
                if ( T < dp[j]) {
                    next_dp[j] = Math.min(next_dp[j], T+1);
                    continue;
                }
                long time = dp[j] + 1 + p.a * (dp[j] + 1) + p.b;
                if (T < time) {
                    next_dp[j] = Math.min(next_dp[j], dp[j]);
                    continue;
                }
                next_dp[j+1] = Math.min(next_dp[j+1], Math.min(dp[j+1],time));
                next_dp[j] = Math.min(next_dp[j], dp[j]);
            }
            dp = next_dp;
        }
        long ans = 0;
        for (int i = 0; i <= 40; i++) {
            if (T < dp[i]) {
                continue;
            }
            long count = i;
            long x = zero_tree.floorKey(T - dp[i]);
            ans = Math.max(ans, count + zero_tree.get(x));
        }
        System.out.println(ans);
    }

    class Pair {
        long a;
        long b;
        Pair(long a, long b) {
            this.a = a;
            this.b = b;
        }
    }

    class ZeroPairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.b, o2.b);
        }
    }

    class NonZeroPairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            return -Long.compare(o1.a * (o2.b + 1), o2.a * (o1.b+1));
        }
    }
}


Measured memory_bytes: 159384
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main(void){
  char s[1000];
  uint64_t r;
  fgets(s, 1000, stdin);
   r=strtoul(s,NULL,0);
  printf("%ld\n",r*r);
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> deg(n,0);
  vector<int> a(n);
  vector<vector<int>> dp(n);
  for(int i=1;i<n;i++){
    cin >> a[i];
    a[i]--;
    deg[a[i]]++;
  }
  queue<int> que;
  for(int i=0;i<n;i++){
    if(deg[i]==0){
      dp[a[i]].push_back(0);
      deg[a[i]]--;
      // cout << i+1 SP 0 << endl;
      if(deg[a[i]]==0) que.push(a[i]);
    }
  }
  int now;
  int ans=0;
  while(!que.empty()){
    now=que.front();
    que.pop();
    int ans=0;
    sort(all(dp[now]));
    for(int i=0;i<dp[now].size();i++){
      ans=max(ans,dp[now][i]-i);
    }
    ans+=dp[now].size();
    // cout << now+1 SP ans << endl;
    if(now==0){
      cout << ans << endl;
      return 0;
    }
    dp[a[now]].push_back(ans);
    deg[a[now]]--;
    if(deg[a[now]]==0) que.push(a[now]);
  }
  return 0;
}

Measured memory_bytes: 6528
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().ToCharArray();

            var result = 0;
            var dist = 0;

            foreach(var i in Enumerable.Range(0, N))
            {
                if(i==0)
                {
                    //すべての距離を計算
                    foreach(var j in Enumerable.Range(1, N-1))
                    {
                        if (S[j] == 'E') dist++;
                    }
                    result = dist;
                }
                else
                {
                    //前の項の距離を加算
                    if (S[i - 1] == 'W') dist++;
                    //今の項の距離を除外
                    if (S[i] == 'E') dist--;
                    if (dist < result) result = dist;
                }
            }

            Console.WriteLine(result);
        }
    }

}


Measured memory_bytes: 14816
#include <stdio.h>

int heap[500001],n;


int parent(int x)
{
  return x/2;
}

int left(int x)
{
  return x*2;
}

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



void maxHeapify(int *heap,int i)
{
  int l,r,largest,tmp;
  l = left(i);
  r = right(i);

  if(l <= n && heap[l] > heap[i]) largest = l;
  else largest = i;

  if(r <= n && heap[r] > heap[largest]) largest = r;

  if(largest != i){

    tmp=heap[i];
    heap[i]=heap[largest];
    heap[largest]=tmp;

    maxHeapify(heap,largest);
  }
}


void buildMaxHeap(int *heap)
{
  int j;
  for(j=n/2;j>=1;j--) maxHeapify(heap,j);
}


int main()
{
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&heap[i]);

  buildMaxHeap(heap);

  for(i=1;i<=n;i++) printf(" %d",heap[i]);
  printf("\n");

  return 0;
}



Measured memory_bytes: 3696
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  cout << "ABC" << N;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long
#define PI M_PI

int main(void){
    int i;
    int N; scanf("%d",&N);
    int A[N];
    REP(i,N) scanf("%d",&A[i]);

    i=0;
    double ans = 0;
    while(i<N){
        ans += (double)1/A[i];
        i++;
    }

    printf("%f",1/ans);
    
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#define N 50022
using namespace std;

int main(){

	int pn[N], n, p;

	fill(pn, pn+N, 1);
	for(int i=2; i<N; i++){
		if(pn[i] == 1){
			for(int j=2; (p = i * j)<N; j++){
				pn[p] = 0;
			}
		}
	}
	
	while(cin >> n){
		for(int i=n-1; i>0; i--){
			if(pn[i] == 1){
				cout << i << " ";
				break;
			}
		}
		for(int i=n+1; i<N; i++){
			if(pn[i] == 1){
				cout << i << endl;
				break;
			}
		}		
	}

	return 0;

}

Measured memory_bytes: 1352
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S; cin >> S;
    int N = S.size();

    bool ok = false;

    regex re("A[a-z]+C[a-z]+");
    if (regex_match(S, re)) ok = true;

    string ans = ok ? "AC" : "WA";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll x[200005];
ll check[200005];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		check[i] = x[i];
	}
	sort(check, check + n);
	double index = (double)(check[n / 2] + check[n / 2 - 1]) / 2;
	for (int i = 0; i < n; i++) {
		if (x[i] >= index) {
			cout << check[n / 2 - 1] << endl;
		}
		else {
			cout << check[n / 2] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll GCD(ll a, ll b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}

ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    auto v = divisor(GCD(a, b));
    sort(RALL(v));
    cout << v[--k] << endl;
}

Measured memory_bytes: 256
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
constexpr auto mod = 1000000007;
using namespace std;
 


int main() {
char c;
  cin>>c;
  char d=c+1;
  cout<<d;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	ll a, b;
	cin >> a >> b;

	ll c = b - a;

	ll sum0 = 0;
	for (ll i = 1; i <= c; i++)
	{
		sum0 += i;
	}


	println(sum0 - b);
}

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

int main(){
    long long x; cin >> x;
    for (long long a = -2000; a <= 2000; a++) {
        for (long long b = -2000; b <= 2000; b++) {
            long long f1 = a*a*a*a*a;
            long long f2 = b*b*b*b*b;

            if ((f1 - f2) == x) {
                cout << a << ' ' << b; exit(0);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3628
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
 
total=0  
for i in range(0,N):
    total+= ans//a[i]

print(total%(10**9+7))

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

typedef long long ll;



 int main(){

   int  a=0,maxi=0,n;
  cin>>n;
  string s;

  cin>>s;

  for(int i=0;i<s.length();i++){
    if(s[i] == 'I')
        a ++;
    else if(s[i] == 'D')
        a--;

    maxi = max(maxi,a);
  }

    cout<<maxi<<endl;

 return 0;
 }


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var n, q = sc.nextInt
    while(n != 0 || q != 0) {
      val cand = (for(_ <- 1 to n) yield {
        for(_ <- 1 to sc.nextInt) yield sc.nextInt }).flatten
      println(((1 to 100)
        .toList.map(x => (cand.count(_ == x), x))
        .filter(_._1 >= q)
        .sortWith((a, b) =>
          if(a._1 == b._1) a._2 < b._2 else a._1 > b._1) :+ (0, 0)).head._2)
      n = sc.nextInt
      q = sc.nextInt
    }
  }
}

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

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

  int a,b,c;
  cin >> a >> b >> c;

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

  cout << endl;
  return 0;
}


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

x = list(map(int, input().split()))

maxint = 50 * N

dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]

dp[0][0][0] = 1

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

for i in range(1, N+1):
    res += dp[N][i][i * A]

print(res)

Measured memory_bytes: 119520
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<ll, ll>;
const int maxn = 4079, mlg = 17, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int x, y,a, b, k;
	cin >> x >> y >> a >> b >> k;
	x = x*60+y;
	a = a*60+b;
	x = a-x;
	cout << max(0, x-k);
}


Measured memory_bytes: 3644
import java.util.*;
import java.io.*;

class Main{
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public static void main(String[] args) throws IOException{
                int num = Integer.parseInt(br.readLine());
                Deque<String> ar = new ArrayDeque<>(num);
                for(int i=0; i<num; i++){
                        int val;
                        String strs = br.readLine();
                        if(strs.charAt(0) == 'i')
                                ar.addFirst(strs.substring(7));
                        else if(strs.charAt(6) == 'F')
                                ar.removeFirst();
                        else if(strs.charAt(6) == 'L')
                                ar.removeLast();
                        else
                                ar.remove(strs.substring(7));
                }
                String j = ar.poll();
                while(j != null){
                        System.out.print(j);
                        j = ar.poll();
                        if(j!=null)
                                System.out.print(" ");
                }
                System.out.println();
        }
}

Measured memory_bytes: 163356
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    ll N,i; cin >> N >> i;
    cout << N-i+1 << endl;
}


Measured memory_bytes: 3576
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int a , b , n ; 
    cin >> a >> b >> n ; 
    int x = min(b - 1, n) ;
    int ans = a * x / b - a * (x / b) ;
    cout << ans << endl;
    return 0; 
}


Measured memory_bytes: 3588
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

x, y = map(int,input().split())
if x > 2*y or y > 2*x or (x+y) % 3 != 0:
    print(0)
    exit()

d = (x+y)//3
MOD = 10**9+7
f, i = prepare(10**6, MOD)
nx = (2*y-x) // 3
print(f[d] * i[nx] % MOD * i[d-nx] % MOD)

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


int main()
{
    string s;
    cin>>s;
    string res="";
    for(int i=0;i<s.length();i++){
        if(i==4)    res +=' ';
        res +=s[i];
    }
    cout<<res<<endl;
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  string s,t;
  cin>>s>>t;
  int ns = int(s.size()), nt = int(t.size());
  int ans = INFint;
  for(int i(0);i<=ns-nt;i++){
    string tmp = s.substr(i,nt);
    //cout << tmp << endl;
    int cnt(0);
    for(int j(0);j<nt;j++){
      if(tmp[j] != t[j]) cnt++;
    }
    ans = min(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}


void solution()
{
    ll k,i,j,h,m,w,n;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    ll g=a[1];
    for(i=2;i<=n;i++)
    {
        g=__gcd(g,a[i]);
    }
    if(g>1)
    {
        cout<<"not coprime";
        return;
    }
    set<ll>s;
    for(i=1;i<=n;i++)
    {
        if(a[i]==1)continue;
        if(a[i]%2==0)
        {
            if(s.find(2)!=s.end())
            {
                cout<<"setwise coprime";
                return;
            }
            s.insert(2);
            while(a[i]%2==0)
            a[i]/=2;
        }
        for(j=3;j<=sqrt(a[i]);j+=2)
        {
            if(a[i]%j==0)
            {
                if(s.find(j)!=s.end())
                {
                    cout<<"setwise coprime";
                    return;
                }
                s.insert(j);
                while(a[i]%j==0)
                a[i]/=j;
            }
        }
        if(a[i]>1)
        {
            if(s.find(a[i])!=s.end())
            {
                cout<<"setwise coprime";
                return;
            }
            s.insert(a[i]);
        }
    }
    cout<<"pairwise coprime";
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}





Measured memory_bytes: 11420
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (ab, bc, ca) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1], v[2])
    };

    println!("{}", (bc * ab) / 2);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            scanner.nextInt();
        }
        int i;
        for (i=0;i<=(n-1)/(k-1);i++){
        }
        if ((n-1)%(k-1)==0) i--;
        System.out.println(i);

    }

}


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

struct psi{string s; int p, i;};
int n, p;
string s;
psi sp[110];

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> s >> p;
		sp[i].s = s;
		sp[i].p = p;
		sp[i].i = i+1;
	}
	sort(sp, sp+n, [](psi a, psi b){return (a.s < b.s) || (a.s == b.s && a.p > b.p);});
	for (int i = 0; i < n; ++i){
		cout << sp[i].i << endl;
	}
}

Measured memory_bytes: 256
N, X = map(int,input().split())
L = input().split()
L = [int(i) for i in L]

bound_times = 0
now_point = 0

for i in L:
    if now_point > X:
        break
    now_point += i
    bound_times += 1

if now_point <= X:
    bound_times += 1
    
print(bound_times)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	rep(i, N) {
		rep(j, D) {
			cin >> X[i][j];
		}
	}
	int count = 0;
	int tmp_dist;
	rep(i, N) {
		for (int j = i + 1; j < N; j++) {
			tmp_dist = 0;
			rep(k, D) {
				tmp_dist += pow((X[i][k] - X[j][k]), 2);
			}
			if (sqrt(tmp_dist) == int(sqrt(tmp_dist))) {
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

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

int main() {
  long long num, Yen, Bis;
  long long cnt = 1;
  long long hYen = 0;
  
  cin >> num >> Yen >> Bis;
  
  if(Yen+1 >= Bis){
    // 増やし続ける
    cnt += num;
  }else{
    // 円→ビスケットに交換する
    for(int i = 0; i < num; i++){
      if(i == 0 && num % 2 == 1){
        // 奇数でラストはビスケット増やして終わり
        cnt++;
        continue;
      }
      
      if(hYen > 0){
        cnt += Bis;
        hYen--;
        continue;
      }else if(i == num-1){
          cnt++;
          continue;
      }else if(cnt >= Yen){
          cnt -= Yen;
          hYen++;
      }else{
          cnt++;
      }
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map
//std::cout << std::setfill('0') << std::right << std::setw(4) << 12; // "0012"

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

bool check(string s){
  vector<char> v = {'3','5','7'};
  bool flag = true;
  for(char a:v){
    bool exist = false;
    REP(i,s.size()){
      if(s[i]==a){exist = true;break;}
    }
    if(!exist){flag =false;break;}
  }
  return flag;
}

ll N;
ll dfs(string s){
  ll s_num=stol(s);
  if(s_num>N){return 0;}
  if(s_num==0){s = "";}
  ll r = check(s);
  vector<string> v = {"3","5","7"};
  for(string add:v){
    r += dfs(s+add);
  }
  return r;
}

int main(){
  cin >> N;
  ll r = dfs("0");
  printf("%Ld\n",r);
}


Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable:4996)

int main(void)
{
	int H;
	int W;
	int loop1;
	int loop2;

	while(1) {

		scanf("%d %d", &H, &W);

		if((H == 0) && (W == 0)){
			break;
		}

		for(loop1 = 0; loop1 < H; loop1++){
			for(loop2 = 0; loop2 < W; loop2++){
				if(loop1 == 0 || loop1 % 2 == 0){
					if((loop2 == 0) || (loop2 % 2 == 0)){
						printf("#");

					}else{
						printf(".");
					}
				}else{
					if((loop2 == 0) || (loop2 % 2 == 0)){
						printf(".");

					}else{
						printf("#");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return (0);
}

Measured memory_bytes: 572
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

void out(int num){
    if(!num){
        putchar('0');
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        putchar(buf[i]);
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        putchar('\n');
    }
    // cout << ss.str();
}


Measured memory_bytes: 1152
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        p: [f64; n],
    }

    let expectations: Vec<_> = p.iter().map(|x| (1.0 + x) / 2.0).collect();
    let mut sum = expectations.iter().take(k).sum::<f64>();
    let mut ans = sum;

    for i in k..n {
        sum += expectations[i] - expectations[i - k];
        if ans < sum {
            ans = sum;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 6112