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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, T;
    cin >> N >> T;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;

    vector<ll> imos(T + 1, 0);
    rep(i, N) {
        ll l = items[i].first;
        ll r = items[i].second;
        imos[r] -= 1;
        imos[l] += 1;
    }

    rep(t, T) {
        imos[t + 1] += imos[t];
    }
    ll ans = *max_element(imos.begin(), imos.end());
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



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

int H, W;
vector<vector<char>> S;
vector<vector<int>> Sh;
vector<vector<int>> Sw;

void show(vector<vector<int>> T)
{
	return;
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W; w++)
		{
			cout << T[h][w] << "   ";
		}
		cout << "\n";
	}
	cout << endl;
}

int main(){
	cin >> H >> W;
	S = vector<vector<char>>(H, vector<char>(W));
	Sh = vector<vector<int>>(H, vector<int>(W, 0));
	Sw = vector<vector<int>>(H, vector<int>(W, 0));
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W; w++)
		{
			cin >> S[h][w];
		}
	}
	for (int h = 0; h < H; h++)
	{
		int cnt = 0;
		for (int w = 0; w < W; w++)
		{
			if(S[h][w] == '.'){
				cnt++;
				Sw[h][w] = cnt;
			}
			else cnt = 0;
		}
		for (int w = W - 2; w >= 0; w--)
		{
			if(S[h][w] == '#') continue;
			Sw[h][w] = max(Sw[h][w], Sw[h][w+1]);
		}
	}
	show(Sw);
	for (int w = 0; w < W; w++)
	{
		int cnt = 0;
		for (int h = 0; h < H; h++)
		{
			if(S[h][w] == '.'){
				cnt++;
				Sh[h][w] = cnt;
			}
			else cnt = 0;
		}
		for (int h = H - 2; h >= 0; h--)
		{
			if (S[h][w] == '#') continue;
			Sh[h][w] = max(Sh[h][w], Sh[h+1][w]);
		}
	}
	
	show(Sh);
	
	int ans = 0;
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W; w++)
		{
			if (S[h][w] == '.')
				ans = max(ans, Sh[h][w] + Sw[h][w] - 1);
		}
		
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

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

#define PII pair < int , int >
#define x first
#define y second
vector < PII > now; int N , M , K;

int main(){
	cin >> N >> M >> K;
	for(int i = 1 ; i <= K ; ++i){int x , y; cin >> x >> y; now.push_back(PII(x , y));}
	sort(now.begin() , now.end());
	int delt = 0 , ans = N;
	for(int i = 0 ; i < now.size() ; ++i)
		if(now[i].x - now[i].y > delt) ans = min(ans , now[i].x - 1);
		else if(now[i].x - now[i].y == delt) ++delt;
	cout << ans; return 0;
}

Measured memory_bytes: 2420
V, E = map(int, input().split())
d = [[10 ** 9] * V for _ in range(V)]
dp = [[-1] * V for _ in range((1 << V))]
for i in range(E):
    s, t, di = map(int, input().split())
    d[s][t] = di

def rec(S, v, dp):
    # メモ化再帰なのですでに探索済みなら値を返却する
    if dp[S][v] >= 0: return dp[S][v]
    # S == (1 << V) - 1はSを二進数表記したときに全てのbitが1であるかどうかを判定している
    # Sの全てのbitが1かつ、v(現在のノード)が0のときは、一周巡回したということになるので、dp[S][v]=0を設定する
    if (S == ((1 << V) - 1)) and v == 0:
        dp[S][v] = 0
        return 0
    res = 10 ** 9
    for u in range(V):
        # 集合Sを右シフトして左からu番目のbitが0の場合、到達していないノードという判定になるから、そのノードの最短経路を求めにいく
        if (S >> u & 1) == 0:
            # 集合Sに対して、今から調査するノードを整数で表すと(1 << u)となるので、S | (1 << u)を引数にする
            # ちなみにS >> u & 1 == 0であることが確定しているので、orだけじゃなくて加算しても動く
            res = min(res, rec(S + (1 << u), u, dp) + d[v][u])
    dp[S][v] = res
    return dp[S][v]

ans = rec(0, 0, dp)
print(ans if ans < 10 ** 9 else -1)




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


void solve() {
    ll N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
}

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


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

