akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<pair<ll,ll>,ll> mp;
ll knapsack01(ll N, ll W, vector<ll> v, vector<ll> w){
    if(N==0||W==0) return 0;
    if(mp.find({N,W})!=mp.end()){
        return mp[{N,W}];
    }
    else{
        if(w[N-1]>W){
            mp[{N,W}] = knapsack01(N-1,W,v,w);
            return mp[{N,W}];
        }
        else{
            mp[{N,W}] = max(v[N-1]+knapsack01(N-1,W-w[N-1],v,w),knapsack01(N-1,W,v,w));
            return mp[{N,W}];
        }
    }
}

ll t[101][100001];
ll DPknapsack01(ll N, ll W, vector<ll> v, vector<ll> w){
    for(int i = 0; i <= N; i++){
        t[i][0]=0;
    }
    for(int j = 0; j <= W; j++){
        t[0][j]=0;
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W; j++){
            if(w[i-1]>j)
                t[i][j] = t[i-1][j];
            else
                t[i][j] = max(t[i-1][j],v[i-1]+t[i-1][j-w[i-1]]);
        }
    }
    return t[N][W];
}

int main(){
    ll N,W;
    cin >> N >> W;
    vector<ll> v,w;
    vector<pair<ll,ll>> obj;
    for(ll i = 0; i < N; i++){
        ll x,y;
        cin >> x >> y;
        obj.push_back({x,y});
    }
    sort(obj.begin(), obj.end());
    for(ll i = 0; i < N; i++){
        w.push_back(obj[i].first);
        v.push_back(obj[i].second);
    }
    //cout << knapsack01(N,W,v,w) << '\n';
    //memset(t,0,sizeof(t));
    cout << DPknapsack01(N,W,v,w);
    //cout << '\n';
    /*
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= W; j++){
            cout << t[i][j] << string(11-floor(log10((t[i][j])?t[i][j]:1)+1),' ');
        }
        cout << '\n';
    }*/
}


Measured memory_bytes: 82544
#include<iostream>
#include<string>
using namespace std;
int main() {
	int p;
	string st;
	cin>>st;
	if(st.find("C")==string::npos||st.find("F")==string::npos)
	{
		cout<<"No\n";
		return 0;
	}
	p=st.find("C");
	if(st.find("F",p)!=string::npos)
	{
		cout<<"Yes\n";
		return 0;
	}else cout<<"No\n";
	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++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

typedef long long Int;

int main() {

    int K, S;
    cin >> K >> S;

    int cnt = 0;

    rep(i,K+1) rep(j,K+1) {
        if (S - i - j >= 0 && S - i - j <= K) cnt++;
    }

    cout << cnt << endl;


    return 0;
}


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

int main() {
    set<string> sets;
    int n;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;

        sets.insert(s);
    }

    cout << (int) sets.size() << endl;
}


Measured memory_bytes: 19224
#include <iostream>
#include <array>

using namespace std;

