akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Ghjattu{
    double x,y;
}G[10];
int vis[10],n;
double ans=0;
double getdis(int a,int b){
    double xx=(G[a].x-G[b].x)*(G[a].x-G[b].x);
    double yy=(G[a].y-G[b].y)*(G[a].y-G[b].y);
    return sqrt(xx+yy);
}
int fi(int n){
    int res=1;
    for(int i=2;i<=n;i++) res*=i;
    return res;
}
int main(){
    while(cin>>n){
        for(int i=1;i<=n;i++){
            cin>>G[i].x>>G[i].y;
        }
        for(int i=1;i<=n;i++) vis[i]=i;
        double cnt=0;
        ans=0;
        do{
            cnt=0;
            for(int i=2;i<=n;i++){
                cnt+=getdis(vis[i],vis[i-1]);
            }
            ans+=cnt;
        }while(next_permutation(vis+1,vis+1+n));
        int t=fi(n);
        printf("%.10lf\n", ans/t);
    }
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    cout<<1<<endl;
  }
  else if(a==b&&b!=c){
    cout<<2<<endl;
  }
  else if(a!=b&&b==c){
    cout<<2<<endl;
  }
  else if(a==c&&b!=c){
    cout<<2<<endl;
  }
  else{
    cout<<3<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char a;
	scanf("%c",&a);
	if(a=='a' || a=='i' || a=='u' || a=='e' || a=='o'){
		printf("vowel\n");
	}
	else{
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <assert.h>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 1005
#define mod 998244353
#define INF 0x3f3f3f3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int main() {
	int A, B;
	cin >> A >> B;
	if (A >= 13) B = B;
	else if (A >= 6) B /= 2;
	else B = 0;
	cout << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    s[i] == 'I' ? x++ : x--;
    res = max(res, x);
  }
  dump(res);
  return 0;
}


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

int l[50];
int N;
int K;

int main()
{
    cin >> N >> K;
    for(int i = 0;i < N;i++)
    {
        cin >> l[i];
    }
    sort(l,l + N);

    int result = 0;
    for(int i = 0;i < K;i++)
    {
        result += l[N - i - 1];
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstring> 
using namespace std;
int c[1001][1001];

int lcs(string x, string y)
{
    int maxl = 0;
    int m = x.length(), n = y.length();
 
    for (int i = 0; i <= m; i++) c[i][0] = 0;
    for (int j = 0; j <= n; j++) c[0][j] = 0;


    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (x[i-1] == y[j-1])
            { 
                // if(i==0 || j==0) c[i][j] = 1;
                c[i][j] = c[i-1][j-1] + 1; 
            }else
            {
                // if(i==0 || j==0) c[i][j] = 0;
                c[i][j] = max(c[i][j-1], c[i-1][j]);
            }
            maxl = max(maxl, c[i][j]);
        } 
    } 
    // printf("%d\n", c[m][n]);
    return c[m][n];
}