int N, M;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    int ans = 0;
    for (int i=1; i*i<=M; i++) {
        if (M%i==0) {
            if (i*N<=M) ans = max(ans, i);
            if (i!=M/i) {
                int j = M/i;
                if (j*N<=M) ans = max(ans, j);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

bool comp(pii &a, pii &b)
{
    return a.second < b.second;
}

int main()
{
    int n;
    cin >> n;
    vi as(n);
    for(int i=0; i<n; i++) cin >> as.at(i);

    vpi mp;
    for(int i=0; i<n; i++)
    {
        mp.push_back(make_pair(i+1, as.at(i)));
    }
    sort(mp.begin(), mp.end(), comp);
    for(int i=0; i<n; i++)
    {
        if(i != n-1) cout << mp.at(i).first << " ";
        else cout << mp.at(i).first;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2164
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    REP(i, N) cin>>X[i];
    ll res = 0;
    ll pos = X[0];
    FOR(i, 1, N){
        if(A*(X[i]-pos) < B){
            res += A*(X[i]-pos);
        }
        else {
            res += B;
        }
        pos = X[i];
    }
    cout << res << endl;
    return 0;
    
}

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

int main(){

	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	string ans="Yes";

	for(int i = 0; i < A; i++)
	{
		if(!(S[i] >= '0' && S[i] <= '9')) ans = "No";
	}
	if(S[A] != '-') ans = "No";
	for(int i = A+1; i < A+B+1; i++)
	{
		if(!(S[i] >= '0' && S[i] <= '9')) ans = "No";
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io

	int A, B;

	cin >> A >> B;
	B *= 2;
	A -= B;
	if (A < 0)
		cout << "0\n";
	else
		cout << A << "\n";
	return 0;
}

Measured memory_bytes: 256
N, u, v = map(int, input().split())
u, v = u - 1, v - 1
T = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    T[a].append([b, 1])
    T[b].append([a, 1])


def dijkstra(graph, start, inf=float('inf')):
    import heapq
    n = len(graph)
    distances = [inf] * n
    distances[start] = 0
    visited = [False] * n

    # 距離・頂点
    hq = [(0, start)]
    while hq:
        dist, fr = heapq.heappop(hq)
        visited[fr] = True

        for to, cost in graph[fr]:
            new_dist = distances[fr] + cost
            if (visited[to]) or (distances[to] <= new_dist):
                continue

            distances[to] = new_dist
            heapq.heappush(hq, (new_dist, to))

    return distances


U_dist = dijkstra(T, u)
V_dist = dijkstra(T, v)

ans_candidates = [dv for du, dv in zip(U_dist, V_dist) if du < dv]
print(max(ans_candidates) - 1)


Measured memory_bytes: 48800
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
lb = [0] * (len(B)+1)
lsum = [0] * (len(B)+1)
temp = 0
for i in range(len(B)):
    lb[i]= bisect.bisect_left(A,B[i])
    
for i in range(len(B)):
    lsum[i] = lb[i] +lsum[i-1]


ans = 0    
for i in range(len(C)):
    temp = bisect.bisect_left(B,C[i])
    ans +=lsum[temp-1]


print(ans)

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

using namespace std;

const int maxN = 1e5+10;
int N, A[maxN];

int main()
{
    cin >> N;
    for (int i=0; i < N; i++) cin >> A[i];
    int cnt = 0, tmp = 0;
    for (int i=0; i < N; i++)
    {
        if (A[i]%4 == 0) cnt++;
        else
            if (A[i]%2 == 0) tmp++;
    }
    int odd = N - cnt - tmp;
    if ((tmp == 0 && cnt+1 >= odd) || (tmp && cnt >= odd)) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 640
#include <stdio.h>

int swap(int *a, int *b)
{
	int tmp;

	tmp = *a;
	*a = *b;
	*b = tmp;

	return (0);
}

int main(void)
{
	int n;
	int i, j;
	int sides[3];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		for (j = 0; j < 3; j++){
			scanf("%d", sides + j);
		}
		if (sides[0] < sides[1]) swap(sides, sides + 1);
		if (sides[0] < sides[2]) swap(sides, sides + 2);


		puts(sides[0] * sides[0] == sides[1] * sides[1] + sides[2] * sides[2] ? "YES" : "NO");
	}

	return (0);
}

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

int main()
{
    int ans[200];
    int i=-1;//top.array
///bunnki ???????????\????????????????????????????????????????????????
  char s[100];
  while(scanf("%s",s)!= EOF)
  {

    if(s[0]=='+')
      {
        ans[i-1]=ans[i]+ans[i-1];
        i--;
      }
    else if(s[0]=='-')
    {
      ans[i-1]=ans[i-1]-ans[i];
      i--;
    }
    else if(s[0]=='*')
    {
      ans[i-1]=ans[i-1]*ans[i];
      i--;
    }
    else //read number, extend array
    {
      i++;
      ans[i]= atoi(s);
    }
  }
  printf("%d\n",ans[i]);
  return 0;
}

Measured memory_bytes: 1848
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

from fractions import gcd
def solve():
    n = II()
    A = LI()

    ans = A[0]
    for i in range(1, n):
        ans = gcd(ans, A[i])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16296
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

M = 10 ** 9 + 7

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

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

def solve():
  N = read()
  C = [-1] * N
  p = 0
  for i in range(N):
    c = read() - 1
    if C[p-1] != c:
      C[p] = c
      p += 1
  N = p
  del C[N:]

  dp = [0] * (N+1)
  dp[0] = 1
  last = [0] * (2 * 10**5 + 10)
  for i in range(N):
    c = C[i]
    last[c] = (last[c] + dp[i]) % M
    dp[i+1] = last[c]
  # print('dp', dp)
  print(dp[-1])

solve()

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

using namespace std;

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

const int N = 200010;

int n,a[N];
ll ans[N];
vector<ll> all;

map<int,ll> freq,mn;

int main(){
  //freopen("input.txt", "r", stdin);
	scanf("%d",&n);

	for (int i = 0; i < n; ++i){
		scanf("%d",&a[i]);
		freq[a[i]]++;
		if(mn.find(a[i]) == mn.end())
			mn[a[i]] = 1e9;
		mn[a[i]] = min(mn[a[i]],i*1ll);
		all.push_back(a[i]);
	}
	all.push_back(0);
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end()) - all.begin());
	reverse(all.begin(),all.end());
	for (int i = 0; i + 1 < all.size(); ++i){
		ans[mn[all[i]]] += 1ll * freq[all[i]] * (all[i]-all[i+1]); 
		freq[all[i + 1]] += freq[all[i]];
		mn[all[i+1]] = min(mn[all[i+1]],mn[all[i]]);
	}
	for (int i = 0 ; i < n; ++i){
		printf("%lld\n", ans[i]);
	}
    return 0;
}

Measured memory_bytes: 16116
k,n = map(int, input().split())
L = list(map(int, input().split()))
c=[]
for i in range(n-1):
	p=L[i+1]-L[i]
	c.append(p)

e=k-L[n-1]+L[0]
c.append(e)

print(k-max(c))

Measured memory_bytes: 26420
a, b, c, d, e, f = map(int, input().split())
S = list(input())
i = 0
number1 = a
number2 = b
number3 = c
number4 = d
number5 = e
number6 = f

while i < len(S) :
    if S[i] == "N" :
        number1 = b
        number2 = f
        number3 = c
        number4 = d
        number5 = a
        number6 = e
    elif S[i] == "S" :
        number1 = e
        number2 = a
        number3 = c
        number4 = d
        number5 = f
        number6 = b
    elif S[i] == "E" :
        number1 = d
        number2 = b
        number3 = a
        number4 = f
        number5 = e
        number6 = c
    elif S[i] == "W" :
        number1 = c
        number2 = b
        number3 = f
        number4 = a
        number5 = e
        number6 = d
    a = number1
    b = number2
    c = number3
    d = number4
    e = number5
    f = number6
    i = i + 1
print(number1)


Measured memory_bytes: 5600
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
using namespace std;
typedef long long int ll;

int main(){

	typedef pair<int, int> P;
	int n, a[100], b[100], c[100], d[100], ans=0;
	bool flag[100];
	P red[100], blue[100];
	for(int i=0; i<100; i++){
		flag[i]=true;
	}
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		red[i]=P(a[i], b[i]);
	}
	for(int i=0; i<n; i++){
		cin >> c[i] >> d[i];
		blue[i]=P(c[i], d[i]);
	}

	sort(red, red+n);
	reverse(red, red+n);
	for(int i=0; i<n; i++){
		ll min_d=LLONG_MAX, min_j;
		for(int j=0; j<n; j++){
			if(red[i].first<c[j] && red[i].second<d[j] && d[j]<min_d){
				min_d=d[j];
				min_j=j;
			}
		}
		if(min_d!=LLONG_MAX){
			ans++;
			c[min_j]=-1;
		}
	}
	cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define endl		'\n'
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,l=2,t=0,k=1,x,ans=0,s,f,m;
int main()
{   ios
    cin>>x>>f>>m;
    if(abs(f-x)<=abs(m-x)) cout<<"A";
    else cout<<"B";

	return 0;
}


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

public class Main {

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

        int N = sc.nextInt(); // 参加者数
        int K = sc.nextInt(); // 初期ポイント
        int Q = sc.nextInt(); // 問題数
        int[] points = new int[N];

        Arrays.fill(points, K-Q);
        
        for(int i=0; i<Q; i++) {
            points[sc.nextInt()-1]++;
        }
        
        for(int point:points) {
            if(point >0 ) {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }
    }

}


Measured memory_bytes: 57440
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var num_AB = Console.ReadLine().Split(' '); //.Select(i => double.Parse(i)).ToArray();

            var str_bb = num_AB[1].Split('.');
            var str_B = str_bb[0] + str_bb[1];

            var A = ulong.Parse(num_AB[0]);
            var B = ulong.Parse(str_B);

            var num_P = (A * B) / 100;

            Console.WriteLine(num_P);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n;
  cin >> n;
  if (__builtin_popcount(n) == 1) {
    cout << "No" << nl;
    return 0;
  }
  cout << "Yes" << nl;
  bool even = (n % 2 == 0);
  int rt = n+1;
  for (int i = 1; i <= 2; i++) {
    cout << i << " " << i+1 << nl;
  }
  cout << "3 " << n+1 << nl;
  for (int i = n+1; i <= n+2; i++) {
    cout << i << " " << i+1 << nl;
  }
  for (int nx = 5; nx <= n; nx+=2) {
    cout << rt << " " << nx << nl;
    cout << nx << " " << nx-1 << nl;
    cout << rt << " " << nx+n-1 << nl;
    cout << nx+n-1 << " " << nx+n << nl;
  }
  if (even) {
    cout << n << " " << n-1 << nl;
    int search = n^1^(n-1);
    cout << search+n << " " << n+n << nl;
  }
  
  return 0;
}



Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <limits>

using ll = long long;
using namespace std;
int gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}
int main(){
    ll n,p;
    cin >> n >> p;
    bool h=true;
    for(int i=0;i<n;i++){
        int x;cin >> x;
        if(x%2==1){
            h=false;
            break;
        }
    }
    cout<<setprecision(100);
    if(h){
        if(p==1){
            cout<<0<<endl;
        }else{
            cout<<pow(2,n)<<endl;
        }
        return 0;
    }
    cout<<pow(2,n-1)<<endl;
}

Measured memory_bytes: 512
n = int(input())
l = len(str(n))
res = 0
if l%2 != 0 :
    res = n+1-10**(l-1)
    while l >= 1:
        l -= 2
        res += 10**(l-1)*9
if l%2 == 0:
    l -= 1
    while l >= 1:
        res += 10**(l-1)*9
        l -= 2
print(int(res)) 

Measured memory_bytes: 3060
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmax(T &a, const T b) { return a < b && (a = b, true); }
template<class T>
inline bool chmin(T &a, const T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<string> S(N);
	for (int i = 0; i < N; i++) cin >> S[i];

	vector<pair<int, int>> l, r;
	for (int i = 0; i < N; i++) {
		int sum = 0, m = 0;;
		for (const auto &c : S[i]) {
			sum += (c == '(') - (c == ')');
			chmin(m, sum);
		}
		if (sum > 0) l.emplace_back(m, sum);
		else r.emplace_back(m - sum, -sum);
	}

	sort(l.begin(), l.end(), greater<>());
	sort(r.begin(), r.end(), greater<>());
	DMP(l, r);

	auto check = [](auto &vec) {
		int sum = 0;
		for (int i = 0; i < vec.size(); i++) {
			if (sum + vec[i].first < 0) return -1;
			sum += vec[i].second;
		}
		return sum;
	};

	if (int res = check(l); res != -1 && res == check(r)) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 42548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			int change = 1000 - n;
			
			int coin = 0;
			
			int[] coins = {500,100,50,10,5,1};
			for(int i = 0; i < coins.length ; i++){
				coin += change / coins[i];
				change %= coins[i];
			}
			
			System.out.println(coin);
		}
	}

}

