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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vector<ll> P(N);
  for (ll i = 0; i < N; ++i) {
    cin >> P.at(i);
  }
  vector<ll> sorted(N, 0);
  sorted.at(0) = 1;
  for (ll i = 1; i < N; ++i) {
    if (P.at(i - 1) < P.at(i)) {
      sorted.at(i) = sorted.at(i - 1) + 1;
    }
    else {
      sorted.at(i) = 1;
    }
  }


  // for (ll i = 0; i < N; ++i) {
  //   cout << sorted.at(i) << " ";
  // }
  // cout << "\n";
  ll ans = 1;
  ll num = 0;
  bool f = false;
  vector<bool> sor(N, false);
  for (ll i = 0; i < N; ++i) {
    if (sorted.at(i) >= K) {
      sor.at(i) = true;
      num = 1;
      if (i == K - 1) {
        f = true;
      }
    }
  }
  if (f) {
    num = 0;
  }
  ans += num;
  set<ll> st;
  for (ll i = 0; i < K; ++i) {
    st.insert(P.at(i));
  }
  for (ll i = 0; i + K < N; ++i) {
    // cout << "i" << i << *st.begin() << ' ' << *st.rbegin() << "\n";
    if (!((*st.begin() == P.at(i)) && (*st.rbegin() < P.at(i + K)))) {
      // cout << "i" << i << "\n";
      if (!sor.at(i + K)) {
        ans += 1;
      }
    }
    st.erase(P.at(i));
    st.insert(P.at(i + K));
  }
  cout << ans << "\n";
}


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