int main()
{
    
 //   freopen("n4.txt","r",stdin);
    string x,y;
    int q;
    cin>>q;
    while(q--)
    {
        cin>>x>>y;
        int ans = lcs(x, y);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 7088
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    i = 1
    for m in range(M):
        if N%2 == 0 and i%2 == 1 and i >= N/2:
            i += 1
        print(M-m,M-m+i)
        i += 2
    

main()


Measured memory_bytes: 9200
from collections import deque
import numpy as np

h,w = map(int,input().split())
geo = np.zeros((h,w),dtype=np.bool)
for i in range(h):
    geo[i] = [x=='.' for x in input()]
geo_i = np.ones((h,w),dtype=np.int) * -1 - (~geo)
    
res = 0

def one_step(igeo,deq,pos,h,w):
    n = igeo[pos]
    for gp in [(0,1),(0,-1),(1,0),(-1,0)]:
        cpos = pos[0]+gp[0], pos[1]+gp[1]
        if h>cpos[0]>=0 and w>cpos[1]>=0:
            if igeo[cpos] == -1:
                igeo[cpos] = n+1
                deq.append(cpos)
    return

for ih in range(h):
    for iw in range(w):
        if geo[ih,iw]:
            igeo = geo_i.copy()
            igeo[ih,iw] = 0
            deq = deque()
            deq.append((ih,iw))
            while len(deq)>0:
                pos = deq.popleft()
                one_step(igeo,deq,pos,h,w)
            res = max(res, igeo.max())
print(res)

Measured memory_bytes: 20340
#include <stdio.h>
 
int BSearch(int A[] ,unsigned int sp ,unsigned int ep ,int n){ //あり、なしのみboolで返す
  int mid = (ep+sp) / 2;
  int l = sp;
  int r = ep;
  while(l <= r){
    mid = (l + r) / 2;
    if(A[mid] == n){
      return 1;
    }
    else if(A[mid] < n){
      l = mid + 1;
    }
    else{
      r = mid - 1;
    }
  }
  return 0;
}
 
int main(void){
  int n,q;
  int counter = 0;
  int S[100000];
  int T[50000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
 
 
  for(int i=0;i<q;i++){
    if(BSearch(S,0,n,T[i]) == 1)
      counter++;
  }
  printf("%d\n",counter);
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }
  sort(A.begin(), A.end(), greater<int>());
  ll ans = 0;
  for(float i=0; i < A.size()-1; ++i) {
    ans += A[ceil(i/2)];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3984
#include <iostream>
int main() {
	char l,r{};
	std::cin >> l;
	if(l=='A')
		r='T';
	else if(l=='T')
		r='A';
	else if(l=='C')
		r='G';
	else if(l=='G')
		r='C';
	std::cout<<r<<std::endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<ll> h(n);
    FOR(i,0,n)cin>>h[i];

    vector<ll> sum(n);
    vector<ll> higher(n);
    FOR(i,0,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        sum[a]++;
        sum[b]++;
        if(h[a]>h[b])higher[a]++;
        if(h[b]>h[a])higher[b]++;
    }
    ll ans=0;
    FOR(i,0,n){
        if(sum[i] == higher[i])ans++;
    }
    cout<<ans<<endl;
}

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

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

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

  bool flag = true;

  for(int i=N-1;i>0;i--) {
    if(H[i-1]<=H[i]) ;
    else if (H[i-1]-1==H[i]) H[i-1] -= 1;
    else { 
      flag = false;
      break;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return (0);
}


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

int main(){
  string s;
  ull q;
  cin >> s >> q;
  bool rev = false;
  string fr,bc;
  for(ull i=0;i<q;i++){
    ull t;
    cin >> t;
    if( t == 1 ){
      rev = !rev;
      continue;
    }
    
    ull f;
    string c;
    cin >> f >> c;
    if( f == 1 ){
      if( !rev ){
      	fr = c + fr;
      }else{
        bc = bc + c;
      }
      
    }else{
      if( !rev ){
        bc = bc + c;
      }else{
        fr = c + fr;
      }
    }
  }
  
 
  if( rev ){
    reverse(s.begin(),s.end());
    reverse(fr.begin(),fr.end());
    reverse(bc.begin(),bc.end());
    s = bc + s + fr;
    cout << s << endl;
  }else{
    cout << fr + s + bc << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 1512
#include <stdio.h>

int main(void) {

	int n,i,num;
	int bnum, fnum, rnum;
	int v[4][3][10];
	int b, f, r;

	for (b = 0; b < 4; b++) {
		for (f = 0; f < 3; f++) {
			for (r = 0; r < 10; r++) {

				v[b][f][r] = 0; 

			}
		}
	}


	scanf("%d", &n);

	for (i = 0; i < n; i++) {

		scanf("%d %d %d %d", &bnum, &fnum, &rnum, &num);

		b = bnum - 1;
		f = fnum - 1;
		r = rnum - 1;
		
		v[b][f][r] += num;

	}

	for (b = 0; b < 4; b++) {
		for (f = 0; f < 3; f++) {
			for (r = 0; r < 10; r++) {

				printf(" %d", v[b][f][r]);

			}
			printf("\n");
		}
		if (b < 3) {
			printf("####################\n");
		}
	}

	return(0);

}


Measured memory_bytes: 2104
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *

import numpy as np

import math

def rootCheck(checkList):
    nextList=[]
    for i in checkList:
        for j in root[i]:
            if hint[j] == -1:
                hint[j] = i
                nextList.append(j)
    if len(nextList) >0:
        rootCheck(nextList)



if __name__ == '__main__':
    sys.setrecursionlimit(10 ** 6)
    n, m = map(int, input().split())
    root = {}
    for i in range(m):
        b, c = map(int, input().split())
        if b-1 in root:
            root[b-1].append(c-1)
        else:
            root[b-1]=[c-1]
        if c-1 in root:
            root[c-1].append(b-1)
        else:
            root[c-1]=[b-1]
    hint =[-1]*n

    for i in root[0]:
        if hint[i] == -1:
            hint[i] = 0


    rootCheck(root[0])

    if -1 in hint:
        print("No")
    else:
        print("Yes")
        for i in hint[1:]:
            print(i+1)




Measured memory_bytes: 147028
#include <iostream>
using namespace std;
int main ()
{int n;
int a[100];
int b[100];
int c[100];
cin>>n;
for (int i=0;i<n;i++)
cin>>a[i];
for (int i=0;i<n;i++)
cin>>b[i];
for (int i=0;i<n-1;i++)
cin>>c[i];
int sum=0;
for (int i=0;i<n;i++)
    sum=sum+b[i];
for (int i=0;i<n-1;i++)
{if(a[i]+1==a[i+1])
sum=sum+c[a[i]-1];}

cout <<sum;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

strings = []
results = []
pred = ["+","-","*","/","?"]
loop do
    strings = gets.split
    if strings[1] == pred[4] then
        break
    end

    case strings[1]
    when pred[0] then
        results << strings[0].to_i + strings[2].to_i
    when pred[1] then
        results << strings[0].to_i - strings[2].to_i
    when pred[2] then
        results << strings[0].to_i * strings[2].to_i
    when pred[3] then
        if strings[2] == 0 then
            break
        end
        results << strings[0].to_i / strings[2].to_i
    end
end
puts results


Measured memory_bytes: 6884
#include <bits/stdc++.h>
using namespace std;
int n, sum;
int a[25], b[25], c[25];
int main() {
	cin >> n;
	for (int i=1; i<=n; i++) cin >> a[i];
	for (int i=1; i<=n; i++) cin >> b[i];
	for (int i=1; i<=n-1; i++) cin >> c[i];
	for (int i=1; i<=n; i++) {
		sum += b[a[i]];
		if (i > 1 && a[i] - a[i-1] == 1) sum += c[a[i-1]];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=1;i<v.size();i++){
		int k=0;
		for(int j=i+1;j<v.size();j++){
            while(k<i&&v[k]+v[i]<=v[j])k++;
            ans+=i-k;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(h)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d = warshall_floyd(d) 
ans = 0 
for i in range(h):
    for j in range(w):
        if A[i][j] != 1 and A[i][j] != -1:
            ans += d[A[i][j]][1]
print(ans)

Measured memory_bytes: 40668
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 998244353;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005],w[500005];
//bool check[5005];
char s[500005],t[500005];
bool flag,dame;

ll  fact[400005];
ll rfact[400005];
ll dp[10005][10005];
bool isprime[500005];
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<400000; i++){
        fact[i] = (fact[i-1]*i) % mod;
        rfact[i] = rui(fact[i],mod - 2);
    }
}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;
}

int main(){
	cin >> n;
	cin >> s;
	cin >> k;
	for(i=0;i<n;i++){
		if(s[k-1] == s[i]){
			pu(s[i]);
		}else{
			pu("*");
		}
	}
	el;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  sort(a.begin(), a.end());
  int diff = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (i % 2)
      diff -= a[a.size() - 1 - i];
    else
      diff += a[a.size() - 1 - i];
  }
  cout << diff << "\n";
  return 0;
}


Measured memory_bytes: 256
//Hello Wolrd
//There is Special Pig Jiong in the world. 
#include<cstdio>
#include<ctype.h>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
const double pi = acos(-1.0);
#define pc putchar
#define RG register
#ifdef wzpOrz
char __wzp[1<<15|1],*__S=__wzp+32768;
#define gc() (__S>=__wzp+32768?(__wzp[fread(__wzp,sizeof(char),1<<15,stdin)]=EOF),*((__S=__wzp)++):*(__S++))
#else
#define gc getchar
#endif
inline ll read(){
	RG ll x=0,f=1;RG char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){
	if(x<0)x=-x,pc('-');
	if(x>=10)write(x/10);
	putchar(x%10+'0');
}
void writeln(ll x){
	write(x);puts("");
}
const int Mod = 1e9+7;
int Pow(int a,int b){int ans=1;for(;b;b>>=1,a=1ll*a*a%Mod)if(b&1)ans=1ll*ans*a%Mod;return ans;}
#define rd read
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Down(i,a,b) for(RG int i=(a);i>=(b);--i)
#define fin(x) {freopen(#x".in","r",stdin);}
#define fout(x) {freopen(#x".out","w",stdout);}
#define y1 ________y1
#define x first
#define y second

ll n,m;
int main(){
	n = rd(),m = rd();
	if(n==1&&m==1) printf("%lld\n",1ll); else
	if(n==1) printf("%lld\n",m-2); else
	if(m==1) printf("%lld\n",n-2); else{
		ll ans = 0;
		ans = (m-2) * (n-2);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#define Link "https://arc085.contest.atcoder.jp/tasks/arc085_c"

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

#define TASK "MUL"

#define pii pair<int,int>
#define i first
#define v second

using namespace std;

void OpenFile()
{
    freopen(TASK".INP","r",stdin);
    freopen(TASK".OUT","w",stdout);
}

const int oo = 1e9 + 1;
const int maxn = 3e3 + 1;
int n,S,T,a[maxn],cf[maxn],cnt,b[maxn],num[maxn];
vector <pii> e[maxn];
long long res;

void Enter()
{
    cin >> n;
    for (int i=1;i<=n;++i)
        cin >> a[i];
}

void Connect(int u, int v, int w)
{
    e[u].push_back(pii(++cnt,v));
    cf[cnt] = w;
    e[v].push_back(pii(++cnt,u));
}

void Init()
{
    S = 0;
    T = n + 1;
    cnt = 1;
    for (int i=1;i<=n;++i) {
        if (a[i] <= 0)
            Connect(S,i,-a[i]);
        else {
            Connect(i,T,a[i]);
            res += a[i];
        }
        for (int j=i+i;j<=n;j+=i)
            Connect(i,j,+oo);
    }
}

bool Can(int S, int T)
{
    queue <int> qu;
    fill(b,b+n+1+1,+oo);
    b[S] = 0;
    qu.push(S);
    while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        if (u == T)
            return 1;
        for (pii p : e[u]) {
            int i = p.i;
            int v = p.v;
            if (cf[i] > 0 && b[v] == +oo) {
                b[v] = b[u] + 1;
                qu.push(v);
            }
        }
    }
    return 0;
}

int Find(int u, int mn)
{
    if (u == T)
        return mn;
    num[u] = cnt;
    for (pii p : e[u]) {
        int i = p.i;
        int v = p.v;
        if (num[v] != cnt && cf[i] > 0 && b[v] == b[u] + 1)
            if (int x = Find(v,min(mn,cf[i]))) {
                cf[i] -= x;
                cf[i^1] += x;
                return x;
            }
    }
    return 0;
}

void Solve()
{
    //cout << res << '\n';
    while (Can(S,T))
        while (int x = (++cnt,Find(S,+oo)))
            res -= x;//, cout << "   " << x << '\n';
    cout << res;
}

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

    //OpenFile();

    Enter();
    Init();
    Solve();
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
from collections import deque

class MM:
    def __init__(self, c_max, c_cnt):
        self.c_max = c_max
        self.c_cnt = c_cnt

def solve(N: int, A: "List[int]"):
    sl = list(reversed(sorted(A)))
    score = 0
    c_max = sl[0]
    h = {sl[0]: 1}
    queue = deque()
    queue.append(c_max)
    for i in range(1, len(sl)):
        score += c_max

        if c_max == sl[i]:
            h[c_max] += 1
        else:
            h[c_max] -= 1
            if sl[i] in h:
                h[sl[i]] += 2
            else:
                h[sl[i]] = 2
                queue.append(sl[i])

            if h[c_max] == 0:
                queue.popleft()
                c_max = queue[0]
        # print(f'{i} {sl[i]} {c_max} {h}')
    print(score)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 52600
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;


int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        int j = i;
        while(j < s.length() && s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T'){
            j++;
        }
        ans = max(ans,j - i);
    }
    cout << ans << endl;
    return 0;
}

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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

// }}}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int odd = 0;
    int four = 0;
    int two = 0;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if (a % 4 == 0) {
            four++;
        } else if (a % 2 == 0) {
            two++;
        } else {
            odd++;
        }
    }
    if (odd > four + 1) {
        cout << "No" << endl;
        return 0;
    }
    if (odd == four + 1) {
        if (two == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  vector<ull> a;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    a.push(tmp);
  }

  vector<ull> b;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    b.push(tmp);
  }

  vector<ull> c;
  each(i, n-1) {
    ull tmp;
    cin >> tmp;
    c.push(tmp);
  }

  ull result = 0;
  each(i, n) {
    const auto ate = a[i];
    const auto satisfied_point = b[ate - 1];
    result += satisfied_point;

    if (0 < i) {
      if ((a[i-1] + 1) == ate) {
        result += c[a[i-1]-1];
      }
    }

  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


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

	bool h = a == 'H';
	bool s = b == 'H';

	if (!h && !s) cout << 'H' << endl;
	if (h && !s) cout << 'D' << endl;
	if (!h && s) cout << 'D' << endl;
	if (h && s) cout << 'H' << endl;

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
from bisect import bisect_left
def main():
    n=int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))

    A.sort()
    C.sort()
    sum=0
    for i in range(n):
        cnt=1
        cnt*= bisect_left(A,B[i])
        cnt*= n-bisect_right(C,B[i])
        sum+=cnt 

    print(sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 22720
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int tmp;
    rep(i,n) {
        cin >> tmp;
        tmp--;
        a[i] = tmp;
    }

    int now = 0;
    int ans = 0;
    int flag = 0;
    while(a[now] > 0) {
        tmp = now;
        if(a[now] == 1) {
            ans++;
            flag = 1;
            break;
        }
        now = a[now];
        a[tmp] = 0;
        ans++;
    }

    if(flag)
        cout << ans << endl;
    else
        cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << a * b;
    return 0;
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
s=input()
b=0
for i in range(len(s)):
    if (i+1)%2==0 and s[i]=='R':
        b=1
    elif (i+1)%2==1 and s[i]=='L':
        b=1
print('No' if b else 'Yes')

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, a, b, k);
  for (int i = min(a, b);; --i) {
    if (a % i + b % i == 0) {
      --k;
      if (k == 0) {
        out(i);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3588
from collections import deque

h, w = (int(x) for x in input().split())
ch, cw = (int(x) - 1 for x in input().split())
dh, dw = (int(x) - 1 for x in input().split())
s = [list(input()) for _ in range(h)]
d = [[-1] * w for _ in range(h)]
d[ch][cw] = 0
walk = [[0, 1], [0, -1], [1, 0], [-1, 0]]
warp = [[2, 2], [2, 1], [2, 0], [2, -1], [2, -2], [1, 2], [1, 1], [1, -1], [1, -2], [0, 2], [0, -2], [-1, 2], [-1, 1],
     [-1, -1], [-1, -2], [-2, 2], [-2, 1], [-2, 0], [-2, -1], [-2, -2]]

que = deque([[0, ch, cw]])
while que:
    count, y, x = que.popleft()
    if d[y][x] < count:
        continue
    for NY, NX in walk:
        if 0 <= y + NY < h and 0 <= x + NX < w and s[y + NY][x + NX] != '#':
            if d[y + NY][x + NX] == -1 or d[y + NY][x + NX] > count:
                d[y + NY][x + NX] = count
                que.appendleft([count, y + NY, x + NX])
    for NY, NX in warp:
        if 0 <= y + NY < h and 0 <= x + NX < w and s[y + NY][x + NX] != '#':
            if d[y + NY][x + NX] == -1 or d[y + NY][x + NX] > count + 1:
                d[y + NY][x + NX] = count + 1
                que.append([count + 1, y + NY, x + NX])

print(d[dh][dw])

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
int A[MC],B[MC],C[MC];
LL ansB[MC];
LL ans;

int main(){
	cin >> N;
	repp(i,0,N) cin >> A[i];
	repp(i,0,N) cin >> B[i];
	repp(i,0,N) cin >> C[i];
	A[N] = B[N] = C[N] = 1e9 + 7;
	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);
	int x = 0 , z = 0;
	repp(i,0,N){
		while(A[x] < B[i]) ++x;
		while(C[z] <= B[i]) ++z;
		ans += (LL)x * (N-z);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1536
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  x[i],y[i]=map(int, input().split())

d=0

for i in range(N):
  c=i+1
  for j in range(c,N):
    d+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
a=math.factorial(N)
print(d*2*(N-1)/(N*(N-1)))

Measured memory_bytes: 3188
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());


        var array = new long[N + 1];
        for (var i = 1; i <= N; i++)
        {
            for (var j = i; j <= N; j += i)
            {
                array[j] += 1;
            }
        }

        long ans = 0;

        for (var i = 0; i <= N; i++)
        {
            ans += array[i] * i;
        }

        Console.WriteLine(ans);
        Console.ReadLine();

    }
}

Measured memory_bytes: 94920
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  fo(i,a)
    cin>>b[i];
  long long c=0;
  fo(i,a){
    if(b[i]>2){
      if(b[i]%2==0){
        c+=b[i]/2-1;
        b[i]=2;
      }
      else{
        c+=b[i]/2;
        b[i]=1;
      }
    }
  }
  fo(i,a-1){
    if(b[i]==1){
      if(b[i+1]>0){
        b[i+1]--;
        c++;
      }
    }
    if(b[i]==2)
      c++;
  }
  if(b[a-1]==2)
    c++;
  cout<<c<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a<=b){
            for (int i=0;i<b;i++){
                System.out.print(a);
            }
        }else if (a>b){
            for (int i=0;i<a;i++){
                System.out.print(b);
            }
        }
    }
}

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

int main(){
  int acnum=0,wanum=0;
  string s,s1,s2;
  int n,m;
  cin >> n>>m;
  int wa[n];
  bool acflg[n];
  for(int i=0;i<n;i++){
  	wa[i]=0;
    acflg[i]=false;
  }
  
  for(int i=0;i<m;i++){
    int no;
    string result;
    cin >> no >> result;
    
    //ACフラグがたっていればcontinute
    if(acflg[no-1]==true) continue;
    if(result == "AC"){
      acnum++;
      acflg[no-1]=true;
      wanum += wa[no-1];
    }else{
      wa[no-1]++;
    }
  }
  
  cout << acnum << " " << wanum << endl;
  
  return 0;
}

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

int main()
{
    unsigned int a, b, c;
    int res = 0;
    int poisoned = 0;

    cin >> a >> b >> c ;

    // a is not delicious
    // b,c is delicious
    // c has poison
    //
    while(true)
    {
        if(poisoned != 1 && (c > 0))
        {
            poisoned = 1;
            c--;
            res++;
        }
        else if( b > 0 )
        {
            poisoned = 0;
            b--;
            res++;
        }
        else if( a > 0 )
        {
            poisoned = 0;
            a--;
            if( (c==0) && (b==0))
            {
                break;
            }
        }
        else
        {
            break;
        }

        //cout << a << ' ' << b << ' ' << c << ' ' << res << endl;
    }

    cout << res << endl;

	return 0;
}	




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n;
  cin>>n;
  vector<vector<int>  > a(n, vector<int>(26,0));


  string str;

  r(i,n){
    cin>>str;
    r(j,str.size()){
      a.at(i).at(str.at(j)-'a')++;

    }
  }


  string ans;
  int min;

  for(int i=0;i<26;i++){
    min=100;
    for(int j=0;j<n;j++){
      if(min>a.at(j).at(i))min=a.at(j).at(i);
    }
    for(int j=0;j<min;j++){
      ans+=(char)'a'+i;
    }
  }

  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        long L = scan.nextLong();
        long R = scan.nextLong();
        int ans = Integer.MAX_VALUE;
        long x = 0;
        if (R - L >= 2019) {
            System.out.println(0);
            System.exit(0);
        }
        for (long i = L; i < R; i++) {
            for (long j = L + 1; j <= R; j++) {
                int m = (int) ((i * j) % 2019);
                ans = Math.min(ans, m);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

long long int fact(int N){
	long long int ret = 1;
	FOR(i,1,N+1){
		ret = (ret * i)% SURP;
	}
	return ret;
}

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

	int ret;
	ret = a + b;
	if (ret % 2 == 1){
		ret = ret/2 + 1;
	}else{
		ret  = ret/2;
	}

	cout << ret << endl;
	return 0;
}


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

int main() {
  int A;
  int B;
  cin >> A >> B;
  int C = A * B % 2;
  
  if (C == 1) {
    cout << "Odd" << endl;
  }
  
  else if (C != 1) {
    cout << "Even" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

string s;
int x, y;
VI xMove, yMove;

bool calc(int now, const VI &move, int target) {
    unordered_set<int> dp;
    dp.emplace(now);
    FORE(e, move) {
        unordered_set<int> ndp;
        FORE(e2, dp) {
            ndp.emplace(e2 + e);
            ndp.emplace(e2 - e);
        }
        dp = ndp;
    }
    return dp.count(target);
}

int main(void) {
    cin >> s;
    cin >> x >> y;
    int st = 0;
    s += 'T';
    {
        bool nowX = true;
        int cnt = 0;
        bool isFirst = true;
        FORE(e, s) {
            if (e == 'T') {
                if (cnt) {
                    if (isFirst) st = cnt;
                    else if (nowX) xMove.EB(cnt);
                    else yMove.EB(cnt);
                    cnt = 0;
                }
                isFirst = false;
                nowX = !nowX;
            } else {
                cnt++;
            }
        }
    }
    bool ok = calc(st, xMove, x) && calc(0, yMove, y);
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 768
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll h, w; cin >> h >> w;

    ll ans = INF;
    RANGE(i, 1, h-1) {
        ll s0 = i * w;
        {
            ll s1 = (h - i) * (w / 2);
            ll s2 = (h - i) * ((w+1) / 2);
            chmin(ans, max({s0, s1, s2}) - min({s0, s1, s2}));
        }
        {
            ll s1 = ((h - i) / 2) * w;
            ll s2 = ((h - i + 1) / 2) * w;
            chmin(ans, max({s0, s1, s2}) - min({s0, s1, s2}));
        }
    }
    RANGE(j, 1, w-1) {
        ll s0 = h * j;
        {
            ll s1 = (h / 2) * (w - j);
            ll s2 = ((h+1) / 2) * (w - j);
            chmin(ans, max({s0, s1, s2}) - min({s0, s1, s2}));
        }
        {
            ll s1 = h * ((w - j) / 2);
            ll s2 = h * ((w - j + 1) / 2);
            chmin(ans, max({s0, s1, s2}) - min({s0, s1, s2}));
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+7;
const int inf=0x3f3f3f3f;
int a[1001];
int d[1001];
int main()
{
    int n,x;
    while(cin>>n>>x)
    {
        for(int i=1;i<=n;i++)
            cin>>a[i];
        int ans=1;
        d[1]=0;
        if(n==1)
        {
            cout<<ans<<endl;
            continue;
        }
        for(int i=2;i<=n+1;i++)
        {
            d[i]=d[i-1]+a[i-1];
            if(d[i]<=x)
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}




Measured memory_bytes: 256