akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	auto start = high_resolution_clock::now(); 

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

	int cnt = 0;
	for(int i = 0 ; i < n; i++){
		char x = a[i];
		char y = b[i];
		char z = c[i];

		vector<char> temp;
		temp.pb(x);
		temp.pb(y);
		temp.pb(z);

		sort(temp.begin(), temp.end());

		if(temp[0] == temp[1]){
			if(temp[1] == temp[2]){
				cnt += 0;
			}
			else{
				cnt += 1;
			}
		}
		else{
			if(temp[1] == temp[2]){
				cnt += 1;
			}
			else{
				cnt += 2;
			}	
		}

		// trace4(x,y,z,cnt);
	}

	cout << cnt ;

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
N = input()
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
old_a = 99

for i in range((len(A))):
  a = int(A[i])
  ans += B[a-1]
  if a - old_a == 1:
    ans += C[old_a-1]
  old_a = a
print(ans)

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

long long int X;

int main() {
    cin >> X;

    long long int yokin = 100;
    long long int rishi;
    int i = 0;
    while (yokin < X) {
        rishi = yokin / 100;
        yokin += rishi;
        i++;
    }

    cout << i << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
string s; int c[100009];
int main() {
	cin >> s;
	int depth = 0; c[0] = 1;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '(') depth++;
		if(s[i] == ')') depth--;
		c[depth]++;
	}
	long long ret = 0;
	for(int i = 0; i <= s.size(); i++) {
		ret += 1LL * c[i] * (c[i] - 1) / 2;
	}
	cout << ret - 1 << endl;
	return 0;
}

Measured memory_bytes: 3464
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

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

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);

    ll N,K;
    cin>>N>>K;
    int count=0;
    ll t=1;
    while(t<N){
        t*=K;
        count++;
    }
    if(t==N){
        cout<<count+1<<endl;
    }else cout<<count<<endl;
}

Measured memory_bytes: 256
n=int(input())
multi3 = [int(x.strip()) for x in input().split()]
ans=1
flag=True
for i in multi3:
    if ans*i>10**18:
        flag=False
    elif i==0:
        flag=True
        ans=0
        break
    else:
        ans*=i
if(flag):
    print(ans)
else:
    print(-1)


Measured memory_bytes: 21596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  if (a <= 5) cout << 0 << '\n';
  else if (6 <= a && a <= 12) cout << b / 2 << '\n';
  else cout << b << '\n';
  return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define rep(i,n) for (int i=0; i<(n); i++)

using namespace std;

