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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w,n; cin>>h>>w>>n;
  vpll p(n);
  set<pll> sp;
  rep(i,n){
    ll a,b; cin>>a>>b; a--,b--;
    p[i]={a,b};
    sp.insert(p[i]);
  }
  ll dy[]={1,1,1,0,0,0,-1,-1,-1};
  ll dx[]={-1,0,1,-1,0,1,-1,0,1};
  
  vll ans(10);
  set<pll> s;
  rep(i,n){
    ll y,x; tie(y,x)=p[i];
    rep(j,9){
      ll ny=dy[j]+y, nx=dx[j]+x;
      
      if(ny>=0&&ny<h && nx>=0&&nx<w){
        if(s.count({ny,nx})) continue;
        s.insert({ny,nx});
        
        ll d=ny-1,u=ny+1;
        if(d<0||u>=h) continue;
        ll l=nx-1,r=nx+1;
        if(l<0||r>=w) continue;
        
        ll cnt=0;
        ireps(ki,d,u){
          ireps(kj,l,r){
            if(sp.count({ki,kj})) cnt++;
          }
        }
        ans[cnt]++;
      }
    }
  }
  ll sum=0;
  irep(i,1,10) sum+=ans[i];
  ans[0]=(h-2)*(w-2)-sum;
  rep(i,10){
    cout<<ans[i]<<endl;
  }
  
}


Measured memory_bytes: 64384
a,b,c=map(int,input().split())
k=int(input())
d={"a":a,"b":b,"c":c}
for i in range(k+1):
    if d["a"]<d["b"]<d["c"]:
        print("Yes")
        exit()
    elif d["a"]>=d["c"]:
        d["c"]*=2
    elif d["a"]>=d["b"]:
        d["b"]*=2
    elif d["b"]>=d["c"]:
        d["c"]*=2
print("No")

Measured memory_bytes: 61756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);

int main(){
	fastio()
	int N;cin>>N;
	N = N%10;
	if(N==3) cout<<"bon\n";
	else if(N==0 || N== 1 || N==6 || N==8) cout<<"pon\n";
	else cout<<"hon\n"; 
	
	
	
	return 0;
}


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