int main() {
    int32_t n, b, f, r, v;
    const int32_t ROOMS = 10, FLOORS = 3, BLDGS = 4;
    array<array<array<int32_t, ROOMS>, FLOORS>, BLDGS> population = {{{0}}};

    cin >> n;

    for (int32_t i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        population[b - 1][f - 1][r - 1] += v;
    }

    for (b = 0; b < BLDGS; b++) {
        for (f = 0; f < FLOORS; f++) {
            for (r = 0; r < ROOMS; r++) {
                cout << " " << population[b][f][r];
            }

            cout << endl;
        }

        if (b != BLDGS - 1) {
            cout << "####################" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3016
#include<stdio.h>
#include<string.h>
int main()
{
  int i,j,k,f;
  char a[100];
  char b[100];
  char c[100];
  scanf("%s %s %s",a,b,c);
  i=strlen(a);
  j=strlen(b);
  k=strlen(c);
  if(a[i-1]==b[0] && b[j-1]==c[0])
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  return 0;
}


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

int main() {
  double N,i,sum=0,ans,a,x,y;
  cin>>N;
  for(i=0;i<N;i++){
  	double x;
    cin>>x;
    y=1/x;
    sum+=y;
   }
  
  ans=1/sum;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {

    int N;
    cin >> N;

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

    int max = *max_element(p.begin(), p.end());
    int sum = accumulate(p.begin(), p.end(), 0);

    cout << sum - max / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define P pair<int,int>
#define PI acos(-1.0)
#define ls o<<1
#define rs o<<1|1
using namespace std;

int main()
{
#ifdef LOCAL
    freopen("test.in","r",stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;LL ans=0;
    for(int i=1;i<=n;i++) ans+=1LL*(n-i+1)*i;
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        if(u>v) swap(u,v);
        ans-=1LL*u*(n-v+1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3640
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

void move_E(int sai[]){
	int temp;
	int i;

	temp = sai[1];
	sai[1] = sai[4];
	sai[4] = sai[6];
	sai[6] = sai[3];
	sai[3] = temp;
	
}


void move_S(int sai[]){
	int temp;
	int i;
	temp = sai[1];
	sai[1] = sai[5];
	sai[5] = sai[6];
	sai[6] = sai[2];
	sai[2] = temp;
}

void move_R(int sai[]){
	int temp;
	int i;
	temp = sai[2];
	sai[2] = sai[3];
	sai[3] = sai[5];
	sai[5] = sai[4];
	sai[4] = temp;
}

int sarch(int sai[], int sai2[]){
	int re[7];
	int i, j, k;
	int flag = 0;
	int ori[7];
	for(i=0; i<7; i++)
		ori[i] = sai[i];


	//printf("top:1,2,6,5\n");
	/* top:1,2,6,5 */
	for(j=0; j< 4; j++){
		for(i=0; i< 4; i++){
			flag = 1;
//			printf("%d%d%d%d%d%d %d%d%d%d%d%d\n", sai[1],sai[2],sai[3],sai[4],sai[5],sai[6],sai2[1],sai2[2],sai2[3],sai2[4],sai2[5],sai2[6]);
			for(k=1; k< 7; k++){
				if(sai[k] != sai2[k])
					flag *= 0;
			}			

			move_R(sai);
			if(flag == 1)
				break;
		}
		if(flag == 1)
			break;
		move_S(sai);
	}

	if(flag == 0){
		//printf("top:3\n");
		/* top:3 */
		for(i=0; i<7; i++)
		sai[i] = ori[i];

		move_E(sai);
		move_E(sai);
		move_E(sai);
		for(i=0; i< 4; i++){
			flag = 1;
//			printf("%d%d%d%d%d%d %d%d%d%d%d%d\n", sai[1],sai[2],sai[3],sai[4],sai[5],sai[6],sai2[1],sai2[2],sai2[3],sai2[4],sai2[5],sai2[6]);
			for(k=1; k< 7; k++){
				if(sai[k] != sai2[k])
					flag *= 0;
			}
			move_R(sai);
			if(flag == 1)
				break;
		}
	}

	if(flag == 0){
		/* top:4 */
		//printf("top:4\n");
		for(i=0; i<7; i++)
			sai[i] = ori[i];

		move_E(sai);
		for(i=0; i< 4; i++){
			flag = 1;
//			printf("%d%d%d%d%d%d %d%d%d%d%d%d\n", sai[1],sai[2],sai[3],sai[4],sai[5],sai[6],sai2[1],sai2[2],sai2[3],sai2[4],sai2[5],sai2[6]);
			for(k=1; k< 7; k++){
				if(sai[k] != sai2[k])
					flag *= 0;
			}
			move_R(sai);
			if(flag == 1)
				break;
		}
	}
	
	return flag;
	
}

int main(){
	int n;
	int i, j;
	int **sai;
	int flag = 1;

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

	for(i=0; i<n; i++){
		for(j=0; j< 6; j++){
			scanf("%d", &sai[i][j+1]);
		}
	}

	
	for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			if(sarch(sai[i], sai[j]) == 1){
				flag = flag * 0;
			}
		}
	}

	
	if(flag == 1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	

	return 0;

}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> w(n);
  int sum1 = 0;
  rep(i,n){
    cin >> w.at(i);
    sum1 += w.at(i);
  }

  int ans = INF,sum2 = 0;
  rep(i,n){
    sum2 += w.at(i);
    sum1 -= w.at(i);
    ans = min(ans,abs(sum2-sum1));
  }

  cout << ans << endl;

}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <cstdlib>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
int judge(double t1, double t2){
  int j=1;
  if(abs(t2-t1)>M_PI) j*=-1;
  if(t2-t1<0) j*=-1;
  return j;
}

int main(void){  
  double x[4],y[4],t[4];
  while(cin>>x[0]){
    int s = 0;
    cin.ignore();
    cin >> y[0];
    for(int i=1;i<4;i++){
      cin.ignore();
      cin >> x[i];
      cin.ignore();
      cin >> y[i];
    }
    REP(i,4)
      t[i] = atan2(y[(i+1)%4]-y[i], x[(i+1)%4]-x[i]);
    REP(i,4)
      s+=judge(t[i],t[(i+1)%4]);
    if(abs(s) == 4)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

#define rep(i, n) for(int i=0;i<n;i++)

using namespace std;
int main() {
	string s[3];
	rep(i, 3) cin >> s[i];

	rep(i, 3)
		rep(j, 3)
		if (i == j)
			cout << s[i][j];

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  a[(int)1e5+1]={0};
int main()
{
	int n,i,j,s=0;
	scanf("%d",&n);
	a[0]=0;
	a[n+1]=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=abs(a[i-1]-a[i]);
	}
	s+=abs(a[n]-a[0]);
	for(i=1;i<=n;i++)
	{
		printf("%d\n",s-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]));
	}
	return 0;
}

Measured memory_bytes: 1664
import math
N,P=map(int,input().split())

if N==1:
  print(P)
  exit()

for i in range(int(math.sqrt(P))+1,1,-1):
  #print(i)
  temp=i
  tempdiv=P
  count=0
  while(True):
    if tempdiv%temp==0:
      tempdiv=tempdiv//temp
      count+=1
      if count==N:
        print(i)
        exit()
      else:
        continue;
    else:
      break;

print(1)

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll x, y;
    cin >> x >> y;
    bool result = false;
    rep(i, x + 1) {
        ll num = x - i;
        if (i * 2 + num * 4 == y) {
            result = true;
        }
    }

    if (result) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> l(2 * n);
    rep(i, 2 * n){
        cin >> l[i];
    }
    ll ans = 0;
    sort(l.begin(), l.end());
    for(int i = 0; i < 2 * n; i += 2){
        ans += l[i];
    }
    cout << ans << endl;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    lint N;
    cin >> N;
    lint A[200000],B[200000];
    for(int i=0;i<N;i++) cin >> A[i] >> B[i];
    lint sum=0;
    for(int i=0;i<N;i++) sum+=A[i];
    lint pt=INT64_MAX;
    bool same=true;
    for(int i=0;i<N;i++){
        if(A[i]>B[i]){
            if(B[i]<pt) pt=B[i];
        }
        if(A[i]!=B[i]) same=false;
    }
    if(same) cout << '0' << endl;
    else if(pt==INT64_MAX) cout << sum << endl;
    else cout << (sum-pt) << endl;

    return 0;
}

Measured memory_bytes: 2432
h, w = map(int, input().split())

s_org = h * w

answer = h * w
for i in range(2):
  if i == 1:
    h, w = w, h
  for height in range(1, h+1):
    s1 = height * w
    remain_height = h - height
    s2 = remain_height * int(w / 2)
    s3 = s_org - (s1 + s2)
    s_max = max([s1, s2, s3])
    s_min = min([s1, s2, s3])
    answer = min([answer, (s_max - s_min)])

    s1 = height * w
    s2 = int((h - height) / 2) * w
    s3 = s_org - (s1 + s2)
    s_max = max([s1, s2, s3])
    s_min = min([s1, s2, s3])
    answer = min([answer, (s_max - s_min)])
  
print(answer)

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

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

    vector<int> p(N);

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

    int count = 0;

    for(int i = 0; i < N; i++)
    {
        if(p.at(i) != i+1)count++;
    }

    if(count == 2 || count == 0)cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

score=factorization(m)
#print(score)

if m==1:
    print(1)
    exit()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10**9+7 #割る数
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans=1
for item in score:
    c=item[1]
    ans*=cmb(n+c-1, c, p)
    #print(ans)
print(ans%p)






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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var length = c2i(RL());
            //var rl = spr(RL()).Select(x=>c2i(x)).ToList();
            var str =RL();
            var ret = String.Empty;
            if (str.Length <= length)
            {
                ret = str;
            }
            else
            {
                ret = str.Substring(0,(int)length)+"...";
            }




            Console.WriteLine(ret);
            Console.ReadLine();
        
        }
 
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 27544
#include <stdio.h>
#include <string.h>
 
int main(int argc, char *argv[])
{
  int count = 0;
  char S[2*100000+1];
  char T[2*100000+1];
  
  scanf("%s", S);
  scanf("%s", T);
  
  for( int i=0; i<strlen(S); i++) {
    if( *(S+i) != *(T+i) )
      count++;
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 2088
#include <iostream>

using namespace std;

int sx,sy,tx,ty;
int main(){
    cin >> sx >> sy >> tx >> ty;

    for(int y = sy; y < ty; y++){
        cout << "U";
    }    
    for(int x = sx; x < tx; x++){
        cout << "R";
    }
    for(int y = ty; y > sy; y--){
        cout << "D";
    }
    for(int x = tx; x > sx; x--){
        cout << "L";
    }


    cout << "L";
    for(int y = sy; y < ty; y++){
        cout << "U";
    }
    cout << "U";
    for(int x = sx; x < tx; x++){
        cout << "R";
    }
    cout << "R";
    cout << "D";
    
    cout << "R";
    for(int y = ty; y > sy; y--){
        cout << "D";
    }
    cout << "D";

    for(int x = tx; x > sx; x--){
        cout << "L";
    } 
    cout << "L";
    cout << "U";


    return 0;
}

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

int X, A, B;

int main() {
    cin >> X >> A >> B;

    if (B <= A) cout << "delicious" << endl;
    else if (B <= A+X) cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> bl, rd;
    rep(i, 0, n) {
        int a, b;
        cin >> a >> b;
        rd.emplace_back(b, a);
    }
    rep(i, 0, n) {
        int c, d;
        cin >> c >> d;
        bl.emplace_back(c, d);
    }
    sort(bl.begin(), bl.end());
    sort(rd.rbegin(), rd.rend());
    rep(i, 0, n) rd[i] = {rd[i].second, rd[i].first};
    int ans = 0;
    set<int> st;
    rep(i, 0, n) {
        rep(j, 0, n) {
            if (rd[j].first < bl[i].first && rd[j].second < bl[i].second && st.count(j) == 0) {
                ans++;
                st.insert(j);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=int(a);i<int(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define filx(a,x) memset(a,x,sizeof(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

#define MAX 100000
ll n,m;
ll w[111],v[111];
ll dp[MAX+10];
void solve(){
    cin>>n>>m;
    repi(i,n)cin>>w[i]>>v[i];
    filx(dp,INF);
    dp[0]=0;
    repi(i,n)repr(j,MAX+5){
        if(j+v[i]>MAX)continue;
        chmin(dp[j+v[i]],dp[j]+w[i]);
    }
    repr(i,MAX+5){
        if(dp[i]<=m){
            cout<<i<<endl;
            return;
        }
    }
}

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include <cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main(){
	ll N, X, T;
	cin >> N >> X >> T;
	cout << (N + X - 1) / X * T << endl;
}



Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

string solve(string s,string ss){
  if(s==ss)return "IDENTICAL";
  
  vector<string> vs;
  string add="";
  for(int i=0;i<s.size();i++){
    if(s[i]=='"'){
      vs.pb(add);
      add="";
    }else{
      add+=s[i];
    }
  }
  vs.pb(add);

  add="";
  vector<string> vss;
  for(int i=0;i<ss.size();i++){
    if(ss[i]=='"'){
      vss.pb(add);
      add="";
    }else{
      add+=ss[i];
    }
  }
  vss.pb(add);

  int cnt=0;
  // for(int i=0;i<vs.size();i++)cout<<"debug: "<<vs[i]<<" "<<vss[i]<<" ==> "<<(vs[i]==vss[i])<<endl;
  if(vs.size()!=vss.size())return "DIFFERENT";
  for(int i=0;i<min(vs.size(),vss.size());i++){
    // cout<<"debug: "<<vs[i]<<" "<<vss[i]<<endl;
    if(i%2==0){
      if(vs[i]!=vss[i])return "DIFFERENT";
    }else{
      if(vs[i]!=vss[i])cnt++;
    }
  }
  
  // cout<<cnt<<endl;
  if(cnt<=1)return "CLOSE";
  else return "DIFFERENT";
}

int main(){
  string s,ss;
  while(cin>>s){
    if(s==".")break;
    cin>>ss;
    cout<<solve(s,ss)<<endl;;
  }
  return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}



void solve() {
    ll h;
    cin >> h;
    
    vector<ll> two;
    rep(i, 50) two.eb(pow(2LL, i));
    
    int it = ub(two, h);
    it--;
    ll cnt = 0;
    
    ll x = two[it];
    // cout << x << endl;
    while (x) {
        cnt += x;
        x /= 2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
S = input()

if S=="SUN":
    print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto S=vecin(N);

	int M=in();
	REP(i,M){
		int u=in(),v=in();
		reverse(S.begin()+u,S.begin()+v);
	}

	REP(i,N-1){
		cout << S[i] << ' ';
	}
	out(S[N-1]);
	return 0;
}


Measured memory_bytes: 3208
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,x,ans=1;
  cin >> n;
  map<int,int> m;
  for(int i=2; i<=n; i++) {
    x=i;
    for(int j=2; j<=x; j++) {
      while(x%j==0) {
        m[j]++;
        x/=j;
      }
    }
  }
  for(auto p:m) {
    ans*=p.second+1;
    ans%=MOD;
  }
  cout << ans << "\n";
}

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

enum {B, C};

int main() {
	int n; cin >> n;  // ???????????????????????°
	
	while(n--){
		int balls[10] = {0};
		for(int i = 0; i < 10; i++){
			cin >> balls[i];
		}
		
		bool isYES = true;
		int top[2] = {0}; // ???B?????????C???????????¨????????????
		for(int i = 0; i < 10; i++){
			if (top[B] < balls[i]){
				top[B] = balls[i];
			} else if (top[C] < balls[i]) {
				top[C] = balls[i];
			} else {
				isYES = false;
				break;
			}
		}
		cout << (isYES ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;

int main(){
	ll N;
	cin >> N;
	vector<ll> H(N,0);
	for(ll i=0;i<N;i++){
		cin>>H[i]
	;}
	bool ans=1;
	for(ll i=N-1;i>0;i--){
		if(H[i]==H[i-1]-1)H[i-1]--;
		else if(H[i]<H[i-1]-1){ans=0;break;}
	;}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

return 0;
}  



Measured memory_bytes: 1152
// ... (Triple Dots)
#include <bits/stdc++.h>
using namespace std;

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size()<=k){
        cout << s << endl;
        return 0;
    }
    s.erase(s.begin()+k, s.end());
    cout << s << "..." << endl;
    return 0;
}

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

int main(){
	string n;
	cin >> n;
	if(n[0] == '9' || n[1] == '9') cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;

void solve(){
    string s;cin>>s;
    string str[]={"Sunny","Cloudy","Rainy"};
    if(s==str[0]) cout<<str[1];
    else if(s==str[1]) cout<<str[2];
    else if(s==str[2]) cout<<str[0];
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 256
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in("a.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

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

    if (b/a < c) {
        cout << b/a;
    }
    else {
        cout << c;
    }

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



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

int main(){
 int n,i,j;
 char a;
 int cards[4][14]={};
 cin >> n;
 for(int k=1;k<=n;++k){
  cin >> a >> j;
  if(a=='S') i=0;
  else if(a=='H') i=1;
  else if(a=='C') i=2;
  else i=3;

  cards[i][j]=1;
 }
 for(i=0;i<=3;++i){
  for(j=1;j<=13;++j){
   if(cards[i][j]==0){
    if(i==0) cout << "S " << j << endl;
    else if(i==1) cout << "H " << j << endl;
    else if(i==2) cout << "C " << j << endl;
    else cout << "D " << j << endl;
   }
  }
 }
 return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>
#include<string>
using namespace std;

int main()
{

	int str;
	char t[2];
	scanf("%d",&str);
	t[0]=str/100;
	str = str%100;
	t[1]=str;
	int judge = 0;
	if(t[0]>=1 && t[0]<=12)
		judge++;

	if(t[1]>=1 && t[1]<=12)
		judge+=10;

	if(judge==11)
		printf("AMBIGUOUS\n");
	else if(judge==10)
		printf("YYMM\n");
	else if(judge==1)
		printf("MMYY\n");
	else
		printf("NA\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void)
{	
	string n,n1,n2,n3,y3;
	string x1,y1,y2,g="1000";
	int x=0;
	int i,x2;
	int flg=0;
	int a[5],b[5],c[5];
	while(1){
		cin>>n;
		if(n=="0000"){
			break;
		}
		flg=0;
		x=0;
		while(1){
			n1="";
			n2="";
			n3="";
			x1="";
			y1="";
			y2="";
			y3="";
			
			for(i=0;i<4;i++){
				x1=n[i];
				a[i]=stoi(x1);
			}
			if(n=="6174"){
				break;
			}
			if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]){
				flg=1;
				break;
			}
			
			//一回目
			sort(a,a+4,greater<int>());
			/*for(i=0;i<4;i++){
				cout<<a[i];
			}
			cout<<endl;*/
			//x++;
			for(i=0;i<4;i++){
				b[i]=a[i];
				x2=a[i];
				y3=to_string(x2);
				n1+=y3;
			}
			if(n1=="6174"){
				break;
			}
			
			//二回目
			sort(a,a+4);
			/*for(i=0;i<4;i++){
				cout<<a[i];
			}*/
			//cout<<endl;
			//x++;
			for(i=0;i<4;i++){
				c[i]=a[i];
				x2=a[i];
				n2+=to_string(x2);
			}
			//cout<<n2<<endl;
			if(n2=="6174"){
				break;
			}
			//三回目
			//x++;
			for(i=0;i<4;i++){
				int f1=c[i];
				y1+=to_string(f1);
				int f2=b[i];
				y2+=to_string(f2);
			}
			//cout<<y1<<" "<<y2<<endl;
			int m;
			m=stoi(y1);
			int e;
			e=stoi(y2);
			int h;
			h=e-m;
			
			//cout<<m<<" "<<e<<endl;
			//cout<<h<<endl;
			n3=to_string(h);
			if(h<1000){
				n3="0"+n3;
			}
			//cout<<n3<<endl;
			x++;
			if(n3=="6174"){
				break;
			}
			n=n3;
			
		}
		if(flg==1){
			cout<<"NA"<<endl;
		}
		else{
			cout<<x<<endl;
		}
	}
	return 0;
}


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

int main(){
  int stc,cmdc,rx,ry,tx,ty;
  char tc;
  int stloc[21][21];
  int gstc;

  while (1){
    cin >> stc;
    if (stc==0) break;
    
    for (int i=0;i<21;i++)
      for (int j=0;j<21;j++)
      stloc[i][j]=0;
    rx=ry=10;
    gstc=0;    

    for (int i=0;i<stc;i++){
      cin >> tx >> ty;
      stloc[tx][ty]=1;
    }
    
    cin >> cmdc;
    
    for (int i=0;i<cmdc;i++){
      cin >> tc >> tx;
      if (tc == 'E'){
	for (int j=rx+1;j<=rx+tx;j++){
	  gstc += stloc[j][ry];
	  stloc[j][ry]=0;
	}
	rx+=tx;
      }else if (tc == 'N'){
	for (int j=ry+1;j<=ry+tx;j++){
	  gstc += stloc[rx][j];
	  stloc[rx][j]=0;
	}
	ry+=tx;
      }else if (tc == 'W'){
	for (int j=rx-1;j>=rx-tx;j--){
	  gstc += stloc[j][ry];
	  stloc[j][ry]=0;
	}
	rx-=tx;
      }else if (tc == 'S'){
	for (int j=ry-1;j>=ry-tx;j--){
	  gstc += stloc[rx][j];
	  stloc[rx][j]=0;
	}
	ry-=tx;
      }
    }
   
    if (gstc == stc) cout << "Yes" <<endl;
    else cout << "No" << endl;

  }
  return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int imos[111111];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    memset(imos,0,sizeof(imos));
    rep(i,n){
      string s,t;
      cin>>s>>t;
      int start=stoi(s.substr(0,2))*60*60+stoi(s.substr(3,2))*60+stoi(s.substr(6,2));
      int end=stoi(t.substr(0,2))*60*60+stoi(t.substr(3,2))*60+stoi(t.substr(6,2));
      imos[start]+=1;
      imos[end]-=1;
      //dbg(start); dbg(end);
    }
    rep(i,100000)imos[i+1]+=imos[i];
    cout<<*max_element(imos,imos+100000)<<endl;
  }
	return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n;cin >> n;
    map<ll,ll> mp;
    rep(i,n){
        ll a;cin >> a;mp[a]++; 
    }
    if(mp.size()>3)cout << "No" <<endl;
    if(mp.size()==3){
        bool flag=true;
        ll x=0;
        for(auto p:mp){
            x^=p.fi;
            if(p.se!=n/3)flag=false;
        }
        cout << ((flag&&x==0)? "Yes" :"No") <<endl;
    }
    if(mp.size()==2){
        if(n%3)cout << "No" <<endl;
        else{
            ll t=n/3;
            if(mp[0]!=t)cout << "No" <<endl;
            else{
                bool flag=true;
                pl p=*mp.rbegin();
                if(p.se!=2*t)flag=false;
                cout << (flag? "Yes" :"No") <<endl;
            }
        }
    }
    if(mp.size()==1){
        cout << (mp[0]? "Yes" :"No") <<endl;
    }
}

Measured memory_bytes: 8336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,X;
    cin >>N>>X;
    ll now = 0;
    ll ans = 0;
    rep(i,N){
        ll l;
        cin>>l;
        if(now<=X){
            ans++;
        }
        now+=l;
    }  
    if(now<=X){
            ans++;
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3624
n,m = gets.chomp.split.map(&:to_i)
town = Array.new(n,0)
m.times do |i|
  a,b = gets.chomp.split.map(&:to_i)
  town[a - 1] += 1
  town[b - 1] += 1
end

town.size.times do |i|
  puts town[i]
end

Measured memory_bytes: 1916
#include<stdio.h>

int N, i;
double x;
char c[5];
double ans;

int main(){
	ans = 0;
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%lf%s", &x, c);
		if(c[0]=='J'){
			ans += x;
		}else{
			ans += x*380000.0;
		}
	}
	printf("%lf\n", ans);
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;

    int count = S.size() - T.size() + 1;
    vector<string> ans;

    rep(i, count) {
        bool match = true;
        rep(j, T.size()) {
            if(S[j+i] != '?' && S[j+i] != T[j]) {
                match = false;
                break;
            }
        }
        if(match) {
            string tmp;

            rep(j, S.size()) {
                if(j >= i && j < i + T.size()) {
                    tmp += T[j - i];
                } else {
                    if(S[j] == '?')
                        tmp += "a";
                    else
                        tmp += S[j];
                }
            }
            ans.push_back(tmp);
        }
    }

    if(ans.empty()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    } else {
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k; cin>>n>>k;
    int a[n];
    rep(i,n) cin>>a[i];
    repi(i,k,n){
        if(a[i-k]<a[i]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

ans = 0
for i in range(n):
    if p[i] == i + 1:
        if p[i] == n:
            p[i - 1], p[i] = p[i], p[i - 1]
        else:
            p[i + 1], p[i] = p[i], p[i + 1]
        ans += 1

print(ans)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int

using namespace std;

void solve(){
    double pi=3.141592;
    double r;
    cin>>r;
    cout<<fixed<<setprecision(5)<<2*pi*r;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3800
h,n = map(int,input().split())

ab_input = [list(map(int,input().split())) for i in range(n)]
max_d = max(a for a,b in ab_input)

dp =[0]*(h+max_d)
for i in range(1,h+max_d):
    dp[i]=min(dp[i-a]+b for a,b in ab_input)
print(dp[h])

Measured memory_bytes: 9492
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int c=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R')
    c++;
  }
  int ans=c;
  for(int i=0;i<c;i++){
    if(s[i]=='R')
    ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3752
var n,i,t,x,y,ans:longint;
procedure fresh;inline;
begin
  t:=0;inc(ans);
end;
begin
  read(n,x);
  for i:=2 to n do
  begin
    read(y);
    case t of
      0:if x>y then t:=1 else
        if x<y then t:=2;
      1:if x<y then fresh;
      2:if x>y then fresh;
    end;
    x:=y;
  end;
  writeln(ans+1);
end.

Measured memory_bytes: 128
from scipy.sparse.csgraph import shortest_path
import numpy as np
import itertools

N, M, R = map(int, input().split())
r = [int(x) for x in input().split()]

# 任意の2地点間の距離を求める
edge = np.zeros((N+1, N+1))
for _ in range(M):
  A, B, C = map(int, input().split())
  edge[A, B] = C

# 引数 directed=False とすると無向グラフ
dist = shortest_path(edge, directed=False).astype(int)

# 全訪問順を試す。8! = 40320なので十分
answer = 10 ** 18
for visit in itertools.permutations(r):
  p = 0
  prev = visit[0]
  for x in visit[1:]:
    
    p += dist[prev, x]
    prev = x
  answer = min(answer, p)
  
print(answer)

Measured memory_bytes: 18256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<queue>

using namespace std;

int main(){
  int n;
  cin >> n;
  if(n%2) cout << (n-1)/2 << endl;
  else cout << n/2 -1 << endl;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2==0){
    cout << (a+b)/2 << endl;
  }
  else if((a+b)%2<0.5){
    cout << (a+b)/2 << endl;
  }
  else if((a+b)%2>=0.5){
    cout << (a+b)/2+1 << endl;
  }
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define MAX 100001
#define NIL -1

struct Node{int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u){
    int i,c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, "; //親がいなかったらroot
    else if(T[u].l == NIL) cout << "leaf, "; //左の子がいなかったらleaf
    else cout << "internal node, ";

    cout << "[";

    for(int i=0, c=T[u].l; c != NIL; i++, c = T[c].r ){
        if(i) cout << ", "; //初期値は0であるため最初は記されない
        cout << c;
    }
    cout << "]" << endl;
}

//再帰的に深さを求める
int rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r, p); //右の兄弟に同じ深さを設定
    if(T[u].l != NIL) rec(T[u].l, p+1); //左の子に自分の深さ+1を設定
}

int main(){
    int v,d,c,l,r;
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
    cin >> n;
    for(int i=0; i<n; i++){
        T[i].p = T[i].l = T[i].r = NIL; //全てNILを格納する
    }
    for(int i=0; i<n; i++){
        cin >> v >> d; //vは節点の番号、dは次数
        for(int j=0; j<d; j++){
            cin >> c;
            if(j == 0) T[v].l = c; //次数が0のとき
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(int i=0; i<n; i++){
        if(T[i].p == NIL) r=i;
    }

    rec(r,0);

    for(int i=0; i<n; i++) print(i);

    return 0;
}



Measured memory_bytes: 7696