int main() {
	FAST;

	int n;
	cin >> n;
	int a[n];

	rep(i,n) cin >> a[i];

	int r = -1, curr=0, curl=0;
	long long int ans = 0;

	rep(i,n) {
		while (curr == curl && r < n) {
			r++;
			curr ^= a[r];
			curl += a[r];
		}
		ans += r - i;
		curr ^= a[i];
		curl -= a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter


def prime_factorize(n):
    A = []
    while n % 2 == 0:
        A.append(2)
        n //= 2

    f = 3
    while f * f <= n:
        if n % f == 0:
            A.append(f)
            n //= f
        else:
            f += 2

    if n != 1:
        A.append(n)

    return A


def main():
    n = int(input())

    A = prime_factorize(n)
    AC = Counter(A)

    ans = 0
    for v in AC.values():
        k = 1
        while True:
            v -= k
            if v < 0:
                break

            ans += 1
            k += 1

    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll A, B;
  IN(A,B);
  OUT(max({A+B,A-B,A*B}));

  return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
counts = {}
for i in range(n):
    a = int(input())
    count = counts.get(a, 0)
    counts[a] = count + 1

c = 0
for k, v in counts.items():
    if v % 2 == 1:
        c += 1
print(c)


Measured memory_bytes: 60248
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define sz(a) ((int)(a).size())
#define vi vector<int>
#define pii pair<int,int>
#define R(a) scanf("%d",&a)
#define per(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);i++)
#define rix(i,x) for(int i=last[x];i;i=pre[i])
ll pow(ll a,ll b,ll M){ll t=1;for(a%=M;b;b>>=1){if(b&1)t=t*a%M;a=a*a%M;}return t;}
const int N=305;
int a[N][N],ans,n,m,p[N],c[N],v[N];
int check(int x){
	rep(i,1,n)p[i]=1;
	rep(i,1,m)v[i]=0;
	while(true){
		rep(i,1,m)c[i]=0;
		rep(i,1,n)c[a[i][p[i]]]++;
		int fg=0;
		rep(k,1,m)if(c[k]>x)v[k]=1,fg=1;
		rep(i,1,n){
			while(v[a[i][p[i]]])p[i]++;
			if(p[i]>m)return 0;
		}
		if(!fg)return 1;
	}
}
int main(){
	cin>>n>>m;
	rep(i,1,n)rep(j,1,m)R(a[i][j]);
	for(int l=1,r=n;l<=r;){
		int x=(l+r)/2;
		if(check(x))r=x-1,ans=x;else l=x+1;
	}
	cout<<ans<<endl;
}


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

int main()
{
  char buf[4];
  cin >> buf;
  
  int p = 700;
  for(int i = 0; i < 3; i++)
  {
    if(buf[i] == 'o')
    {
      p += 100;
    }
  }
  
  cout << p << endl;
}

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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long n,k;
	cin>>n>>k;
	vector<long long> hoge(n);
	long long pre;
	for(long long i=0;i<n;i++){
		cin>>hoge.at(i);
		if(i==0) pre=hoge.at(i);
	}

	for(long long i=k;i<n;i++){
		if(hoge.at(i)>pre) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		pre=hoge.at(i-k+1);
	}

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}


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

using namespace std;
const int INF = 1e9;
typedef pair<int, int> P;

int main() {
  int h, w, d;
  cin >> h >> w >> d;
  
  int n = h * w;
  vector<P> a(n + 1);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int x;
      cin >> x;
      a[x] = P(i , j);
    }
  }
  vector<int> dist(n + 1, 0);
  for (int i = d + 1; i <= n; ++i) {
    int cost = abs(a[i - d].first - a[i].first) + abs(a[i - d].second - a[i].second);
    dist[i] = dist[i - d] + cost;
  }
  
  int q;
  cin >> q;
  while(q--) {
    int l, r;
    cin >> l >> r;
    int ans = dist[r] - dist[l];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
//#define mod 998244353
#define y1 laksjdalskhdals
using namespace std;
int te = 1;
string s;
ll t1[500009], t2[500009], ans;
void solve() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s;
    int n = int(s.size());
    for(int i=0;i<=n;i++)
        t1[i] = t2[i] = -1;
    for(int i=0;i<s.size();i++) {
        if((i==0 || s[i - 1] == '>') && s[i]=='<') {
            t1[i] = 0;
            t2[i] = 0;
        }
    }
    if(s[s.size() == '>'])
        t1[n] = t2[n] = 0;
    for(int i=1;i<=n;i++) {
        if(t1[i - 1] != -1 && s[i - 1] == '<')
            t1[i] = t1[i - 1] + 1;
    }
    for(int i=n-1;i>=0;i--) {
        if(t2[i] == -1 && t2[i + 1] != -1 && s[i] == '>')
            t2[i] = t2[i + 1] + 1;
    }
    for(int i=0;i<=n;i++)
        ans += max(t1[i], t2[i]);
    cout<<ans;
}
int main () {
//    freopen("task2-test-input.txt", "r", stdin);
//    freopen("task2-test-output.txt", "w", stdout);
//    cin>>te;
    while(te--) {
        solve();
    }
}


Measured memory_bytes: 8732
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
d=[]
ct=0
for i in range(k):
    #for m in range(k):
     #   if (n-1-m)%k==
    for j in range(i,n,k):
        d.append(t[j])
    for l in range(len(d)-1):
        if d[l]==d[l+1]:
            d[l+1]='out'
   # print(d,i,n,k)
    ct+=d.count('r')*p+d.count('s')*r+d.count('p')*s
    d=[]
    #print(ct)
    #ct+=

print(ct)    
#print(t.count("r")*r+)

Measured memory_bytes: 4792
#include <stdio.h>

