akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int x,y;
  cin >> x >> y;
  vector <int> ans;
  if (x <= y) {
    ans.pb(y - x);
  }
  if (-x <= y) {
    ans.pb(y + x + 1);
  }
  if (x <= -y) {
    ans.pb(-y-x+1);
  }
  if (-x <= -y) {
    ans.pb(1-y+x+1);
  }
  sort(ALL(ans));
  cout << ans.front() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a < b) swap(a, b);
  if(a < c) swap(a, c);
  cout << 10 * a + b + c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}


int main() {
  string s;
  cin>>s;
  int N=s.size();
  bool ok=false;
  for(int i=1;i<N;i++){
      if((s[i]-'0')<9){ok=true;}
  }
  if(ok){cout<<(s[0]-'0')-1+9*(N-1)<<endl;}
  else{cout<<(s[0]-'0')+9*(N-1)<<endl;}
  return 0;
}

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

int main(void){
    int A, B;
    cin >> A >> B;

    if ( (1 <= A && A <= 9) && (1 <= B && B <= 9)){
        cout << A * B << endl;
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int D,N;
int T[200];
int A[200];
int B[200];
int C[200];
int dp[200][101];
int main() {
	cin >> D >> N;
	for(int i=0;i<D;i++){
		cin >> T[i];
	}
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i] >> C[i];
		if(A[i]<=T[0]&&T[0]<=B[i]){
			dp[0][C[i]]=0;
		}
	}
	for(int i=1;i<D;i++){
		for(int j=0;j<N;j++){
			if(A[j]<=T[i]&&T[i]<=B[j]){
				for(int k=0;k<=100;k++){
					if(dp[i-1][k]!=-1){
						dp[i][C[j]]=max(dp[i][C[j]],dp[i-1][k]+abs(C[j]-k));
						//cout << i << ", " << j << ": " << dp[i][j] << endl;
					}
				}
			}
		}
	}
	int ret=0;
	for(int i=0;i<=100;i++){
		ret=max(ret,dp[D-1][i]);
	}
	cout << ret << endl;
}

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

using P = pair<int, int>;

constexpr int dx[] = {1, 0, -1, -1, 0, 1};
constexpr int dy[] = {0, -1, -1, 0, 1, 1};

bool solve(){
    int t, n;
    cin >> t >> n;
    if(t == 0) return true;
    set<P> ng, visited;
    for(int i=0;i<n;i++){
        int x, y;
        cin >> x >> y;
        ng.insert(P(x,y));
    }
    int sx, sy;
    cin >> sx >> sy;
    queue<P> que;
    map<P,int> dist;
    que.push(P(sx,sy));
    visited.insert(P(sx,sy));
    dist[P(sx,sy)] = t;
    while(!que.empty()){
        P p = que.front();
        que.pop();
        if(dist[p] == 0) continue;
        int x = p.first, y = p.second;
        for(int k=0;k<6;k++){
            int nx = x+dx[k], ny = y+dy[k];
            if(ng.count(P(nx,ny)) || visited.count(P(nx,ny))) continue;
            visited.insert(P(nx,ny));
            que.push(P(nx,ny));
            dist[P(nx,ny)] = dist[p]-1;
        }
    }
    cout << visited.size() << endl;
    return false;
}

int main(){
    while(!solve());
    return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
typedef long long ll;
const int N = 1e5+87;
int a[N], b[N], c[N];
ll pr[N], po[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,y,z;
    cin >> x >> y >> z;
    int n = x + y + z;
    ll ans = 0;
    vector<pii> v;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        ans += c[i];
        a[i] = a[i] - c[i];
        b[i] = b[i] - c[i];
        v.emplace_back(a[i],b[i]);
    }
    sort(begin(v),end(v),[](const pii&x,const pii&y){return x.F-x.S < y.F-y.S;});
    priority_queue<int,vector<int>,greater<int>> pq;
    ll su = 0; 
    for (int i = 0; i < n; ++i) {
        pq.push(v[i].S);
        su += v[i].S;
        if (pq.size() > y) {
            su -= pq.top();
            pq.pop();
        }
        pr[i] = su;
    }
    while (pq.size()) pq.pop();
    su = 0;
    for (int i = n-1; i >= 0; --i) {
        pq.push(v[i].F);
        su += v[i].F;
        if (pq.size() > x) {
            su -= pq.top();
            pq.pop();
        }
        po[i] = su;
    }
    ll mx = LLONG_MIN;
    for (int i = y-1; n-1-i >= x; ++i)
        mx = max(mx,pr[i]+po[i+1]);
    cout << ans + mx << endl;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

// GCD, LCM
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;}