Measured memory_bytes: 24004
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;//料理の種類
int x;
int sum;
bool prime[1000001];
int main()
{

  for(int i = 0;i <1000001;i++){
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for(int i = 2;i <1000001;i++){
    if(prime[i]){
      for(int j = 2*i;j <1000001;j+=i){
	prime[j]= false;
      }
    }
  }
  while(cin>>n>>x,n||x){
    bool flag1=false;
    int dish[40];
    bool check[1000001];
    for(int i = 0;i < 1000001;i++){
      check[i]=false;
    }
    for(int i = 0;i < n;i++){
      cin>>dish[i];
    }
    check[0] =true;//0はどの料理からでも作れる
    for(int i = 0;i <=x;i++){
      if(check[i]){
	for(int j = 0;j <n;j++){
	  if(i + dish[j]<=x)
	    check[i+dish[j]] = true;
	}
      }
    }
    int ans = 0;

    for(int i =x;i >0;i--){//上から調べる
      if(check[i]&&prime[i]){
	flag1 = true;
	ans = i;
	break;
      }
    }
 for(int i = 0 ;i < 1000000;i++){
     x +=1;
     x -=1;
}
    if(flag1)
      cout <<ans<<endl;
    else
      cout <<"NA"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int n,m,c=0;
	cin>>n>>m;
	//std::vector<long int,long int > left,right ;
	long int left=INT_MIN,right=INT_MAX;
	//unordered_map<long int> hash;
	while(n--)
	{
	    long int l,r;
	    cin>>l>>r;
	    if(left<l)
	    {
	        left=l;
	    }
	    if(right>r)
	    {
	        right=r;
	    }
	   /* for(long int i=l;i<=r;i++)
	    {
	        hash[i]++;
	    }*/
	}
//	cout<<right<<" "<<left<<endl;
    if((right-left+1)<0)
    cout<<"0";
    else
	cout<<right-left+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a,b;
  cin >> a >> b;
  int A=a.size();
  int B=b.size();
  if(A>B) cout << "GREATER" << endl;
  else if(A<B) cout << "LESS" << endl;
  else {
    if(a>b) cout << "GREATER" << endl;
    else if(a<b) cout << "LESS" << endl;
    else cout << "EQUAL"<< endl;
    


  }
  return 0;
    

}


Measured memory_bytes: 256
#include<stdio.h>

#define N 10000

int main()
{
				int a[N] = {0};
				int i,j,k;
				int count = 0;
				i = 0;

				while(1){
								scanf("%d",&a[i]);
								count++;
								if(a[i] == 0)
												break;
								i++;
				}

				for(i=0;i<count-1;i++){
								printf("Case %d: %d\n",i+1,a[i]);
				}

				return 0;
}


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


int A[200000];

int main() {

        int N, max_temp = 0; long long  sum = 0;

        cin >> N;

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


                cin >> A[i];

        }


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

        if ( max_temp < A[i] ){

                max_temp = A[i];

                }
        else if ( max_temp >= A[i]) {

                sum += max_temp - A[i];

        }
        }


        cout << sum;

        return 0;


}