int selection(int A[],  int n){
	int i, j, count, temp, minj;
	count=temp=minj=0;
	for(i=0;i<n;i++){
		minj=i;
		for(j=i;j<n;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		temp=A[i];
		A[i]=A[minj];
		A[minj]=temp;
		if(minj!=i){
			count++;
		}
	}
	for(i=0;i<n;i++){
		printf("%d", A[i]);
		if(i!=(n-1)){
			printf(" ");
		}
	}
	return count;
}

int main(int argc, char const *argv[])
{
	int i, n, a[100];
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &a[i]);
	}	
	printf("\n%d\n", selection(a, n));
	return 0;
}




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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    li res = 0;
    li mi = n + 1;
    rin{
        li a;
        cin >> a;
        if (a <= mi) {
            res++;
        }
        mi = min(mi, a);
    }
    cout << res << endl;

    return 0;
}

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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == s[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}

	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
def max_heapify(A, n, i):
    l = 2 * i
    r = 2 * i + 1

    if l < n+1 and A[l] > A[i]:
        largest = l
    else:
        largest = i

    if r < n+1 and A[r] > A[largest]:
        largest = r
        
    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        max_heapify(A, n, largest)

n = int(input())
A = [None] + [int(i) for i in input().split()]
for i in range(int(n/2), 0, -1):
    max_heapify(A, n, i)
print(" ", end="")
print(*A[1:], sep=" ")


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

struct city {
  int x;
  int y;
  int64_t p;
};

struct linescore {
  int lineid;
  int64_t s;
};

int64_t recursive_score(int K,
                        vector<vector<linescore>> &city_line_scores,
                        int current_line,
                        int selected_num,
                        vector<bool> &exist_lines) {
  if (selected_num == K) {
    int64_t s = 0;
    for (int i = 0; i < (int)city_line_scores.size(); i++) {
      for (auto line_score : city_line_scores[i]) {
        if (exist_lines[line_score.lineid]) {
          s += line_score.s;
          break;
        }
      }
    }
    return s;
  }

  int64_t min_score = 100000000000000LL;
  if (current_line >= (int)exist_lines.size() - 2) {
    return min_score;
  }
  exist_lines[current_line] = true;
  min_score = min(min_score, recursive_score(K, city_line_scores, (current_line % 2 == 0 ? current_line + 2 : current_line + 1), selected_num + 1, exist_lines));
  exist_lines[current_line] = false;
  min_score = min(min_score, recursive_score(K, city_line_scores, current_line + 1, selected_num, exist_lines));
  return min_score;
}

