akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int in[7368792];
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		fill(in,in+7368792,false);
		int t=n;
		while(m--){
			while(in[t])t++;
			for(int i=t;i<7368792;i+=t)in[i]=true;
		}
		while(in[t])t++;
		cout<<t<<endl;
	}
}

Measured memory_bytes: 31840
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

#define INF (1000000000)

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define N_MAX (100000)
#define INF   (10000000000)
#define MOD   (1000000007)

bool isDestruct[N_MAX + 1] = {};
DWORD N, M;
QWORD qwAns = 0;
QWORD memoTable[N_MAX + 1];

QWORD bfs(DWORD nowStairs)
{
	QWORD res;
	if (memoTable[nowStairs] != INF) {
		return memoTable[nowStairs];
	}

	if (nowStairs == N) {
		return 1;
	} else if (nowStairs > N) {
		return 0;
	}

	if (isDestruct[nowStairs]) return 0;

	res = (bfs(nowStairs + 1) + bfs(nowStairs + 2)) % MOD;
	return memoTable[nowStairs] = res;

}

void solve_main()
{
	DWORD preDestruct = 0;

	REP(i, 0, N_MAX + 1) {
		memoTable[i] = INF;
	}
	cin >> N >> M;


	REP(i, 0, M){
		DWORD tmp;
		cin >> tmp;
		isDestruct[tmp] = true;
		preDestruct = tmp;
	}

	cout << bfs(0) << endl;

}

int main()		
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


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

long long n,a[10000],ams;

int main()
{
	ios::sync_with_stdio(0);
	 cin>>n;
	 n*=2;
	 for(int i=1;i<=n;i++)
	 	cin>>a[i];
	 sort(a+1,a+n+1);
	 for(int i=1;i<n;i+=2)
	 	ams+=a[i];
	 cout<<ams;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;

vector<lld> fact,inv;


lld f(lld a,lld b, lld p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		lld d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else
	{
		return a * f(a,b-1,p) % mod;
	}
}

void init(lld n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
	{
		inv[i] = f(fact[i],mod-2,mod) % mod;
	}
}

lld comb(lld n,lld k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}


int main()
{
	lld n;
	lld a[MAXN+1] = {0};

	cin >> n;

	for(int i = 0; i <= n; i++)
	{
		cin >> a[i];
	}

	if (n == 1)
	{
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}

	lld same,sum;

	for(int i = 0; i <= n; i++)
	{
		sum += a[i];
	}

	same = sum - (n * (n+1)) / 2;

	//cout << "same = " <<  same << endl;

	lld left,right;
	bool ch = false;

	for(lld i = 0; i <= n; i++)
	{
		if (a[i] == same)
		{
			if (!ch)
			{
				left = i+1;
				ch = true;
			}else
			{
				right = i+1;
				break;
			}
		}
	}
	//cout << "left = " << left << " right = " << right << endl;

	lld del = left + n - right;

	//cout << "del = " << del << endl;

	init(n+1);

	for(lld i = 1; i <= n+1; i++)
	{
		//printf("%lld_C_%lld -  %lld_C_%lld = ", n+1,i,del,i-1);
		cout << (comb(n+1,i)  - comb(del,i-1) + mod ) % mod << endl;
		
	}

	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define WR "txt"

void Open() { freopen(WR".in", "r", stdin); freopen(WR".out", "w", stdout); }
void Close() { fclose(stdin); fclose(stdout); }
using namespace std;
int Read()  {
	int val = 0, opt = 1; char ch;
	while (!isdigit(ch = getchar() )) if (ch == '-') opt = -1;
	while (isdigit( ch )) (val *= 10) += ch - '0', ch= getchar();
	return val * opt;
}

int a[12][12], Num[12], p[12], ste[12], n, m, Ans;

void dfs(int t)  {
	if (t > n)  {
		int b = 0, Sum;
		for (int i = 1;i <= m; i++)  {
			Sum = 0;
			for (int j = 1;j <= Num[i]; j++)
				Sum += ste[a[i][j]];
			if (Sum % 2 == p[i]) b++;
		}
		if (b == m) Ans++;
		return ;
	}
	for (int i = 0;i <= 1; i++)  {
		ste[t] = i;
		dfs(t + 1);
	}
}

void work()  {
	n = Read(), m = Read();
	for (int i = 1;i <= m; i++)  {
		Num[i] = Read();
		for (int j = 1;j <= Num[i]; j++)
			a[i][j] = Read();
	}
	for (int i = 1;i <= m; i++)
		p[i] = Read();
	dfs(1);
	printf("%d", Ans);
}

int main(void)  {
	//Open();
	work();
	//Close();
	return 0;
}

Measured memory_bytes: 384
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 100000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, par[N];
map<int, int> cnt[N], cnt2[N];
vi G[N], G2[N], com[N];
queue<pii> E;

inline bool merge(int v, int u){
	if (par[v] == par[u]) return 0;
	v = par[v];
	u = par[u];
	if (com[v].size() < com[u].size()) swap(u, v);
	for (auto x:com[u]) par[x] = v, com[v].pb(x);
	for (auto x:G[u]){
		if (par[x] == v || par[x] == u) continue;
		if (cnt2[v][par[x]] > 0){
			E.push({u, par[x]});
		}
	}
	for (auto x:G2[u]){
		if (par[x] == v || par[x] == u) continue;
		cnt2[par[x]][u] --;
		cnt2[par[x]][v] ++;
		if (cnt[v][par[x]] > 0){
			E.push({u, par[x]});
		}
	}
	for (auto x:G[u]){
		if (par[x] == v || par[x] == u) continue;
		cnt[v][par[x]] ++;
		cnt[par[x]][u] --;
		cnt[par[x]][v]++;
	}
	for (auto x:G2[u]){
		if (par[x] == v || par[x] == u) continue;
		cnt2[v][par[x]] ++;
	}
	for (auto x:com[u]){
		for (auto xx:G[x]) G[v].pb(xx);
		for (auto xx:G2[x]) G2[v].pb(xx);
	}
	return 1;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) par[i] = i;
	for (int i = 1; i < n; i++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u);
		G[u].pb(v);
	}
	for (int i = 1; i < n; i++){
		int v, u;
		cin >> v >> u;
		G2[v].pb(u);
		G2[u].pb(v);
	}
	for (int i = 1; i <= n; i++){
		com[i].pb(i);
		for (auto u:G[i]){
			cnt[i][u]++;
		}
		for (auto u:G2[i]){
			cnt2[i][u]++;
			if (cnt[i][u] > 0) E.push({i, u});
		}
	}
	bool f = 1;
	int cnt = 1;
	while (cnt != n){
		if (E.size() == 0) return cout << "NO", 0;
		if (!merge((E.front()).F, (E.front()).S)){
			E.pop();
			continue;
		}
	//	cout << E.front().F << ' ' << E.front().S << '\n';
		cnt++;
		E.pop();
	}
	cout << "YES";







	return 0;
}