int main()
{
	long long int n, k;
	cin >> n >> k;
	vector<long long int> h(n);
	for (int i = 0; i < n; ++i) cin >> h[i];
	
	if (n <= k)
	{
		cout << 0 << endl;
		return 0;
	}
	
	sort(h.begin(), h.end(), greater<long long int>());
	
	long long int cnt = 0;
	for (int i = k; i < n; ++i)
	{
		cnt = cnt + h[i];
	}
	
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
using ll = long long;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

vector<int> articulationPoint(const Graph& g){
    int n = g.size(), idx;
    vector<int> low(n), ord(n), art;
    function<void(int)> visit = [&](int v){
        low[v] = ord[v] = ++idx;
        for(auto &e : g[v]){
            int w = e.dst;
            if(ord[w] == 0){
                visit(w);
                low[v] = min(low[v], low[w]);
                if((ord[v] == 1 && ord[w] != 2) ||
                   (ord[v] != 1 && low[w] >= ord[v])) art.push_back(v);
            } else low[v] = min(low[v], ord[w]);
        }
    };
    for(int u = 0; u < n; u++) if(ord[u] == 0){ idx = 0; visit(u); }
    return art;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    while(cin >> n >> m){
        Graph g(n);
        rep(i,m){
            int a,b;
            cin >> a >> b;
            g[a].emplace_back(a,b,0);
            g[b].emplace_back(b,a,0);
        }
        vector<int> arts = articulationPoint(g);
        sort(all(arts));
        auto last = unique(all(arts));
        for(auto it = arts.begin(); it != last; ++it) cout << *it << '\n';
    }
}

Measured memory_bytes: 5708
#include<stdio.h>
#include<string.h>
int main()
{
    char s[]="Sunny",c[]="Cloudy",r[]="Rainy",u[100000];
    int i=0,j=0;
    gets(u);
    while(u[i]!='\0'){
        if(u[i]==s[i])
            i++;
        else
            break;
    }
    if(u[i]=='\0' && j==0){
        printf("Cloudy\n");
        j++;
    }
    while(u[i]!='\0'){
        if(u[i]==c[i])
            i++;
        else
            break;
    }
    if(u[i]=='\0' && j==0){
        printf("Rainy\n");
        j++;
    }
    while(u[i]!='\0'){
        if(u[i]==r[i])
            i++;
        else
            break;
    }
    if(u[i]=='\0' && j==0){
        printf("Sunny\n");
        j++;
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
struct edge{
	int to;
	edge *nxt;
}edges[2*MAXN + 5], *adj[MAXN + 5];
edge *ecnt = &edges[0];
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
	p = (++ecnt);
	p->to = u, p->nxt = adj[v], adj[v] = p;
}
struct node{
	int lb, ub;
	bool flag;
	int key;
}a[MAXN + 5];
bool flag = true;
void dfs(int rt, int pre) {
	for(edge *p=adj[rt];p!=NULL;p=p->nxt) {
		if( p->to == pre ) continue;
		dfs(p->to, rt);
		if( a[p->to].flag ) {
			if( !a[rt].flag ) {
				a[rt].lb = a[p->to].lb - 1;
				a[rt].ub = a[p->to].ub + 1;
			}
			else {
				if( (a[rt].lb & 1) == (a[p->to].lb & 1) ) {
					flag = false;
					break;
				}
				else {
					int lb = a[p->to].lb - 1;
					int ub = a[p->to].ub + 1;
					if( lb > a[rt].ub ) {
						flag = false;
						break;
					}
					else if( a[rt].lb > ub ) {
						flag = false;
						break;
					}
					else {
						a[rt].lb = max(a[rt].lb, lb);
						a[rt].ub = min(a[rt].ub, ub);
					}
				}
			}
			a[rt].flag = true;
		}
		if( !flag ) break;
	}
}
void dfs2(int rt, int pre) {
	if( pre != -1 ) {
		if( a[rt].lb <= a[pre].key + 1 && a[pre].key + 1 <= a[rt].ub )
			a[rt].key = a[pre].key + 1;
		else a[rt].key = a[pre].key - 1;
	}
	else {
		if( !a[rt].flag ) a[rt].key = 0;
		else a[rt].key = a[rt].lb;
	}
	for(edge *p=adj[rt];p!=NULL;p=p->nxt)
		if( p->to != pre ) 
			dfs2(p->to, rt);
}
int main() {
	int N, K;
	scanf("%d", &N);
	for(int i=1;i<N;i++) {
		int A, B;
		scanf("%d%d", &A, &B);
		addedge(A, B);
	}
	scanf("%d", &K);
	for(int i=1;i<=K;i++) {
		int V, P;
		scanf("%d%d", &V, &P);
		a[V].flag = true;
		a[V].lb = a[V].ub = a[V].key = P;
	}
	dfs(1, -1);
	if( !flag ) {
		puts("No");
		return 0;
	}
	else puts("Yes");
	dfs2(1, -1);
	for(int i=1;i<=N;i++)
		printf("%d\n", a[i].key);
}

Measured memory_bytes: 11008
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

struct S {
    int a,b;
};

void solve() {
    int n;
    cin >> n;
    vector<S> s(n);
    
    REP(i,0,n) cin >> s[i].a;
    REP(i,0,n) cin >> s[i].b;
    sort(all(s), [](auto &l, auto &r) {return l.a - l.b > r.a - r.b;});
    //REP(i,0,n) cout << s[i].a << endl;
    LL sum = 0, asum = 0, bsum = 0;
    REP(i,0,n) asum += s[i].a;
    REP(i,0,n) bsum += s[i].b;
    if (asum < bsum) {
        cout << -1 << endl;
        return;
    }
    int cnt = 0;
    REP(i,0,n) if (s[i].a < s[i].b) {
        ++cnt;
        sum += s[i].b - s[i].a;
    }
    REP(i,0,n) {
        if (sum <= 0) break;
        ++cnt;
        sum -= s[i].a - s[i].b; 
    }
    cout << cnt << endl;
}

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

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 3e3 + 100;
const int oo = 1e8;
const int mod = 1e9 + 7;

int n;

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    int x; cin >> x;
    int ans = 1000 * (x / 500);
    x %= 500;
    ans += 5 * (x / 5);
    cout << ans;
}


Measured memory_bytes: 256
/*input
1
*/
/**
    Author: Kristopher Paul
    Date Created: 01-09-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
n = int(input())
d = {}
mod = 998244353
max_v = 0
lis = list(map(int, input().split()))

# 先頭はかならず0
if lis[0] != 0:
    print(0)
    exit()

for v in lis:
    if v not in d:
        d[v] = 1
    else:
        d[v] += 1
    max_v = max(max_v, v)

# 0はひとつだけ
if 0 not in d or d[0] > 1:
    print(0)
    exit()

ans = 1
# 木を作ることができるならば1~max_vまでの数字がそれぞれ1つ以上存在する
for i in range(1, max_v + 1):
    if i not in d or i - 1 not in d:
        ans *= 0
    else:
        ans *= pow(d[i - 1], d[i], mod)
        ans %= mod
print(ans)

Measured memory_bytes: 23752
#include<iostream>
using namespace std;
int main(){
  int N,M,A,B,count=0,anscount=0;
  int d1[1000]={};
  int d2[1000]={};

  cin>>N>>M>>A>>B;
  for(int i=0;i<N;i++)cin>>d1[i];
  for(int i=0;i<N;i++)
    if(d1[i]>=A){
      count++;
      d2[i]=1;
    }
    else break;

  if(N-count<M)
    if(count!=0)
      for(int i=N-1;i>=0;i--)
	if(d2[i]==1)
	  if(d1[i]<=B)d2[i]=0;
	  else break;

  for(int i=0;i<N;i++)
    if(d2[i]==1)anscount++;
  cout<<anscount<<endl;

  return 0;
}

Measured memory_bytes: 1168
H, N = map(int, input().split())
special_move = input().split()
def answer(H: int, N: int, special_move: list) -> str:
    damage = 0
    for i in range(0, N):
        damage += int(special_move[i])
    if damage >= H:
        return 'Yes'
    else:
        return 'No'
print(answer(H, N, special_move))

Measured memory_bytes: 16636
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;
using lint = long long;

lint ten = 1;
lint M;
lint maxdiff = 0, ans = 0;

void dfs(int N, int used, lint num) {
    if (N == 0) {
        lint diff = min(abs(num - M), ten - abs(num - M));
        if (diff > maxdiff || (diff == maxdiff && num < ans)) {
            ans = num;
            maxdiff = diff;
        }
    } else {
        for (int d = 0; d < 10; ++d) {
            if ((used >> d) & 1) continue;
            dfs(N - 1, used | (1 << d), num * 10 + d);
        }
    }
}

int main() {
    string S;
    cin >> S;
    int N = S.size();
    for (int i = 0; i < N; ++i) ten *= 10;
    M = stoll(S);

    dfs(N, 0, 0);
    cout << right << setw(N) << setfill('0') << ans << endl;
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll n,i;
    cin >> n;
    int a[n];
    rep(i, n)cin >> a[i];
    for (i = 0;; i++) {
        rep(j, n){
            if (a[j] % 2 == 0) {
                a[j] = a[j] / 2;
            }else if(a[j] % 2 == 1){
                goto loopend;
            }
        }
    }
    
loopend:;
    cout << i << endl;
    return 0;
}


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

using namespace std;

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

	if ((a + b) * 10 / 2 % 10 >= 5)
		cout << (a + b + 1) / 2;
	else
		cout << (a + b) / 2;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main() {
	int d;
	cin >> d;
	switch (d)
	{
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;
	case 24:
		cout << "Christmas Eve" << endl;
		break;
	case 25:
		cout << "Christmas" << endl;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, n,nn[101]={0}, max=0, max_num=1 ;
    
    scanf(" %d", &n);
 
for(i=n; i>0; i--){
    n=i;
    while(n>0){
        
        if(n%2==0){
            nn[i]++;
            n=n/2;
            if(nn[i]>max){
                max = nn[i];
                max_num = i;
            }
        }else{
            break;
        }
        
        
       
        //n--;
    }
   /* 
    if(nn[i]>max){
        max = nn[i];
        max_num = i;
    }
    */
}
    
    printf("%d\n", max_num);
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();

            var sum = 0L;
            for (int i = 1; i <= N; i++)
            {
                var n = N / i;
                // 等差数列の和
                sum += n * (2 * i + (n - 1) * i) / 2;
            }

            return sum;
        }
      
        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