int main() {
  int N;
  cin >> N;
  vector<city> cities(N);
  for (int i = 0; i < N; i++) {
    int x, y, p;
    cin >> x;
    cin >> y;
    cin >> p;
    cities[i] = city{x, y, p};
  }

  vector<bool> exist_lines(N * 2 + 2);
  for (int j = 0; j < N; j++) {
    exist_lines[j * 2] = false;
    exist_lines[j * 2 + 1] = false;
  }
  exist_lines[N * 2] = true;
  exist_lines[N * 2 + 1] = true;

  vector<vector<linescore>> city_line_scores(N);
  for (int i = 0; i < N; i++) {
    int xi = cities[i].x;
    int yi = cities[i].y;
    int64_t pi = cities[i].p;

    vector<linescore> line_score(N * 2 + 2);

    for (int j = 0; j < N; j++) {
      int xj = cities[j].x;
      int yj = cities[j].y;

      line_score[j * 2] = linescore{j * 2, pi * abs(xi - xj)};
      line_score[j * 2 + 1] = linescore{j * 2 + 1, pi * abs(yi - yj)};
    }
    line_score[N * 2] = linescore{N * 2, pi * abs(xi)};
    line_score[N * 2 + 1] = linescore{N * 2 + 1, pi * abs(yi)};

    sort(line_score.begin(), line_score.end(), [](linescore a, linescore b) { return a.s < b.s; });
    city_line_scores[i] = line_score;
  }

  for (int K = 0; K < N; K++) {
    int64_t S = recursive_score(K, city_line_scores, 0, 0, exist_lines);
    cout << S << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3616
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#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 long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e7 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int a , b ; 
    cin >> a >> b ; 
    if ( a == 1 || b == 1 ) {
        cout << 1 << endl ; 
    }
    else cout << (a * b + 1) / 2 << endl;
    return 0; 
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	a=~~input[0]
	b=~~input[1]
	console.log(a < 9 && b < 9 ? "Yay!":":(");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

var N;
reader.on('line', (l) => {
  N = l;
});

reader.on('close', () => {
  var odd = 0;
  for (var i = 0; i < N; i++) {
    odd += digit_num(i + 1) % 2;
  }
  console.log(odd);
});

function digit_num(n) {
  var num = 1;
  while (n >= 10) {
    num++;
    n /= 10;
  }
  return num;
}

Measured memory_bytes: 7756
import java.util.Scanner;

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

        int[] bests = new int[n];
        for (int i = 0; i < n; i++) {
            bests[i] = Integer.MAX_VALUE;
        }
        int i = 0;
        bests[0] = 0;
        bests[1] = Math.abs(xs[1] - xs[0]);
        if (n == 2) {
            System.out.println(bests[1]);
            return;
        }

        while (true) {
            bests[i + 2] = Math.min(bests[i + 1] + Math.abs(xs[i + 2] - xs[i + 1]), bests[i] + Math.abs(xs[i + 2] - xs[i]));
            if (i + 2 == n - 1) {
                System.out.println(bests[i + 2]);
                return;
            }
            i++;
        }
    }
}



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


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓


            var s = Console.ReadLine();

            var r = new int[s.Length];

            var prev = 'L';
            var a = 0;
            var b = 0;
            var count = 0;

            var lastR = 0;
            var firstL = 0;

            for (int i = 0; i < s.Length; i++)
            {
                var c = s[i];

                if (prev == 'R')
                {
                    if (c == 'R')
                    {
                        //...RR
                        lastR = i;
                        if (count % 2 == 0)
                        {
                            a++;
                        }
                        else
                        {
                            b++;
                        }
                    }
                    else
                    {
                        //...RL
                        firstL = i;
                        if (count % 2 == 0)
                        {
                            a++;
                        }
                        else
                        {
                            b++;
                        }
                    }
                }
                else
                {
                    if (c == 'R')
                    {
                        //...LR
                        if ((i+firstL) % 2 == 0)
                        {
                            r[lastR] = a;
                            r[firstL] = b;
                        }
                        else
                        {
                            r[lastR] = b;
                            r[firstL] = a;
                        }

                        //reset
                        a = 1;
                        b = 0;
                        count = 1;
                        lastR = i;
                        prev = c;
                        
                        continue;
                    }
                    else
                    {
                        //...LL
                        if (count % 2 == 0)
                        {
                            a++;
                        }
                        else
                        {
                            b++;
                        }

                    }
                }

                prev = c;
                count++;
            }
            //...LR
            if ((r.Length + firstL) % 2 == 0)
            {
                r[lastR] = a;
                r[firstL] = b;
            }
            else
            {
                r[lastR] = b;
                r[firstL] = a;
            }

            for (int i = 0; i < r.Length; i++)
            {
                Console.Write(r[i]);
                Console.Write(' ');
            }
            Console.WriteLine();

			//↑
        }
	}
}

Measured memory_bytes: 13364
N = int(input())

R = ["AC", "WA", "TLE", "RE"]
C = [0, 0, 0, 0]

for i in range(N):
    S = input()
    if S == R[0]:
        C[0] += 1
    elif S == R[1]:
        C[1] += 1
    elif S == R[2]:
        C[2] += 1
    elif S == R[3]:
        C[3] += 1

