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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

ll dp[100010][110];

void solve()
{
  ll N, W; cin >> N >> W;
  vector<ll> w(N+1), v(N+1); rep1(i, N) cin >> w[i] >> v[i];
  ll ans = 0;

  rep(i, W) rep(j, N) dp[i][j] = 0;

  rep1(j, N) {
    rep1(i, W) {
      chmax(dp[i][j], dp[i][j-1]);
      if(i-w[j] >= 0) {
	
	chmax(dp[i][j], dp[i - w[j]][j - 1] + v[j]);
      }
    }
  }
  /*
  rep(j, N + 1) {
    rep(i, W + 1) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  ans = dp[W][N];
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair
int main(){
	char a[10002],b[10002];
	scanf("%s%s",a,b);
	int n = strlen(a);
	int m = strlen(b);
	int i,j;
	int dp[n+1][m+1];
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
			else if(a[i-1]==b[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	// printf("%d\n",dp[n][m] );
	char ans[dp[n][m]+1];
	ans[dp[n][m]]='\0';
	int fin = dp[n][m]-1;
	while(n>0 && m>0){
		if(a[n-1] == b[m-1]){
			ans[fin] = a[n-1];
			n--;
			m--;
			fin--;
		}
		else if(dp[n-1][m]>dp[n][m-1]){
			n--;
		}
		else
		{
			m--;
		}
	}
	printf("%s\n",ans );
	return 0;
}

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

int main(){
  int N,D;
  cin >> N >> D;
  vector<vector<int>> v(N,vector<int>(D));
  loop(i,N){
    loop(j,D){
      cin >> v.at(i).at(j);
    }
  }
  int ans = 0;
  loop(i,N){
    for(int j=i+1;j<N;++j){
      double dis = 0;
      loop(k,D){
        int l = pow(v.at(i).at(k)-v.at(j).at(k),2);
        dis += l;
      }
      dis = sqrt(dis);
      if(floor(dis)==dis){
        ++ans;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
double x[66],y[66],ans=1e9+100,c[66];
queue<pair<pair<double,double>,double> >q;
vector<double>v;
double ddd(double xx,double yy,double aa)
{
	v.clear();
	for(int i=0;i<n;i++)
	{
		v.push_back(c[i]*sqrt(max(abs(x[i]-xx)-aa,0.0)*max(abs(x[i]-xx)-aa,0.0)+max(abs(y[i]-yy)-aa,0.0)*max(abs(y[i]-yy)-aa,0.0)));
	}
	sort(v.begin(),v.end());
	return v[k-1];
}
double nd(double xx,double yy)
{
	v.clear();
	for(int i=0;i<n;i++)
	{
		v.push_back(c[i]*sqrt((x[i]-xx)*(x[i]-xx)+(y[i]-yy)*(y[i]-yy)));
	}
	sort(v.begin(),v.end());
	return v[k-1];
}
int main()
{
	cout<<setprecision(10);
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i]>>c[i];
	}
	q.push(make_pair(make_pair(0.0,0.0),1000.0));
	while(!q.empty())
	{
		double xx=q.front().first.first,yy=q.front().first.second,dd,t=q.front().second;
		dd=ddd(xx,yy,t);
		q.pop();
		if((ans-dd)<=0.0000001*max(1.0,dd))
		{
			continue;
		}
		ans=min(ans,nd(xx,yy));
		for(double i=-0.5;i<=0.5;i+=1.0)
		{
			for(double j=-0.5;j<=0.5;j+=1.0)
			{
				q.push(make_pair(make_pair(xx+i*t,yy+j*t),t/2.0));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  
  for(int i = 0; i < num.size(); i++){
    cin >> num.at(i);
  }
  
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  int ans = 0;
  
  for(int i = 0; i < num.size(); i++){
    if(i % 2 == 0){
      ans += num.at(i);
    } else {
      ans -= num.at(i);
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc170/abc170_d
from collections import Counter

def main():
    N = input()
    A = sorted(map(int, input().split(' ')))
    B = Counter(A)
    r = 0
    for a in A:
        if B[a] == 0:
            continue
        if B[a] == 1:
            r += 1
        for i in range(2, A[-1] // a + 1):
            B[a * i] = 0
    print(r)
    return

main()


Measured memory_bytes: 96764
#include <iostream>


using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    if(N > 0 && N < 1000) {
        cout << "ABC";
    }
    else if(N > 999 && N < 1999) {
        cout << "ABD";
    }
    
    return 0;
}


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

using ll = long long;
using namespace std;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);

#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}


void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> A, B;
	CINV(B, M);
	int res = 0;
	rep(i, N) {
		CINV(A, M);
		int t = C;
		rep(i, M) t += A[i] * B[i];
		if (t > 0) res++;
	}
	cout <<res << endl;
}

void solve()
{
}




Measured memory_bytes: 256
import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
h[0] -= 1
for i in range(1, n-1):
    dif_1 = h[i] - h[i+1]
    dif_2 = h[i] - h[i-1]
    if dif_1 > 1:
        print(ans)
        sys.exit()
    elif dif_1 == 1 or dif_2 > 0:
        h[i] -= 1


max_h = 0
for i in range(1, n):
    max_h = max(max_h, h[i-1])
    dif = h[i] - max_h
    if dif < 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)

Measured memory_bytes: 23132
#include<stdio.h>

int sisya(int a,int b){
	int temp=a%b*10;
	
	if(temp/b >=5)return a/b+1;
	else return a/b;
	
}



int main(){
	int value,num;
	int v_sum=0;
	int n_sum=0;
	int cnt=0;
	
	while(scanf("%d,%d",&value,&num)!=EOF){
		cnt++;
		v_sum+=value*num;
		n_sum+=num;
	}
	num=sisya(n_sum,cnt);
	printf("%d\n%d\n",v_sum,num);
	
	return 0;
}


Measured memory_bytes: 1916
n, m, t = map(int, input().split())
a = list(map(int, input().split()))
ts = [0 for i in range(t)]
for i in a:
    ts[max(i - m, 0)] = 2 * m
temp = 0
count = 0
for i in range(1, t):
    ts[i] = max(ts[i - 1] - 1, ts[i])
print(ts.count(0))



Measured memory_bytes: 5716
import sys
from collections import Counter

N = int(input())
a = list(map(int,input().split()))
a.sort()
YES = 'Yes'
NO = 'No'
if a == [0]*N:
  print(YES)
  sys.exit()
  
if N%3 !=0:
  print(NO)
  sys.exit()
  
counter = Counter(a)
if len(counter) > 3:
  print(NO)
  sys.exit()
elif len(counter) == 3:
  if list(counter.values()) != [N//3,N//3,N//3]:
    print(NO)
  else:
    xor = 0
    for key in counter.keys():
      xor ^= key
    if xor == 0:
      print(YES)
    else:
      print(NO)
  sys.exit()
elif len(counter) == 2:
  if list(counter.keys())[0] == 0 and list(counter.values())[0] == N//3:
    print(YES)
  else:
    print(NO)
  sys.exit()

print(NO)

Measured memory_bytes: 14468
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#include<string.h>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
using namespace std;
const int maxn=200000+6;
#define mod 1000000007
#define INF 0x3f3f3f3f
map<int,int>mmp;
int main()
{
    int n;
    cin>>n;
    int flag=0;
    rep(i,1,n)
    {
        int x;
        cin>>x;
        if(mmp[x]){flag=1;break;}
        mmp[x]=1;
    }
    if(!flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


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

int main(){
  
  long long x, y;
  cin>>x>>y;
  
  int cnt=0;
  
  while(1){
    cnt++;
    x*=2;
    if(x>y) break;
  }

  cout<<cnt<<endl;
  
  return 0;
}


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

vector<vector<int>> G(3e5);
vector<bool> seen(3e5,false);
int cnt;

void dfs(int u) {
  seen[u]=true;
  cnt++;
  for(auto next:G[u]) {
    if(seen[next]!=false) continue;
    dfs(next);
  }
}

int main() {
  int n,m,ans=0;
  cin>>n>>m;
  int a,b;
  for(int i=0;i<m;i++) {
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int u=1;u<=n;u++) {
    if(seen[u]==false) {
      cnt=0;
      dfs(u);
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 22796
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 537427207;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int h,w;cin>>h>>w;
    string s;
    rep(i,h){cin>>s;cout<<s<<endl<<s<<endl;}
}

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

int main(){
 int K;
 string S;
 cin >> K >> S;
 
 int n;
 n = S.size();
 string moji;
   
 if(n<=K){
   cout << S << endl;
 }
 else{
   for(int i=0; i<K; i++){
     moji += S[i];
   }
   cout << moji + "..." << endl;
 }
  
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    map< vector<ll>, ll > m;
    string s;
    ll n, ans = 0;
    cin >> n;
    for (ll i = 0; i < n; ++i) {
        cin >> s;
        vector<ll> c(26);
        for (ll j = 0; j < 10; ++j) ++c.at(s.at(j) - 'a');
        ++m[c];
    }
    for (auto i = m.begin(); i != m.end(); ++i) ans += (*i).second * ((*i).second - 1);
    cout << ans / 2 << '\n';
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  set<int> cl;
  vint sum(10);
  rep(i, N) {
    int a; cin >> a;
    int b = min(8LL, a/400);
    cl.insert(b);
    sum[b]++;
  }
  if(cl.count(8LL)) cout << max(1LL, (int)cl.size()-1) << " ";
  else cout << cl.size() << " ";
  if(cl.count(8LL)) cout << (int)cl.size()+sum[8]-1 << endl;
  else cout << cl.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
   int a,b,c,d;
   cin>>a>>b;
   if(a<b)
   {


   c=b-a;
   d=b+c;
   }
   if(b<a)
   {


   c=a-b;
   d=b-c;
   }
   if(a==b)
   {

           c=0;
           d=c+a;
   }
   cout<<d;
	
}


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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int a,b;
  cin >> a >> b;
  cout << (a < b?0:10) << endl;
}

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

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

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

int main() {
    int r;
    cin >> r;
    cout << r*r << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// UnionFind 解説：https://youtu.be/TdR816rqc3s?t=8424
struct UnionFind {
	vi d;
	UnionFind(int n = 0) : d(n, -1) {}

	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);

		if (x == y) return false;

		if (d[x] > d[x]) swap(d[x], d[x]);
		d[x] += d[y];
		d[y] = x;
		return true;
	}

	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};

// ──────────────────────────────────────────────────────────────────

int d[10][10];

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

	rep(i, 10) rep(j, 10) {
		int v;
		cin >> v;
		d[i][j] = v;
	}

	vvi c(n, vi(m));
	rep(i, n) rep(j, m) {
		int v;
		cin >> v;
		c[i][j] = v;
	}

	rep(k, 10) rep(i, 10) rep(j, 10) {
		chmin(d[i][j], d[i][k] + d[k][j]);
	}

	/*
	rep(i, 10) {
		rep(j, 10) {
			if (d[i][j] == inf) cout << "INF" << " ";
			else cout << d[i][j] << " ";
		}
		cout << endl;
	}
	*/

	int ans = 0;
	rep(i, n) {
		rep(j, m) {
			if (c[i][j] != -1) ans += d[c[i][j]][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <set>

using namespace std;

int main() {
  int p, W{};
  set<int> s;
  map<int,int> m;
  string S;
  cin >> p >> p;
  while (cin >> p >> S) {
    if (s.count(p)) continue;
    else if (S=="AC") s.insert(p), W += m[p];
    else ++m[p];
  }
  cout << s.size() << " " << W << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        int n = i + 1;
        int sum = n % 10;
        while (n /= 10) {
            sum += n % 10;
        }
        p[i] = make_pair(i + 1, sum);
    }

    int a, b;
    cin >> a >> b;
    ll ans = 0;
    for (const auto& c : p) {
        if (c.second >= a && c.second <= b) {
            ans += c.first;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int r, D, x2000;
    vector<int> x;

    cin >> r >> D >> x2000;
    x.push_back(x2000);

    for(int i = 1; i <= 10; i++)
    {
        int current_x = r * x[i - 1] - D;
        x.push_back(current_x);

        cout << current_x << endl;
    }
}

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

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {            
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int count = 0;

            for (int i = 0; i < s.Length; i++)
            {
                if(s[i] == t[i])
                {
                    count++;
                }
            }

            Console.WriteLine(count.ToString());
        }
    }
}


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

int main()
{
    int64_t x;
    cin>>x;
  
    int x500 = x/500;
  
    int x5 = (x%500)/5;
    
   int sum = (x500*1000)+(x5*5);

   cout<<sum<<endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int total = a + b + c;
        
        String output = "Yes";
        if(a * 2 != total && b * 2 != total && c * 2 != total) output = "No";
        System.out.println(output);
    }
}


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

int main() 
{
	int a, b, k; cin >> a >> b >> k;
	for (int i = a; i <= min(b, a + k - 1); i++)cout << i << endl;
	for (int i = max(b - k + 1, a + k); i <= b; i++) cout << i << endl;

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,K;
    cin>>N>>K;
    if(1+2*(K-1)>N)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*************************************************************************
    > File Name: D.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-12-16 19:27:12
 ************************************************************************/

#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int h,w,k;
set<int> v[MAXN];
int main()
{
    scanf("%d%d",&h,&w);
    scanf("%d",&k);
    for(int i=0;i<k;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v[y].insert(x);
    }
    if(k==0)
    {
        printf("%d\n",h);
        return 0;
    }
    int ans=h;
    int now=1;
    for(int i=1;i<=w;i++)
    {
        auto it=v[i].lower_bound(now);
        if(it!=v[i].end()) ans=min(ans,*it-1);
        if(i==w) break;
        if(v[i].count(now+1)||now==h) break;
        now++;
        bool f=true;
        while(now<=h&&v[i+1].count(now))
        {
            now++;
            if(v[i].count(now)) {f=false; break;}
        }
        if(now>h||!f) break;
    }
    printf("%d\n",ans);
    return 0;
}



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


int max_num = 100100100;

int dp[20010];

int main() {
    int H, N;
    cin >> H >> N;
    
    
    for (int i = 0; i < 20010; ++i) dp[i] = max_num;
    dp[0] = 0;

    vector<int> A(N);
    vector<int> B(N);

    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];

    for (int i = 0; i < 10010; ++i){
        for (int j = 0; j < N; ++j){
            dp[i+A[j]] = min(dp[i+A[j]], dp[i]+B[j]);
        }
    }
    int ans = max_num;
    for (int i = H; i < 20010; ++i){
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct Edge { int from, to; };
int main() {
    int N, M;
    cin >> N >> M;
    vector<Edge> edges(M);
    vector<vector<bool>> adj(N, vector<bool>(N, false)), cp;
    for (int i = 0, a, b; i < M; i++) {
        cin >> a >> b;
        edges[i] = {a, b};
        adj[a - 1][b - 1] = adj[b - 1][a - 1] = true;
    }
    int ans = M;
    for (int i = 0; i < M; i++) {
        cp = adj;
        int a = edges[i].from, b = edges[i].to;
        cp[a - 1][b - 1] = cp[b - 1][a - 1] = false;
        queue<int> q;
        q.push(a);
        vector<bool> visited(N, false);
        visited[a - 1] = true;
        while (!q.empty()) {
            int t = q.front();
            q.pop();
            for (int j = 1; j <= N; j++) {
                if (j == t) continue;
                if (cp[t - 1][j - 1] && !visited[j - 1]) {
                    q.push(j);
                    visited[j - 1] = true;
                }
            }
        }
        if (visited[b - 1]) ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;
 
int main(){
  int n;
  cin >> n;
  
  vector<vector<int>> h(n, vector<int>(3));
  rep(i,n){
    rep(j,3){
      cin >> h.at(i).at(j);
    }
  }
  vector<vector<int>> dvector(n, vector<int>(3,0));
  
  
  rep(i,n){
    
    if (i == 0){
      rep(l,3){dvector.at(0).at(l) = h.at(0).at(l);}
      continue;
    }
    
    rep(j,3){
      rep(k,3){
        
      if(k != j){
        dvector.at(i).at(j) = max(dvector.at(i).at(j), dvector.at(i-1).at(k)+h.at(i).at(j));
      }
      
      }
    }
  }
    
    int ans = 0;
    rep(i,3){
    ans = max(ans, dvector.at(n-1).at(i));
    }
    
    cout << ans << endl;
    
  }


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

double abso(double x) {
    if (x<0) return -x;
    return x;
}

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    int t, a; cin >> t >> a;
    int h; cin >> h;
    int j=0; double to = t-h*0.006;
    for(int i=1;i<n;++i) {
        cin >> h;
        if(abso(a-(t-h*0.006)) < abso(a-to)) {
            j=i;
            to=t-h*0.006;
        }
    }
    cout << j+1 << endl;
    return 0;
}


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

int main() {
    int mod = 1000000007;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<ll> dp(13, 0);
    dp[0] = 1;
    int m = 1;
    rep(i, s.size()) {
        vector<ll> tmp(13, 0);
        rep(j, 10) {
            if (s[i]!='?' && s[i]-'0'!=j) continue;
            rep(k, 13) tmp[k] += dp[(k-j*m%13+13)%13];
        }
        rep(k, 13) tmp[k]%=mod;
        dp = tmp;
        m = 10*m%13;
    }
    cout << dp[5] << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    char x;
    int count[26]={0},a,i;
    while(cin>>x){
        a=x-'a';
        if(a<0){
            a+=32;
        }
        count[a]++;
    }
    for(i=0;i<26;i++){
        cout<<(char)(i+'a')<<" : "<<count[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1144
# -*- coding:utf-8 -*-
import sys
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
a = Counter(A)
width = -1
height = -1
candinate = []
for tmp in reversed(sorted(list(set(A)))):
    b = a[tmp]
    if b >= 4:
        if width == -1:
            width = tmp
        if height == -1:
            height = tmp
    elif b >= 2:
        if width == -1:
            width = tmp
            b = 0
        if height == -1 and b != 0:
            height = tmp
    else:
        pass
    if width != -1 and height != -1:
        print(width*height)
        sys.exit()
print(0)

Measured memory_bytes: 20892
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int lB = 0;
        int rA = 0;
        int lrBA = 0;

        int ans = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            boolean isLeftB = false;
            boolean isRightA = false;
            if (s.charAt(0) == 'B')
                isLeftB = true;
            if (s.charAt(s.length()-1) == 'A')
                isRightA = true;

            if (isLeftB && isRightA)
                lrBA++;
            else if (isLeftB)
                lB++;
            else if (isRightA)
                rA++;

            for (int j = 0; j < s.length(); j++) {
                if (s.indexOf("AB", j) >= 0) {
                    ans++;
                    j = s.indexOf("AB", j);
                } else {
                    break;
                }
            }
        }

        if (lrBA == 0) {
            ans += Math.min(lB, rA);
        } else {
            if (lB == 0 && rA == 0)
                ans += lrBA - 1;
            else
                ans += lrBA += Math.min(rA, lB);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 31500
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    long long int i,j,a,b,n,x,y,z,t,k,sum,sum1;
    vector<long long int> v,v1;
    string s,s1;
    unordered_map<long long int,long long int> m,m1;
    unordered_map<long long int,vector<long long int>> m3;
    t=1;
  //  cin>>t;
    while(t--)
    {
        cin>>n;
        sum=1e10;
        for(i=0;i>-1;i++)
        {
            j=abs((ll)(pow(i,5)+0.5));
            if(m1[j]==1)
            {
                cout<<i<<" "<<m[j-n];
                return 0;
            }
            else if(m1[-j]==1)
            {
                cout<<i<<" "<<m[-j-n];
                return 0; 
            }
            m[j]=i;
            m[-j]=-i;
            m1[n+j]=1;
            m1[n-j]=1;
          
        }
       
    }
}











Measured memory_bytes: 4120
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B = MAP()

print(A*B//gcd(A, B))


Measured memory_bytes: 5156
def main():
    import heapq
    n = int(input())
    ab = [tuple(map(int, input().split())) for _ in [0]*n]
    # 1周目
    d = dict()
    for a, b in ab:
        d[(a, b)] = d.get((a, b), 0)+1
    left, right = [(b, a) for a, b in ab], [(-a, b) for a, b in ab]
    heapq.heapify(left)
    heapq.heapify(right)
    ans1 = 0
    now = 0
    for i in range(n):
        while left:
            a, b = heapq.heappop(left)
            a, b = b, a
            if d[(a, b)] > 0:
                d[(a, b)] -= 1
                if b < now:
                    ans1 += now-b
                    now = b
                elif now < a:
                    ans1 += a-now
                    now = a
                break
        while right:
            a, b = heapq.heappop(right)
            a, b = -a, b
            if d[(a, b)] > 0:
                d[(a, b)] -= 1
                if now < a:
                    ans1 += a-now
                    now = a
                elif b < now:
                    ans1 += now-b
                    now = b
                break
    ans1 += abs(now)
    # 2周目
    d = dict()
    for a, b in ab:
        d[(a, b)] = d.get((a, b), 0)+1
    left, right = [(b, a) for a, b in ab], [(-a, b) for a, b in ab]
    heapq.heapify(left)
    heapq.heapify(right)
    ans2 = 0
    now = 0
    for i in range(n):
        while right:
            a, b = heapq.heappop(right)
            a, b = -a, b
            if d[(a, b)] > 0:
                d[(a, b)] -= 1
                if now < a:
                    ans2 += a-now
                    now = a
                elif b < now:
                    ans2 += now-b
                    now = b
                break
        while left:
            a, b = heapq.heappop(left)
            a, b = b, a
            if d[(a, b)] > 0:
                d[(a, b)] -= 1
                if b < now:
                    ans2 += now-b
                    now = b
                elif now < a:
                    ans2 += a-now
                    now = a
                break
    ans2 += abs(now)
    print(max(ans1, ans2))


main()

Measured memory_bytes: 53704
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	int ans = n / (a + b) * a + min(a, n % (a + b));
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
string s;
vector<pair<char, int>> moving;
int solve(int now) {
	for (int i = 0; i < moving.size(); ++i) {
		if (s[now] == moving[i].first) {
			now += moving[i].second;
			if (now < 0) return -1;
			if (now >= s.length()) return 1;
		}
	}
	return 0;
}
int main(){
	int n, query;
	cin >> n >> query;
	cin >> s;
	REP(i, query) {
		string a, b;
		cin >> a >> b;
		moving.push_back(make_pair(a[0], b == "R" ? 1 : -1));
	}
	int bot = 0;
	int top = n-1;
	long long ans = n;
	while (top - bot > 1) {
		int mid = (top + bot) / 2;
		if (solve(mid) == -1) {
			bot = mid;
		}
		else {
			top = mid;
		}
	}
	if (solve(top) == -1) {
		ans -= top + 1;
	}
	else if (solve(bot) == -1) {
		ans -= bot + 1;
	}
	bot = 0;
	top = n - 1;
	while (top - bot > 1) {
		int mid = (top + bot) / 2;
		if (solve(mid) == 1) {
			top = mid;
		}
		else {
			bot = mid;
		}
	}
	if (solve(bot) == 1) {
		ans -= n - bot;
	}
	else if (solve(top) == 1) {
		ans -= n - top;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2804
#include <cstdio>
using namespace std;
int n, a, x, y, c[100005];
int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &a), c[a]++;
	for(i=1; i<=100000; i++) if(c[i]) c[i]%2 ? x++ : y++;
	printf("%d", x+y-y%2);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9+7;
const ll inf = 1e10;
const double pi = 3.141592;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

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

template<class T>
bool contain(const string& s, const T& v){
  return s.find(v) != std::string::npos;
}

ll f(int a, int b){
  if(a == b || a == 0 || b == 0) return 1;
  else return f(a-1, b-1)%mod+f(a-1, b)%mod;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  unordered_set<ll> num;
  rep(i , n){
    ll tmp;
    cin >> tmp;
    if(num.count(tmp)) num.erase(tmp);
    else num.insert(tmp);
  }
  cout << num.size() << "\n";
  return 0;
}   

Measured memory_bytes: 4388
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[]a = new int[N];

    for(int i=0; i<N; i++){
    a[i] = sc.nextInt();
}
    Arrays.sort(a);
    
    int max = a[N-1];
    int min = a[0];

	System.out.println(max-min);
      }
}

Measured memory_bytes: 35756
# 解説と以下を参考に作成
# https://atcoder.jp/contests/abc105/submissions/17007379
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
import math


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N):
    if N == 0:
        print('0')
        return

    ans = ''
    while N != 0:
        # 1桁目が 1 or 0 かはNが奇数か偶数かによってのみ決まる.
        #  → 2 で割った余りから 1 or 0 を決定する.
        m = N % 2
        ans = str(m) + ans
        # 1桁目の情報を取り除いて(偶数にして)右シフトし, 次の桁についても同様に確認していく.
        # この時, 2(,4,6,...)桁目は負の要素となっているので, 1桁目(1 or 0)として判定するために正負を反転させる.
        N = (N - m) * (-1) >> 1
    print(ans)


if __name__ == '__main__':
    N = int(input())
    solve(N)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 9056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  int A,B,X;
  cin >> A >> B >> X;
  if(A<=X&&X<=A+B){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(auto&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(auto&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(auto&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(auto&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(auto&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto& operator<<(auto& o,TRI<S,T,U>& t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int n;
int a[MAX_N], sm[MAX_N];

template<typename V> class BIT {
private:
	int n; vector<V> bit;
public:
	void add(int i,V x){ i++; while(i < n) bit[i] += x, i += i & -i;}
	V sum(int i){ i++; V s = 0; while(i>0) s += bit[i], i -= i & -i; return s;} //0_indexedで[0,i]の要素の和
	BIT(){} BIT(int sz){ n = sz + 1, bit.resize(n,0);} //初期値がすべて0の場合
	BIT(vector<V>& v){ n = (int)v.size()+1; bit.resize(n, 0); rep(i,n-1) add(i,v[i]);}
	void print(){ rep(i,n-1)cout<<sum(i)-sum(i-1)<< " ";cout<<endl;}
	void print_sum(){ rep(i,n)cout<<sum(i-1)<<" ";cout<<endl;}	//-1スタート
};

// cri 以上
bool possible(int cri)
{
    ll res = 0;
    BIT<int> bt(3*n+2);
    rep(i,n){
        sm[i+1] = sm[i] + (a[i] >= cri);
        bt.add(n+1+2*sm[i+1]-(i+1), 1);
    }
    rep(i,n){
        res += bt.sum(3*n+1) - bt.sum(n+2*sm[i]-i);
        if(i == n-1) break;
        bt.add(n+1+2*sm[i+1]-(i+1), -1);
    }
    return res >= ((ll)(n+1)*n/2+1)/2;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vi A(n);
    rep(i,n){
        cin >> a[i];
        A[i] = a[i];
    }
    zip(A);
    int l = 0, r = len(A);
    while(r-l>1){
        int mid=(l+r)/2;
        if(possible(A[mid])){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << A[l] << "\n";
    return 0;
}


Measured memory_bytes: 2668
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

ll L[1000];
ll D[1000];

int main(){
	ll n,x;
	cin>>n>>x;
	for(int i=1;i<=n;i++){
		cin>>L[i];
	}
	ll cnt=1;
	D[1]=0;
	for(int i=2;i<=n+1;i++){
		D[i]=D[i-1]+L[i-1];
		if(D[i]>x){
			break;
		}
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    int n ; cin >> n;
    ll ans = 0;
    for (int i = 1 ; i <= n ; i++){
        for (int j = 1 ; j <= n ; j++){
            if (i * j >= n) break;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**9)

def main():
    n = int(input())
    # index '0' is not used.
    fact = [2]*(n+1)
    fact[1] = 1

    for i in range(2, n+1):
        if n < i*i:
            break
        else:
            fact[i*i] += 1

        for j in range(i+1, n+1):
            now = i*j
            if now <= n:
                fact[i*j] += 2
            else:
                break
    
    ans = 0
    for i in range(1, n+1):
        ans += i * fact[i]

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

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

int main()
{
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 - h1) * 60 + (m2 - m1) - k << endl;
}

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 100000000;
typedef pair<int, int> P;

int main() {
    int h, w;
    cin >> h >> w;
    bool area[h][w];
    int d[h][w];
    char ch;
    int count = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> ch;
            if (ch == '.') {
                area[i][j] = true;
                count++;
            } else {
                area[i][j] = false;
            }
            d[i][j] = INF;
        }
    }
    queue<P> que;
    que.push(P(0, 0));
    d[0][0] = 0;
    while (que.size()) {
        P p = que.front(); que.pop();
        if (p.first == w-1 && p.second == h-1) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && area[ny][nx] && d[ny][nx] == INF) {
                //cout << nx << " " << ny << endl;
                que.push(P(nx, ny));
                d[ny][nx] = d[p.second][p.first] + 1;
            }
        }
    }
    int ans = count - d[h-1][w-1] - 1;
    if (ans < 0) ans = -1;
    
    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)
	a, b := 0, 0
	for i := 0; i < m; i++ {
		var v int
		fmt.Scan(&v)
		if v < x {
			a++
		} else {
			b++
		}
	}
	if a < b {
		fmt.Println(a)
		return
	}
	fmt.Println(b)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int A=x1*a+y1*b+(x1/10)*c+(y1/20)*d;
    int B=x2*a+y2*b+(x2/10)*c+(y2/20)*d;
    if(A<B)cout<<"kenjiro"<<endl;
    else if(B<A)cout<<"hiroshi"<<endl;
    else cout<<"even"<<endl;
    
    return 0;
}



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

using namespace std;

const int MAX = 1e5 + 5 ;
long long par[MAX] , sz[MAX];
void init()
{
    for(int i = 1 ; i <= 1e5 ; ++i)
        par[i] = i * 1ll , sz[i] = 1ll;
}

int root(int node)
{
    if(par[node] == node)
        return node ;
    return par[node] = root(par[node]) ;
}

long long ans = 0ll ;

void Union(int x , int y)
{
    int a = root(x) ;
    int b = root(y) ;
    if(a == b)
        return ;
    ans -= (sz[a] * (sz[a]-1ll) / 2ll) ;
    ans -= (sz[b] * (sz[b]-1ll) / 2ll) ;
    if(sz[a] < sz[b])
    {
        sz[b] += sz[a] ;
        par[a] = par[b] ;
        ans += (sz[b] * (sz[b]-1ll) / 2ll) ;
    }
    else
    {
        sz[a] += sz[b] ;
        par[b] = par[a] ;
        ans += (sz[a] * (sz[a]-1ll) / 2ll) ;
    }
}

int main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0) ;
    int n , m;
    cin>>n>>m ;
    pair<int , int>arr[m] ;
    for(int i = 0 ; i < m ; ++i)
    {
        cin>>arr[i].first>>arr[i].second ;
    }
    init();
    long long ANS[m] ;
    for(int i = m-1 ; i >= 0 ; --i)
    {
        ANS[i] = (n * 1ll * (n-1ll) / 2ll) - ans;
        Union(arr[i].first , arr[i].second) ;
    }
    for(int i = 0 ; i < m ; ++i)
        cout<<ANS[i]<<"\n";
    return 0 ;
}


Measured memory_bytes: 4480
from fractions import gcd

def lcm(x, y):
	return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())

sub = B - A + 1
cDivNum = (B//C) - ((A-1)//C)
dDivNum = (B//D) - ((A-1)//D)
cdDivNum = (B//lcm(C,D)) - ((A-1)//lcm(C,D))

#print(sub,cDivNum,dDivNum,cdDivNum)
print(sub - (cDivNum+dDivNum-cdDivNum))

Measured memory_bytes: 65644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int n,a,b;
    
    cin >> n;
    
    if (n == 1){
    
    cout << "Hello World" << endl;
    }else {
    
    cin >> a >> b;
    
    cout << a+b << 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++)
typedef long long ll;

ll dfs(int num, ll cur, ll n, bool has_3, bool has_5, bool has_7) {
  if (num == 0) {
    if (!has_3 || !has_5 || !has_7) return 0;
    return (cur <= n) ? 1 : 0;
  }
  int res = 0;
  res += dfs(num - 1, cur * 10 + 3, n, true, has_5, has_7);
  res += dfs(num - 1, cur * 10 + 5, n, has_3, true, has_7);
  res += dfs(num - 1, cur * 10 + 7, n, has_3, has_5, true);
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll n;
  cin >> n;
  int num = ceil(log10(n));
  ll ans = 0;
  for (int i = 3; i <= num; ++i) {
    ans += dfs(i, 0, n, false, false, false);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256