Measured memory_bytes: 4348
import sys
import itertools

S = input()
if len(S) == 1:
    print(int(S))
    sys.exit()

ls = []
a = [0, 1]
for i in itertools.product(a, repeat=len(S)-1):
    ans = 0
    start = 0
    for j, x in enumerate(i):
        if x == 1:
            ans += int(S[start:j+1])
            start = j + 1
    ans += int(S[start:len(S)])
    ls.append(ans)
print(sum(ls))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size();
  REP(i, n){
    string tmp = s.substr(i, n - i) + s.substr(0, i);
    if(tmp == t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,m,k,a,i,j,count[10000000],ans;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        count[i]=0;
    }
    for(i=0;i<n;i++){
        scanf("%d",&k);
        for(j=0;j<k;j++){
            scanf("%d",&a);
            count[a-1]++;
        }
    }
    for(i=0;i<m;i++){
        if(count[i]==n){
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=200010,INF=2e9+1;
const long long inf=2e10+1;
struct point{
	int x,y;
	point(int _x=0,int _y=0):x(_x),y(_y){};
	bool operator <(const point&A)const{
		return x==A.x?y<A.y:x<A.x;	
	}
}P[N],A[N],B[N];
int n,tot1,tot2,ans;
long long Ans=inf;
char s[N][10];
void solve(){
	A[tot1+1].x=B[tot2+1].x=INF;
	sort(A+1,A+tot1+1);sort(B+1,B+tot2+1);
	for(int i=1;i<=tot1;++i){
		point tmp=*lower_bound(B+1,B+tot2+1,A[i]);
		if(A[i].x==tmp.x)ans = min(ans , tmp.y-A[i].y);
	}
	tot1=tot2=0;
}
int main(){
//	freopen("F.in","r",stdin);
//	freopen("F.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d%d%s",&P[i].x,&P[i].y,s[i]);
	
	ans=INF;
	for(int i=1;i<=n;++i)if(s[i][0]=='R')A[++tot1]=point(P[i].y,P[i].x);
	else if(s[i][0]=='L')B[++tot2]=point(P[i].y,P[i].x);
	solve();
	for(int i=1;i<=n;++i)if(s[i][0]=='U')A[++tot1]=point(P[i].x,P[i].y);
	else if(s[i][0]=='D')B[++tot2]=point(P[i].x,P[i].y);
	solve();
	if(ans!=INF)Ans=5ll*ans,ans=INF;
	
	for(int i=1;i<=n;++i)if(s[i][0]=='R')A[++tot1]=point(P[i].x-P[i].y,P[i].x);
	else if(s[i][0]=='D')B[++tot2]=point(P[i].x-P[i].y,P[i].x);
	solve();
	for(int i=1;i<=n;++i)if(s[i][0]=='D')A[++tot1]=point(P[i].x+P[i].y,P[i].x);
	else if(s[i][0]=='L')B[++tot2]=point(P[i].x+P[i].y,P[i].x);
	solve();
	for(int i=1;i<=n;++i)if(s[i][0]=='R')A[++tot1]=point(P[i].x+P[i].y,P[i].x);
	else if(s[i][0]=='U')B[++tot2]=point(P[i].x+P[i].y,P[i].x);
	solve();
	for(int i=1;i<=n;++i)if(s[i][0]=='U')A[++tot1]=point(P[i].x-P[i].y,P[i].x);
	else if(s[i][0]=='L')B[++tot2]=point(P[i].x-P[i].y,P[i].x);
	solve();
	if(ans!=INF)Ans=min(Ans,10ll*ans);
	
	if(Ans==inf)cout<<"SAFE"<<endl;
	else cout<<Ans<<endl;
	return 0;
}


Measured memory_bytes: 10396
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    auto t = sread();
    auto dif = max(s.length - t.length, 0);
    foreach_reverse (i; 0 .. dif + 1)
    {
        auto parts = s[i .. t.length + i];
        if (parts.is_match(t))
        {
            ans_write(s, t, i);
            return;
        }
    }
    writeln("UNRESTORABLE");
}

bool is_match(T)(T a, T b)
{
    foreach (i, e; a)
    {
        if (!(e == b[i] || e == '?'))
            return false;
    }
    return true;
}

void ans_write(string s, string t, long p)
{
    auto s_before = s[0 .. p];
    auto s_after = s[p + t.length .. $];
    foreach (e; s_before ~ t ~ s_after)
    {
        if(e == '?')
            write('a');
        else
            e.write();
    }
    writeln();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
using ll = long long;


vector<set<int>> group;
vector<int> g_num;
vector<vector<int>> fri;
vector<vector<int>> blo;

void func(int p, int gn){
    for(auto f: fri[p]){
        if(g_num[f] == -1){
            group[gn].insert(f);
            g_num[f] = gn;
            func(f, gn);
        }
    }
}

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    g_num.resize(n, -1);
    fri.resize(n);
    blo.resize(n);
    vector<int> a(m);
    vector<int> b(m);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        fri[a[i] - 1].push_back(b[i] - 1);
        fri[b[i] - 1].push_back(a[i] - 1);
    }
    vector<int> c(k);
    vector<int> d(k);
    for(int i = 0; i < k; i++){
        cin >> c[i] >> d[i];
        blo[c[i] - 1].push_back(d[i] - 1);
        blo[d[i] - 1].push_back(c[i] - 1);
    }
    for(int i = 0; i < n; i++) {
        if(g_num[i] == -1){
            set<int> tmp{i};
            group.push_back(tmp);
            g_num[i] = group.size() - 1;
            func(i, g_num[i]);
        }
    }
    for(int i = 0; i < n; i++){
        int ans = group[g_num[i]].size() - fri[i].size() - 1;
        for(int bp:blo[i]){
            if(group[g_num[i]].count(bp) == 1) ans--;
        }
        cout<< ans << ' ';
    }
}

Measured memory_bytes: 20024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W, K;
  cin >> H >> W >> K;
  ll b_cnt = 0;
  vector<vector<char>> MAP(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> MAP[i][j];
      if (MAP[i][j] == '#') b_cnt++;
    }
  }
  ll ans = 0;
  for (int bit1 = 0; bit1 < (1 << H); bit1++) {
    for (int bit2 = 0; bit2 < (1 << W); bit2++) {
      auto c = MAP;
      for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
          if (bit1 & (1 << h) || bit2 & (1 << w)) c[h][w] = 'R';
        }
      }
      ll cnt = 0;
      for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
          if (c[h][w] == '#') cnt++;
        }
      }
      if (cnt == K) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