for i in range(len(C)):
    print(R[i], "x", C[i])

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



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

    
    int n; cin >> n;
    string s;
    map<string, int> m;
    rep(i,n){
        cin >> s;
        m[s]++;
    }
    cout << m.size() << endl;
}

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

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>H>>W;
	vector<string>s(H);
	for(auto &i:s)cin>>i;
	vector<vector<int>>ans(H,vector<int>(W,MOD));
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='c')ans[i][j]=0;
			if(j){
				ans[i][j]=min(ans[i][j-1]+1,ans[i][j]);
			}
		}
	}
	for(auto i:ans){
		for(int j=0;j<i.size();j++){
			if(j)cout<<" ";
			cout<<(i[j]==MOD?-1:i[j]);
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3212
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
ll min(ll x,ll y)
{
    if (x < y) {
        return x;
    } else {
        return y;
    }
}
int main()
{
    ll x,k,d,ans;
    scanf("%lli %lli %lli",&x,&k,&d);
    if (x<0) {x = -x;}
    ll s;
    s = x/d;
    while (1)
    {
    if (s>=k) {
        ans = x - k*d;
        break;
    }
    if (s%2 == k%2) {
        ans = min(x-s*d,(s+2)*d-x);
        break;
    } else {
        ans = min(x-(s-1)*d,(s+1)*d-x);
        break;
    }
    }
    printf("%lli",ans);
    return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 2e2 + 20;
const int maxb = 20;

int dp[maxn][maxn][maxn][2] , R[maxn][maxn];

string s[maxn];

void upd(int l , int r , int y , int i , int pt)
{
	if(l < pt && pt < r)
		dp[l][r][y][i] = max(dp[l][r][y][i] , min(dp[l][pt][y][i ^ 1] , dp[pt][r][y][i ^ 1]));
}

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

	int n , m;
	cin >> n >> m;

	for(int i = 0; i < n; i++)
		cin >> s[i];

	for(int i = 0; i < n; i++)
		for(int j = m - 1; j >= 0; j--)
		{
			if(j != m - 1 && s[i][j + 1] == s[i][j])
				R[i][j] = R[i][j + 1];
			else
				R[i][j] = j + 1;
		}

	for(int l = n - 1; l >= 0; l--)
		for(int r = l + 1; r <= n; r++)
			for(int y = 0; y < m; y++)
			{
				if(r - l == 1)
					dp[l][r][y][0] = R[l][y];
				else
				{
					if(s[l][y] != s[l + 1][y])
						dp[l][r][y][0] = -1;
					else
						dp[l][r][y][0] = min(R[l][y] , dp[l + 1][r][y][0]);
				}
			}

	if(dp[0][n][0][0] >= m)
		return cout << 0 << endl , 0;

	for(int i = 1; i < maxb; i++)
	{
		// ofoghi
		int x = i&1;
		for(int l = 0; l < maxn; l++)
			for(int r = 0; r < maxn; r++)
				for(int k = 0; k < maxn; k++)
					dp[l][r][k][x] = 1e9;

		for(int l = 0; l < n; l++)
			for(int y = 0; y < m; y++)
			{
				int pt = l;
				for(int r = l + 1; r <= n; r++)
				{
					dp[l][r][y][x] = -1;
					while(pt < r && dp[l][pt + 1][y][x ^ 1] >= dp[pt + 1][r][y][x ^ 1])
						pt++;
					upd(l , r , y , x , pt);
					upd(l , r , y , x , pt - 1);
					upd(l , r , y , x , pt + 1);
				}
			}

		// amudi

		for(int l = 0; l < n; l++)
			for(int r = l + 1; r <= n; r++)
			{
				for(int y = 0; y < m; y++)
				{
					int k = dp[l][r][y][x ^ 1];
					if(0 <= k && k < m)
						dp[l][r][y][x] = max(dp[l][r][y][x] , dp[l][r][k][x ^ 1]);
					else
						dp[l][r][y][x] = max(dp[l][r][y][x] , k);
				}
			}

		if(dp[0][n][0][x] >= m)
			return cout << i << endl , 0;
	}
}



















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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    string ans = ":(";
    for (int x = 1; x <= 46297; x++)
        if (int(1.08 * x) == n)
            ans = to_string(x);
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream> //if文が使える
#include <vector>　//可変文字列が扱える

using namespace std;

int main() {
  //input
  int n, k;
  cin >> n >> k;
  k --;

  vector<char> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
    cerr << a[i];
  }
  //solve
  if (a[k] == 'A'){
    a[k] = 'a';
  }else if(a[k] == 'B'){
    a[k] = 'b';
  }else{
    a[k] = 'c';
  }

  // output
  for (int i = 0; i < n; i++){
    cout << a[i];
  }
cout << endl;

  return 0;
}


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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x : a){
        cin >> x;
    }
    int ct = 1;
    for(int i = 0; i < n; i++){
        if(ct == a[i]){
            ct++;
        }
    }
    ct--;
    if(n - ct < n){
        cout << n - ct;
    }else{
        cout << -1;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b) = readListOfInt()
    val ans = (a + b) % 24
    println(ans)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    val rtn = v.map { it.toList() }.toList()
    return rtn 
}

