akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct SCC{
	vector<vector<int> > G;
	vector<vector<int> > rG;
	vector<int> vs;
	vector<bool> used;
	vector<int> cmp;
	int sz,newsz;
	SCC(int n):G(n),rG(n),used(n,false),cmp(n){sz = n;}
	
	//辺を張る
	void add_edge(int from,int to){
		G[from].PB(to);
		rG[to].PB(from);
	}
	
	void dfs(int v){
		used[v] = true;
		REP(i,G[v].size()){
			if(!used[G[v][i]])dfs(G[v][i]);
		}
		vs.PB(v);
	}
	
	void rdfs(int v,int k){
		used[v] = false;
		cmp[v] = k;
		REP(i,rG[v].size()){
			if(used[rG[v][i]])rdfs(rG[v][i],k);
		}
	}
	
	//ＳＣＣ実行
	int reMake(){
		vs.clear();
		REP(i,sz)if(!used[i])dfs(i);
		int k = 0;
		for(int i = sz-1;i >= 0;i--){
			if(used[vs[i]]){
				rdfs(vs[i],k++);
			}
		}
		return newsz = k;
	}
	
	void makeList(vector<vector<int> > &v){
		REP(i,sz){
			REP(j,G[i].size()){
				if(cmp[i] == cmp[G[i][j]])continue;
				v[cmp[i]].PB(cmp[G[i][j]]);
			}
		}
	}

	void makeReverseList(vector<vector<int> > &v){
		REP(i,sz){
			REP(j,G[i].size()){
				if(cmp[i] == cmp[G[i][j]])continue;
				v[cmp[G[i][j]]].PB(cmp[i]);
			}
		}
	}
	
	int scc_node(int n){
		return cmp[n];
	}
};


int main(){
	int n,m;cin >> n >> m;
	
	SCC scc(n);
	
	REP(i,m){
		int a,b;cin >> a >> b;
		scc.add_edge(a,b);
	}
	
	scc.reMake();
	
	int q;cin >> q;
	
	REP(i,q){
		int a,b;cin >> a >> b;
		if(scc.scc_node(a) == scc.scc_node(b)){
			cout << 1 << endl;
		}
		else{
			cout << 0 << endl;
		}
	}
			
	return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define N 100009
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;
int dp[N][3],dp1[N][3];

int main(){
    int i,j,n,m,t,k,x,y;
    sd(n);
    for(i=1; i<=n; i++){
        sd3(dp[i][0],dp[i][1],dp[i][2]);
    }
    int ans=0;
    for(i=1; i<=n; i++){
        for(j=0; j<3; j++){
            for(k=0; k<3; k++){
                if(j!=k){
                    dp1[i][j]=max(dp1[i][j],dp1[i-1][k]+dp[i][j]);
                }
            }
            ans= max(ans,dp1[i][j]);
        }
    }
    tr(ans);
}

Measured memory_bytes: 2560
n,k = (int(i) for i in input().split())
X = [int(i) for i in input().split()]

ans = float('inf')
for i in range(n-k+1):
    l,r = i,i+k-1
    tmp = min(abs(X[l])+abs(X[l]-X[r]),abs(X[r])+abs(X[l]-X[r]))
    ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 14252
#include<stdio.h>

int main(){
   int array[5];
   for(int i = 0;i<5;i++){
      scanf("%d",&array[i]);
   }
   for(int i = 0;i<5;i++){
   if(array[i] == 0){
         printf("%d\n",i+1);
   }
  }
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,t;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>t;
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        if(a[i]+t>=a[i+1])ans+=a[i+1]-a[i];
        else ans+=t;
    }
    Cout(ans+t);
    return 0;
}


Measured memory_bytes: 1792
/* 北さん参考 */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> s_cnt(26, 0), t_cnt(26, 0);

    /* それぞれの文字が何個ずつ出てくるか見る */
    REP(i, s.length()) s_cnt[s[i] - 'a']++;
    REP(i, t.length()) t_cnt[t[i] - 'a']++;

    sort(s_cnt.begin(), s_cnt.end());
    sort(t_cnt.begin(), t_cnt.end());

    bool ans = true;
    REP(i, 26) if(s_cnt[i] != t_cnt[i]) ans = false;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 776