import java.util.*;
	class Main{
		public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			int[][] a = new int[3][3];
			for (int i = 0; i < 3; i++)
				for (int j = 0; j < 3; j++)
					a[i][j] = sc.nextInt();
			int n = sc.nextInt();
			Set<Integer> set = new HashSet<>();
			for (int i = 0; i < n; i++)
				set.add(sc.nextInt());
			int count = 0, countr = 0, countd = 0;
			for (int i = 0; i < 3; i++){
				count = 0;
				for (int j = 0; j < 3; j++){
					//~ System.out.println(a[i] + " 2 " );
					if(set.contains(a[i][j])){
						count++;
						//~ System.out.println(a[i][j] + " 1 ");
					} 
					if(i == j){
							if (set.contains(a[i][j])){
									countd++;
									//~ System.out.println(a[i][j] + " 2 " );
						}
					}
				}
				countr = Math.max(count, countr);
			}
			int countc = 0;
				for (int i = 0; i < 3; i++){
				count = 0;
				for (int j = 0; j < 3; j++){
					if(set.contains(a[j][i]) ){
						count++;
					}
				}
				countc = Math.max(countc, count);
				} 
				
				int countdd = 0;
			if(set.contains(a[0][2]))
				countdd++;
			if(set.contains(a[1][1]))
				countdd++;
			if(set.contains(a[2][0]))
				countdd++;
				
			if(countc == 3 || countr == 3 | countd == 3 || countdd == 3)
				System.out.println("Yes");
			else 
				System.out.println("No");
		}
	}


