akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

struct student{
    int x;
    int y;
}ans[100005];

bool cmp(student a,student b){
    if ( a.x != b.x){
        return a.x < b.x;
    }
    return a.y<b.y;
}

int main(){
   int n,m;
   scanf("%d%d",&n,&m);
   for (int i = 0; i < m; i++){
        scanf("%d %d",&ans[i].x,&ans[i].y);
   }
   sort(ans,ans+m,cmp);
   int mi = ans[0].x;
   int mx = ans[0].y;
   int result = 0;
   for (int i = 1; i < m; i++){
        mi = max(mi,ans[i].x);
        mx = min(mx,ans[i].y);
        if (mi >= mx){
            result += 1;
            mi = ans[i].x;
            mx = ans[i].y;
        }
   }
   printf("%d\n",result+1);
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    int i;
    for(i=0;i<m;i++){
        cin >> a.at(i);
        n -= a.at(i);
    }

    if(n >= 0){
        cout << n << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3200
package main

import (
	"bytes"
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	if len(s) == 2 {
		fmt.Println(s)
	} else {
		b := &bytes.Buffer{}
		for i := len(s) - 1; i >= 0; i-- {
			b.WriteByte(s[i])
		}
		fmt.Println(b.String())
	}
}


Measured memory_bytes: 640
#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++)


double Main(int N, vector<double> &p) {
    double dp[N+1][N+1];
    REP(i, N+1) REP(j, N+1) dp[i][j] = 0;
    dp[1][1] = p[0];
    dp[1][0] = 1.0 - p[0];
    for(int i = 2; i < N+1; i++) {
        dp[i][i] = dp[i-1][i-1]*p[i-1];
        for(int j = 1; j < N+1; j++) {
            dp[i][i-j] = dp[i-1][i-j]*(1-p[i-1]) + dp[i-1][i-1-j]*p[i-1];
        }
    }
    double ans = 0.0;
    for (int i = N; i > N/2; i--) ans += dp[N][i];
    return ans;
}

int main(void) {
    int N;
    cin >> N;
    vector<double> p(N);
    REP(i, N) cin >> p[i];
    printf("%.10f", Main(N, p));
    return 0;
}

Measured memory_bytes: 70528
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MOD 1000000007
#define MAX 510000

long int FAC[MAX],FINV[MAX],INVE[MAX];
long int SUM(long int a,long int b){return (a%MOD+b%MOD+MOD)%MOD;}//a+b
long int PROD(long int a,long int b){return a%MOD*(b%MOD)%MOD;}//a*b
long int POW(long int a,long int b){//a^b
  long int c=1;
  for(a%=MOD;b;a=PROD(a,a),b>>=1)if(b&1)c=PROD(a,c);
  return c;
}
long int INV(long int a){return a<MAX?INVE[a]:POW(a,MOD-2);}//a^-1
long int QUOT(long int a,long int b){return PROD(a,INV(b));}//a/b
void init_inv(long int a){//make inv list
  INVE[1]=1;
  for(long int i=2;i<=a;i++)INVE[i]=SUM(0,-PROD(INVE[MOD%i],MOD/i));
}
void init_com(long int a){//make fac and facinv list
  FAC[0]=FAC[1]=1;
  FINV[0]=FINV[1]=1;
  init_inv(a);
  for(long int i=2;i<=a;i++){
    FAC[i]=PROD(FAC[i-1],i);
    FINV[i]=PROD(FINV[i-1],INV(i));
  }
}
long int COM(long int a,long int b){return PROD(PROD(FAC[a],FINV[a-b]),FINV[b]);}

int main(){
  long int h,w,a,b;
  scanf("%ld %ld %ld %ld",&h,&w,&a,&b);
  init_com(h+w-2);
  long int ans=0;
  for(long int i=b;i<w;i++)ans=SUM(PROD(COM(i+h-a-1,i),COM(w+a-i-2,a-1)),ans);
  printf("%ld",ans);
}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;

int main(){

	int a,b,c,d;
	cin >> a >> b >> c >> d;
	
	if(b < c || a > d){
		puts("0");
		return 0;
	}
	if((a<c && b>d) || (a>c && b<d)){
		cout << min(b-a,d-c) << endl;
		return 0;
	}

	cout << min(abs(b-c),abs(d-a)) << endl;

	return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#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(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	FOR(i,0,3){
		if(a[i] % 2 == 0){
			ANS(0);
			return 0;
		}
	}
	sort(ALL(a));
	ANS((ll)a[0] * a[1]);
	return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> L(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());

  int64_t result = 0;
  for (int64_t a = 0; a < N; ++a) {
    for (int64_t b = a + 1; b < N; ++b) {
      const int64_t end = static_cast<int64_t>(lower_bound(L.begin(), L.end(), L[a] + L[b]) - L.begin());
      const int64_t begin = b + 1;
      const int64_t c_count = (end - begin);
      result += c_count;
      // cerr << L[a] << ", " << L[b] << ", count=" << c_count << endl;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3632
z=lambda i,c:i+c*50;n,m,s=map(int,input().split());e=[[]for _ in range(4**9)];from heapq import*;t=z(0,min(2500,s));d=[9**20]*(4**9);d[t]=0;h=[[0,t]];q=[9**20]*(n-1)
for _ in range(m):
  u,v,a,b=map(int,input().split())
  for i in range(a,2501):e[z(u-1,i)].append((z(v-1,i-a),b));e[z(v-1,i)].append((z(u-1,i-a),b))
for i in range(n):
  c,r=map(int,input().split())
  for j in range(c,2501):e[z(i,j-c)].append((z(i,j),r))
while h:
  c,v=heappop(h)
  if d[v]<c:continue
  for u,t in e[v]:
    if c+t<d[u]:d[u]=c+t;heappush(h,[c+t,u])
for i in range(n-1):
  for j in range(2501):q[i]=min(q[i],d[z(i+1,j)])
print(*q)

Measured memory_bytes: 134564
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int st;
	int ed;
}a[200005];
bool cmp(node x,node y)
{
	return x.ed<y.ed;
}
int main()
{
	int n,i,t=0,ans=1,total=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	    scanf("%d%d",&a[i].st,&a[i].ed);
	sort(a+1,a+n+1,cmp);
	t=a[1].ed;
	ans=1;
	for(i=1;i<=n+1;i++)
	{
	    if(total<=t)
	    {
	    	t=a[i].ed;
		}
		else 
		{
			printf("No");
			return 0;
		}
	    total+=a[i].st;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;
/*
Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
    if (


}

Node treeSuccessor(Node x){


}
 

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
    
    while(x/*->key*/ != 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 inorder(Node u){
    if(u->left != NIL){
        inorder(u->left);
    }
        printf(" %d",u->key);
    if(u->right != NIL){
        inorder(u->right);
    }

}
void preorder(Node u){
    printf(" %d",u->key);
    if(u->left != NIL){
        preorder(u->left);
    }
    if(u->right != NIL){
        preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
   /* if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }  else */if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }/* else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }*/
  }

  return 0;
}

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

const int M=1e5+5;
const int MO=1e9+7;
inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}
 
int inv[M],fa[M],ifa[M];
void init()
{
	fa[0]=ifa[0]=1;
	inv[1]=fa[1]=ifa[1]=1;
    for(int i=2;i<M;i++)
    {
    	fa[i]=mul(fa[i-1],i);
    	inv[i]=mul(MO-MO/i,inv[MO%i]);
    	ifa[i]=mul(inv[i],ifa[i-1]);
    }
}
 
int C(int n,int m)
{
	if(n<m) return 0;
	return mul(mul(fa[n],ifa[m]),ifa[n-m]);
}

char s[M];
int dp[M][2];
int n;

int getdp(int cur,int lim)
{
	if(cur==n) return 1;
	int &ans=dp[cur][lim];
	if(ans!=-1) return ans;
	ans=0;
	int up=lim?s[cur]-'0':1;
	for(int i=0;i<=up;i++)
	{
		if(i==0) addv(ans,getdp(cur+1,lim&&i==up));
		else addv(ans,mul(2,getdp(cur+1,lim&&i==up)));
	}
	return ans;
}

int main()
{
	scanf("%s",s);
	n=strlen(s);
	init();
	memset(dp,-1,sizeof(dp));
	printf("%d\n",getdp(0,1));
	return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

int solve() {
    int n;
    cin >> n;
    int n10 = 1, n8 = 1, n9 = 1;
    rep(i, 1, n) {
        n10 = n10 * 10 % MOD;
        n8 = n8 * 8 % MOD;
        n9 = n9 * 9 % MOD;
    }
    int ans = ((n10 - 2 * n9 + n8) % MOD + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

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


Measured memory_bytes: 3644
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
for i in range(len(H)):
    H[i] = T - H[i] * 0.006
for i in range(len(H)):
    H[i] = abs(H[i] - A)
for i, j in enumerate(H):
    if j == min(H):
        print(i+1)


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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

S = input()

if S == "ABC":
    print("ARC")
else:
    print("ABC")


Measured memory_bytes: 10248
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#define __DEBUG__
#undef __DEBUG__
#define MAXN 100005

using namespace std;

int main(){
    int N;
    typedef long long ll;
    pair<ll,int> D[MAXN];//D,ソートする前のノードの番号
    pair<int,int> ans[MAXN];
    int Chi[MAXN];
    ll Dep[MAXN];//深さの和　木の根でDと一致するはず
    map<ll,int> Ds;//D,ソート後のノードの番号 配列の逆(Dから配列のindexを探しやすくするため)
    map<ll,int>::iterator it;
    cin>>N;
    for(int i = 0;i < N;i++){
        cin>>D[i].first;
        D[i].second=i+1;
        Chi[i]=1;
        Dep[i]=0;
    }
    sort(D,D+N,greater<pair<ll,int> >());
    for(int i = 0;i < N;i++){
        Ds[D[i].first]=i;
    }
#ifdef __DEBUG__
    cout<<"sorted:"<<endl;
    for(int i = 0;i < N;i++){
        cout<<D[i].first<<","<<D[i].second<<"/";
    }
    cout<<endl;
#endif
    for(int i = 0;i < N-1;i++){
        ll Dj = D[i].first+Chi[i]*2-N;
        if(it = Ds.find(Dj),it==Ds.end()){
            cout<<-1<<endl;
            return 0;
        }
        int j = it->second;
        Chi[j]+=Chi[i];
        Dep[j]+=Dep[i]+Chi[i];
        ans[i]=make_pair(D[i].second,D[j].second);
    }
#ifdef __DEBUG__
    cout<<Dep[N-1]<<endl;
#endif
    if(Chi[N-1]!=N||Dep[N-1]!=D[N-1].first){
        cout<<-1<<endl;
        return 0;
    }
    for(int i = 0;i < N-1;i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
  int H;
  int N;
  vector<int> A;

  cin >> H >> N;

  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  if (H <= accumulate(A.begin(), A.end(), 0)) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};



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

    string s;
    cin>>s;
    for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) if (s[i]!=s[j]) {cout<<"Yes"; return 0;}
    cout<<"No";

}

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

#define x first
#define y second

typedef long long LL;
typedef std::pair<int, int> pair;
const int N = 200005, mod = 1000000007;

int n, head[N], nxt[N], p2[N];

void reduce(int &x) {x += x >> 31 & mod;}
void link(int x, int y) {nxt[y] = head[x], head[x] = y;}

int idx, id[N], cnt[N], dep[N];
std::vector<pair> dp[N]; 

void dfs(int x, int d = 0) {
	int max = -1; ++cnt[d];
	for (int i = head[x]; i; i = nxt[i]) {
		dfs(i, d + 1);
		if (dep[i] >= dep[x])
			max = i, dep[x] = dep[i] + 1;
	}
	id[x] = max == -1 ? ++idx : id[max]; int sec = -1;
	static int more[N];
	for (int i = head[x]; i; i = nxt[i]) if (i != max) {
		sec = std::max(sec, dep[i]);
		for (int j = dep[x] - dep[i] - 1; j < dep[x]; ++j) {
			int a, b; std::tie(a, b) = dp[id[i]][j - (dep[x] - dep[i] - 1)];
			more[j] = ((LL) more[j] * (a + b) + (LL) b * dp[id[x]][j].y) % mod;
			dp[id[x]][j].y = ((LL) dp[id[x]][j].x * b + (LL) dp[id[x]][j].y * a) % mod;
			dp[id[x]][j].x = (LL) dp[id[x]][j].x * a % mod;
		}
	}
	for (int i = dep[x] - sec - 1; i < dep[x]; ++i)
		reduce(dp[id[x]][i].x += more[i] - mod), more[i] = 0;
	dp[id[x]].emplace_back(1, 1);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n, p2[0] = 1;
	for (int i = 1; i <= n; ++i)
		reduce(p2[i] = p2[i - 1] * 2 - mod);
	for (int i = 1, x; i <= n; ++i)
		std::cin >> x, link(x, i);
	dfs(0); int ans = 0;
	for (int i = 0; i <= dep[0]; ++i)
		ans = (ans + (LL) dp[id[0]][i].y * p2[n + 1 - cnt[dep[0] - i]]) % mod;
	std::cout << ans << '\n';
	return 0;
}

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

int main() {
    int N;
    cin>>N;
    long sum=0;
    int a[300010];
    for(int i=0;i<3*N;++i)cin>>a[i];
    sort(a,a+3*N,greater<int>());
    for(int i=0;i<N;++i){
        sum+=a[i*2+1];
    }
    cout<<sum<<endl;
}


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

int h, w, k;
vector<vector<int>> a(11, vector<int>(1001));

int recSum(int r0, int c0, int r1, int c1) {
	return a[r1][c1] - a[r1][c0] - a[r0][c1] + a[r0][c0];
}

int recMax(int bit, int l, int r) {
	int max = 0;
	int prev = 0;
	for (int i = 0; bit > 0; bit >>= 1, i++) {
		if (bit & 1) {
			if (recSum(prev, l, i + 1, r) > max)
				max = recSum(prev, l, i + 1, r);
			prev = i + 1;
		}
	}
	if (recSum(prev, l, h, r) > max)
		max = recSum(prev, l, h, r);
	return max;
}

int main() {
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			a[i + 1][j + 1] = s[j] - 48 + a[i + 1][j] + a[i][j + 1] - a[i][j];
		}
	}

	int min = h + w - 2;
	for (int bit = 0; bit < 1 << (h - 1); bit++) {
		int part = __builtin_popcount(bit);
		int prev = 0;
		for (int i = 0; i < w; i++) {
			if (recMax(bit, prev, i + 1) > k) {
				if (prev == i) {
					part = min;
					break;
				} else {
					part++;
					prev = i;
				}
			}
		}
		if (recMax(bit, prev, w) > k) {
			if (prev == w - 1) {
				part = min;
				break;
			} else {
				part++;
			}
		}

		if (part < min) {
			min = part;
		}
	}
	cout << min << endl;
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, T;
	std::vector<std::pair<int, int>> CT;
	std::cin >> N >> T;
	CT.resize(N);
	for (auto& ct : CT) {
		std::cin >> ct.first >> ct.second;
	}
	
	int cost = 9999;
	for (const auto& ct : CT) {
		if (ct.second <= T)
			cost = std::min(cost, ct.first);
	}
	if (cost == 9999) {
		std::cout << "TLE\n";
	} else {
		std::cout << cost << "\n";
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char* argv[])
{
  int N; cin >> N;

  bool ans = true;
  set<string> W;
  string prev;
  for (int i = 0; i < N; i++) {
    string w; cin >> w;
    if (W.find(w) == W.end()) {
      W.insert(w);
    } else {
      ans = false;
      break;
    }

    if (i > 0) {
      if (w[0] != prev[prev.size()-1]) {
	ans = false;
	break;
      }
    }
    prev = w;
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define y1 orzorz

typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef long double ldb;
typedef double db;

namespace IO {
#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)
#define putc(x) *nowps ++ = (x)

	const uint Buffsize = 1 << 15, Output = 1 << 23;
	static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
	static char Out[Output], *nowps = Out;

	inline void flush() {fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}
	template<class T>inline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}
	template<class T>inline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}

	template<class T>inline void read(T &_) {
		_ = 0; static char __; T ___ = 1;
		for(__ = getc(); !isdigit(__); __ = getc()) if(__ == '-') ___ = -1;
		for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
		_ *= ___;
	}

	template<class T>inline void write(T _, char __ = '\n') {
		if(!_) putc('0');
		if(_ < 0) putc('-'), _ = -_;
		static uint sta[111], tp;
		for(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;
		for(; tp; putc(sta[tp --] ^ 48)); putc(__);
	}

	inline void procStatus() {
		std::ifstream t("/proc/self/status");
		std::cerr << std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
	}
}

using namespace std;
using namespace IO;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int f[N], inv[N], a[N], n, ans;

int main() {
#ifdef ylsakioi
	file("agc028");
#endif
	
	read(n);
	inv[1] = 1;
	For(i, 2, n) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	For(i, 1, n) read(a[i]), f[i] = (f[i - 1] + inv[i]) % mod;
	For(i, 1, n) (ans += 1ll * a[i] * (f[i] - inv[1] + f[n - i + 1]) % mod) %= mod;
	//For(i, 1, n) For(j, i, n) (ans += 1ll * a[i] * inv[j - i + 1] % mod) %= mod;
	//For(i, 1, n) For(j, 1, i - 1) (ans += 1ll * a[i] * inv[i - j + 1] % mod) %= mod;
	For(i, 1, n) ans = 1ll * i * ans % mod;

	write(ans);

	return flush(), 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
 
using namespace std;

int main(int argc, char const *argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max(a, max(b, c)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char str[101];
    scanf("%s",str);
    int lengh = strlen(str);
    //printf("%d\n",lengh);
    int count  = 0;
    if(lengh % 2 == 0){
        for(int i = 0;i < lengh / 2;i++){
            if(str[i] != str[lengh - 1 - i]){
                count++;
            }
        }
    }else{
         for(int i = 0;i < (lengh + 1) / 2;i++){
            if(str[i] != str[lengh - 1 - i]){
                count++;
            }
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v[200010];
ll val[200010];
ll sol[200010];
ll N,Q;
void dfs(ll pos,ll prec,ll g){
  g+=val[pos];
  sol[pos]=g;
  for(ll i=0;i<v[pos].size();i++){
    if(v[pos][i]==prec)continue;
    dfs(v[pos][i],pos,g);
  }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		cin>>N>>Q;
		for(ll i=0;i<N-1;i++){
      ll a,b;
      cin>>a>>b;
      v[a].push_back(b);
      v[b].push_back(a);
		}
		for(ll i=0;i<Q;i++){
      ll a,b;
      cin>>a>>b;
      val[a]+=b;
		}
		dfs(1,-1,0);
		for(ll i=1;i<=N;i++)cout<<sol[i]<<" ";
		return 0;
}


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

signed main(){

  int n; cin >> n;
  if(n <= 6) cout << 1 << endl;
  else if(n <= 11) cout << 2 << endl;
  else {
    n -= 11;
    if(n%11 == 0) cout << 2 + n/11*2 << endl;
    else if(n%11 <= 6) cout << 2 + n/11*2 + 1 << endl;
    else cout << 2 + n/11*2 + 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
program main
    integer :: n, get_a, ans = 0
    integer :: a(100000) = 0
    integer :: sort_a(100000) = 0
    integer :: now_num = 0, counter = 1, ad = 1

    read *, n
    do i=1,n
        read *, a(i)
    end do

    sort_a = quick(a)
    
    do i=1,n
        if(now_num == sort_a(i)) then
            ad = ad * (-1)
        else
            now_num = sort_a(i)
            ad = 1
        end if
        ans = ans + ad
    end do

    print *, ans 


contains
    recursive function quick(a) result(r)
        integer, intent(in) :: a(:)
        integer, allocatable :: r(:)
        integer :: p
        if(size(a) < 2) then
            r = a
        else
            p = a(1)
            r = [quick(pack(a(2:), a(2:) > p)), pack(a, a == p), quick(pack(a(2:), a(2:) < p))]
        end if
    end function quick
end program main

Measured memory_bytes: 164864
n = int(input())
s = input()

n_left = 0
ans = s
for i in range(n):
  if s[i] == '(':
    n_left += 1
  elif s[i] == ')':
    if n_left == 0:
      ans = '(' + ans
    else:
      n_left -= 1
for i in range(n_left):
  ans += ')'
print(ans)

Measured memory_bytes: 3060
import sys, math
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]

m = max(a)
primes = list(range(m+1))
primes[1] = 0
for i in range(2, m+1, 2): primes[i] = 2

for i in range(3, int(m ** 0.5)+1):
    for j in range(i, m+1, i):
        if primes[j] > i: primes[j] = i

b = [0] * (m + 1)
jdg_p = True
for aa in a:
    aset = set()
    while aa != 1:
        aset.add(primes[aa])
        aa //= primes[aa]
    for aaset in aset:
        b[aaset] += 1
        if b[aaset] >= 2:
            jdg_p = False
            break
        else:
            b[aaset] += 1
    if not jdg_p: break

x = a[0]
jdg_s = True
for aa in a[1:]:
    x = math.gcd(x, aa)
if x != 1: 
    jdg_s = False

if jdg_p: print('pairwise coprime')
elif jdg_s: print('setwise coprime')
else: print('not coprime')

Measured memory_bytes: 133216
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <array>
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;


typedef long long ll;
//typedef pair<string, int> pii;
//typedef pair<ll, ll> pll;
typedef vector<int> vi;
//typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef pair <int,int> pii;
typedef pair <int,pii> pi;
#define fi first
#define se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sort(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define floop(a,n) for(int i=a; i<n; i++)
#define max3(a,b,c) max(a, max(b,c))
#define max4(a,b,c,d) max(a, max(b,max(c,d)))
#define min3(a,b,c) min(a, min(b,c))
#define min4(a,b,c,d) min(a, min(b,min(c,d)))
vector <int> v;
string int_to_string(double a){return to_string(a);}
double string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}

long double factorial(long double a){
    if(a==0)
        return 1;
    else
        return a*factorial(a-1);
    
}





int main()
{
    int a,b,n;
    cin >> a;
    
    cout << 3*a*a << endl;
    
 }
    



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();
        int[] d = IntStream.range(0,N).map(i -> scan.nextInt()).toArray();
        Arrays.sort(d);
        int ans = 1;
        for(int i= 0;i<N-1;++i){
            if(d[i+1] > d[i])++ans;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28872
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
a,b= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
if abs(a-b)>1:
    print(0)
    exit(0)
else :
    s = 1
    for i in range(1, a + 1):
        s*=i
        s%=rem
    for i in range(1, b + 1):
        s *= i
        s %= rem
    if a == b: s*=2
    s%=rem
    print(s)

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

int main() {
    int h, w;
    bool ans = true;
    cin >> h >> w;
    vector<vector<char>> b(h, vector<char>(w));
    vector<int> dx{+1, -1, 0, 0};
    vector<int> dy{0, 0, +1, -1};
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> b[i][j];
        }
    }
    rep(i, 0, h){
        rep(j, 0, w){
            if(b[i][j] == '#'){
                bool count = false; 
                rep(k, 0, 4){
                if(i+dy[k] < 0 || i+dy[k] >= h) continue;
                if(j+dx[k] < 0 || j+dx[k] >= w) continue;
                if(b[i+dy[k]][j+dx[k]] == '#') count = true;
                }
                if(!count) ans = false;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    auto v = make_vec<int>(n, n);
    rep(i, n) rep(j, n) v[i][j] = -1;
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            v[i][x] = y;
        }
    }

    int ans = 0;
    rep(bit, 1 << n) {
        bool ok = 1;
        rep(i, n) {
            if (!(bit & (1 << i))) continue;
            rep(j, n) {
                if (v[i][j] == 1 && !(bit & (1 << j))) ok = 0;
                if (v[i][j] == 0 && bit & (1 << j)) ok = 0;
            }
        }
        if (ok) chmax(ans, __builtin_popcount(bit));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
    vector<int> v1(n),v2(n);
    fri(0,n-1) cin>>v1[i];
    fri(0,n-1) cin>>v2[i];
    for(i=0;i<n;i++){
        if(v1[i]>v2[i]){
            sum[0]+=(v1[i]-v2[i]);
        }
    }
    cout<<sum[0];
	return 0;
}
//.........


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
	char c;
	c=getchar();
	if(c=='a'||c=='e'||c=='o'||c=='i'||c=='u')
	{
		cout<<"vowel\n";
	}
	else 
		cout<<"consonant\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a,b;
    cin>>a>>b;
    int ans=-10000;
    ans=max(ans,a+b);
    ans=max(ans,a-b);
    ans=max(ans,a*b);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[100000];
vector<int> G[100000], R[100000];
vector<int> vs;
bool used[100000];
int ord[100000];
int size[100000];

void dfs(int x) {
  if (used[x]) return;
  used[x] = true;
  for (int t : G[x]) dfs(t);
  vs.pb(x);
}
void rdfs(int x, int k) {
  if (used[x]) return;
  used[x] = true;
  ord[x] = k;
  for (int t : R[x]) rdfs(t, k);
}

int scc() {
  rep(i, N) used[i] = false;
  rep(i, N) dfs(i);
  rep(i, N) used[i] = false;
  int k = 0;
  for (int i=vs.size()-1; i>=0; i--) {
    if (!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) {
    int a;
    cin >> a;
    A[i] = (i+a) % N;
  }
  int c = 0;
  rep(i, N) if (A[i] == i) c++;
  rep(i, N) {
    G[i].pb(A[i]);
    R[A[i]].pb(i);
  }
  scc();
  rep(i, N) size[ord[i]]++;
  rep(i, N) {
    if (size[ord[i]] >= 2) c++;
  }
  cout << c << "\n";
  return 0;
}

Measured memory_bytes: 19816
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;
ll dp[105][100005];

int main()
{
    ll n,W;
    cin >> n >> W;
    vector<ll> v(n);
    vector<ll> w(n);
    rep(i,n){
        cin >> v[i] >> w[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }
            else{
                dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
} 


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

int main()
{
    int N,Y,i,j,c=0;
    long long int sum=0;

    scanf("%d %d",&N,&Y);

    int a[N+5],b[N+5];

    for(i=0; i<N; i++)
    {
        scanf("%d %d",&a[i],&b[i]);
    }

    sort(a,a+N);
    sort(b,b+N);

    int k=N-1;

    for(j=k; j>=0; j--)
    {
        if(a[k]<=b[j])
        {
            sum+=b[j];
            c++;
            if(sum>=Y)
            {
                printf("%d\n",c);
                return 0;
            }
        }
        else
        {
            break;
        }
    }
    int m=N-1;

    for( ; ; )
    {
        sum+=a[m];
        c++;
        if(sum>=Y)
            break;
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 1024
use std::io::Read;
use std::io::*;
use std::str::FromStr;
     
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
    
fn main() {
    let buf: String = read();
    let mut iter = buf.split_whitespace();
    let mut n = iter.next().unwrap().parse::<i32>().unwrap();
    let p: Vec<i32> = (0..n).map(|_| read()).collect();
    let mut ans = 0;
    let mut cur_min = std::i32::MAX;
    for x in p {
        cur_min = std::cmp::min(cur_min, x);
        if x == cur_min {
            ans += 1;
        }
    }
    println!("{}", ans)
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
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 /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}








int main (){
  int k,s;
  cin >> k >> s;
  int cnt = 0;
  rep (i,k+1) {
    rep (j,k+1){
      int z = s - i - j;
      if (z >= 0 && z <= k){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3564
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int yono = 0;
        if(s / 100 < 13 && s / 100 > 0){
            yono++;
        }
        if(s % 100 < 13 && s % 100 > 0){
            yono += 2;
        }
        if(yono == 0){
            System.out.println("NA");
        }else if(yono == 1){
            System.out.println("MMYY");
        }else if(yono == 2){
            System.out.println("YYMM");
        }else{
            System.out.println("AMBIGUOUS");
        }
        sc.close();
    }
}

Measured memory_bytes: 35776
#include <stdio.h>

int main(void){
    int n = 0, m = 0;
    int a = 0, b = 0;
    int ans[51];

    scanf("%d%d", &n, &m);
    for(int i = 1; i<= n; i++){
        ans[i] = 0;
    }
    for(int i = 0; i < m; i++){
        scanf("%d%d", &a, &b);
        ans[a]++;
        ans[b]++;
    }

    for(int i = 1; i<= n; i++){
        printf("%d\n", ans[i]);
    }    

    return 0;

} 


Measured memory_bytes: 128
def c():
    n = int(input())
    a = list(map(int, input().split()))
    x = []
    def set_col(rate):
        if rate <= 399:
            return '灰色'
        elif rate <= 799:
            return '茶色'
        elif rate <= 1199:
            return '緑色'
        elif rate <= 1599:
            return '水色'
        elif rate <= 1999:
            return '青色'
        elif rate <= 2399:
            return '黄色'
        elif rate <= 2799:
            return '橙色'
        elif rate <= 3199:
            return '赤色'
        else:
            x.append(1)
            return

    res = set(map(set_col, a))
    if None in res: res.remove(None)
    mi = max(1, len(res))
    ma = len(res) + len(x)
    print(mi, ma)

c()


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

int main() {
    int n;
    cin>>n;
    vector<int> dp(n);
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    dp[n-1]=0;
    dp[n-2]=abs(h[n-1]-h[n-2]);
    for(int i=n-1;i>=2;i--){
        dp[i-2] = min(dp[i-1] + abs(h[i-1]-h[i-2]), dp[i] + abs(h[i]-h[i-2]));
    }
    cout << dp[0] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> s(H);
  for(int i=0;i<H;++i) cin >> s[i];
  int dp[110][110];
  dp[0][0]=0;
  if(s[0][0]=='#') dp[0][0]++;
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(i > 0 || j > 0){
        dp[i][j] = 1e9;
        if(i>0) dp[i][j] = min(dp[i][j],dp[i-1][j] + ((s[i][j]=='#') && (s[i-1][j]=='.')));
        if(j>0) dp[i][j] = min(dp[i][j],dp[i][j-1] + ((s[i][j]=='#') && (s[i][j-1]=='.')));
      }
    }
  }
  
  cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll g[5005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n >> k;
	for(i=1;i<=k;i++)
	{
		cin >> x;
		for(j=1;j<=x;j++)
		{
			cin >> m;
			g[m]=1;
		}
	}
	x=0;
	for(i=1;i<=n;i++)
		if(!g[i])x++;
	cout<<x<<endl;
}

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

template <class T>
class Point{
public:
    int id;
    T x, y;
    Point(){}
    Point(int _id, int _x, int _y) : id(_id), x(_x), y(_y){}
    bool operator < (const Point &p) const{
        return id < p.id;
    }
};

template <class U>
class TwoDimTree{
    struct node{int location, l, r;};
private:
    int n, idx = 0, NIL = -1;
    vector<Point<U>> &P;
    vector<node> tdt;
    function<bool(Point<U>, Point<U>)> cmp_odd = [](Point<U> p1, Point<U> p2){
        if(p1.x==p2.x) return p1.y < p2.y;
        else return p1.x < p2.x;
    };
    function<bool(Point<U>, Point<U>)> cmp_even = [](Point<U> p1, Point<U> p2){
        if(p1.y==p2.y) return p1.x < p2.x;
        else return p1.y < p2.y;
    };

    int make2DTree(int l, int r, int depth){
        if(r<=l) return -1;
        int mid = (l+r) / 2;
        int t = idx++;
        if(depth%2){
            sort(P.begin()+l, P.begin()+r, cmp_even);
        } else {
            sort(P.begin()+l, P.begin()+r, cmp_odd);
        }
        tdt[t] = {mid, NIL, NIL};
        tdt[t].l = make2DTree(l, mid, depth+1);
        tdt[t].r = make2DTree(mid+1, r, depth+1);
        return t;
    }

    // [sx, tx], [sy, ty]
    void find(int v, U sx, U tx, U sy, U ty, int depth, vector<Point<U>> &res){
        U x = P[tdt[v].location].x, y = P[tdt[v].location].y;
        if(sx<=x and x<=tx and sy<=y and y<=ty) res.push_back(P[tdt[v].location]);

        if(depth%2){
            if(tdt[v].l!=NIL and sy<=y){
                find(tdt[v].l, sx, tx, sy, ty, depth+1, res);
            }
            if(tdt[v].r!=NIL and y<=ty){
                find(tdt[v].r, sx, tx, sy, ty, depth+1, res);
            }
        } else {
            if(tdt[v].l!=NIL and sx<=x){
                find(tdt[v].l, sx, tx, sy, ty, depth+1, res);
            }
            if(tdt[v].r!=NIL and x<=tx){
                find(tdt[v].r, sx, tx, sy, ty, depth+1, res);
            }
        }
    }

public:
    TwoDimTree(size_t _n, vector<Point<U>> &_P) : n(_n), P(_P){
        tdt = vector<node>(n);
        make2DTree(0, n, 0);
    }

    void _find(U sx, U tx, U sy, U ty, vector<Point<U>> &res){
        find(0, sx, tx, sy, ty, 0, res);
    }
};

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N;
    cin>>N;
    vector<Point<int>> P(N);
    for(int i=0;i<N;i++){
        P[i].id = i;
        cin>>P[i].x>>P[i].y;
    }
    TwoDimTree<int> tdt(N, P);
    int Q, sx, tx, sy, ty;
    cin>>Q;
    for(int i=0;i<Q;i++){
        cin>>sx>>tx>>sy>>ty;
        vector<Point<int>> res;
        tdt._find(sx, tx, sy, ty, res);
        sort(res.begin(), res.end());
        for(auto u : res) printf("%d\n", u.id);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 14152