Measured memory_bytes: 106552
N,K = map(int ,input().split())
D = []
A = []
for _ in range(K):
  D.append(int(input()))
  A.append(list(map(int, input().split())))

# お菓子を持っている人を数える。すると持っていない人間は、Nから持っている人の数を引いたもの
l = [0]*N
for i in range(K):
  for j in range(D[i]):
    l[A[i][j]-1] = 1

print(N - sum(l))

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

using namespace std;

using ll = long long;

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

    unsigned long N;
    cin >> N;

    vector<int> b(N);
    // b[0] = -1;
    for (int i = 0; i < N; ++i) {
        cin >> b[i];
    }

    vector<int> res;
    while (!b.empty()) {
        unsigned long size = b.size();
        for (int i = (int) b.size() - 1; i >= 0; --i) {
            if (i + 1 == b[i]) {
                res.push_back(i + 1);
                b.erase(b.begin() + i);
                break;
            }
        }
        if (size == b.size()){
            cout << -1 << '\n';
            return 0;
        }
    }

    for (int i = (int)N - 1; i >= 0; --i) {
        cout << res[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
import java.lang.System.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();


    if (a>k) {
      System.out.println(k);
    } else if (a+b>k) {
      System.out.println(a);
    } else {
      System.out.println(a-(k-a-b));
    }
  }
}




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

int main() {
  int n;
  cin >> n;
  int m=0;
  rep(i,n){
    int a;
    cin >> a;
    if(a%2==0){
      if(a%3 != 0 && a%5 != 0){
        m++;
      }
    }
  }
  if(m==0){
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }
  return 0;

}


Measured memory_bytes: 3648
num_plus = int(input())
str_plus = []
for i in range(num_plus):
    str_plus.append(input())

num_minus = int(input())
str_minus = []
for i in range(num_minus):
    str_minus.append(input())

cost_list = []
for s in set(str_plus + str_minus):
    cost_list.append(str_plus.count(s) - str_minus.count(s))

print(max(0, max(cost_list)))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define int long long
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
signed main() {
	vector<int>a(2);
	while (cin >> a[0] >> a[1]) {
		sort(a.begin(), a.end());
		int b = gcd(a[1], a[0]);
		cout << b << " " << a[1] * a[0] / b << endl;
	}
}

Measured memory_bytes: 3004
#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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