Measured memory_bytes: 23124
#include<stdio.h>
int n,m,r,t,i,j,k,a[100][100],b[100][100];
 int main(){
    long c;
    scanf("%d%d%d",&n,&m,&r);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            scanf("%d",&a[i][j]);
    for(i=0;i<m;i++)
        for(j=0;j<r;j++)
            scanf("%d",&b[i][j]);
    for(i=0;i<n;i++)
        for(j=0;j<r;j++){
            for(k=c=0;k<m;k++){
                c+=a[i][k]*b[k][j];
            }
            printf("%ld%s",c,j==r-1?"\n":" ");
        }
}



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

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0);

    string N; cin >> N;
    bool has = false;
    for (int i = 0; i < N.length(); i++) {
        if (N.at(i) == '7'){
            has = true;
            break;
        }
    }

    cout << ((has)? "Yes":"No");

}

Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

//----------------------------------------



int main(void)
{
	int n;

	cin >> n;


	vector<int> kazu(n);

	rep(i, n) cin >> kazu[i];
	int ans = 0;

	for (int i = 1; i < n - 1; i++)
	{
		if (kazu[i] > kazu[i - 1] && kazu[i] < kazu[i + 1]) ans++;
		if (kazu[i] < kazu[i - 1] && kazu[i] > kazu[i + 1]) ans++;

	}

	cout << ans << endl;
}