int main(){
	long long int N,K,ANS(0);
  	cin >> N >> K;
  	vector<long long int> H(N);
  	for(int i = 0 ; i < N ; i ++){
     	cin >> H[i];
    }
  	sort(H.begin(),H.end());
  	for(int i = 0 ; i < N - K ; i ++){
      ANS += H[i];
    }
  	cout << ANS << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4,sux,suy;
  cin >> x1 >> y1 >> x2 >> y2;
  sux=x2-x1;
  suy=y2-y1;
  x3=x2-suy;
  y3=y2+sux;
  x4=x1-suy;
  y4=y1+sux;
  cout << x3<<" "  << y3<<" " << x4<<" " << y4 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

struct edge{
    int color, to, id;
};
vector<int> ans;
int max_k = 1;

void dfs(int v, int p, int par_col, vector<vector<edge>> &G){
    int col = 1;
    for(auto nv : G[v]){
        if(nv.to == p) continue;
        if(col == par_col) ++col;
        nv.color = col++;
        ans[nv.id] = nv.color;
        chmax(max_k, nv.color);
        dfs(nv.to, v, nv.color, G);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ans.resize(n);
    vector<vector<edge>> G(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge e;
        e.color = -1, e.to = b, e.id = i;
        G[a].push_back(e);
        e.to = a;
        G[b].push_back(e);
    }
    dfs(0, -1, -1, G);
    cout << max_k << endl;
    rep(i,n-1){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8320
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        String[] line1 = sc.nextLine().split(" ");
        String[] line2 = sc.nextLine().split(" ");
        sc.close();

        int[] Cum1 = new int[N + 1];
        int[] Cum2 = new int[N + 1];

        Cum1[0] = 0;
        Cum2[0] = 0;

        int tmp1 = 0;
        int tmp2 = 0;
        for (int i = 0; i < N; i++) {
            tmp1 += Integer.parseInt(line1[i]);
            tmp2 += Integer.parseInt(line2[i]);
            Cum1[i + 1] = tmp1;
            Cum2[i + 1] = tmp2;
        }

        int max = 0;
        for (int j = 1; j < N; j++) {
            int line2val = Cum2[N] - Cum2[j - 1];
            int val = Cum1[j] + line2val;
            if (val >= max) {
                max = val;
            }
        }

        if (max == 0) {
            max = Integer.parseInt(line1[0]) + Integer.parseInt(line2[0]);
        }

        System.out.println(max);
    }

}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>

struct Node {
    int key;
    Node *parent, *left, *right;
};
Node *nil, *root;

void Insert(int key)
{
    Node *x = root;
    Node *y = nil;
    Node *z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = nil;
    z->right = nil;
    while (x != nil) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == nil) {
        root = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

void PrintPreorder(Node *node)
{
    if (node != nil) {
        fprintf(stdout, " %d", node->key);
        PrintPreorder(node->left);
        PrintPreorder(node->right);
    }
}

void PrintInorder(Node *node)
{
    if (node != nil) {
        PrintInorder(node->left);
        fprintf(stdout, " %d", node->key);
        PrintInorder(node->right);
    }
}

int main(int argc, char *argv[])
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        char inst[10];
        scanf("%s", inst);

        if (inst[0] == 'i') {
            int key;
            scanf("%d", &key);
            Insert(key);
        } else if (inst[0] == 'p') {
            PrintInorder(root);
            fprintf(stdout, "\n");
            PrintPreorder(root);
            fprintf(stdout, "\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26128
#include <bits/stdc++.h>
using namespace std;
const int SZ = 330;

struct Edge
{
  int a, b, c, d;
};

struct Query
{
  int y, u, v, id;
};

int n, q, cntColor[100100], dist[100100], depth[100100], par[100100][20], ans[100100];
int timeIn[100100], timeOut[100100], dfsTime, ds[100100];
vector <Edge> edges, coloredEdges[100100];
vector < pair<int, int> > adj[100100];
vector <Query> queries[100100];

void input()
{
  int a, b, c, d;
  cin >> n >> q;
  for (int i = 1; i < n; i++)
  {
    cin >> a >> b >> c >> d;
    edges.push_back({a, b, c, d});
    adj[a].push_back({b, d});
    adj[b].push_back({a, d});
    coloredEdges[c].push_back({a, b, c, d});
  }
}

void visit(int x)
{
  timeIn[x] = dfsTime++;
  for (auto u : adj[x])
  {
    int y = u.first, d = u.second;
    if (y != par[x][0])
    {
      dist[y] = dist[x] + d;
      depth[y] = depth[x] + 1;
      par[y][0] = x;
      visit(y);
    }
  }
  timeOut[x] = dfsTime++;
}

void initTree(int root)
{
  dfsTime = 0;
  visit(root);
  for (int j = 0; j < 17; j++)
    for (int i = 1; i <= n; i++)
      par[i][j + 1] = par[par[i][j]][j];
}

int isChild(int x, int y)
{
  return timeIn[y] <= timeIn[x] && timeOut[x] <= timeOut[y];
}

int lca(int x, int y)
{
  if (depth[x] > depth[y])
    swap(x, y);
  for (int i = 17; i >= 0; i--)
    if (depth[y] - (1 << i) >= depth[x])
      y = par[y][i];
  if (x == y)
    return x;
  for (int i = 17; i >= 0; i--)
    if (par[x][i] != par[y][i])
    {
      x = par[x][i];
      y = par[y][i];
    }
  return par[x][0];
}

void solve(int color)
{
  for (int i = 1; i <= n; i++)
  {
    dist[i] = depth[i] = par[i][0] = 0;
    ds[i] = i;
    adj[i].clear();
  }

  function<int(int)> get = [&](int x)
  {
    return x == ds[x] ? x : ds[x] = get(ds[x]);
  };

  for (auto edge : edges)
    if (edge.c != color)
    {
      int da = get(edge.a), db = get(edge.b);
      ds[da] = db;
    }

  for (auto edge : edges)
    if (edge.c == color)
    {
      int da = get(edge.a), db = get(edge.b);
      adj[da].push_back({db, edge.d});
      adj[db].push_back({da, edge.d});
    }

  initTree(get(1));
  for (auto query : queries[color])
  {
    int u = get(query.u), v = get(query.v), z = lca(u, v);
    ans[query.id] -= dist[u] + dist[v] - dist[z] * 2;
    ans[query.id] += (depth[u] + depth[v] - depth[z] * 2) * query.y;
  }
}

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

  input();
  initTree(1);

  int x, y, u, v;
  for (int i = 0; i < q; i++)
  {
    cin >> x >> y >> u >> v;
    int z = lca(u, v);
    ans[i] = dist[u] + dist[v] - dist[z] * 2;
    if (coloredEdges[x].size() >= SZ) queries[x].push_back({y, u, v, i});
    else
    {
      for (auto edge : coloredEdges[x])
      {
        int a = edge.a, b = edge.b;
        if (dist[a] > dist[b])
          swap(a, b);
        if (isChild(a, z) && (isChild(u, b) || isChild(v, b)))
          ans[i] += y - edge.d;
      }
    }
  }

  for (int i = 1; i < n; i++)
    if (!queries[i].empty())
      solve(i);

  for (int i = 0; i < q; i++)
    cout << ans[i] << '\n';
}


Measured memory_bytes: 30312
#include<stdio.h>

int main(void)
{
   int n, a[100000], i, x=0, z[100000]={0};

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

   i=0;
   while(x!=1){
      x=a[x]-1;
      if(z[x]==1){
         printf("-1\n");
         return 0;
      }
      z[x]=1;
      i++;
   }

   printf("%d\n",i);
   return 0;
}

Measured memory_bytes: 2488
N=int(input())
a=int(N/4)
b=int(N/7)
bol=0
for i in range(a+1):
    for j in range(b+1):
        if (i*4+j*7)==N:
            bol=1
if bol==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;

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


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
string S;
signed main() {
    cin >> N >> S;
    int cnt = 0;
    rep(i, N) { if (S[i] == 'R') { cnt++; }}
    int ans = 0;
    for (int i = cnt; i < N; i++) { if (S[i] == 'R') { ans++; }}
    cout << ans << endl;
}

Measured memory_bytes: 3760
using System;

class Program
{
    static void Main(string[] args)
    {
        var hw = Console.ReadLine().Split();
        var h = int.Parse(hw[0]);
        var w = int.Parse(hw[1]);
        Console.WriteLine(new string('#', w + 2));
        for (int i = 0; i < h; i++) Console.WriteLine("#" + Console.ReadLine() + "#");
        Console.WriteLine(new string('#', w + 2));
    }
}


Measured memory_bytes: 13140
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
      X /= 50;
        int count = 0;
      for (int ia = 0; ia <= A; ia++) {
       	for (int ib = 0; ib <= B; ib++) {
          for (int ic = 0; ic <= C; ic++) {
            if (10 * ia + 2 * ib + ic == X) {
              count++;
            }
          }
        }
      }
		// 出力
		System.out.println(count);
	}
}

Measured memory_bytes: 23124
N,K = map(int,input().split())
p = list(map(int,input().split()))
max = 0
r = 0
for i in range(K):
  max = max + p[i] + 1
  r = r + p[i] + 1
  
for j in range(N-K):
  r = r -p[j] + p[K+j]
  if max < r:
    max = r
    
print(max/2)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int maxn = 1e2+5;
int main()
{
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = w * (ll)1 * h / 2.0;
    if (x == w / 2.0 && y == h / 2.0)
    printf("%f 1",s);
    else
    printf("%f 0",s);
    return 0; 
}

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

using namespace std;

int main(){
    long long q, h, s, d;
    long long n;
    cin >> q >> h >> s >> d >> n;
    long long mn_for_1_l = min(q*4, min(h*2, s));
    long long mn_for_2_l = min(q*8, min(h*4, min(s*2, d)));
    long long ans = 0;
    if (n % 2 == 0 && mn_for_2_l <= 2 * mn_for_1_l){
        ans += mn_for_2_l * (n / 2);
    } else if (n % 2 == 0 && mn_for_2_l >= 2 * mn_for_1_l){
        ans += mn_for_1_l * n;
    } else if (n % 2 != 0 && mn_for_2_l <= 2 * mn_for_1_l){
        ans = ans + mn_for_2_l * (n / 2) + mn_for_1_l;
    } else if (n % 2 != 0 && mn_for_2_l >= 2 * mn_for_1_l){
        ans += mn_for_1_l * n;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var AP = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = AP[0];
            var P = AP[1];

            var output = (A * 3 + P) / 2;
            Console.WriteLine(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
const int N=310;

int n,c,l[N],g[N],ways=0;
double f[N][N][70],ans=0;

void dfs(int x) {
	if(x==n+1) {
		++ways;
		memset(f,0,sizeof(f));
		f[0][l[1]][0]=1;
		for(int i=0;i<c;i++)
			for(int j=i;j<=c;j++)
				for(int s=0;s<(1<<(n-1));s++) {
					if(f[i][j][s]==0) continue;
					if(i^j) f[i+1][j][s]+=f[i][j][s];
					int id=g[i%n];
					if(id&&!(s>>(id-2)&1)) f[i+1][min(c,max(j,i+l[id]))][s|(1<<(id-2))]+=f[i][j][s]/(c/n);
				}
		ans+=f[c][c][(1<<(n-1))-1];
		return;
	}
	for(int i=1;i<n;i++)
		if(!g[i]) {
			g[i]=x;dfs(x+1);g[i]=0;
		}
}

int main() {
	cin>>n>>c;c*=n;
	for(int i=1;i<=n;i++) cin>>l[i],l[i]*=n;
	sort(l+1,l+n+1,[&](int x,int y) { return x>y; });
	dfs(2);
	cout<<setprecision(11)<<fixed<<ans/ways;
	return 0;
}


Measured memory_bytes: 52864
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int n,m,x[100010],y[100010];
namespace work1{
	std::bitset<50001>s[50001],L[100010];
	void main(){
		for(int i=1;i<=n;++i)s[i][i]=s[0][i]=1;
		for(int i=m;i;--i){
			L[i]=s[x[i]]&~s[y[i]];
			s[y[i]]=(s[x[i]]|=s[y[i]]);
		}
		for(int i=1;i<=n;++i)s[0]&=s[i];
		if(!s[0].any())puts("-1");
		else{
			int w=s[0]._Find_first();
			for(int i=1;i<=m;++i)putchar(L[i][w]?'^':'v');
		}
	}
}
namespace work2{
	char ans[100010];
	int to[50010],M[50010];
	void main(){
		if(n==2)return(void)puts("-1");
		for(int i=1;i<=n;++i)to[i]=i,M[i]=1;
		for(int i=m;i;--i){
			if(to[x[i]]^to[y[i]]){
				if(M[to[x[i]]]>1)ans[i]='v',--M[to[x[i]]],++M[to[x[i]]=to[y[i]]];
				else ans[i]='^',--M[to[y[i]]],++M[to[y[i]]=to[x[i]]];
			}else ans[i]='v';
		}
		printf("%s",ans+1);
	}
}
int main(){
	n=gi(),m=gi();int t=gi();
	for(int i=1;i<=m;++i)x[i]=gi(),y[i]=gi();
	if(t==1)work1::main();
	else work2::main();
	return 0;
}


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

int main(void) {
	int a, b, k, n = 0;
	vector<int> ans(100, 0);
	cin >> a >> b >> k;
	for (int i = 1; i <= max(a, b); i++) {
		if (a % i == 0 && b % i == 0) {
			ans.at(n) = i;
			n++;
		}
	}
	cout << ans.at(n - k) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N)
{

    for (int i = 0; i < 100000; i++)
    {
        if ((int)(i * 1.08) == N)
        {
            cout << i << endl;
            return;
        }
    }

    cout << ":(" << endl;
}
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int solve(int N, int M) {
    int ans = 0;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if (a[i] + a[j] <= M) {
                ans = max(ans, a[i] + a[j]);
            }
        }
    }
    return ans;
}

int main(void) {
    int N, M;
    vector<int> ans;
    while (1) {
        cin >> N >> M;
        if (!N && !M) break;
        ans.push_back(solve(N, M));
    }
    
    for (auto i: ans) {
        if (i) {
            cout << i << endl;
        } else {
            cout << "NONE" << endl;
        }
    }
}   





Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define PI 3.141592653589793
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    char C;
    string S = "abcdefghijklmnopqrstuvwxyz";
    cin >> C;
    char ans;
    for(int i = 0; i < S.size(); i++){
        if(C == S[i]){
            ans = S[i+1];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans, surplus = 0, 0
for i in range(N):
    tmp = min(A[i], surplus)
    ans += tmp
    A[i] -= tmp
    if B[i] > A[i]:
        ans += A[i]
        surplus = B[i] - A[i]
    else:
        ans += B[i]
        surplus = 0
tmp = min(A[N], surplus)
ans += tmp
print(ans)


Measured memory_bytes: 19156
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   if(N==1) System.out.println("Hello World");
   else 
   {
    int A = sc.nextInt();
    int B = sc.nextInt();
     
    System.out.println(A+B);
   }
 }
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if(A.size() == n + 1) {
        int now = 0;
        rep(i, q) {
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vector<int> (q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int> (1,1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

enum Color {
    BLACK, WHITE, COLOR_NUM
};

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

    vector<vector<ll>> p(COLOR_NUM, vector<ll>(N));

    for (ll i = 0; i < 2 * N; i++) {
        char c;
        ll t;
        cin >> c >> t;
        p[c == 'W'][t - 1] = i;
    }

    vector<vector<vector<ll>>> sum(COLOR_NUM, vector<vector<ll>>(N + 1, vector<ll>(N + 1, 0)));
    for (ll i = 0; i < N; i++) {
        for (ll j = i + 1; j < N; j++) {
            if (p[BLACK][j] < p[BLACK][i]) {
                sum[BLACK][i][N]++;
            }
        }
        for (ll j = N - 1; j >= 0; j--) {
            sum[BLACK][i][j] = sum[BLACK][i][j + 1] + (p[WHITE][j] < p[BLACK][i]);
        }
    }
    for (ll i = 0; i < N; i++) {
        for (ll j = i + 1; j < N; j++) {
            if (p[WHITE][j] < p[WHITE][i]) {
                sum[WHITE][N][i]++;
            }
        }
        for (ll j = N - 1; j >= 0; --j) {
            sum[WHITE][j][i] = sum[WHITE][j + 1][i] + (p[BLACK][j] < p[WHITE][i]);
        }
    }

    vector<vector<ll>> dp(N + 2, vector<ll>(N + 2, INT_MAX));
    dp[0][0] = 0;
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; j <= N; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + sum[BLACK][i][j]);
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + sum[WHITE][i][j]);
        }
    }
    std::cout << dp[N][N] << endl;
}

Measured memory_bytes: 94336
#include<stdio.h>

int main(){
  int n,i=0,c=0; scanf("%d",&n);
  char s[n]; scanf("%s",s);
  while(i<n){
    if (s[i]=='A' && i<n-2){
      if (s[i+1]=='B'){
        if (s[i+2]=='C'){
          c++; i+=3;
        }else i+=2;
      }else i+=1;
    }else i+=1;
  }
  printf("%d\n",c);
  return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> D1(N);
    vector<int> D2(N);
    rep(i, N){
        cin >> D1[i] >> D2[i];
    }

    for (int i = 2; i < N; i++){
        if(D1[i-2] == D2[i-2] && D1[i-1] == D2[i-1] && D1[i] == D2[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


int Main(int A, int B, int C)
{
    return max(C-A+B, 0);
}

int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    cout << Main(A, B, C) << endl;
    return 0;
}

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

int main(){
    int w, h ,n;
    std::cin >> w >> h >> n;
    std::vector<int> a1{0};
    std::vector<int> a2{w};
    std::vector<int> a3{0};
    std::vector<int> a4{h};
    
    int x, y, a;
    for(int i = 0; i < n; ++i){
        std::cin >> x >> y >> a;
        switch(a){
            case 1:
                a1.push_back(x);
                break;
            case 2:
                a2.push_back(x);
                break;
            case 3:
                a3.push_back(y);
                break;
            case 4:
                a4.push_back(y);
                break;
        }
    }

    int xVariance = *std::min_element(a2.begin(), a2.end()) - *std::max_element(a1.begin(), a1.end());
    int yVariance = *std::min_element(a4.begin(), a4.end()) - *std::max_element(a3.begin(), a3.end());
    
    if(xVariance < 0 || yVariance < 0){
        std::cout << 0 << std::endl;
    }else{
        std::cout << xVariance * yVariance << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
a=[]
for i in range(3):
    a.extend(list(map(int,input().split())))


n=int(input())

for i in range(n):
    b=int(input())
    if b in a:
        a[a.index(b)]=-1
        
check=[[0,1,2],[3,4,5],[6,7,8],
       [0,3,6],[1,4,7],[2,5,8],
       [0,4,8],[2,4,6]]

flag=False
for c in check:
    if a[c[0]]==-1 and a[c[1]]==-1 and a[c[2]] ==-1:
        flag=True
    if flag:
        break
    
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
bingo = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
l = [int(input()) for _ in range(n)]

for i in l:
    for p in range(3):
        for q in range(3):
            if bingo[p][q] == i:
                bingo[p][q] = -1

flag = False

for i in range(3):
    t = True
    for j in range(3):
        t &= bingo[i][j] == -1
    flag |= t

for i in range(3):
    t = True
    for j in range(3):
        t &= bingo[j][i] == -1
    flag |= t

flag |= bingo[0][0]==-1 and bingo[1][1]==-1 and bingo[2][2]==-1
flag |= bingo[0][2]==-1 and bingo[1][1]==-1 and bingo[2][0]==-1

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

#define maxN 100000
int N, K;
int a[maxN];
ll b[maxN];

//ｘに対してスコアはいくつになるか
ll check(int x){
  ll res = 0LL;
  for(int i = 0; i < N; i++){
    if((x | a[i]) <= x){
      res += b[i];
    }
  }
  return res;
}

//候補の数がｘ、見ているビットがy
ll dfs(int x, int y){
  //cout << x << " " << y << endl;
  if(y == 0){
    ll ans = check(x);
    return ans;
  }

  //xのyビットが０
  if((x & (1 << y)) == 0){
    return dfs(x, y - 1);
  }
  else {
    ll res1 = dfs(x, y - 1);

    x -= (1 << y);
    for(int i = 0; i < y; i++){
      x |= (1 << i);
    }
    ll res2 = check(x);

    return max(res1, res2);
  }
}

int main(){
  cin >> N >> K;
  for(int i = 0; i < N; i++) cin >> a[i] >> b[i];

  cout << dfs(K, 30) << endl;
  return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007


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

	int n;
	string s[2];
	cin>>n;
	rep(i,2){
		cin >> s[i];
	}
	long long ans=1;
	int prev=-1;
	for (int i=0;i<n;){
		if (s[0][i]==s[1][i]){
			if (prev == -1){
				ans = 3;
			}
			else if (prev==0){
				ans *= 2;
			}
			else{
				ans *= 1;
			}
			prev=0;
			i++;
		}
		else{
			if (prev == -1){
				ans=6;
			}
			else if (prev == 0){
				ans *= 2;
			}
			else{
				ans *= 3;
			}
			prev=1;
			i+=2;
		}
		ans%=MOD;
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int N, Z, W, a[2001] = {};

int main() {
	cin >> N >> Z >> W;
	for (int i = 1; i <= N; i++)cin >> a[i];
	if (N == 1) {
		cout << abs(a[1] - W) << endl;
	}
	else {
		if (abs(W - a[N]) > abs(a[N] - a[N - 1])) {
			cout << abs(W - a[N]) << endl;
		}
		else {
			cout << abs(a[N] - a[N - 1]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
a = 0
b = 0

for n,i in enumerate(itertools.permutations([i for i in range(1,N+1)],N),1):
    if i == P:
        a = n
    if i == Q:
        b = n

print(abs(a-b))



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

class Cmondai
{
    static void Main()
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        var sUniq = S.Distinct().ToArray();
        var tUniq = T.Distinct().ToArray();
        var ans = "Yes";
        if (sUniq.Count() != tUniq.Count()) ans = "No";
        for (int i=0; i<sUniq.Count();++i)
        {
            if (ans == "No") break;
            if (S.Count(x => x == sUniq[i])!=T.Count(x => x == tUniq[i])) ans = "No";
        }
        Console.WriteLine(ans);
    }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL n, a, b;cin >> n >> a >> b;
    cout << max(0LL, (a+b*(n-1))-(b+a*(n-1))+1) << endl;
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int K;
  vector<int> X(M, 0);
  for (int i = 0; i < N; i++) {
    cin >> K;
    int a;
    for (int j = 0; j < K; j++) {
      cin >> a; a--;
      X[a]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (X[i] == N) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

char a[3];
int main()
{
	int ans = 0;
	for(int i = 0; i < 3; i++)
	{
		scanf("%c",&a[i]);
		if(a[i] == '1')
		{
			ans++;
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#! /usr/bin/env python3

n = int(input())

comb = [False for _ in range(55555+1)]

nums = [2]
i = 2

while i <= 55555:
    if comb[i] == False:
       if i % 5 == 1: nums.append(str(i))
       comb[i] = True
       j = i + i
       while j <= 55555:
           comb[j] = True
           j += i

    i += 1

res = []
for i in range(n):
    res.append(nums[i])

print(" ".join(map(str, res)))


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
static const double PI = 3.14159265359;

int main()
{
	int N;
	std::cin >> N;
	int64_t sum = 0;
	for (int i = 1; i <= N; ++i) {
		if ((i % 3 != 0) && (i % 5 != 0)) {
			sum += i;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int n, a[100010] = {};
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a[i]--;
	}
	int now = 0, ans = -1;
	for(int i = 0;i < n;i++){
		if(now == 1){
			ans = i;
			break;
		}
		now = a[now];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  long long N,min,ans=0;
  vector <long long> P(200000);
  cin >>N;
  for(int i=0;i<N;i++){
    cin >>P.at(i);
    
  }
  min=P.at(0);
  for(int i=0;i<N;i++){
    if(min>=P.at(i)){
      min =P.at(i);
      ans++;
    }
  } 
  
  cout <<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t W,H,x,y; cin>>W>>H>>x>>y;

    int64_t symPx=W-x,symPy=H-y,multi=0;
    if(x==symPx && y==symPy) multi=1;

    cout<<W*H/2.<<" "<<multi<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int money = 100000,n;
  cin >>n;
  while(n--){
    money = (int)(money*1.05);
    if(money%1000){money = (money/1000+1)*1000;}
  }
  cout <<money<<endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n,h1,n1,k;
  cin >> h >> n >> h1 >> n1 >>k;
  int sum=0 ,sum2=0;
  sum=h*60+n;
  sum2=h1*60+n1;
  int g=sum2-sum;
  cout << g-k << endl;
}


Measured memory_bytes: 3552
use std::collections::HashMap;
use std::error::Error;
use std::io;

pub fn main() {
    if let Err(_e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<dyn Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    let n: i64 = input.trim().parse()?;
    let map = resolve_prime(n);
    let mut result = 0;
    for &x in map.values() {
        let mut temp = x;
        let mut i = 1;
        while temp >= i {
            temp -= i;
            result += 1;
            i += 1;
        }
    }
    println!("{}", result);

    Ok(())
}

fn resolve_prime(mut n: i64) -> HashMap<i64, i64> {
    let mut i = 2i64;
    let mut result = HashMap::new();
    while i * i <= n {
        if i != 2 && i % 2 == 0 {
            i += 1;
            continue;
        }
        if n % i == 0 {
            let count = result.entry(i).or_insert(0);
            *count += 1;
            n /= i;
        } else {
            i += 1;
        }
    }
    if n != 1 {
        let count = result.entry(n).or_insert(0);
        *count += 1;
    }
    result
}


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


int main()
{
    //ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    getchar();
    string s1,s2,s3;
    cin>>s1>>s2;
    for(int i=0;s1[i]!='\0' && s2[i]!='\0';i++)
    {
        if(s1[i]!='\0')
            s3+=s1[i];
        if(s2[i]!='\0')
            s3+=s2[i];
    }
    cout<<s3<<"\n";

    return 0;
}


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

int main(){

  int n,a;

  while( cin >> n,n){

    int flag = 0,cnt = 0;

    for(int i = 0 ; i < n ; i++){
      cin >> a;
      if(a > 1)flag = 1;
      if(a > 0)cnt++;
    }
    if(flag)cout << cnt + 1 << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		label:while(true){
			int A = 0;
			int B = 0;
			for(int cases = 0;cases<3;cases++){
				A = 0;
				B = 0;
				String str= cin.next();
				if(str.equals("0")){
					break label;
				}
				for(int i = 1;i<str.length();i++){
					if(str.charAt(i)=='A'){
						A++;
					}
					else{
						B++;
					}
				}
				if(A>B){
					A++;
				}
				else{
					B++;
				}
				System.out.println(A +" " + B);
			}
		}
	}

}

Measured memory_bytes: 11000
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

AB.sort(key=lambda x: x[1])
Atime = [0]
for i in range(N) :
    Atime.append(Atime[i]+AB[i][0])

for i in range(N) :
    if Atime[i+1] > AB[i][1] :
        print("No")
        exit()

print("Yes")


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

// 1を始点としてDFSでグラフ上を探索し条件を満たすパスを数え上げる

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool has_visited[nmax]) {
    bool has_visited_all = true;
    for (int i = 0; i < N; i++) {
        if (has_visited[i] == false) {
            has_visited_all = false;
        }
    }
    if (has_visited_all) {
        return 1;
    }

    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (graph[v][i] == false) {
            continue; // 辺が生えてないのでスルー
        }
        if (has_visited[i]) {
            continue; // すでに訪問済みなのでスルー
        }
        has_visited[i] = true;
        ret += dfs(i, N, has_visited);
        has_visited[i] = false;
    }
    return ret;
}

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }
    bool has_visited[nmax];
    for (int i = 0; i < N; i++) {
        has_visited[i] = false;
    }
    has_visited[0] = true;
    cout << dfs(0, N, has_visited) << endl;
    return 0;
}


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

using namespace std;
int main(){
  cin.tie(0); 
  ios::sync_with_stdio(false);
  int N,a,w,t,r;
  N = a = w = t = r = 0;
  string s;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> s;
    if( s[0] == 'A' ){
      a++;
    }else if( s[0] == 'W' ){
      w++;
    }else if( s[0] == 'T' ){
      t++;
    }else{
      r++;
    }
      
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
  
  
  return 0;
}



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

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

    int n, h;
    cin >> n >> h;

    vector<int> A(n);
    vector<pair<int, bool>> B(n + 1);
    REP(i, n){
        cin >> A[i] >> B[i].first;
        B[i].second = false;
    }

    sort(A.begin(), A.end(), greater<int>());

    B[n].first = A[0];
    B[n].second = true;

    sort(B.begin(), B.end(), greater<pair<int, bool>>());

    int cnt = 0, idx = 0;
    while(h > 0){
        if(B[idx].second){
            cnt += (h + B[idx].first - 1) / B[idx].first;
            break;
        }else{
            h -= B[idx].first;
            cnt++;
        }
        idx++;
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
		System.out.println(Math.min(
				Math.min(a * x + b * y, Math.min(x, y) * c * 2 + (x - Math.min(x, y)) * a + (y - Math.min(x, y)) * b),
				Math.max(x, y) * c * 2));
	}

}

Measured memory_bytes: 27072
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void CandyDistribution() {
	int N, M;
	cin >> N >> M;
	i64 a[100005];
	i64 res = 0;
	map<i64, i64> m;
	m[0] = 0;
	for (size_t i = 0; i < N; i++)
	{
		cin >> a[i];
		a[i] += (i == 0) ? 0 : a[i - 1];
		a[i] %= M;
		if (m.count(a[i])) {
			m[a[i]]++;
			res += m[a[i]];
		}
		else {
			m[a[i]] = 0;
		}
	}

	cout << res;
}

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

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout); 
	char a;
	cin>>a;
	if(a<='Z')cout<<"A\n";
	else cout<<"a\n";
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define maxn 120000
using namespace std;
typedef long long LL;
LL a[3][maxn];
LL f[3][maxn]; 
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 1; i <= N; i += 1)
		for(int j = 0; j < 3; j += 1) cin >> a[j][i];
	for(int i = 1; i <= N; i += 1)
		for(int j = 0; j < 3; j += 1)
			for(int k = 0; k < 3; k += 1) if(j != k)
				f[j][i] = max(f[j][i], f[k][i - 1] + a[j][i]);
	cout << max(max(f[0][N], f[1][N]), f[2][N]);
} 

Measured memory_bytes: 5248
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

int ans=0;

signed main(){
    SPEED;
    int n,d;
    cin >> n >> d;
    int ans;
    ans=n/(2*d+1);
    if(n%(2*d+1)!=0)++ans;
    cout << ans << endl;
}


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

int main(){
    char s[101];
    scanf("%s",&s);
    int hug=0;
    int n=strlen(s);
    for(int i=0;i<n;++i){
        if(s[i]!=s[n-1-i])
        ++hug;
    }
    printf("%d\n",hug/2);
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define maxn 15

int gcd(int x, int y)
{
    if (x < y)
        swap(x, y);
    if (y == 0)
        return x;
    return gcd(x % y, y);
}

signed main()
{
    long double N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    A = min(min(A, B), min(min(C, D), E));

    cout << fixed << setprecision(0) << 4 + ceil(N / A) << endl;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
const int N = 3e5+10;
const double eps = 0.00000001;
const ll mod = 1e18 + 7 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
struct Edge{
    int next;
    int to;
}edge[N];
int head[N],tot;
inline void add(int from,int to){
    edge[++tot].next = head[from];
    edge[tot].to = to;
    head[from] = tot;
}
int cnt[N];
int pre[N];
int Find(int x) {return pre[x]==0?x:pre[x] = Find(pre[x]);}
int Size[N];
int ans[N];
void join(int x,int y){
    int q = Find(x),p = Find(y);
    if(q != p){
        if(Size[q] > Size[p]) pre[p] = q,Size[q] += Size[p];
        else pre[q] = p,Size[p] += Size[q];
    }
}
bool vis[N];
void dfs(int x){
    vis[x] = 1;
    for(int i = head[x];i;i = edge[i].next){
        int  y = edge[i].to;
        if(!vis[y]){
            join(x,y);
            dfs(y);
        }
    }
}
int main(){
    int n = read(),m = read(),k = read();
    fill(Size+1,Size + n +1,1);
    rep(i,1,m){
        int u = read(),v = read();
        cnt[u] ++;
        cnt[v] ++;
        add(u,v);
        add(v,u);
    }
    for(int i = 1;i <= n;++i) dfs(i);
    rep(i,1,k){
        int u = read(),v = read();
        if(Find(u) == Find(v)) cnt[u] ++,cnt[v] ++;
    }
    rep(i,1,n) cout << Size[Find(i)] - cnt[i] - 1<<' ';
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int>month={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int m1,d1,m2,d2;cin>>m1>>d1>>m2>>d2;
	cout<< (month[m1]==d1? 1:0)<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    A,B=map(int,input().split())
    if A>=13:
        print(B)
    elif A>=6:
        print(B//2)
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

ll path[100001];
ll visit[100001];

ll dfs(auto &ar,ll s){
	for(auto i:ar[s]){
		if(visit[i]==1){
			path[s]=max(path[s],path[i]+1);
			continue;
		}
		visit[i]=1;
		path[s]=max(path[s],dfs(ar,i)+1);
	}
	return path[s];	
}

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		ll n,m;
		cin>>n>>m;
		ve<list<ll> >ar(n+1);
		for(ll i=0,u,v;i<m;i++){
			cin>>u>>v;
			ar[u].pb(v);
		}
		lr(n+1){
			path[i]=-1;
		}
		ll ans=0;
		for(ll i=1;i<=n;i++){
			if(visit[i]==1)
				continue;
			visit[i]=1;
			ans=max(dfs(ar,i),ans);
		}
		cout << ans+1 << "\n";
		return 0;
	}

Measured memory_bytes: 8576