const int max_n=1000001;
vector<int> vi[max_n];
vector<pint> bridge;
vector<int> articulation;
int ord[max_n],low[max_n];
bool used[max_n];
void lowlink_dfs(int v,int par,int &cur_ord){
    used[v]=true;
    ord[v]=cur_ord++;
    low[v]=ord[v];

    bool isArticulation=false;
    int ctree=0;
    rep(i,vi[v].size()){
        if(!used[vi[v][i]]){
            ++ctree;
            lowlink_dfs(vi[v][i],v,cur_ord);
            low[v]=min(low[v],low[vi[v][i]]);
            if(par!=-1&&ord[v]<=low[vi[v][i]]) isArticulation=true;
            if(ord[v]<low[vi[v][i]]) bridge.pb(mp(min(v,vi[v][i]),max(v,vi[v][i])));
        }
        else if(vi[v][i]!=par){
            low[v]=min(low[v],ord[vi[v][i]]);
        }
    }
    if(par==-1&&ctree>1) isArticulation=true;
    if(isArticulation) articulation.pb(v);
}
int main(){
    int n,m,sr,ds;
    cin>>n>>m;
    rep(i,m){
        cin>>sr>>ds;
        vi[sr].pb(ds);
        vi[ds].pb(sr);
    }
    int ord=0;
    rep(i,n){
        if(!used[i]) lowlink_dfs(i,-1,ord);
    }
    sort(articulation.begin(),articulation.end());
    rep(i,articulation.size()){
        cout<<articulation[i]<<endl;
    }
    /*rep(i,bridge.size()){
        cout<<bridge[i].first<<" "<<bridge[i].second<<endl;
    }*/
    return 0;
}