int main(){
  int k;
  cin>>k;
  ll ans=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        ans+=gcd(gcd(i,j),l);
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}


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

using namespace std;

using ll = long long;

typedef vector<vector<int> > Matrix; //隣接行列

const int INF = 1000000000;

Matrix dist;

//trueなら負の閉路を検出
bool warshall_floyd(int n) { //nは頂点数
    for (int k = 0; k < n; k++) { //経由点
        for (int i = 0; i < n; i++) { //始点
            for (int j = 0; j < n; j++) { //終点
                if (dist[i][k] != INF && dist[k][j] != INF) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }

    //負の閉路を検出
    for (int i = 0; i < n; i++) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    dist.resize(10, vector<int>(10, INF));
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> dist[i][j];
        }
    }
    warshall_floyd(10);
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a;
            cin >> a;
            if (a == -1) continue;
            ans += dist[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 1234;
LL A[MAXN], B[MAXN], C[MAXN];

int main() {
    int X, Y, Z, K;
    scanf("%d %d %d %d", &X, &Y, &Z, &K);
    for (int i = 0; i < X; i++) scanf("%lld", &A[i]);
    for (int i = 0; i < Y; i++) scanf("%lld", &B[i]);
    for (int i = 0; i < Z; i++) scanf("%lld", &C[i]);
    sort(A, A + X);
    sort(B, B + Y);
    sort(C, C + Z);
    vector<LL> cand;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++)
            cand.push_back(A[i] + B[j]);
    }
    sort(cand.rbegin(), cand.rend());
    vector<LL> ans;
    for (int i = 0; i < min(X * Y, K); i++) {
        for (int j = 0; j < Z; j++) {
            ans.push_back(cand[i] + C[j]);
        }
    }
    sort(ans.rbegin(), ans.rend());
    for (int i = 0; i < K; i++) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 43364
from fractions import gcd

from functools import reduce


n = int(input())
a_list = [int(x) for x in input().split()]

temp = reduce(lambda x, y: (x * y) // gcd(x, y), a_list)

mod = 10 ** 9 + 7
ans = sum([temp // a for a in a_list]) % mod
print(ans)

Measured memory_bytes: 264700
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

signed main(){
	int a, b, c;
	cin >> a >> b >> c;
	if((a == b && a != c) || (a == c && a != b) || (b == c && a != b))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3596
//When I was writing this, only God and I knew what it is
//Now, only The_Blitz know...

#pragma GCC optimize ("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define FER(i,a,b) for(int i = int(a); i < int(b); ++ i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); -- i)
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> ii;

const int N = 1e5 + 2;
const int Mod = 1e9 + 7;

map<ll, ll> m;

int main(){
	ll n, k; cin >> n >> k;
	FER(i, 0, n){
		ll a, b; cin >> a >> b;
		m[a] += b;
	}
	ll acc = 0;
	for(auto x: m){
		if(acc + x.ss >= k){
			cout << x.ff << endl;
			break;
		}
		acc += x.ss;
	}
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <iostream>
 
using namespace std;
 
int main() {
    int P, Q, R, min;
    cin >> P >> Q >> R;
    min = P + Q;
    if (min > Q + R) { min = Q + R; }
    if (min > P + R) { min = P + R; }
    cout << min << endl;
}

Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[200005];
    bool flag=false;
    int x,a,n,k,r,s,p,tmp_i;
    ll ans=0;
    char t[100005],u;
   
   cin >> n >> k >> r >> s >> p >> t;
    //for(int i=0;i<n;i++) cin >> s[i];
    //for(int i=0;i<n;i++) cin >> t[i];

    for(int i=0;i<n;i++){
        if(i<k){
            if(t[i] == 'r') ans+=p;
            else if(t[i] == 's') ans+=r;
            else if(t[i] == 'p') ans+=s;
        }else{
            if(t[i] != t[i-k]){
                if(t[i] == 'r') ans+=p;
                else if(t[i] == 's') ans+=r;
                else if(t[i] == 'p') ans+=s;
            }else{
                t[i] = 'f';
            }
        }
    }
    
    
    //cout << (!flag ? "Yes" : "No");
    cout << ans;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 10010;

int n, cnt;
bool a[N], b[N];
char s[12];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    int m = strlen(s);
    for (int j = 1; j < m; ++j)
      if (s[j - 1] == 'A' && s[j] == 'B')
        ++cnt;
    if (s[0] == 'B')
      a[i] = true;
    b[i] = s[m - 1] == 'A';
  }
  int ca = count(a + 1, a + n + 1, true), cb = count(b + 1, b + n + 1, true);
  if (min(ca, cb)) {
    cnt += min(ca, cb);
    bool f = true;
    for (int i = 1; i <= n; ++i)
      if (a[i] ^ b[i])
        f = false;
    if (f)
      --cnt;
  }
    printf("%d\n", cnt);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    X = LI()
    energy = [0 for _ in range(1,100)]
    for p in range(1,100):
        for x in X:
            energy[p-1] += (x-p)**2
    print(min(energy))

main()



Measured memory_bytes: 27220
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll i,j,x,y,ans;
    cin>>x>>y;
        ans=abs((x-2)*(y-2));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3564
#define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

int main(){
	double v;
	while (cin >> v) {
		int n = 0;
		while (n - v * v / 98 - 1.0 < EPS) ++n;
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)

        cnt := 0
        for m := 1; m <= n; m += 2 {
                if numDivisor(m) == 8 {
                        cnt++
                }
        }
        fmt.Println(cnt)
}

func numDivisor(n int) int {
        cnt := 0
        for m := 1; m <= n; m++ {
                if n%m == 0 {
                        cnt++
                }
        }
        return cnt
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE

bool solve(const int N, const vector<int>& A) {
    map<int, int> ct;
    for (int a : A) ++ct[a];
    if (ct.size() > 3) return false;
    vector<int> xs, ns;
    for (auto kv : ct) xs.push_back(kv.first), ns.push_back(kv.second);
    if (ct.size() == 1) return xs[0] == 0;
    if (ct.size() == 2) return ct.begin()->first == 0 && max(ns[0], ns[1]) == 2*min(ns[0], ns[1]);
    return xs[2] == (xs[0] ^ xs[1]) && ns[0] == ns[1] && ns[1] == ns[2];
}

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

    int N; cin >> N;
    vector<int> A(N);
    for (int& a : A) cin >> a;
    cout << (solve(N, A) ? "Yes" : "No") << '\n';

    return 0;
}


Measured memory_bytes: 4224
s=input()

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        print(i + 1 ,i+1 + 1)
        exit()
    if s[i]==s[i+2]:
        print(i + 1,i+2 + 1)
        exit()

if s[-2]==s[-1 ]:
    print(len(s)-1 ,len(s))
    exit()

print(-1,-1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  ll N, X; cin >> N >> X;
  vector<ll> L(N);
  REP(i, N){
    cin >> L[i];
  }

  ll cnt = 1;
  vector<ll> d(N+2);
  d[1] = 0;
  FOR(i, 2, N+2){
    d[i] = d[i-1] + L[i-2];
    if(d[i] <= X) cnt++;
  }

  // REP(i, N+2){
  //   DUMP(d[i]);
  // }

  cout << cnt << endl;

}


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


int main(){
    ll N;cin>>N;
    ll a[200010],b[200010];
    rep(i,0,N){
        cin>>a[i];
        b[i]=a[i]-i-1;
    }
    sort(b,b+N);
    ll ans=0;
    rep(i,0,N)ans+=abs(b[i]-b[N/2]);
    cout<<ans<<endl;
}







Measured memory_bytes: 3328
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        Console.WriteLine(((n - m) * 100 + m * 1900) << m);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

vector<int> g[55];

struct LowestCommonAncester{
    int n,h;
    vector<vector<int>> g,par;
    vector<int> dep;
    LowestCommonAncester(int n):n(n),g(n),dep(n){
        h=1;
        while((1<<h)<=n)h++;
        par.assign(h,vector<int> (n,-1));
    }
    void add_edge(int u,int v){
        g[u].push_back(v);
        g[v].push_back(u);
    }
    void dfs(int v,int p,int d){
        par[0][v]=p;
        dep[v]=d;
        for(auto u:g[v]){
            if(u!=p)dfs(u,v,d+1);
        }
    }
    void build(int r){
        dfs(r,-1,0);
        for(int i=0;i<h-1;i++){
            for(int j=0;j<n;j++){
                if(par[i][j]>=0)par[i+1][j]=par[i][par[i][j]];
            }
        }
    }
    int lca(int u,int v){
        if(dep[u]>dep[v])swap(u,v);
        for(int i=0;i<h;i++){
            if((dep[v]-dep[u])&1<<i)v=par[i][v];
        }
        if(u==v)return u;
        for(int i=h-1;i>=0;i--){
            if(par[i][u]!=par[i][v])u=par[i][u],v=par[i][v];
        }
        return par[0][u];
    }
    int distance(int u,int v){
        return dep[u]+dep[v]-dep[lca(u,v)]*2;
    }
};

LowestCommonAncester LCA(50);
vector<pair<int,int>> v;
vector<pair<int,int>> vv;
map<pair<int,int>,int> mp;

void dfs(int v,int s,int t,int cnt,int pp){
	for(int p:g[v]){
		if(p==pp)continue;
		if(LCA.lca(p,s)==p||LCA.lca(p,t)==p){
			if(LCA.lca(v,p)==p)continue;
			mp[{min(p,v),max(p,v)}]|=(1<<cnt);
			dfs(p,s,t,cnt,v);
		}
	}
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	for(int i=0;i<n-1;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		v.push_back(make_pair(x,y));
		g[x].push_back(y);
		g[y].push_back(x);
		LCA.add_edge(x,y);
	}
	LCA.build(0);
	int m; cin >> m;
	for(int i=0;i<m;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		vv.push_back({x,y});
	}
	for(int i=0;i<m;i++){
		dfs(LCA.lca(vv[i].first,vv[i].second),vv[i].first,vv[i].second,i,-1);
	}
	ll ans=(1LL<<(n-1));
	for(int i=1;i<(1<<m);i++){
		int cnt=0;
		for(auto p:v){
			if(mp[{min(p.first,p.second),max(p.first,p.second)}]&i){
				cnt++;
			}
		}
		//cout << cnt << " " << i << endl;
		ans+=(__builtin_popcount(i)%2?-1:1)*(1LL<<(n-1-cnt));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <algorithm>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define MX 200500
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
int n, m, low, hig, rcnt, ans;
int buf[MX];
struct INFO {int l, r;} dat[MX];
IN bool operator < (const INFO &x, const INFO &y) {return x.l == y.l ? x.r > y.r : x.l < y.l;}
std::priority_queue <int, std::vector <int>, std::greater <int> > pq;
int main(void)
{
	in(n), in(m);
	low = 1, hig = m;
	for (R int i = 1; i <= n; ++i) in(dat[i].l), in(dat[i].r);
	std::sort(dat + 1, dat + 1 + n);
	for (R int i = 1; i <= n; ++i)
	{
		pq.push(dat[i].r);
		if (low <= dat[i].l) ++low;
		else
		{
			buf[++rcnt] = pq.top();
			pq.pop();
		}
	}
	std::sort(buf + 1, buf + 1 + rcnt);
	for (R int i = rcnt; i; --i)
	{
		if (hig >= buf[i] && hig >= low) --hig;
		else ++ans;
	}
	printf("%d", ans);
}


Measured memory_bytes: 3192
#include<iostream>

using namespace std;

int main(){

    string s;
    cin >> s;

    int a=0;

    if(s.length() % 2 ==1){
        cout << "No" << endl;
    }
    else{
        for(int i=0;i<(s.length())/2;i++){
            if(s[ 2*i ]== 'h' && s [2*i+1]=='i')
                a+=1;
        }
        if(a==(s.length()/2))
            cout << "Yes" <<endl;
        else
            cout << "No" << endl;
        

    }

        


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	for (int i = 0; i + m <= n; i++) {
		for (int j = 0; j + m <= n; j++) {
			bool ok = true;
			for (int ii = 0; ii < m; ii++) {
				for (int jj = 0; jj < m; jj++) {
					if (a[i + ii][j + jj] != b[ii][jj]) {
						ok = false;
					}
				}
			}
			if (ok) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) a.begin(), a.end()
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
  int N; cin >> N;
  vector<array<int, 3>> abc(N);
  rep(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

  vector<array<int, 3>> dp(N+1);
  rep(i, N) rep(j, 3) rep(k, 3) {
    if (j == k) continue;
    chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
  }

  int ans = *max_element(all(dp[N]));
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

int main(){
	int a,b;
	string s;
	cin>>a>>b;
	cin>>s;
	if(s[a]!='-'){
				printf("No\n");
				return 0;
			}
	for(int i=0;i<=(a+b);i++){
			if(i==a) continue;
			
			if(s[i]<'0'||s[i]>'9'){
				printf("No\n");
				return 0;
			}
	}
	int l=s.length();
	if(l!=(a+b+1))printf("No\n");
	else printf("Yes\n");
	return 0;
	}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1e5+10;
int n,a[N],ans;
int main()
{
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	for (i=1;i<=n;i++)
	  if (a[i]==i)
	  {
	  	ans++;
	  	if (a[i+1]==i+1)
	  	  i++;
	  }
	printf("%d",ans);
}

Measured memory_bytes: 512
s=input()

if s==s[::-1]:
  if s[:(len(s)-1)//2] == s[:(len(s)-1)//2:-1]:
    ss=s[(len(s)+3)//2-1:len(s)]
    if ss ==  ss[::-1]:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 61788
h = int(input())
cnt = 0
s = 0

if h == 1:
  print(1)
  
else:
  for i in range(100):
      h = int(h/2)
      cnt += 1
      if h == 1:
          break

  for j in range(cnt+1):
      s += 2 ** j

  print(s)

Measured memory_bytes: 38724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    String str;
    double a, b, c, d, e, f;
    double x, y;
    while ((str = buf.readLine()) != null) {
      String[] tmp = new String[6];
      tmp = str.split(" ");
      a = Double.parseDouble(tmp[0]);
      b = Double.parseDouble(tmp[1]);
      c = Double.parseDouble(tmp[2]);
      d = Double.parseDouble(tmp[3]);
      e = Double.parseDouble(tmp[4]);
      f = Double.parseDouble(tmp[5]);
      y = (c*d - a*f) / (b*d - a*e);
      x = (c - b*y) / a;
      System.out.printf("%.3f %.3f\n", x, y);
    }
  }
}

Measured memory_bytes: 24776
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int l, r;
  int ans = INT_MAX;
	cin >> l >> r;
	const int mod = 2019;

  if (r - l > mod){
    puts("0");
    return 0;
  }

  r %= mod;
  l %= mod;
	for(int i=l; i<=r; i++) {
	  for(int j=i+1; j<=r; j++) {
      ans = min(ans,i*j%mod);
    }
	}

  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	string sd,t;
	cin >> sd >> t;
	string mi = "{";
	rep(i,sd.size()-t.size()+1){
		string s(sd);	//copy
		bool flag = 1;	//合致できる前提
		FOR(j,i,i+t.size()){
			if(sd[j]=='?'){
				s[j]=t[j-i];
			}
			else if(sd[j]!=t[j-i]){
				flag = 0;	//駄目です
				break;
			}
			}
		if (!flag){
			continue;
		}
		//合致する感じなのでいいです！miと比較する準備
		rep(j,s.size()){
			if(s[j]=='?'){
				s[j]='a';
			}
		}
		mi = min(mi,s);
	}
		cout << (mi == "{" ? "UNRESTORABLE" : mi) <<"\n";
		return 0;
	}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b;
    int d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
}



Measured memory_bytes: 3148
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;

    int i = 1000;
    while (i <= n) {
        i += 1000;
    }
    cout << (i - n) % 1000;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
M = int(input())
uv = [list(map(int, input().split())) for _ in range(M)]

class Tree:
  C, RL = {}, {}
  R, N, D, S, P = None, None, None, None, None
  def __init__(s, num):
    s.N = num
  def set(s, a, b):
    if a in s.C: s.C[a].append(b)
    else: s.C[a] = [b]
    if b in s.C: s.C[b].append(a)
    else: s.C[b] = [a]
  def dfs(s, x, y, r):
    if x == y:
      return [x]
    for i in s.C[x]:
      if i != r:
        t = s.dfs(i, y, x)
        if t != False:
          return [x] + t
    return False

T = Tree(N)
for a, b in ab:
  a -= 1
  b -= 1
  T.set(a, b)

D = [[-1] * N for _ in range(N)]
for i in range(N - 1):
  a, b = ab[i][0] - 1, ab[i][1] - 1
  a, b = min(a, b), max(a, b)
  D[a][b] = i

NL = [[] for _ in range(M)]
for i in range(M):
  x, y, r = uv[i][0] - 1, uv[i][1] - 1, uv[i][0] - 1
  L = T.dfs(x, y, r)
  n = L[0]
  t = 0
  for j in range(1, len(L)):
    m = L[j]
    x, y = min(n, m), max(n, m)
    t = t | (1 << D[x][y])
    n = m
  NL[i] = t
  

ans = 1 << (N - 1)
c = 0
for i in range(1, 1 << M):
  t = i
  f = 0
  k = 0
  for j in range(M):
    if t & 1:
      f += 1
      k = k | NL[j]
    t >>= 1
  cnt = bin(k).count("1")
  if f % 2 == 1:
    c += pow(2, (N - 1 - cnt))
  else:
    c -= pow(2, (N - 1 - cnt))
print(ans - c)

Measured memory_bytes: 44316
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define vector vector<int>
#define vectorp vector<pair<int,int>>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
   string s;
   cin >> s;
   int n = s.size();
   string res(n,'x');
   cout<<res;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void check (int num){
  if( num % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
  return;
}

int main (){
  int a = 0, b = 0;
  cin >> a >> b;
  check (a*b);
 
}


Measured memory_bytes: 3628
#coding:utf-8
import numpy as np
n = int(input())


a = np.ones((2,1)).astype(np.int)
a[-1][-1]+len(a)
i = 1
while(1):
    if len(a)>=500:
        break
    if n==a[-1][-1]:
        print ("Yes")
        print (len(a))
        for line in a:
            print (i," ".join(line.astype(np.str).tolist()))
        exit()
    i+=1
    temp = int((1/2)*i*(i+1))
    add = np.array((list(range(temp-i+1,temp+1))))

    a = np.c_[a,add]
    a = np.r_[a,add.reshape(1,-1)]
print ("No")


Measured memory_bytes: 16488
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

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

int r,l;
int n;

void solve() {
    int ans = 0;
    string s;
    r = 0;
    l = 0;
    int a = 1;
    rep(i,n) {
        cin>>s;
        if(l==0 && s == "lu") {
            l^=1;
        }
        if(l==1 && s == "ld") {
            l^=1;
        }
        if(r==0 && s == "ru") {
            r^=1;
        }
        if(r==1 && s == "rd") {
            r^=1;
        }
        if(r==l && a == r) {
            ans++;
            a^=1;

        }
        // cout<<r<<","<<l<<endl;
    }
    cout<<ans<<endl;

}

int main() {
    while(cin>>n) {
        if(n==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(void){
  string str;
  cin >> str;

  for(int i = 0; i < str.size(); ++i){
    if(str[i] == '1'){
      str[i] = '9';
    } else {
      str[i] = '1';
    }
  }

  cout << str << endl;

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	int l;
	cin >> l;
  ld line = (double)l/(double)3;
  ld vol = line * line * line;
	cout << std::fixed << std::setprecision(9) << vol << endl;
  return 0;
}

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

int n, m;
int pd[N_MAX];
int pi[N_MAX];

pair<int, int> fol(int id){
    if(pi[id]==id) return make_pair(id, 0);
    else{
        pair<int, int> t=fol(pi[id]);
        pi[id]=t.first;
        pd[id]=t.second+pd[id];
        return make_pair(t.first, pd[id]);
    }
}

int main(){
    cin>>n>>m;
    for(int i=0; i<N_MAX; i++){
        pi[i]=i;
        pd[i]=0;
    }

    bool ans=true;;
    for(int i=0; i<m; i++){
        int l, r, d;
        cin>>l>>r>>d;
        l--; r--;

        pair<int, int> rl, rr;
        rl=fol(l);
        rr=fol(r);
        if(rl.first==rr.first){
            if(rr.second-rl.second!=d){
                ans=false;
                break;
            }
        }
        else{
            pi[rr.first]=rl.first;
            pd[rr.first]=rl.second-rr.second+d;
        }
//      for(int i=0; i<n; i++) cout<<"root:"<<pi[i]<<" d:"<<pd[i]<<endl;
    }
    if(ans) 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 complex<double> Vec;

ll N;
vector<Vec> Vs;
const double EPS = 1e-10;
double R;

ll classify(Vec v, Vec w) {
  Vec dotcross = conj(v) * w;
  double dot = dotcross.real(), cross = dotcross.imag();
  return cross > EPS ? 0 : -cross > EPS ? 1 : dot > EPS ? 2 : 3;
}

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll x, y;
    cin >> x >> y;
    Vs.push_back(Vec(x, y));
  }
  for (Vec v : Vs) {
    Vec sum[4];
    for (Vec w : Vs) sum[classify(v, w)] += w;
    R = max({R, abs(sum[0]), abs(sum[1]), abs(sum[0] + sum[2]),
             abs(sum[1] + sum[2])});
  }
  cout << setprecision(15) << R << endl;
  return 0;
}


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

bool snuke[1000];

int main(){
    int n,k; cin >> n >> k;
    for(int i=0;i<k;i++){
        int d; cin >> d;
        for(int j=0;j<d;j++){
            int a; cin  >> a;
            snuke[a-1]=true;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(!snuke[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
# https://beta.atcoder.jp/contests/abc085/tasks/abc085_c

N, Y = map(int, input().split())


def solve(n, y):
    for a in range(n + 1):
        rest = y - 10000 * a
        if rest < 0:
            break
        if rest == 0 and a == n:
            return a, 0, 0

        bc = n - a
        all_c = 1000 * bc
        rest = rest - all_c
        if rest >= 0 and rest % 4000 == 0:
            b = rest // 4000
            c = bc - b
            if b >= 0 and c >= 0:
                return a, b, c

    return -1, -1, -1


result = solve(N, Y)
print(str(result[0]) + ' ' + str(result[1]) + ' ' + str(result[2]))


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll x = n / (a + b);
	ll y = n % (a + b);
	ll res = 0;
	res += x * a;
	res += min(y, a);
	pv(res)
	return(0);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000001

int main(){
	
	int N;
	cin>>N;
	
	set<string> S;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		S.insert(s);
	}
	
	cout<<S.size()<<endl;
		
	return 0;
}

Measured memory_bytes: 19100
function Main(input) {
  "use strict"
  const temp = input.split("\n");

  const n = parseInt(temp.shift());
  const an = temp.shift().split(" ")
  const obj = {};
  an.forEach(int => {
    if(int in obj) obj[int] += 1;
    else obj[int] = 1;
  })
  const values = Object.keys(obj).map(key => obj[key]);
  const total = values.reduce((acc, x) => acc + x * (x - 1) / 2, 0);
  
  an.forEach(int => console.log(total - obj[int] + 1))


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 49960
n=int(input())
b=list(map(int, input().split()))
a=[0]*n
for j in range(n-1,-1,-1):
  if j==n-1: a[n-1]=b[j-1]
  elif j==0: a[0]=b[0]
  else:
    a[j]=min(b[j],b[j-1])
print(sum(a))

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n;
num inf = 1e15, sz[50005], w[5005], dp[2][5005][5005], tmp[2][5005];
vector<int> g[5005];

inline num min(num a, num b) {
	return a < b ? a : b;
}

void dfs(int u, int p) {
	sz[u] = 1;
	cont (s, 5000) {
		dp[0][u][s] = dp[1][u][s] = inf;
	}
	dp[0][u][1] = w[u] < 0 ? inf : w[u];
	dp[1][u][1] = w[u];
	for (int v : g[u]) {
		if (v == p)  continue;
		dfs(v, u);
		cont (s, sz[u] + sz[v]) {
			tmp[0][s] = tmp[1][s] = inf;
		}
		cont (s1, sz[u]) {
			cont (s2, sz[v]) {
				int s = s1 + s2;
				if (dp[0][v][s2] < inf) {
					tmp[0][s] = min(tmp[0][s], dp[0][u][s1]);
					tmp[1][s] = min(tmp[1][s], dp[1][u][s1]);
				}
				if (dp[1][v][s2] < 0) {
					tmp[0][s] = min(tmp[0][s], dp[0][u][s1]);
					tmp[1][s] = min(tmp[1][s], dp[1][u][s1]);
				}
				tmp[0][s - 1] = min(tmp[0][s - 1], dp[0][u][s1] + dp[0][v][s2]);
				tmp[1][s - 1] = min(tmp[1][s - 1], dp[1][u][s1] + dp[1][v][s2]);
			}
		}
		sz[u] += sz[v];
		cont (s, sz[u]) {
			dp[0][u][s] = tmp[0][s];
			dp[1][u][s] = tmp[1][s];
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	cont (i, n) {
		cin >> w[i];
	}
	cont (i, n - 1) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, -1);
	cont (cnt, n) {
		if (dp[0][1][cnt] < inf || dp[1][1][cnt] < 0) {
			cout << cnt - 1 << endl;
			break;
		}
	}
}


Measured memory_bytes: 392448
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()
f = na()
a.sort()
f.sort()

def ok(h, a, f, k):
    n = len(a)
    s = 0
    for i in range(n):
        s += max(0, a[i]-h//f[n-1-i])
    return s <= k


low = -1; high = 2000000000000
while high - low > 1:
    h = high+low>>1
    if ok(h, a, f, k):
        high = h
    else:
        low = h
print(high)



Measured memory_bytes: 107468
#include <stdio.h>
#define N 100

void swapper(int *a, int *b) {
    int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

void printlist(int A[N], int n) {
    int i;

    for (i = 0; i < n; i++) {
        if (i == n - 1) {
            printf("%d\n", A[i]);
        } else {
            printf("%d ", A[i]);
        }
    }
}

int main(void) {
    int i, j;
    int n, A[N], count = 0, minj;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        swapper(&A[i], &A[minj]);
        if (i != minj) count++;
    }
    printlist(A, n);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

int n;
int p[200002];

int main(){
    IOS;
    cin >> n;
    F0R(i,n){
        cin >> p[i];
    }
    int total = 0;
    int currMin = 99999999;
    F0R(i,n){
        if(p[i] < currMin){
            total++;
            currMin = p[i];
        }
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 1024
N=int(input())
a=list(map(int, input().split()))

flag=1
number=0

while(flag):
    for i in range(N):
        if a[i]%2==1:
            flag=0
            break
        else:
            a[i]=a[i]/2
    if flag==1:
        number=number+1

print(number)


Measured memory_bytes: 39536
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <iomanip>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
	int n;cin>>n;
	multiset<int>st;
	loop(n,i,0){
		int x;cin>>x;
		if(i==0)
			st.insert(x);
		else{
			auto it=st.lower_bound(x);
			if(it!=st.begin())st.erase(--it);
			st.insert(x);
		}
	}
	cout<<sz(st)<<endl;
}


Measured memory_bytes: 4992
#if 0
2019.12.06

按顺序考虑，考虑第一个滚动的球，期望滚动距离为 E 。
由于距离是等差数列，不难得出 E 关于 d, x 的表达式。
接下来就不会算了。

对球和坑按顺序标号，处理完第一个球后剩下的球数和坑数都会少 1 ，对它们重新标号。
然后考虑新标号后的球坑，考虑新的球坑之间的距离，经过归纳可以的出期望距离仍然是等差数列。
根据期望线性，接下来转换为一个新的子问题，求出新的 d, x 并依次解决即可，复杂度 O(n) 。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int main() {
	int n = read;
	double d = int(read), x = int(read);
	double ans = 0;

	while(n) {
		ans += d + (n * 2 - 1) * x / 2;
		/* debug("+%lf %lf %lf\n", d + (n * 2 - 1) * x / 2, d, x); */
		d = (n + 1) * d / n + 2.5 * x / n;
		x *= (n + 2.0) / n;
		-- n;
	}

	printf("%.10lf\n", ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define IN 2047483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a+b){
    int n;
    cin>>n;
    ll dp[2*a][2*b]={};
    int MAP[2*a][2*b]={};
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      MAP[x][y]=1;
    }
    for(int i=1;i<=a;i++){
      if(MAP[i][1])
	break;
      dp[i][1]=1;
    }
    for(int i=1;i<=b;i++){
      if(MAP[1][i])
	break;
      dp[1][i]=1;
    }
    for(int i=2;i<=a;i++){
      for(int j=2;j<=b;j++){
	if(MAP[i][j])
	  continue;
	dp[i][j]=dp[i][j-1]+dp[i-1][j];
      }
    }
    cout<<dp[a][b]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2940