H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
Q = int(input())
qs = [tuple(map(int,input().split())) for i in range(Q)]

places = [None] * (H*W+1)
for i in range(H):
    for j in range(W):
        places[A[i][j]] = (j,i)

costs = [[] for i in range(D)]
for i in range(H*W+1):
    if i <= D:
        costs[i%D].append(0)
    else:
        x1,y1 = places[i-D]
        x2,y2 = places[i]
        c = abs(x1-x2) + abs(y1-y2)
        costs[i%D].append(costs[i%D][-1] + c)

ans = []
for l,r in qs:
    m = l%D
    a = costs[m][r//D] - costs[m][l//D]
    ans.append(a)
print(*ans, sep='\n')

Measured memory_bytes: 40812
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] hand = new int[n];
			int pool = 0;
			String card = sc.next();
			for(int i=0;i<100;i++) {
				int turn = i % n;
				switch (card.charAt(i)) {
				case 'M':
					hand[turn]++;
					break;
				case 'S':
					pool += hand[turn] + 1;
					hand[turn] = 0;
					break;
				case 'L':
					hand[turn] += pool + 1;
					pool = 0;
					break;
				}
			}
			Arrays.sort(hand);
			StringBuilder sb = new StringBuilder();
			for(int i=0;i<n;i++) {
				if (i > 0) {
					sb.append(" ");
				}
				sb.append(hand[i]);
			}
			sb.append(" " + pool);
			System.out.println(sb.toString());
		}
	}

}