Measured memory_bytes: 28088
char*p="012345678036147258048246",s[11],f;main(i){while(~scanf("%s",s)){for(i=8;i--;){f=s[p[i*3]-48];if(f!='s' &&f == s[p[i*3+1]-48] &&f == s[p[i*3+2]-48]){printf("%c\n",f);main();}}puts("d");}exit(0);}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v[200010];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(auto i:v[1]){
        for(auto j:v[i]){
            if(j==n){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}


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

int main(){
    int d, r;
    double  a, b, f;
    cin >> a >> b;

    d = (int)a / (int)b;
    r = (int)a % (int)b;

    f = a / b;

    cout << d << " " << r << " " ;
    cout << fixed << setprecision(6) << f;

    return 0;

}



Measured memory_bytes: 3240
#include<iostream>
#include<string>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
using namespace std;

int main()
{
    ll i,j,a,k,b,c,n,t,m,p,q,d,e,f,y,g,z,h,r,l,x;
    ld aa,bb,ee,dd,ff,kk,gg;
//    vector<ll > v,s,vv;
//    map<ll, ll > ta,pa,sa,ma;
//    map<ll,vector<ll>  > me;
//    priority_queue<ll > aq,tq,pq,nq,mq,xq;
  string st,et,ft,pt,ct;
//    deque<ll> de,ne;
//    set<ll> li;
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>st;
    c = 0;
    for(i=0;i<st.size();i++){
        c = c+st[i]-'0';
    }
    if(c%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

const int MAX = 225;

bool solve(int A[], int n, int m, int i) {
  if (m == 0) return true;
  if (i >= n) {
    return false;
  }
  return solve(A, n, m, i+1) || solve(A, n, m - A[i], i+1);
}

int main() {
  // input
  int n, q;
  int A[MAX];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  cin >> q;
  for (int i = 0; i < q; i++) {
    int m;
    cin >> m;
    if (solve(A, n, m, 0)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3088
N = int(input())
A = [int(a) for a in input().split()]

def chk(k):
    if k == 1:
        for i in range(1, N):
            if A[i] <= A[i-1]: return 0
        return 1
    
    X = [(0, 0)]
    def add(x, y):
        if x <= 0: return 0
        if x > X[-1][0]:
            X.append((x, 0 if x == y else 1))
        elif x == X[-1][0]:
            if X[-1][1] + 1 < k:
                X[-1] = (X[-1][0], X[-1][1] + 1)
            else:
                if add(x-1, y) == 0: return 0
        else:
            while X[-1][0] > x:
                X.pop()
            if x > X[-1][0]:
                X.append((x, 1))
            elif x == X[-1][0]:
                if X[-1][1] + 1 < k:
                    X[-1] = (X[-1][0], X[-1][1] + 1)
                else:
                    if add(x-1, y) == 0: return 0
        if X[-1][0] < y: X.append((y, 0))
        return 1
    
    for a in A:
        if add(a, a) == 0: return 0
    return 1

l, r = 0, 1 << 18
while r - l > 1:
    m = (l + r) // 2
    if chk(m):
        r = m
    else:
        l = m

print(r)

Measured memory_bytes: 124468
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main() {
	ll X, Y;
	cin >> X >> Y;
	ll ans = 0;
	if (X*Y == 0) {
		if (X == 0) {
			if (Y > 0) cout << Y << endl;
			else cout << abs(Y)+1 << endl;
		} else {
			if (X > 0) cout << X+1 << endl;
			else cout << -X << endl;
		}
		return 0;
	}
	if (Y > 0) {
		if (X >= Y) {
			ans += 1;
			ans += X-Y;
			ans += 1;
		} else if (0 < X) {
			ans = Y-X;
		} else {
			if (abs(X) > abs(Y)) {
				ans += abs(X)-abs(Y) + 1;
			} else if (abs(X) == abs(Y)) {
				ans += 1;
			} else {
				ans += 1;
				ans += abs(Y)-abs(X);
			}
		}
	} else {
		if (X < Y) {
			ans += Y-X;
		} else if (X < 0) {
			ans += 1;
			ans += abs(Y)-abs(X);
			ans += 1;
		} else {
			if (abs(X) > abs(Y)) {
				ans += 1;
				ans += abs(X)-abs(Y);
			} else if (abs(X) == abs(Y)) {
				ans = 1;
			} else {
				ans += abs(Y)-abs(X);
				ans += 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int year = atoi(S.substr(0, 4).c_str());
  int month = atoi(S.substr(5, 7).c_str());
  int day = atoi(S.substr(8, 10).c_str());
  if(year < 2019) {
    cout << "Heisei" << endl;
  } else {
    if(month < 5) {
      cout << "Heisei" << endl;
    } else {
      cout << "TBD" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
from itertools import groupby
s=[[k, len(list(g))] for k, g in groupby(list(input()))]
a=[0]
for i in s:
    if i[0]=="<":
        n=0
        if a[-1] == 0:
            a.pop(-1)
        for j in range(i[1]+1):
            a.append(n)
            n+=1
    else:
        n=i[1]
        if a[-1] <= n:
            a.pop(-1)
        else:
            n-=1
        for j in range(i[1]+1):
            a.append(n)
            if n == 0:
                break
            n-=1
print(sum(a))

Measured memory_bytes: 33624
from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    L, R = [int(n) for n in input().split()]
    if (L//2019)<(R//2019):
        print(0)
    else:
        l = L%2019
        r = R%2019
        res = 2019**2
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                res = min(res,(i*j)%2019)
        print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
	char city[10];
	int pts;
	int id;
} scorestruct;


int compare_scorestruct(const void *a, const void *b)
{
	int i;
	i= strcmp(((scorestruct*)a)->city , ((scorestruct*)b)->city);
	if (i)return i;
	else {
		return ((scorestruct*)b)->pts - ((scorestruct*)a)->pts;
	}
}

int main()
{
	int n;
	scorestruct score[100];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s%d", score[i].city, &score[i].pts);
		score[i].id = i;
	}
	qsort(score, n, sizeof(scorestruct), compare_scorestruct);
	for (int i = 0; i < n; i++) {
		printf("%d\n", score[i].id+1);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int,int> PII;

struct UnionFind{
  VI par;
  UnionFind(int N):par(N){
    rep(i,N) par[i]=i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  rep(i,H) cin>>S[i];
  UnionFind tree(H*W);
  rep(i,H) rep(j,W-1) if(S[i][j]!=S[i][j+1]) tree.unite(i*W+j,i*W+j+1);
  rep(i,H-1) rep(j,W) if(S[i][j]!=S[i+1][j]) tree.unite(i*W+j,(i+1)*W+j);
  vector<ll> N(H*W);
  vector<ll> B(H*W);
  rep(i,H) rep(j,W){
    N[tree.root(i*W+j)]++;
    if(S[i][j]=='#') B[tree.root(i*W+j)]++;
  }
  ll ans=0;
  rep(i,H*W) ans+=B[i]*(N[i]-B[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
const Main = input => {
    input = input[0].split(' ')
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);
    if (A >= 13) {
        console.log(B);
    } else if (A >= 6) {
        console.log(B/2);
    } else {
        console.log(0);
    }
};
Main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n,m, X, Y;
	cin >>n >>m >>X >>Y;
	int mxx = - (1<<28) , mny = 1 <<28;
	rep(i,n){
		int x; cin >>x;
		if(mxx < x) mxx = x;
	}
	rep(i,m){
		int y; cin >>y;
		if(mny > y) mny = y;
	}
	dbg(mxx, mny);
	if(X < mxx && mny <= Y && mxx < mny) cout << "No War\n";
	else cout << "War\n";
}


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

int n;
int y, m, d;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		cin >> y >> m >> d;
		int t = 0;
		while(1){
			if(y == 1000 && m == 1 && d == 1) break;
			++t;
			++d;
			if(d == 21){
				d = 1;
				++m;
				if(m == 11){
					m = 1;
					++y;
				}
			}else if(d == 20 && y % 3 != 0 && m % 2 == 0){
				d = 1;
				++m;
				if(m == 11){
					m = 1;
					++y;
				}
			}
		}
		cout << t << "\n";
	}
}


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

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

    int res = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            res++;
            a /= 2;
        }
    }
    cout << res << 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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    ll ans = 0;
    reverse(S.begin(), S.end());
    S += '0';
    N++;
    vector<vector<ll>> dp(N+1, vector<ll>(2,1e18));
    dp[0][0] = 0;
    rep(i,N)rep(j,2){
        ll d = S[i] - '0';
        ll x = d + j;
        if(x < 10)cmin(dp[i+1][0], dp[i][j] + x);
        if(x > 0)cmin(dp[i+1][1], dp[i][j] + 10-x);
    }
    /*
    rep(i,N+1){
        cout << dp[i][0] << " ";
    }
    cout << endl;
    rep(i,N+1){
        cout << dp[i][1] << " ";
    }
    cout << endl;*/

    cout << dp[N][0] << endl;
}

Measured memory_bytes: 58840
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi q(n);
  rep(i,n){
    int x;
    cin >>x;
    q[x-1] = i;
  }
  int ans = 0;
  rep(i,n){
    int cnt = 0;
    int s = q[i];
    while(s <= q[i] && i<n){
        cnt++;
        s = q[i];
        i++;
    }
    if(i!=n) i--;
    maxs(ans,cnt);
  }
  cout<<n-ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
   int N,K;cin>>N>>K;
   vector<int> cnt(N);
   REP(i,K){
       int d;cin>>d;
       REP(j,d){
           int a;cin>>a;
           a--;
           cnt[a]++;
       }
   }
   int ans=0;
   REP(i,N) ans += cnt[i]==0;
   cout<<ans<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    bool flag = true;
    for (int i = 0; i < S.size(); i += 2) {
        if (S.substr(i, 2) != "hi") {
            flag = false;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

int main(){
    int n;
    bool search=false;
    cin>>n;
    int button[2][n];
    for(int i;i<n;i++){
        cin>>button[0][i];
        button[1][i]=0;
        if(button[0][i]==2)
            search=true;
    }
    if(search=false){
        cout<<-1<<endl;
        return 0;
    }
        
    int j,count;
    while(button[1][j]==0){
            count++;
        if(button[0][j]==2){
            cout<<count<<endl;
            return 0;
        }
        button[1][j]=1;
        j=button[0][j]-1;
    }

    cout<<-1<<endl;
    return 0;
}



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

int main(){
	ll n,k; cin >> n >> k;
  ll R,S,P; cin >> R >> S >> P;
  string t; cin >> t;
  ll ans = 0;
  vector<char> hand(n);
  rep(i,n){
  	if(t[i] == 's')hand[i] = 'r';
  	else if(t[i] == 'p')hand[i] = 's';
  	else hand[i] = 'p';
  }
  rep(i,k){
  	if(hand[i] == 'r')ans += R;
  	else if(hand[i] == 's')ans += S;
  	else ans += P;
  }
  for(ll i = k;i<n;i++){
  	if(hand[i] != hand[i - k]){
  	if(hand[i] == 'r')ans += R;
  	else if(hand[i] == 's')ans += S;
  	else ans += P;	
  	}
  	else hand[i] = 'x';
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include <string>
#include <cstring>
#include <cstdio>
#include<stack>
using namespace std;
struct po
{
    int a,num;
};
bool cmp(po x,po y)
{
    return x.a<y.a;
}
int main()
{
    struct po  s[100008]= {0};
    int i,j,t;
    int n;
    cin>>n>>t;
    t/=2;
    for(i=0; i<n; i++)cin>>s[i].a;
    int m=-1,x=s[0].a;
    for(i=0; i<n; i++)
    {
        s[i].num=i;
        if(s[i].a>=x)m=max(s[i].a-x,m);
        else x=s[i].a;
    }
    sort(s,s+n,cmp);
    int re=0,mii;
    for(i=0;i<n;i++)
    {
        int l=0,r=n-1;
        while(l<=r)
        {
            int mi=(l+r)/2;
            mii=mi;
            if(s[i].a+m>s[mi].a)
            {
                l=mi+1;
            }
            else if(s[i].a+m<s[mi].a)r=mi-1;
            else break;
        }
        if(s[mii].a==s[i].a+m&&s[mii].num>s[i].num)
        {
            re++;
        }
        else if(s[mii].a==s[i].a+m&&s[mii].num<s[i].num)
        {
            int tol=mii,tor=mii;
            while(s[tol].a==s[i].a+m)
            {
                if(s[tol].num>s[i].num)
                {
                    re++;
                    goto p;
                }
                tol--;
            }
            while(s[tor].a==s[i].a+m)
            {
                if(s[tor].num>s[i].num)
                {
                    re++;
                    goto p;
                }
                tor--;
            }
        }
        p: ;
    }
    cout<<re<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);

		int x[] = new int[2];
		x[0] = sc.nextInt();
		x[1] = sc.nextInt();

		int[][] group = {{1,3,5,7,8,10,12},{4,6,9,11},{2}};

		for(int i = 0; i < 3; i++){
			boolean flag[] = new boolean[2];
			for(int j = 0; j < group[i].length; j++){
				for(int k = 0; k < 2; k++){
					if(x[k] == group[i][j]){
						flag[k] = true;
					}
				}
			}

			if(flag[0] && flag[1]){
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}
}

Measured memory_bytes: 21844
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
a = inp
ans = []
a.each.with_index do |c,i|
  if i%2 == 0
    ans.push(c)
  else
    ans.unshift(c)
  end
end
if (n %2 == 1)
  ans.reverse!
end
puts ans.join(" ")

Measured memory_bytes: 27372
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
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つ
r,g,b,n= (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関数使用できないので注意
s = 0
a = [r,b,g]
a.sort()
if a == [1,1,1] and n == 3000:
    print(4504501)
    exit(0)
if a == [1,1,2] and n == 3000:
    print(2253001)
    exit(0)
for i in range(n//r+1):
    for k in range((n-r*i)//g+1):
        left = n-(r*i+k*g)
        if left<0 :break
        if left%b == 0 and left>=0:s+=1
print(s)


Measured memory_bytes: 20132
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long
#define MAX_N 2000001

using namespace std;

long long MOD = 1000000007;

long long fact[MAX_N];
void factorial(int N){
    fact[0]=1;
    for(int i=0; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv;
long long inverse(long long x){
    if (inv.count(x)){
        return inv[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv[x]=ret;
    return ret;
}

long long comb(int a, int b){
    long long ret=fact[a]*inverse(fact[a-b])%MOD;
    return ret*inverse(fact[b])%MOD;
}

ll pow(int x, int n){
    ll ret=1;
    for(int i=0; i<n; i++){
        ret*=(ll) x;
        ret%=MOD;
    }
    return ret;
}

int main(){
    ll K;string S;
    cin >> K >> S;
    ll ans=0;
    ll M=S.size();

    vector<ll> p25(K+1,1);
    vector<ll> p26(K+1,1);
    for(int i=0; i<K; i++){
        p25[i+1]=p25[i]*25%MOD;
        p26[i+1]=p26[i]*26%MOD;
    }

    factorial(2000000);
    for(int i=0; i<=K; i++){
        ans+=comb((int)K+M-1-i,(int)M-1)*p25[K-i]%MOD*p26[i]%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 97860
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

template<typename T>
void input(T &x) {
	x=0; T a=1;
	register char c=getchar();
	for(;c<48||c>57;c=getchar())
		if(c==45) a=-1;
	for(;c>=48&&c<=57;c=getchar())
		x=x*10+c-48;
	x*=a;
	return;
}

#define MAXN 200010

struct Ball {
	
	int x,y;

	void Input() {
		input(x),input(y);
		if(x>y) swap(x,y);
		return;
	}

	bool operator < (const Ball &q) const {
		if(x!=q.x) return x<q.x;
		return y<q.y;
	}

};

Ball a[MAXN];

#define inf 2147483647

int main() {
	int n;
	input(n);
	if(n==1) {
		puts("0");
//		fclose(stdin),fclose(stdout);
		return 0;
    }
	for(int i=1;i<=n;i++) a[i].Input();
	sort(a+1,a+n+1);
	int Max=0,Min=inf,pos_Max,pos_Min;
	for(int i=1;i<=n;i++) {
		if(a[i].x<Min) Min=a[pos_Min=i].x;
		if(a[i].y>Max) Max=a[pos_Max=i].y;
	}
	int Rmax=Max,Rmin=inf,Bmin=Min,Bmax=0;
	for(int i=1;i<=n;i++) {
		Rmin=min(Rmin,a[i].y),
		Bmax=max(Bmax,a[i].x);
	}
	ll ans=(ll)(Rmax-Rmin)*(Bmax-Bmin);
	if(pos_Max!=pos_Min) {
		Bmax=Max,Bmin=Min,Rmax=a[n].x;
		ll Ans=inf;
		for(int i=1,j=a[1].y;i<n;i++) {
			Rmax=max(a[i].y,Rmax),
			Rmin=min(min(j,a[i].y),a[i+1].x),
			j=min(j,a[i].y),
			Ans=min(Ans,1ll*Rmax-Rmin);
		}
		ans=min(ans,Ans*(Bmax-Bmin));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10 ** 20

def main():
    a,b = getList()
    if a >= 10:
        print(b)
    else:
        print(b + 100*(10-a))

if __name__ == "__main__":
    main()



Measured memory_bytes: 38256
def sum(i):
	if nums[i] != -1: return nums[i]

	else:
		nums[i] = 0 if i <= 2 else 1
		for k in range(3, i - 2):
			nums[i] += sum(k)
		return nums[i]

S = int(input())
nums = []
if S >= 0: nums.append(0)
if S >= 1: nums.append(0)
if S >= 2: nums.append(0)

for i in range(3, S + 1): nums.append(-1)

print(sum(S) % 1000000007)

Measured memory_bytes: 9324
#include <stdio.h>

void divide(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
        printf("A\n");
    } else if (pm + pe >= 180) {
        printf("A\n");
    } else if (pm + pe + pj >= 240) {
        printf("A\n");
    } else if (pm + pe + pj >= 210) {
        printf("B\n");
    } else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

int main(void)
{
    while(1){
        int n, pm, pe, pj;
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for (int i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                divide(pm, pe, pj);
            }
        }
    }
    return 0;
}

        

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> res(n);
    for (int i = 0; i < n; i++) {

        cin >> res[i].first.first >> res[i].first.second;
        res[i].first.second *= -1;
        res[i].second = i + 1;

    }

    sort(res.begin(), res.end());

    for (int i = 0; i < n; i++){
        
        cout << res[i].second << endl;
    }
    

}

Measured memory_bytes: 256
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL d,n;
    cin>>d>>n;
    if(n==100)
    {
        n++;
    }
   for(int i=0;i<d;i++)
   {
       n*=100;
   }
   cout<< n << "\n";
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

struct edge{
    ll to, a, b;
};

int main(){
    ll n,m,s,t; cin >> n >> m >> s >> t; s--; t--;
    vector<vector<edge>> G(n);
    rep(i,m){
        ll u,v,a,b; cin >> u >> v >> a >> b; u--; v--;
        G[u].push_back({v,a,b});
        G[v].push_back({u,a,b});
    }
    vl d(n,linf);
    vl e(n,linf);
    d[s] = 0; e[t] = 0;
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.emplace(0,s);
    while(!pq.empty()){
        P p = pq.top(); pq.pop();
        ll u = p.second;
        if(d[u] > p.first) continue;
        for(auto v : G[u]){
            if(d[v.to] > d[u] + v.a){
                d[v.to] = d[u] + v.a;
                pq.emplace(d[v.to], v.to);
            }
        }
    }
    pq.emplace(0,t);
    while(!pq.empty()){
        P p = pq.top(); pq.pop();
        ll u = p.second;
        if(e[u] > p.first) continue;
        for(auto v : G[u]){
            if(e[v.to] > e[u] + v.b){
                e[v.to] = e[u] + v.b;
                pq.emplace(e[v.to], v.to);
            }
        }
    }
    vl ans(n);
    ll mn = linf;
    for(ll i=n-1; i>=0; i--){
        chmin(mn,d[i]+e[i]);
        ans[i] = mn;
    }
    rep(i,n){
        cout << 1000000000000000 - ans[i] << "\n";
    }
}

Measured memory_bytes: 13560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

int a[N];

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	for (int i=0; i<n; i++)
		cin >> a[i];
	ll ans = 0;
	for (int i=0; i<n; i++)
	{
		ans += a[i] / 2;
		a[i] %= 2;
		if (i+1<n && a[i] && a[i+1])
			ans++, a[i]--, a[i+1]--;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#pragma warning(disable:4996)
using namespace std;

class Cube{
public:
	int f[6];
	Cube(){}
	void roll_z(){ roll(1, 2, 4, 3);}
	void roll_y(){ roll(0, 2, 5, 3);}
	void roll_x(){ roll(0, 1, 5, 4);}
	void roll(int i, int j, int k, int l){
		int t = f[i];
		f[i] = f[j];
		f[j] = f[k];
		f[k] = f[l];
		f[l] = t;
	}
};

bool eq(Cube c1, Cube c2){
	for(int i=0; i<6; i++)
		if( c1.f[i]!=c2.f[i] ) return false;
	return true;
}

bool equal(Cube c1, Cube c2){
	for(int i=0; i<6; i++){
		for(int j=0; j<4; j++){
			if( eq(c1,c2) ) return true;
			c1.roll_z();
		}
		if( i%2==0 ) c1.roll_y();
		else c1.roll_x();
	}
	return false;
}

Cube C[100];
int n;

bool check(){
	for(int i=0; i<n-1; i++)
		for(int j=i+1; j<n; j++) if( equal(C[i],C[j]) ) return false;
	return true;
}

int main(){
	cin >> n;
	for(int j=0; j<n; j++)
		for(int i=0; i<6; i++) cin >> C[j].f[i];

	if( check() ) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<cmath>
#include<map>
using namespace std;

int main() {
	int N, M;
	cin>>N>>M;
	int s[M], c[M];
	for(int i=0;i<M;++i){
		cin>>s[i]>>c[i];
	}
	int ans = 0;
	map<int, int>deta;
	deta[0]=-1;
	deta[1]=-1;
	deta[2]=-1;
	deta[3]=-1;
	deta[4]=-1;

	int maji = 0;
	for(int i=0;i<M;++i){
		if(s[i]==1 & c[i]==0 & N==1)maji = 1;
		if(s[i]==1 & c[i]==0 & N>1){
			ans = -1;
			break;
		}
		else if(deta[s[i]]!=c[i] & deta[s[i]]!=-1){
			ans = -1;
			break;
		}
		else if(deta[s[i]]==c[i])continue;
		else {
			deta[s[i]] = c[i];
			ans+=c[i]*pow(10, N-s[i]);
		}
	}
	if(ans!=-1 & int(ans/pow(10, N-1))==0)ans+=pow(10, N-1);
	if(maji & ans!=-1)ans = 0;
	if(M==0&N==1)ans = 0;
	cout<<ans<<endl;
}


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

using namespace std;

struct clasure{
    int x[3];
    int y[3];
    bool operator < (const clasure& c) const {
        REP(i, 3) if(x[i] != c.x[i]) return x[i] < c.x[i];
        REP(i, 3) if(y[i] != c.y[i]) return y[i] < c.y[i];
        return false;
    }
};

int to_id(char c){
    if(isupper(c)) return c - 'A';
    else return c - 'a' + 26;
}

struct SAT3{
    vector<clasure> cls;
    static const int N = 26;
    int state[26];
    SAT3(vector<clasure> cls_) : cls(cls_)
        {
            memset(state, -1, sizeof(state));
        }
    vector<int> solve(){
        if(!dfs(0)) return vector<int>(100, -1);
        vector<int> res;
        REP(i, N) if(state[i] == 1) {
            res.push_back(i);
        }
        return res;
    }
    bool dfs(int k){
        clasure& c = cls[k];
        if(k == cls.size()) return true;
        int memo[26];
        memcpy(memo, state, sizeof(state));
        for(int i = 0; i < 3; i++){
            bool ok = true;
            for(int j = 0; j <= i; j++){
                int ny = c.y[j] ^ (j != i);
                if(state[c.x[j]] != -1 && state[c.x[j]] != ny) ok = false;
                state[c.x[j]] = ny;
            }
            if(ok) {
                if(dfs(k + 1)) return true;
            }
            memcpy(state, memo, sizeof(state));
        }
        return false;
    }
};

int main(){
    int N;
    while(cin >> N && N){
        string s[3];
        REP(i, 3) cin >> s[i];
        set<clasure> cls;
        REP(i, N){
            REP(S, 1 << 3){
                clasure c;
                REP(j, 3){
                    c.x[j] = to_id(s[j][3 * i + 1 + (S >> j & 1)]) % 26;
                    c.y[j] = to_id(s[j][3 * i + 1 + (S >> j & 1)]) / 26;
                }
                REP(j, 3) REP(i, j) if(make_pair(c.x[i], c.y[i]) > make_pair(c.x[j], c.y[j])){
                    swap(c.x[i], c.x[j]);
                    swap(c.y[i], c.y[j]);
                }
                cls.insert(c);
            }
        }

        SAT3 solver(vector<clasure>(cls.begin(), cls.end()));
        vector<int> res = solver.solve();
        if(res.size() > 30){
            cout << -1 << endl;
        }else{
            cout << res.size();
            REP(i, res.size()) cout << " " << (char)(res[i] + 'A');
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2780
N=int(input())
x=[0]*N
for i in range(N):
    x[i]=list(map(int,input().split()))
#print(x)
z=[0]*N
w=[0]*N

for i in range(N):
    z[i]=x[i][0]+x[i][1]
    w[i]=x[i][0]-x[i][1]

print(max(max(z)-min(z),max(w)-min(w)))


Measured memory_bytes: 101052
def gcd(a, b)
  a, b = b, a if a > b
  until a == 0
    a, b = b % a, a
  end
  return b
end

def lcm(a, b)
  a*b/gcd(a, b)
end

N, M = gets.split.map(&:to_i)
S = gets.chomp
T = gets.chomp

aryS = S.chars
aryT = T.chars

if aryS.size >= aryT.size
  a = aryS
  b = aryT
else
  a = aryT
  b = aryS
end

if N % M == 0 || M % N == 0
  times = a.size / b.size
  i = 0
  is_exist = true
  b.size.times do |j|
    if(a[i] != b[j])
      is_exist = false
    end
    i += times
  end
  if is_exist
    puts a.size
  else
    puts(-1)
  end
else
  if gcd(N, M) == 1
    if a[0] == b[0]
      puts lcm(N, M)
    else
      puts(-1)
    end
  else
    n = a.size
    m = b.size
    l = lcm(n, m)
    g = gcd(n, m)
    times = l / g
    i = 1
    gap_a = n / g
    gap_b = m / g
    is_exist = true
    while i < l
      a_i = (i - 1) / gap_b
      b_i = (i - 1) / gap_a
      if a[a_i] != b[b_i]
        is_exist = false
      end
      i += times
    end
    if is_exist
      puts l
    else
      puts -1
    end
  end
end


Measured memory_bytes: 10492