map<ll, ll> m;

void solve(long long N, vector<long long> A){
	bool flg = true;
	rep(i, N) {
		if (m[A[i]] != 0) flg = false;
		m[A[i]]++;
	}
	if (flg) cout << "YES" << endl; else cout << "NO" << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 15872
#include<stdio.h>
long long fiboDP(int n) {
 long long fibo_dp[200] = {0};
 fibo_dp[0] = 1;
 fibo_dp[1] = 1;
 for(int i=2; i<=n; i++) {
 fibo_dp[i] = fibo_dp[i-1] + fibo_dp[i-2]; }
 return fibo_dp[n]; }

 int main(void){
 int n;
 scanf("%d\n", &n);
 printf("%lld\n", fiboDP(n));
 return 0;
} 



Measured memory_bytes: 2044
#include<stdio.h>
int main(void)
{
  int A,B,K,cnt=0;
  scanf("%d%d%d",&A,&B,&K);
  
  if(A>B){
    for(int i=A;i>=1;i--){
      if((A%i==0) && (B%i==0)){
        cnt++;
        if(cnt==K){
          printf("%d",i);
        }
      }
    }
  }else{
    for(int i=B;i>=1;i--){
      if((A%i==0) && (B%i==0)){
        cnt++;
        if(cnt==K){
          printf("%d",i);
        }
      }
  	}   
  }
  
  return 0;
}

Measured memory_bytes: 128
N, D = map(int, input().split())

XY = [list(map(int, input().split())) for _ in range(N)]

count = 0

for i in range(N):
    if (XY[i][0] * XY[i][0] + XY[i][1] * XY[i][1]) <= D * D:
        count += 1


print(count)

Measured memory_bytes: 45460
import bisect
# from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, H = map(int, input().split())
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    B.sort()
    ma = max(A)
    ind = bisect.bisect_right(B, ma)

    cnt = 0
    i = N - 1
    while H > 0:
        if i +1> ind:
            H -= B[i]
            cnt += 1
            i -= 1
        else:
            cnt += -(-H // ma)
            break

    print(cnt)


resolve()

Measured memory_bytes: 42716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int h, w, k;
string s[10], t[10];
int ans;

signed main() {
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int i = 0; i < (1 << (h + w)); i++) {
		for (int j = 0; j < h; j++)t[j] = s[j];
		for (int j = 0; j < h; j++)if (i&(1 << j))for (int k = 0; k < w; k++)t[j][k] = 'X';
		for (int j = 0; j < w; j++)if (i&(1 << (h + j)))for (int k = 0; k < h; k++)t[k][j] = 'X';
		int cnt = 0;
		for (int j = 0; j < h; j++)for (int k = 0; k < w; k++)if (t[j][k] == '#')cnt++;
		if (cnt == k)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


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

int main(){
  int N,M;cin>>N>>M;
  if(N<=M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 888
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    o = 0
    f = 0
    for i in range(len(s)):
        if s[i] == "0":
            o += 1
        else:
            f += 1
    print(min(o, f) * 2)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 39408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ShekharN
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int[] arr = IntStream.range(0, 3).map(i -> in.nextInt()).toArray();
            int ans = 0;
            while (true) {
                Arrays.sort(arr);
                if (arr[0] + 2 > arr[2])
                    break;
                arr[0] += 2;
                ans++;
            }
            if (arr[0] != arr[2]) {
                if (arr[0] == arr[1])
                    ans++;
                else ans += 2;
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        public String nextString() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 26452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<int> x(a);
  for(int i = 0;i < a;i++){
    cin >> x.at(i);}
  long long v=0;
  vector<int> one(a);
  int mmm=0;
  for(int i = 0;i < a;i++){
    if(mmm < x.at(i)){mmm = x.at(i);
                      one.at(i) = 1;}
  }
  vector<int> two(a);
  int mmmm = 0;
  for(int i = a-1;i > -1;i--){
    if(mmmm < x.at(i)){mmmm = x.at(i);
                      two.at(i) = 1;}
  }
  for(int i = 0;i < a;i++){
    long long p=1;
    long long q=0;
    long long r=1;
    long long s=0;
    int fone=0;
    int ftwo=0;
    if(one.at(i) == 1)p=i+1;
    else{
    for(int j = i-1;j > -1;j--){
      if(fone==0 && x.at(i)<x.at(j)){q++;fone++;}
      else if(fone==0)p++;
      else if(x.at(i)<x.at(j))break;
      else if(fone==1)q++;
    }
    }
    if(two.at(i) == 1)r=a-i;
    else{
    for(int j = i+1;j < a;j++){
      if(ftwo==0 && x.at(i)<x.at(j)){s++;ftwo++;}
      else if(ftwo==0)r++;
      else if(x.at(i)<x.at(j))break;
      else if(ftwo==1)s++;
    }
    }
    v += (p*s+q*r)*x.at(i);
  }
      cout << v << endl;
}

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

int main() {
	int a, b, c, x, cnt=0;
	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++)
	{
		for (int j = 0; j <= b; j++)
		{
			for (int k = 0; k <= c; k++)
			{
				if (x == i*500 + j*100 + k*50)
				{
					cnt++;
				}
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s,t;cin>>s>>t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
constexpr lint mod=1000000007;
lint inverse(lint a){
    lint m=mod;
    lint u=0,v=1;
    while(a!=0){
        lint t=m/a;
        m-=t*a;std::swap(a,m);
        u-=t*v;std::swap(u,v);
    }
    assert(m==1);
    if(u<0)u+=mod;
    return u;
}
void mul_assign(lint&x,lint y){x=x*y%mod;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<std::vector<lint>>g(n);
    for(lint i=0;i<n-1;i++){
        lint u,v;std::cin>>u>>v;u--,v--;
        g.at(u).push_back(v);
        g.at(v).push_back(u);
    }
    std::vector<lint>p(n,-1),ord;
    std::queue<lint>que;
    que.push(0);
    p.at(0)=0;
    while(!que.empty()){
        lint x=que.front();que.pop();
        ord.push_back(x);
        auto&&v=g.at(x);
        for(lint y:v){
            if(p.at(y)!=-1)continue;
            p.at(y)=x;
            que.push(y);
        }
        if(x)v.erase(std::find(v.begin(),v.end(),p.at(x)));
    }
    auto rord=std::vector<lint>(ord.rbegin(),ord.rend());
    std::vector<lint>sz(n,1);
    for(lint x:rord){
        for(lint y:g.at(x))sz.at(x)+=sz.at(y);
    }
    std::vector<lint>fact(n+1,1);
    for(lint i=1;i<=n;i++)fact.at(i)=fact.at(i-1)*i%mod;
    std::vector<lint>dp(n),ep(n,1);
    for(lint x:rord){
        dp.at(x)=fact.at(sz.at(x)-1);
        for(lint y:g.at(x)){
            mul_assign(dp.at(x),dp.at(y));
            mul_assign(dp.at(x),inverse(fact.at(sz.at(y))));
        }
    }
    for(lint x:ord){
        for(lint y:g.at(x)){
            lint&e=ep.at(y);
            e=dp.at(x);
            mul_assign(e,ep.at(x));
            mul_assign(e,inverse(dp.at(y)));
            mul_assign(e,fact.at(n-sz.at(y)-1));
            mul_assign(e,inverse(fact.at(sz.at(x)-1)));
            mul_assign(e,fact.at(sz.at(y)));
            mul_assign(e,inverse(fact.at(n-sz.at(x))));
        }
    }
    for(lint i=0;i<n;i++){
        lint x=dp.at(i)*ep.at(i)%mod;
        mul_assign(x,fact.at(n-1));
        mul_assign(x,inverse(fact.at(sz.at(i)-1)));
        mul_assign(x,inverse(fact.at(n-sz.at(i))));
        std::cout<<x<<'\n';
    }
}


Measured memory_bytes: 27504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    string ans;

    for (int i = 0; i < S.size(); i++)
    {

        if (S[i] == '0')
        {
            ans.push_back('0');
        }
        else if (S[i] == '1')
        {
            ans.push_back('1');
        }
        else
        {
            if (ans.empty() == false)
            {
                ans.pop_back();
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

//#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

#define lint long long
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;

	lint n;cin>>n;
	lint s=0;
	ivec a(n);
	rep(i, n){
		cin>>a[i];
		s+=a[i];
	}
	lint m;cin>>m;
	lint p,x;
	rep(i, m){
		cin>>p>>x;--p;
		co(s-a[p]+x);
	}

	gc();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include <queue>
#include<numeric>
#define rep(i,n) for(int i=0;i<(n);++i)
#define _GLIBCXX_DEBUG
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

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

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main() {
    ll a, b;
    cin >> a >> b;
    ll x = lcm(a, b);
    cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
   dp[0][0]=0;
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
           }
           else{
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){
               ans=max(ans,j);
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}


Measured memory_bytes: 79104
N,M=map(int,raw_input().split())
A=[map(int,raw_input().split()) for i in range(N)]
C=[map(int,raw_input().split()) for i in range(M)]

ans=[]
l= float("inf")
for a,b in A:
	l= float("inf")
	for i,c in enumerate(C):
		if l>abs(a-c[0])+abs(b-c[1]):
			l=abs(a-c[0])+abs(b-c[1])
			x=i+1
	else:
		ans.append(x)

for i in ans:
	print i

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

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

    int c, sum;

    for(int a = 0; a <= N; ++a){

        for(int b = 0; b <= N - a; ++b){
            c = N - a - b;
            sum = 10000 * a + 5000 * b + 1000 * c;

            if(sum == Y){
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

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

using namespace std;

const int N=2e5+5;
int n;
long long ans;

int a[N],c[N];

string s;

int main() {
        int t;
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) {
                scanf("%d", &a[i]);
                c[a[i]]++;
        }
        for (int i = 1; i <= n; i++) {
                ans += (long long)(c[i] - 1) * c[i] / 2;
        }
        for (int i = 1; i <= n; i++) {
                cout << ans - (long long)(c[a[i]] - 1) << endl;
        }
        return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
int main(void){
	
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(b == 1){
		printf("%d\n", 0);
		return 0;
	}
	
	printf("%d\n", a-b);
	
	return 0;
	
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int d, g; cin >> d >> g;
    g/=100;
    vector<int> p(d+1, 0);
    vector<int> c(d+1,0);
    int m=0;
    for(int i=1;i<=d;++i) {
        cin >> p[i] >> c[i];
        c[i]/=100;
        m+=p[i];
    }
    int pow[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};

    for(int i=0;i<pow[d];++i) {
        int z=0, y=0;
        for(int j=1;j<=d;++j) {
            if(i&(1<<(j-1))) {
                z += j*p[j] + c[j];
                y+=p[j];
            }
        }
        for(int j=d;j>0;--j) {
            if(z>=g) break;
            if(!(i&(1<<(j-1)))) {
                int x = min(p[j], (g-z)/j + (((g-z)%j>0)?1:0));
                z += j*x;
                y+=x;
            }
        }
        if(z<g) continue;
        m=min(m,y);
    }
    cout << m<< endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool prime[1000001];  //sieve of erastothenes(primality check 1 to 10^6)
void sieve()
{
	for(int i=2;i<1000000;i++)
		prime[i]=true;
	for(int i=2;i<=1000;i++)
	{
		if(prime[i])
		{
			for(int j=i*i;j<=1000000;j+=i)
				prime[j]=false;
		}
	}
}
ll binpow(ll a, ll b) {      
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	ll dividend = a>=b ? a:b;
	ll divisor = a<=b ? a:b;
	
	while(divisor!=0)
	{
		ll remainder = dividend%divisor;
		dividend = divisor;
		divisor = remainder;
	}
	return dividend;
}
int main()
{
    ios_base::sync_with_stdio(false);   
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n = 0;
	
	string s;
	cin>>s;
	ll m = s.length();
	for(ll i=0;i<m;i++)
	{
		if(s[i]=='+')
		{
			n++;
		}
		else
		{
			n--;
		}
	}
	cout<<n;
}

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

using namespace std;
#define ll long long

int main()
{
  ll n,m,k;cin>>n>>m>>k;
  ll a[n],b[m],sum=0,ans1=0;
  for(ll i=0;i<n;i++)cin>>a[i];
  for(ll i=0;i<m;i++)cin>>b[i];
vector<ll>suma(n+1),sumb(m+1);
suma[0]=sumb[0]=0;
for(ll i=1;i<=n;i++)
suma[i]=suma[i-1]+a[i-1];
  for(ll i=1;i<=m;i++)sumb[i]=sumb[i-1]+b[i-1];
  for(ll i=0;i<=n;i++){
      ll temp=k-suma[i];
      if(temp<0)break;
      ll l=lower_bound(sumb.begin(),sumb.end(),temp)-sumb.begin();
      if(l>m||sumb[l]>temp)l--;
      ans1=max(ans1,i+l);
  }
   cout<<ans1<<endl;
   return 0;
}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i;
  vector<char> S(4);
  for(i=0;i<4;++i){
    cin >> S[i];
  }
  if(S[0]==S[1] && S[0]!=S[2] && S[2]==S[3]){
    cout << "Yes" << endl;
  }
  else if(S[0]==S[2] && S[0]!=S[1] && S[1]==S[3]){
    cout << "Yes" << endl;
  }
  else if(S[0]==S[3] && S[0]!=S[1] && S[1]==S[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	int a,b,c,d,e; cin >> a >> b >> c >> d >> e;

	vector<int> z{a, b, c, d, e};

	int mi{9};
	int keep{};
	int flag{};
	for(int i = 0; i < 5; ++i){
		if(z[i]%10 != 0){
			if(mi%10 >= z[i]%10)
			{
				mi = z[i];
				keep = i;
			}
		}
		else{
			flag++;
		}
	}

	if(flag == 5){
		mi = z[0];
		keep = 0;		
	}

	//割る時の切り上げは(a+b-1)/b
	//割らないときの切り上げはx進数なら,(i+x-1)/x*x
	int sum = mi;
	for(int i = 0; i < 5; ++i/*auto i: z*/){
		/*入力が等しいときに困る
		if(i != mi)*/
		if(i != keep)
		sum += (z[i]+9)/10*10;
	}

	cout << sum << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> T;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
const int INF = 2e9;
int ans=0;
vector<bool> calc(vector<vector<int>> &g,int n,int i){
  vector<bool> canGoal(n,false);
  canGoal[i]=true;
  queue<int> que;
  que.push(i);
  while(!que.empty()){
    int now=que.front();
    que.pop();
    for(auto to:g[now]){
      if(!canGoal[to]){
        canGoal[to]=true;
        que.push(to);
      }
    }
  }
  return canGoal;
}
int main(){
  int n,m,p;
  cin >> n >> m >> p;
  vector<T> graph;
  vector<vector<int>> g(n),rg(n);
  For(i,0,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph.emplace_back(a,b,p-c);
    g[a].emplace_back(b);
    rg[b].emplace_back(a);
  }
  
  vector<bool> canGoal1=calc(g,n,0);
  vector<bool> canGoal2=calc(rg,n,n-1);
  vector<bool> canGoal(n);
  For(i,0,n) canGoal[i]=canGoal1[i]&canGoal2[i];
  vector<int> coin(n,INF);
  coin[0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      T t=graph[j];
      if(!canGoal[get<0>(t)] || !canGoal[get<1>(t)] || coin[get<0>(t)]==INF) continue;
      if(coin[get<1>(t)] > coin[get<0>(t)] + get<2>(t)){
        coin[get<1>(t)] = coin[get<0>(t)] + get<2>(t);
        if(i==n-1){
            ans=-1;
            break;
        }
      }
    }
  }
  if(ans!=-1) ans=max(0,-coin[n-1]);
  cout << ans << endl;
}

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif


#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define ll long long
#define two pair<int,int>
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repb(i,a,b) for(int i=(a);i>=(b);i--)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);
#define d2 vector<vector<int>>

int n;
d2 base;

d2 mul(d2 &m1, d2 &m2){
  d2 ans(n,vector<int>(n));
  for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)
    for(int k=0;k<n;k++)
     ans[i][j] += m1[i][k]*m2[k][j], ans[i][j] %= limit;
    return ans;
}

d2 getans(int k){
   if(k == 1) return base;
   if(k%2 == 0){
     d2 tmp = getans(k/2);
     return mul(tmp,tmp);
   }
   d2 tmp = getans(k-1);
   return mul(tmp,base);
}

signed main(){
 //input_from_file;
 int k; cin>>n>>k;
 base.resize(n,vector<int>(n,0));
 for(int i=0;i<n;i++)
 for(int j=0;j<n;j++) cin>>base[i][j];
 d2 dp = getans(k);
 int ans = 0;
 for(int i=0;i<n;i++)
 for(int j=0;j<n;j++) ans += dp[i][j], ans %= limit;
 cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
public  class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    String a = stdIn.next();
  
    if(Character.isUpperCase(a.charAt(0))){
      System.out.println("A");
    			}
      else
        System.out.println("a");

  }
}

Measured memory_bytes: 35564
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
int dp[100005];
int h[100005];
int solve(int n)
{
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    if(n==1)
        return dp[1];
    else if(n==2)
        return dp[2];
    else{
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    return dp[n];
    
}
int main()
{
    fastio;
    int n,i,j;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>h[i];
    printf("%d\n",solve(n));
   // system("pause");
    return 0;
}

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

int n, a, b, c;
int l[10];
const int INF = 1<<30;
int ans = INF;

void dfs(int x, int y, int z, int mp, int i) {
    if (i == n) {
        if (x == 0 || y == 0 || z == 0) return;

        int res = mp;
        res += abs(x-a);
        res += abs(y-b);
        res += abs(z-c);
        ans = min(ans, res);
        return;
    }
    
    dfs(x+l[i], y, z, x==0? mp:mp+10, i+1);
    dfs(x, y+l[i], z, y==0? mp:mp+10, i+1);
    dfs(x, y, z+l[i], z==0? mp:mp+10, i+1);
    dfs(x, y, z, mp, i+1);
}

int main() 
{
    cin >> n >> a >> b >> c;
    rep(i,n) cin >> l[i];

    dfs(0, 0, 0, 0, 0);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256