Measured memory_bytes: 256
x = int(input())


def is_prime(n, i=2):
    #if (n == 2):
    #    return True
    #elif (n % i == 0):
    if (n % i == 0):
        return False
    elif (i * i > n):
        return True

    return is_prime(n, i + 1)

if x > 3:
    while(is_prime(x) == False):
        x += 1

print(x)

Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := 0
	mx := 0

	for i := 0; i < n; i++ {
		var p int
		fmt.Scan(&p)

		ans += p
		if p > mx {
			mx = p
		}
	}
	ans -= mx / 2
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>

using namespace std;
using Int = long long;

Int INF = 1LL << 60;

int main() {
	Int D, G;
	cin >> D >> G;

	vector<Int> p(D);
	vector<Int> c(D);

	for (Int i = 0; i < D; i++)cin >> p[i] >> c[i];
	
	Int ans = INF;
	for (Int bit = 0; bit < (1LL << D); bit++) {
		Int sum = 0;
		Int num = 0;

		for (Int i = 0; i < D; i++) {
			if (bit & (1LL << i)) {
				sum += p[i] * 100 * (i + 1) + c[i];
				num += p[i];
			}
		}

		if (sum >= G)ans = min(ans, num);
		else {
			for (Int i = D - 1; i >= 0; i--) {
				if (bit & (1LL << i))continue;
				for (Int j = 0; j < p[i]; j++) {
					if (sum >= G)break;
					sum += 100 * (i + 1);
					num++;
				}
			}
			ans = min(ans, num);
		}

	}

	cout << ans << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

mod=10**9+7

A.sort(reverse=True)
B.sort(reverse=True)

nind=0
mind=0
#nused=0
#mused=0
used=0
ANS=1
for innum in range(N*M,0,-1):
    if nind<N and mind<M and A[nind]==B[mind]==innum:
        nind+=1
        mind+=1
        #nused=1
        #mused=1
        used+=1

    elif nind<N and A[nind]==innum and (mind==M or B[mind]<innum ):
        ANS=ANS*(mind)%mod
        nind+=1
        used+=1

    elif mind<M and B[mind]==innum and (nind==N or A[nind]<innum):
        ANS=ANS*(nind)%mod
        mind+=1
        used+=1

    elif (nind==N or A[nind]<innum) and (mind==M or B[mind]<innum):
        ANS=ANS*(nind*mind-used)%mod
        used+=1
    else:
        ANS=0

    #print(innum,ANS)

print(ANS)

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

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; }
const long long LINF = 1e18;

int main()
{
  int N, K; cin >> N >> K;
  ll h[100000];
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }

  ll dp[100000];
  for (int i = 0; i < 100000; ++i) {
    dp[i] = LINF;
  }

  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K && i+j < N; ++j) {
      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }

  cout << dp[N-1] << endl;
}

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

int main() {
	ll d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int dd = 0;
		for(int i=0; i<n;i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if ( d1 == d2 ) {
				dd++;
				if(dd>=3) {
					System.out.println("Yes");
					System.exit(0);
				}
			}else{
				dd=0;
			}
		}
		System.out.println("No");

	}
	
}