fun gcd(a: Long, b: Long): Long = 
if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/


ll gcd(ll a, ll b)
{
	while (b) {
		ll t = (ll)a % (ll)b;
		a = b;
		b = t;
	}
	return a;
}

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


int main()
{
	cin >> n;
	vi v(n);
	stack<ll> st;
	REP(i, n)
	{
		cin >> v[i];
	}
	REP(i, n) st.push(v[i]);
	while (st.size() != 1) {
		ll a = st.top();
		st.pop();
		ll b = st.top();
		st.pop();
		ll c = lcm(a, b);
		st.push(c);
	}
	cout << st.top() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    ll n{},k{};
    cin>>n>>k;
    ll x = (ll)pow((k-1),(n-1));
    cout<<x*k<<endl;
    return 0;
}


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

int main() {
	int r, c;
	cin >> r >> c;

	vector<vector<int>> tb( r+1, vector<int>( c+1 ) );
	for( int i = 0; i < r; ++i ) {
		for( int j = 0; j < c; ++j ) {
			int x;
			cin >> x;

			tb.at( i ).at( j ) = x;
			tb.at( i ).at( c ) += x;
			tb.at( r ).at( j ) += x;
			tb.at( r ).at( c ) += x;
		}
	}

	for( int i = 0; i < r+1; ++i ) {
		for( int j = 0; j < c+1; ++j ) {
			cout << tb.at( i ).at( j );

			if( j < c ) { cout << ' '; }
		}

		cout << endl;
	}
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x;
  int y;
  //商品の個数を入力
  cin >> x;
  cin >> y;
  
  vector<int> a(x);
  for(int i=0; i<=x-1; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  int s=0;
  
  for(int j=0; j<=y-1; j++){
    s += a.at(j);
  }
  
  cout << s << endl;
    
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <climits>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll n;
ll mod=pow(10,9)+7;
ll arr[3005];
ll dp[3005][3005][2];
ll calc(ll i,ll j,ll flag)
{
    if(i>j)
    {
        return 0;
    }
    if(dp[i][j][flag]!=-1)
    {
        return dp[i][j][flag];
    }
    if(flag==0)
    {
        ll ans1=calc(i+1,j,1)+arr[i];
        ll ans2=calc(i,j-1,1)+arr[j];
        return dp[i][j][0]=max(ans1,ans2);
    }
    ll ans1=calc(i+1,j,0)-arr[i];
        ll ans2=calc(i,j-1,0)-arr[j];
        return dp[i][j][1]=min(ans1,ans2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;++i)
    {
        cin>>arr[i];
    }
    cout<<calc(0,n-1,0)<<endl;
}






































Measured memory_bytes: 144920
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    l = []
    for i in range(n):
        l.append([a[i], i])
    l.sort(reverse=True)
    dp = [[0]*(n+1) for _ in range(n)]
    for i in range(n):
        if i == 0:
            dp[i][0] = l[i][0] * (n-1-l[i][1])
            dp[i][1] = l[i][0] * l[i][1]
        else:
            for j in range(n, -1, -1):
                if dp[i-1][j] > 0:
                    dp[i][j+1] = max(dp[i][j+1], dp[i-1][j] + l[i][0] * abs(j-l[i][1]))
                    dp[i][j] = max(dp[i][j], dp[i-1][j] + l[i][0] * abs(n-i+j-1-l[i][1]))
    print(max(dp[-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 101052
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)

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

  int x=0,answer=1;
  for(int i=1;i<=n;i++){
    int a = 0;
    int b = i;
    while(b%2 == 0){
      a++;
      b /= 2;
    }
    if(a > x) answer = i;
    x = max(x,a);
  }

  cout <<answer <<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,X;
    cin>>N>>X;
    int L[N],i,a;
    for(i=0;i<N;i++)
        cin>>L[i];
    i=1;
    a=0;
    while(a<X){
        if(i>N)
            break;
        a=a+L[i-1];
        if(a>X)
            break;
        i=i+1;
    }
    cout<<i;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;


//文字列検索　KMP法
// kmp をやるための前計算 0-iの接頭辞と接尾辞が何文字まであっているかをTableに保存
vector<int> makeTable(const string& s) {
    int n = s.size();
    vector<int> ret(n+1);
    ret[0] = -1;
    int j = -1;
    for (int i = 0; i < n; i++) {
        while (j >= 0 && s[i] != s[j]) j = ret[j];
        ret[i+1] = ++j;
    }
    return ret;
}
// str の中に word とマッチする場所のリストを返す
// ret のそれぞれの要素 el は, 「str[el] からの文字列が word と一致する」ことを示す
vector<int> kmp(const string& str, const string& word) {
    vector<int> table = makeTable(word), ret;
    int m = 0, i = 0, n = str.size();
    while (m+i < n) {
        if (word[i] == str[m+i]) {
            if (++i == (int)(word.size())) {
                ret.push_back(m);
                m = m+i-table[i];
                i = table[i];
            }
        } else {
            m = m+i-table[i];
            if (i > 0) i = table[i];
        }
    }
    return ret;
}

int main(){

  string s,t;
  cin >> s>>t;

  int sl=s.length();
  int tl=t.length();

  string news="";

  int n=max(1,(2*tl)/sl); //ここ？

  news.reserve(sl*(n+1));

  rep(i,n+1){
    news+=s;
  }



  int newsl=news.length();

  vector<int> kr=kmp(news,t);

//入ってたら1、通ったら-1
  int a[sl]={};
  int ctr[sl]={};

  rep(i,kr.size()){
    if(kr[i]>=sl) break;
    a[kr[i]]=1;
  }
  int maxct=0;
  rep(i,sl){
    if(a[i]!=1) continue;
    int itr;
    int ct=0;
    itr=i;
    while(a[itr]==1){
      ct++;
      a[itr]=-1;
      itr=(itr+tl)%sl;
    }
    if(itr==i){
      std::cout << -1 << '\n';
      return 0;
    }
    ct+=ctr[itr];
    ctr[i]=ct;
    maxct=max(maxct,ct);
  }

  cout << maxct <<endl;
  return 0;
}


Measured memory_bytes: 11004
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N, M;

  cin >> N >> M;

  int s[M];
  int c[M];
  int ret[N];
  for (int i = 0; i < N; ++i)
    ret[i] = -1;
  for (int i = 0; i < M; ++i) {
    cin >> s[i];
    cin >> c[i];
  }

  for (int i = 0; i < M; ++i) {
    if (ret[s[i] - 1] != -1 && ret[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    if (N > 1 && s[i] == 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    ret[s[i] - 1] = c[i];
  }

  if (N == 1 && (ret[0] == 0 || ret[0] == -1)) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < N; ++i) {
    if (ret[i] == -1 && i == 0)
      ret[0] = 1;
    else if (ret[i] == -1)
      ret[i] = 0;
  }

  for (int i = 0; i < N; ++i)
    cout << ret[i];
  cout << endl;

  return 0;
}

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

using ll = long long;

int main(){
    ll k, r=0, g=0, b=0, ans = 0;
    string s;
    cin >> k >> s;
    rep(i,k){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    ans = r*g*b;
    for(int d = 1; 1 + 2*d <= k; d++){
        for(int i = 0; i + 2*d < k; i++){
            if(s[i] != s[i + d] && s[i] != s[i + 2*d] && s[i + d] != s[i + 2*d]) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;;testcase++){
    int2(n, m);
    int a[m]; scn(m, a);

    int res[n];
    rep(i, n)res[i] = 0;

    rep(i, m){
      rep(j, n){
        int(b);
        if(b == a[i])res[j]++;
        else res[a[i] - 1]++;
      }
    }
    rep(k, n)pri(res[k]);



/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define longinf 9223372036854775807LL
#define intinf 2147483647
#define inf 998244353
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d,e=0,g,h;
int i[111110];
int dp[100011];
int ka(int x){
    if(dp[x]!=-1) return dp[x];
    if(x==0) return dp[x]=0;
    if(x==1) return dp[x]=abs(i[0],i[1]);
    int nx=abs(i[x],i[x-1]);
    int ny=abs(i[x],i[x-2]);
    return dp[x]=min(ka(x-1)+nx,ka(x-2)+ny);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a;
  memset(dp,-1,sizeof(dp));
  for(int n=0;n<a;n++) cin >>i[n];
  cout <<ka(a-1)<<'\n';
  return (0);
}


Measured memory_bytes: 3328