Measured memory_bytes: 21352
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        char[][] c = new char[h][w];
        int cnt = 0;
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                if (s.charAt(j) == '#') {
                    cnt++;
                }
                c[i][j] = s.charAt(j);
            }
        }
        int ans = 0;
        for (int i = 0; i < (1 << h); i++) {
            for (int j = 0; j < (1 << w); j++) {
                int tempCnt = 0;
                for (int l = 0; l < h; l++) {
                    if ((i >> l & 1) == 1) {
                        continue;
                    }
                    for (int m = 0; m < w; m++) {
                        if ((j >> m & 1) == 1) {
                            continue;
                        }
                        if (c[l][m] == '#') {
                            tempCnt++;
                        }
                    }
                }
                if (tempCnt == k) {
                    ans++;
                }
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 35940
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define true 1
#define false 0
  int *A;
  int n;

int solve(int i, int m){
  int res;
   if(m==0)return true;
   if(i>=n)return false;

   res = solve(i + 1, m) || solve(i + 1, m - A[i]);
   return res;
 }
int main(){
  int i, j;
  int y,m,c;

  scanf("%d",&n);
  A=(int*)malloc(sizeof(int)*n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&y);

  for(i=0 ; i<y ;i++){
    scanf("%d",&m);
    c=solve(0,m);
    if(c==true)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2108
/*
      author : nishi5451
      created: 11.08.2020 21:10:34
*/

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


int main(){
    int d;
    cin >> d;
    d = 25 - d;
    cout << "Christmas";
    while(d--){
        cout << " Eve";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

struct City{
    int p, y, i;
    string n;

    
};

bool comp1(const City& a, const City& another) {
    if (a.p != another.p)
      return a.p < another.p;
    return a.y < another.y; 
}

bool comp2(const City& a, const City& b) {
   return a.i < b.i;
}

string pad(int num_){
    int num = num_;
    int n = 1;
    while(1){
        if(num < 10)break;
        num = num/10;
        n++;
    }
    n = 6-n;
    string res = to_string(num_);
    rep(i, n){
        res = "0"+res;
    }
    return res;
}

string f(int p, int ci){
    return pad(p)+pad(ci);
}

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<City> PYI(M);
    rep(i, M){
        int p, y;
        cin >> p >> y;
        PYI[i] = {p, y, i};
    }

    sort(all(PYI), comp1);
    int pi = -1;
    int ci = 1;
    rep(i, M){
        auto& c = PYI[i];
        //debug(c.p)debug(c.y)
        if(pi != c.p){
            pi = c.p;
            ci=1;
        }
        c.n = f(c.p, ci);
        //debug(c.n)
        ci++;
    }

    sort(all(PYI), comp2);
    rep(i, M){
        cout << PYI[i].n << "\n";
    }
    return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll a, b;
  cin >> a >> b;
  if (a <= b)
  {
    rep(i,b){
      cout << a;
    }
  }
  else{
    rep(i,a){
      cout << b;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

struct tree{
	int lr[2];
	int sib;
	int degree;
	int parent;
	int depth;
	int height;
};

void d_solve(vector<struct tree> &node, int x){
	for(int i=0;i<2;i++){
		if(node[x].lr[i] != -1){
			node[node[x].lr[i]].depth += node[x].depth + 1;
			d_solve(node, node[x].lr[i]);
		}
	}
}

void h_solve(vector<struct tree> &node, int x){
	for(int i=0;i<2;i++)
		if(node[x].lr[i] != -1)
			h_solve(node, node[x].lr[i]);
	
	if(node[x].degree == 0)
		node[x].height = 0;
	else if(node[x].degree == 2)
		node[x].height = max(node[node[x].lr[0]].height, node[node[x].lr[1]].height) + 1;
	else if(node[x].lr[0] == -1)
		node[x].height = node[node[x].lr[1]].height + 1;
	else if(node[x].lr[1] == -1)
		node[x].height = node[node[x].lr[0]].height + 1;
}

void PrintNode(vector<struct tree> node, int n){
	for(int i=0;i<n;i++){
		cout<<"node "<<i<<": parent = "<<node[i].parent<<", sibling = "<<node[i].sib<<", degree = "<<node[i].degree<<", depth = "<<node[i].depth<<", height = "<<node[i].height<<", ";
		
		if(node[i].parent == -1)
			cout<<"root";
		else if(node[i].degree == 0)
			cout<<"leaf";
		else
			cout<<"internal node";
		cout<<endl;
	}
}

int main(){
	int n, id, d[2], x;
	vector<struct tree> node(25);
	
	cin>>n;
	for(int i=0;i<n;i++){
		node[i].parent = -1;
		node[i].sib = -1;
		node[i].depth = 0;
		node[i].degree = 0;
	}

	for(int i=0;i<n;i++){
		cin>>id>>d[0]>>d[1];
		for(int j=0;j<2;j++){
			node[id].lr[j] = d[j];
			if(d[j] != -1){
				node[d[j]].parent = id;
				node[id].degree++;
				if(j == 0)
					node[d[0]].sib = d[1];
				else
					node[d[1]].sib = d[0];
			}
		}
	}

	for(int i=0;i<n;i++)
		if(node[i].parent == -1)
			x = i;

	d_solve(node, x);
	h_solve(node, x);
	PrintNode(node, n);
	return 0;
}

Measured memory_bytes: 1220
n,m = map(int,input().split())
li = []

for _ in range(n):
    lik = list(map(int,input().split()))
    del lik[0]
    lik.sort()
    li.append(lik)

count = 0
for i in range(1,m+1):
    flag = True
    for j in range(n):
        if i in li[j]:
            pass
        else:
            flag = False
    if flag:
        count += 1

print(count)


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();

    ll a, b;
    cin >> a >> b;
    string ans;
    if (in(0, a, b + 1)) ans = "Zero";
    else if (a > 0) ans = "Positive";
    else {
        if ((b - a + 1) % 2 == 0) ans = "Positive";
        else ans = "Negative";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
string getst(string& s){
	string t;
	int i;
	for(i=1;i<s.size();i++){
		if(s[i]=='/') break;
		t+=s[i];
	}
	s=s.substr(i);
	return t;
}
typedef vector<string> Vst;
typedef vector<int> Vi;
vector<Vi> G;
Vst names;
Vi par;
int main(){
	while(true){
		int N,M;
		cin>>N>>M;
		if(N==0) break;
		//init
		G.clear();
		names.clear();
		par.clear();
		G.pb(Vi());
		names.pb("*");
		par.pb(-1);
		
		rep(i,N){
			string s;
			cin>>s;
			int now=0;
			while(s.size()){
				string t=getst(s);
				if(s.size()==0){
					int nxt=names.size();
					names.pb(t);
					G.pb(Vi());
					G[now].pb(nxt);
					par.pb(now);
				}else{
					int nxt=-1;
					for(int v:G[now]){
						if(names[v]==t) nxt=v;
					}
					if(nxt<0){
						nxt=names.size();
						names.pb(t);
						G.pb(Vi());
						G[now].pb(nxt);
						par.pb(now);
					}
					now=nxt;
				}
			}
		}
		int I=names.size();
//		rep(i,I) cout<<i<<"   "<<names[i]<<"   "<<par[i]<<endl;
		rep(tt,M){
			int x[2]={-1,-1};
			rep(i,2){
				string s;
				cin>>s;
				int now=0;
				bool used=0,lastdot=0;
				while(s.size()){
					string t=getst(s);
					// show(t);
					// show(now);
					// show(s.size());
					if(t==".") continue;			//!!!!!
					if(t==".."){
						if(now==0||G[now].empty()){
							now=-1;
							break;
						}
						now=par[now];
//						if(s.empty()) lastdot=1;
						continue;
					}
					if(t.empty()){			// /end
						t="index.html";
						used=1;
					}
					int nxt=-1;
					for(int v:G[now]) if(names[v]==t) nxt=v;
//					show(nxt);
					if(nxt<0){
						now=-1;
						break;
					}
					now=nxt;
				}
				x[i]=now;
				if(x[i]>=0){
					if(!G[x[i]].empty()&&!used&&!lastdot){		//is directory
						int v=x[i];
						for(int u:G[v]) if(names[u]=="index.html"&&G[u].empty()) x[i]=u;
					}
					if(!G[x[i]].empty()) x[i]=-1;
				}
			}
			if(x[0]<0||x[1]<0) puts("not found");
			else if(x[0]==x[1]) puts("yes");
			else puts("no");
		}
	}
}

Measured memory_bytes: 1232
// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 2e5 + 10;
ll a[MAXN];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	ll sum = 0;
	for(int i = 0; i < n; i ++) cin >> a[i], sum += a[i];
	ll ps = 0, ans = 1e18;
	for(int i = 0; i < n - 1; i ++)	{
		ps += a[i];
		ans = min(ans, abs(ps - (sum - ps)));
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int x,y,f=0,i;
	cin>>x>>y;
	for(i=0;i<=x;i++)
	{
		ll int s=0;
		s+=i*4;
		s+=(x-i)*2;
		if (s==y)
		{
			f=1;
			break;
			
		}
	}
	if (f==0)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
}
    
	
		

	
			

		


 







Measured memory_bytes: 3628
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vvi vector<vector<int>>
#define inf 10000000
using namespace std;
#define int ll
signed main() {
	int N; cin >> N;
	string s; cin >> s;
	int left_blacket = 0, right_blacket = 0;
	for (int i = 0; i < N; i++) {
		string c = s.substr(i, 1);
		if (c == ")") {
			if (right_blacket > 0) {
				right_blacket--;
			}
			else {
				left_blacket++;
			}
		}
		else {
			right_blacket++;
		}
	}
	for (int t = 0; t < right_blacket; t++) {
		s += ")";
	}
	reverse(ALL(s));
	for (int t = 0; t < left_blacket; t++) {
		s += "(";
	}
	reverse(ALL(s));
	cout << s << endl;
}

/*


		*/

Measured memory_bytes: 3616
ptrn = [[0, 1, 2], [0, 2, 4], [0, 4, 3], [0, 3, 1],
        [1, 5, 2], [1, 2, 0], [1, 0, 3], [1, 3, 5],
        [2, 1, 5], [2, 5, 4], [2, 4, 0], [2, 0, 1]];
function dice(num) {
  this.n = num;  // array
  this.check = function(top, front) {
    top = this.n.indexOf(top);
    front = this.n.indexOf(front);
    var flag = true;
    if(top > 2) {
      top = 5 - top;
      flag = false;
    }
    for(let i = 4 * top; i < 12; i++) {
      if(flag && ptrn[i][1] === front) {
        console.log(this.n[ptrn[i][2]]);
        break;
      }else if(!flag && ptrn[i][2] === front) {
        console.log(this.n[ptrn[i][1]]);
        break;
      }
    }
  }
}
function Main(input) {
  input = input.split("\n");
  var dice_a = new dice(input[0].split(" "));
  input.slice(2, 2+Number(input[1])).forEach(function(d){
    t = d.split(" ");
    dice_a.check(t[0], t[1]);
  });
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;

  REP(i,s.length()){
    char c = s[i];
    if(i%2==0){
      if(c=='R' || c=='U' ||c=='D') continue;
      else {
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      if(c=='L' || c=='U' ||c=='D') continue;
      else {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  
  //cout << fixed << setprecision(10);
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
    int n, c1, c2;
    cin >> n;
    int dp[n + 1], h[n + 1];
    For(i, n) {
        cin >> h[i];
        dp[i] = 0;
    }
    dp[2] = abs(h[2] - h[1]);
    For(i, n - 2) {
        c1 = abs(h[i + 2] - h[i + 1]) + dp[i + 1];
        c2 = abs(h[i + 2] - h[i]) + dp[i];
        dp[i + 2] = (c1 > c2 ? c2 : c1);
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	switch (op) {
		case '+':
			printf("%d\n", a+b);
			break;
		case '-':
			printf("%d\n", a-b);
			break;
	}
	return 0;
}


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

int main(){
	ll n,a[110],l=0,r=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		l+=a[i];
	}
	ll ans=l-r;
	for(int i=0;i<n;i++){
		l-=a[i];
		r+=a[i];
		ans=min(ans,abs(l-r));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;
	int a[n];
	forr(i, n) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	int ok[n] = {0};
	int ans  = 0 ;
	ok[0] = 1;
	int idx = 0 ;
	for (int i = 1; i < n; i++) {
		if (ok[idx] == 2)idx++;
		ok[idx]++;
		ans += a[idx];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 6724
#include <cstdio>
char S[1025];
char ch[10][6]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int size[10]={1,5,3,3,3,3,3,4,3,4};
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%s",S);
		int idx=0;
		while(S[idx]!='\0') {
			int nxt=idx;
			int len=0;
			while(S[nxt]==S[idx]) {
				nxt++;
				len++;
			}
			if(S[idx]>'0') {
				len--;
				len%=size[S[idx]-'0'];
				putchar(ch[S[idx]-'0'][len]);
			}
			idx=nxt;
		}
		putchar('\n');
	}
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int a[105] = {};
    for (int n = 1; n <= N; n++)
    {
        cin >> a[n];
    }

    bool dp[100005] = {};

    for (int i = 0; i <= K; i++)
    {
        for (int n = 1; n <= N; n++)
        {
            if (i - a[n] >= 0)
            {
                dp[i] |= ! dp[i - a[n]];
            }
        }
    }

    /*
    for (int i = 0; i <= K; i++)
    {
        cout << dp[i] << " ";
    }
    cout << endl;
    */

    if (dp[K] == true) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 384
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-14 15:33
# @url:https://atcoder.jp/contests/abc045/tasks/arc061_a
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    s=str(input())
    d=[int(x) for x in s[::-1]]
    cnt=[2**(len(s)-1)]
    ans=0
    for i in range(len(d)):
        if i!=0:
            cnt[-1]=cnt[-1]//2
            cnt.append(cnt[-1])
        for j in range(len(cnt)):
            ans+=d[i]*(10**j)*(cnt[j])
    print (ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 76316
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AllSearch
{
    class AtTemplate
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string input = Console.ReadLine();
            int[] numbers = new int[input.Length];
            for(int i = 0;i< input.Length; i++)
            {
                numbers[i] = input[i] - '0';
            }
            int n = (int)Math.Pow(2, input.Length - 1);
            long allSum = 0;
            for (int i = 0; i < n; i++)
            {
                long sum = numbers[input.Length - 1];//うしろから
                long rate = 10;//型に注意！

                for (int j = 0; j < input.Length-1; j++)
                {
                    if ((1 & i >> j) == 1)//+あり
                    {
                        sum += numbers[input.Length - 2 - j];
                        rate = 10;
                    }
                    else
                    {
                        sum += numbers[input.Length - 2 - j] * rate;
                        rate *= 10;
                    }
                }
                allSum += sum;
            }
            Console.WriteLine(allSum);
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
       int a = sc.nextInt();
       int b = sc.nextInt();
 
       if(b % a == 0)   System.out.println(a+b);
       else System.out.println(b-a);
        
    }
}

Measured memory_bytes: 24020
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
list($A,$B) = explode(" ",trim(fgets(STDIN)));
$S = trim(fgets(STDIN));
$pat = sprintf("/^\d{%d}\-\d{%d}$/",$A,$B);
if (preg_match($pat,$S)) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 3828
import sys
m,d = input().split()
if m in ('1','3','5','7','8','10','12'):
  if d == '31':
    print('1')
  else:
    print('0')
elif m == '2':
  if d == '28':
    print('1')
  else:
    print('0')
else:
  if d == '30':
    print('1')
  else:
    print('0')


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

int main() {
  int h=0, w=0;
  cin >> h >> w;
  
  char a;
  
  vector<vector<char>> vec(h, vector<char>(w));
  vector<vector<char>> vecre(w, vector<char>(h));
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cin >> a;
      vec.at(i).at(j) = a;
      vecre.at(j).at(i) = a;
    }
  }
  
  vector<bool> bvec(h, true);
  vector<bool> bvecre(w, true);
  vector<char> vecch(w, '.');
  vector<char> vecchre(h, '.');
  
  for (int i=0; i<h; i++) {
    if (vecch == vec.at(i)) bvec.at(i) = false;
  }
  
  for (int i=0; i<w; i++) {
    if (vecchre == vecre.at(i)) bvecre.at(i) = false;
  }
  
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (bvec.at(i)) {
        if (bvecre.at(j)) {
          cout << vec.at(i).at(j);
        }
        if (j == w-1) cout << endl;
        else cout << "";
      } else {
        break;
      }
    }
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;

void solve(void){
    int N, M;
    cin >> N >> M;
    vector <int> cnt(N, 1);
    vector <bool> red(N, false);
    red[0] = true;
    rep(M, i) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cnt[x]--, cnt[y]++;
        if (red[x]) red[y] = true;
        if (!cnt[x]) red[x] = false;
    }
    int ans = 0;
    rep(N, i) if (red[i]) ans++;

    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int64 long long

vector<vector<int64>> dp;
vector<vector<bool>> vis;

int64 solve(vector<int64> &vec, int l, int r){
    if (vis[l][r])
        return dp[l][r];
    if (l==r)
        return dp[l][r] = vec[l];

    vis[l][r] = true;
    int64 a = vec[l] - solve(vec, l+1, r);
    int64 b = vec[r] - solve(vec, l, r-1);

    return dp[l][r] = max(a, b);
}

signed main() {
    //freopen("input1.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<int64> vec(n);

    for (int i=0; i<n; i++)
        cin >> vec[i];
    

    dp.resize(n, vector<int64>(n, 0));
    vis.resize(n, vector<bool>(n, false));

    cout << solve(vec, 0, n-1);

    return 0;
}

Measured memory_bytes: 75236
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, m;
   cin >> n >> m;
   int s[m], c[m];
   for(int i = 0;i < m;i++) {
      cin >> s[i];
      cin >> c[i];
   }

   string str;
   for(int i = 0;i < n;i++) {
      str+='a';
   }
   for(int i = 0;i < m;i++) {
      if((str[s[i]-1]!=c[i]+'0')&&(str[s[i]-1]!='a')) {
         cout << -1 << endl;
         return 0;
      }
      if(s[i]==1&&c[i]+'0'=='0'&&!(n==1)) {
         cout << -1 << endl;
         return 0;
      }
      str[s[i]-1] = c[i] + '0';
   }

   for(int i = 0;i < n;i++) {
      if(str[i]=='a'&&i==0&&!(n==1)) str[i]='1';
      if(str[i]=='a') str[i]='0';
   }
   cout << str << endl;
}

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

long long calc(string s)
{
    int len = s.size();
    long long ans = stoll(s);
    
    rep(i,1,len)
    {
        string left = s.substr(0,i);
        string right = s.substr(i,len-1);
        ans += stoll(left) * pow(2,right.size()-1);
        ans += calc(right);
    }
    return ans;
}

int main()
{
    string s;
    cin >> s;
    cout << calc(s) << endl;
}

Measured memory_bytes: 4088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

func min(lhs, rhs int64) int64 {
	if lhs < rhs {
		return lhs
	}
	return rhs
}

func main() {
	sc.Split(bufio.ScanWords)
	s := readLine()

	var ans int64

	// count 0
	var cnt0 [2]int64
	var cnt1 [2]int64
	for i := 0; i < len(s); i++ {
		if s[i] == '0' {
			cnt0[i%2]++
		} else {
			cnt1[i%2]++
		}
	}
	// 01010...
	ans0 := cnt0[1] + cnt1[0]
	// 10101...
	ans1 := cnt0[0] + cnt1[1]
	ans = min(ans0, ans1)
	fmt.Println(ans)
}


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

int main(){
    long long k, a, b;
    cin >> k >> a >> b;
    long long ans = 0;
    if(-a + b <= 2){
        ans = 1 + k;
    }else{
        ans = a +  (-a+b) * ((k-(a-1))/2) + (k-(a-1))%2;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s;
    getline(cin,s);
    rep(i,s.size()){
        if(isupper(s[i])) s[i]=tolower(s[i]);
        else if(islower(s[i]))s[i]=toupper(s[i]);
    }
    cout<<s;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	int x; cin >> n >> x;
	vi vs;
	REP(i, n) {
		int m; cin >> m;
		vs.pb(m);
		x -= m;
	}
	// cout << vs;
	// cout << x;
	int mn = 1000;
	for (auto v:vs) {
		mn = min(mn, v);
	}
	n += x / mn;
	cout << n << endl;

}



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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    for (auto &i : A) {
        cin >> i;
    }
    int sum = accumulate(A.begin(), A.end(), 0);
    int cnt = 0;
    for (auto &i : A) {
        if (i*4*m >= sum) {
            cnt++;
        }
    }
    cout << (cnt>=m?"Yes":"No") << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
static int[]check;//1=checked,0=yet,2=checking
static int[][]graph;
    static int[]dis;//-1=cannot arrive
static int n;
final static int MAX=100;
	public static void main(String[] args) {
		int i,j,s,pn,num;
		// TODO Auto-generated method stub
		Scanner sca = new Scanner(System.in);
		n=sca.nextInt();
		check=new int[MAX+1];
		dis=new int[MAX+1];
		graph=new int[MAX+1][MAX+1];
		for(i=1;i<=n;i++){
			num=sca.nextInt();
			pn=sca.nextInt();
			for(j=0;j<pn;j++){
				s=sca.nextInt();
				graph[num][s]=1;
			}
		}
		breadthexpl(1);
	}
	public static void breadthexpl(int now){
	    int i,j,hz;
	    Queue<Integer> que= new ArrayDeque<>();
	    que.offer(now);
	    while(que.peek()!=null){
		hz=que.poll();
		for(j=1;j<=n;j++){
		    if(graph[hz][j]!=0&&check[j]==0){
			check[j]=2;
			dis[j]=dis[hz]+1;
     		      if(dis[hz]==-1&&dis[j]!=-1)dis[hz]++;
			que.offer(j);
		    }
		    check[hz]=1;
		}
	    }
	    for(i=1;i<=n;i++){
		if(check[i]==0)dis[i]=-1;
		System.out.println(i+" "+dis[i]);
	    }
	    
	}

}




Measured memory_bytes: 27972
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int n, a;
long long s, ans;

int main()
{
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i) {
      long long tmp = a * s;
      tmp %= MOD;
      ans += tmp;
      ans %= MOD;
    }
    s += a;
    s %= MOD;
  }
  cout << ans << E;
  //system("pause");
  return 0;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func sum(nums []int) int {
	sum := 0
	for _, num := range nums {
		sum += num
	}
	return sum
}

func main() {
	// Input
	var n, m int
	n = readInt()
	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = readInt()
	}
	m = readInt()
	p := make([]int, m)
	x := make([]int, m)
	for i := 0; i < m; i++ {
		p[i], x[i] = readInt(), readInt()
	}

	// Calculate
	sum := sum(t)
	for i := 0; i < m; i++ {
		fmt.Println(sum - t[p[i]-1] + x[i])
	}
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

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

	vector<int> a(n);
	vector<int> tmp(n);
	rep(i, n){
		cin >> a[i];
		tmp[i] = a[i];
	}

	sort(a.begin(), a.end());
	rep(i, n){
		if(tmp[i] < a[n-1]){
			cout << a[n-1] << endl;
		}else{
			cout << a[n-2] << endl;
		}
	}


    return 0;
}



Measured memory_bytes: 3200
n = int(input())

al = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
ss = ["a"]
if n == 1:
    print("a")
else:
    for k in range(2, n+1):
        ssn = []
        for s in ss:
            for i in range(k):
                if i > 0:
                    if al[i - 1] not in s:
                        break
                sx = s + al[i]
                if k == n:
                    print(sx)
                ssn.append(sx)
        ss = ssn

Measured memory_bytes: 14192
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split();
            var S = list[0];
            var T = list[1];

            var answer = string.Empty;
            for (int i = 0; i < N; i++)
            {
                answer += new string(new char[] { S[i], T[i] });
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
import heapq
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))

# 前半と後半
first, second = [], []
heapq.heapify(first)
heapq.heapify(second)

first_sum, second_sum = 0, 0

for i in range(N):
    heapq.heappush(first, a[i])
    first_sum += a[i]
    heapq.heappush(second, -a[3 * N - 1 - i])
    second_sum += a[3 * N - 1 - i]

# first, secondそれぞれ0 - Nまで探索
L_sum = [first_sum]
R_sum = [second_sum]

for i in range(N, 2 * N):
    heapq.heappush(first, a[i])
    first_sum += a[i]
    first_sum -= heapq.heappop(first)
    L_sum.append(first_sum)

    heapq.heappush(second, -a[3 * N - 1 - i])
    second_sum += a[3 * N - 1 - i]
    second_sum -= - heapq.heappop(second)
    R_sum.append(second_sum)

ans = -10 ** 15

R_sum = R_sum[::-1]

for i in range(N + 1):
    ans = max(ans, L_sum[i] - R_sum[i])

# print(L_sum, R_sum)
print(ans)


Measured memory_bytes: 121880
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(a,x.size()) cout << x[a] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

int main() {
    int n; cin >> n;
    ll sum = 0;
    int end;
    REP(i,n+1) {
        sum += i;
        if (n <= sum) {
            end = i;
            break;
        } 
    }
    int omit = sum - n;
    REP(i,end+1) if (i != omit) printf("%d\n",i);
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<ll> x(n), y(m);
	rep(i,n) cin >> x.at(i);
	rep(i,m) cin >> y.at(i);
	ll ans = 0, sum = 0;
	rep(i,n){
		ans += x.at(i) * i - x.at(i) * (n - i - 1);
		ans %= mod;
	}
	rep(i,m){
		sum += y.at(i) * i - y.at(i) * (m - i - 1);
		sum %= mod;
	}
	cout << ans * sum % mod << endl;
}


Measured memory_bytes: 1792