Measured memory_bytes: 36024
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
l o=0,ans=1;
bool ok=0,w[5000005];
int main()
{
	l n,k;
	cin>>n>>k;
	if(n==1)
	{
		cout<<k<<endl;
		return 0;
	}
	for(int i=2;ok==0;i++)
	{
		if(i*i>k)
			break;
		if(w[i]==1)
			continue;
		o=1;
		for(int c=0;c<n;c++)
		{
			o=o*i;
			if(o>k)
			{
				ok=1;
				break;
			}
		}
		if(k%o==0)
			ans=i;
		else
			for(l d=i;d<5000005;d+=i)
				w[d]=1;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;

#define FILENAME ""
               
int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //	freopen(FILENAME ".in", "r", stdin);
    //	freopen(FILENAME ".out", "w", stdout);
   	ll n;
   	cin >>n ;
   	vector <pair<ll, ll>> a;
   	for (int i = 0; i < n; i++) {
   	 	ll x, y;
   	 	cin >> x >> y;
   	 	a.pb(mp(y, x));
   	}
   	sort(all(a));
   	ll sum = 0;
   	for (int i = 0; i < n; i++) {
   	 	sum += a[i].se;
   	 	if (sum > a[i].fi) {
   	 	 	re cout << "No", 0;
   	 	}
   	}
   	cout << "Yes";
    return 0;
}

Measured memory_bytes: 6512
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int N;
	cin>>N;
	int *A = new int[N];
	for(int i = 0; i < N; i++){
		A[i] = 0;
	}
	for(int i = 0; i < N-1; i++){
		int num;
		cin>>num;
		A[num-1]++;
	}
	for(int i = 0; i < N; i++){
		cout<<A[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 4420
import bisect
n, k, c = map(int, input().split())
s = input()
a = []
for i in range(n):
    if s[i] == 'o':
        a.append(i+1)

m = len(a)
l = [0 for _ in range(m)]
r = [0 for _ in range(m)]

cur = 0
l[0] = a[0]
while True:
    to = bisect.bisect_left(a, a[cur] + c + 1)
    if to == m:
        break
    l[to] = l[cur] + 1
    cur = to

for i in range(m-1):
    if l[i] > l[i+1]:
        l[i+1] = l[i]

#print(l)

r[m-1] = 1
cur = m-1
while True:
    to = bisect.bisect_left(a, a[cur] - c) - 1
    if to == -1:
        break
    r[to] = r[cur] + 1
    cur = to

for i in range(m-1):
    x = m - 2 - i
    if r[x] < r[x+1]:
        r[x] = r[x+1]

#print(r)
l = [0] + l
r = [r[0]] + r + [0]

for i in range(1, m+1):
    if l[i-1] + r[i+1] < k:
        print(a[i-1])

Measured memory_bytes: 59768
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

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

  int H, W, N;
  cin >> H >> W >> N;
  int M = max(H,W);
  cout << (N+M-1)/M << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main (int, char**) {
    int N;
    float M;
  	std::cin >> N >> M;
    float sum = 0;
    float A[N];

    for (int i=0; i<N; i++) {
        std::cin >> A[i];
        sum += A[i];
    }

    float min = sum / (4 * M);
    float count = 0;
    for (int i=0; i<N; i++) {
        if (A[i] >= min) {
            count = count + 1;
        } else {
            continue;
        }
        if (count >= M) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll ns, mc;
    cin >> ns >> mc;
    ll nss = ns * 2;
    ll ans = min(nss, mc) / 2;
    ns -= ans;
    mc -= ans * 2;
    cout << ans + mc / 4;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal X = sc.nextBigDecimal();
        BigDecimal a = new BigDecimal("100");
        BigDecimal b = new BigDecimal("1.01");
        int i = 0;
        while (true) {
          a = a.multiply(b);
          a = a.setScale(0,BigDecimal.ROUND_DOWN);
          i++;
          if (a.compareTo(X) >= 0) {
            System.out.println(i);
            break;
            }
        }
	}
}

Measured memory_bytes: 37876
#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;
vi G[200100];
int ans = 0;
int check[200100];
int main() {
  map<P,int> mp;
  int n;
  cin >> n;
  vi a(n-1),b(n-1);
  rep(i, n - 1) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    a[i] = x;
    b[i] = y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  queue<P> q;
  q.push(make_pair(0, -1));
  while (!q.empty()) {
    P p = q.front();
    q.pop();
    int u = p.first;
    check[u] = 1;
    int c = p.second;
    int now = 0;
    for (auto v : G[u]) {
      if (check[v])
        continue;
      if (now == c)
        now++;
      q.push(make_pair(v, now));
      mp[make_pair(u,v)] = now;
      maxs(ans, now);
      now++;
    }
  }
  cout << min(n-1,ans+1) << endl;
  rep(i,n-1){
    cout<<mp[make_pair(a[i],b[i])]+1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 18540