akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

ll power(ll p, ll q) {
  ll ans = 1;
  for (int i = 0; i < q; i++) {
    ans *= p;
  }
  return ans;
}

ll combi(ll n, ll r) {
  if (r == 0) return 1;
  if (r == n) return 1;
  return combi(n-1, r-1) + combi(n-1, r);
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, P; cin >> N >> P;
  int even = 0;
  int odd = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a % 2 == 0) even++;
    else odd++;
  }
  if (P == 0) {
    ll e = power(2, even);
    ll o = 0;
    for (int i = 0; i <= odd; i+= 2) {
      o += combi(odd, i);
    }
    cout << e * o << endl;
  }else {
    ll e = power(2, even);
    ll o = 0;
    for (int i = 1; i <= odd; i+= 2) {
      o += combi(odd, i);
    }
    cout << e * o << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
llong h,w;
int main(){ _;
  cin>>h>>w;
  vector< vector<char> > a(h,vector<char>(w));
  REP(i,h) REP(j,w) cin>>a[i][j];
  string ss(w+2,'#');
  cout<<ss<<endl;
  REP(i,h){
    cout<<'#';
    REP(j,w)
      cout<<a[i][j];
    cout<<'#'<<endl;
  }
  cout<<ss<<endl;

  return 0;
}


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

using namespace std;
bool f(int a) {
	bool F = 1;
	for (int i = 2;i < sqrt(a*1.0)+1;i++) {
		if (a%i == 0 && a != 2)F = 0;
	}
	return F;
};

int main() {
	int n, x = 0;
	int a[10000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0;i < n;i++) {
		if (f(a[i])) x++;
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 3092
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(input())

B = []
for i in range(M):
    B.append(input())

ans = 'No'

for i in range(N-M+1):
    for j in range(N-M+1):
        flg = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flg = False
                    break
        if flg:
            ans = 'Yes'
            break
print(ans)


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

int main() {
	int h,a;
	cin >> h >> a;
	vector<int> v(a);
	int sum =0;
	for(int i=0;i<a;i++){
		cin >> v.at(i);
		sum = sum + v.at(i);
	}
	if(sum >= h){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 640
gets
array = gets.split.map(&:to_i)

max = 0
count = 0

array.each_with_index do |arr, i|
  if i == 0
    max = arr
  else
    if max > arr
      count += (max - arr)
    elsif max < arr
      max = arr
    end
  end
end

puts count


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

bool is_prime(int x){
        if (x <= 1) return false;
        for (int q = 2; q*q <= x; ++q){
            if (x % q == 0) return false;
        }
    return true;
}

int main(){
        int n; cin >> n;
        while (!is_prime(n)) n++;
        cout << n << endl;
    return 0;
}


Measured memory_bytes: 3612
n = int(input())
for _ in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    if abs((x2-x1)*(y4-y3)-(x4-x3)*(y2-y1)) <= 10**(-10): print("YES")
    else: print("NO")


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

int main()
{
	int N;
	cin >> N;
	vector<pair<int, int>> all;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		all.emplace_back(A, i);
	}
	sort(all.begin(), all.end());
	for (int i = 0; i < N; i++) {
		printf("%d%c", all[i].second + 1, " \n"[i + 1 == N]);
	}
	return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;
 
#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
 
typedef long long ll;
typedef long long int lli;
 
int main() {
    int A, B, C, times;
    string S; 
    cin >> A >> B >> C;
    times = 0;
    times = B / A;
    if (times > C) {
        cout << C << endl;
    } else {
        cout << times << endl;
    }
    
	return 0;
}

Measured memory_bytes: 256
N,K,Q=map(int,input().split())
ans=[K for i in range(N)]
ans=list(map(lambda x:x-Q,ans))
for i in range(Q):
  A=int(input())
  ans[A-1]=ans[A-1]+1
for i in range(N):
  if ans[i]>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 52144
def dfs(array: list, index: int, calc: str, result: int):
    if index == len(array):
        if result == 7:
            return "{}=7".format(calc)
        else:
            return ""

    if index == 0:
        return dfs(array, index + 1, array[index], int(array[index]))
    elif index < len(array):
        return dfs(array, index + 1, calc + "-" + array[index], result - int(array[index])) + dfs(array, index + 1, calc + "+" + array[index], result + int(array[index]))

array = list(input())
S = dfs(array, 0, "", 0)
print(S[:9])


Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

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

    int lb = 0, ub = n;
    rep(i, n)
    {
        ub = min(ub, a[i] + 1);
        lb = max(lb, a[i]);
    }
    //cout << "lb, ub= " << lb << " " << ub << endl;

    for (int i = lb; i <= ub; i++)
    {
        int x = 0, y = 0;
        rep(j, n)
        {
            if (a[j] == i - 1)
            {
                x++;
            }
            if (a[j] == i)
            {
                y++;
            }
        }
        if (x + y != n)
        {
            continue;
        }

        int w = i - x;
        int z = (n - x) / 2;

        //cout << "i=" << i << " x=" << x << " y=" << y << " z=" << z << endl;
        if (w >= 0)
        {
            if (y == 0 || (i - x >= 1 && i - x <= z))
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

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

int n;
int xs[112345];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &xs[i]);
  }

  long res = 0;
  for(int i = 0; i < n; ++i) {
    res += xs[i] / 2;
    xs[i] %= 2;
    if( xs[i] == 1 and xs[i+1] > 0 ) {
      res += 1;
      xs[i] = 0;
      xs[i + 1] -= 1;
    }        
  }

  printf("%ld\n", res);
  
  return 0;
}



Measured memory_bytes: 640
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
l=permutations(range(n),n)
dis=[]
d=[list(map(int,input().split())) for _ in range(n)]
now=0
for i in l:
    #print(i)
    for j in range(n-1):
        now+=hypot((d[i[j]][0]-d[i[j+1]][0]),(d[i[j]][1]-d[i[j+1]][1]))
        #print(now)
print(now/factorial(n))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define lld long long
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s; cin>>s;
    int n=s.length();
    int flag=0;
    if(n%2)flag=1;
    for(int i=0;i<n;i+=2)
    {
    	if(s[i]=='h'&&s[i+1]=='i')continue;
    	else flag=1;
    }
    if(flag)cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = sum(a)
card = []
for i in range(m):
    b,c = map(int,input().split())
    card.append([b,c])

card.sort(key = lambda x: x[1])
card.reverse()
mini = a[0]
i = 0
now = 0 #aの参照インデックス
plus = 0
while i < m and mini < card[i][1]:
    while card[i][0] > 0 and now < n and card[i][1] > a[now]:
        plus += card[i][1]-a[now]
        card[i][0] -= 1
        now += 1
    if now == n:
        now -= 1
        if card[i][1] < a[now]:
            mini = card[i][1]
        else:
            mini = a[now]
        break
    else:
        if card[i][1] < a[now]:
            mini = card[i][1]
        else:
            mini = a[now]
    i += 1
print(ans+plus)

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

#define DIV 1000000007

long long N, K;
long long mini[200005];
long long maxi[200005];

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


	for(long long i = 0; i < N+1; i++) {
		mini[i+1] = i + mini[i];
		mini[i+1]%=DIV;
	}

	for(long long i = 0; i < N+1; i++) {
		maxi[i+1] = (N - i) + maxi[i];
		maxi[i+1]%=DIV;
	}



	long long ans = 0;
	for(long long num = K; num <= N+1; num++) {
		ans += maxi[num] - mini[num] + 1;
		ans = (ans + DIV)%DIV;

	}
	cout << ans << endl;
}


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

int main(){
  ll n, m;
  cin >> n >> m;
  
  if(n >= m){
    cout << 0 << endl;
    return 0;
  }
  
  vector<ll> x(m);
  for(ll i=0; i < m; i++){
    cin >> x[i];
  }
  
  sort(x.begin(), x.end());
  
  vector<ll> diff(m-1);
  for(ll i=0; i<m; i++){
    diff[i] = x[i+1] - x[i];
  }
  
  sort(diff.begin(), diff.end());
    
  vector<ll> accum(m);
  accum[0] = diff[0];
  for(ll i=1; i<m; i++){
    accum[i] = accum[i-1] + diff[i];
  }
  
  cout << accum[m-n-1] << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long h;
int main(void)
{
	scanf("%lld",&h);
	long long tw=0;
	while(h>0)
	{
		h/=2;
		tw++;
	}
	long long sum=1;
	for(long long i=0;i<tw;i++)
	{
		sum*=2;
	}
//	printf("%lld",tw);
	if(h==1)
	{
		printf("1");
	}
	else
	{
		printf("%lld",sum-1);
	}
}

Measured memory_bytes: 256
#include <cstdio>
long long mod = 1000000007;
long long big(long long b, long long p){
	if (p == 1) return b;
	long long h = big(b, p / 2);
	long long res = (h * h) % mod;
	if (p % 2 == 1) res = (res * b) % mod;
	return res;
}
int main(){
	long long n, k;
	scanf("%lld %lld", &n, &k);
	long long a[n];
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	long long ans = 0;
	for (int i = 0; i < n; i++){
		long long e = 0, f = 0, g = 0, h = 0;
		for (int j = 0; j < n; j++){
			if (a[j] > a[i]){
				if (j < i) e++;
				f++;
			}else if (a[j] < a[i]){
				if (i < j) g++;
				h++;
			}
		}
		ans += (((((f + h) * k) % mod) * (k - 1) % mod) * big(2, mod - 2)) + ((e + g) * k) % mod;
		ans %= mod;
	}
	printf("%lld\n", (ans * big(2, mod - 2)) % mod);
}

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

int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		ll a, b, c, k;
		cin >> a >> b >> c >> k;
		ll sum = 0;
		sum += min(a, k);
		k -= sum;
		if(k > 0){
			k-=min(b, k);
		}
		if(k>0){
			sum-=min(k,c);
		}
		cout << sum;
	}
	return 0;
}

Measured memory_bytes: 3596
import numpy as np
row = list(map(int, input().split()))
row2 = [input().split() for i in range(row[0])]
f = np.vectorize(int)
p = f(row2)
ans = 10*100
for bit in range(1<<row[0]):
    sum = 0
    max_rest = 0
    num = 0
    for i in range(row[0]):
        if bit & (1<<i):
            
            sum += 100*(i+1) * p[i][0] + p[i][1]
            num += p[i][0]
        else:
            max_rest = i
    for j in range(p[max_rest][0]):
        if sum < row[1]:
            sum += 100*(max_rest+1)
            num += 1
        else:
            if num < ans:
                ans = num
            break
    
print(ans)
    


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

int main() {
    int X;
    cin >> X;
    vector<bool>ok(X+1);
    ok[1] = 1;
    for(int i = 2; i*i <= X; i++) {
        ok[i*i] = 1;
        int cnt = i*i*i;
        while(cnt <= X) {
            ok[cnt] = 1;
            cnt *= i;
        }
    }
    for(int i = X; i >= 1; i--) {
        if(ok[i]) {
            cout << i << endl;
            return 0;
        }
    }
} 


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
now = h[0]
for i in range(1,n):
    if h[i] - now >= 1:
        h[i] -= 1
        now = h[i]
    elif h[i] - now == 0:
        continue
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 63984
#include<stdio.h>

int main(){
    char C;
    int output;
    scanf("%s",&C);
    if(C == 'z'){
        printf("Input alphabet from 'a' to 'y'.");
        return -1;
    }
    output = (int)C + 1;
    printf("%c",(char)output);
    return 0;
}

Measured memory_bytes: 128
H,W=map(int,input().split())

d=[]
memo=[0]*W
for i in range(H):
  row=list(str(input()))
  if '#' in row:
    d.append(row)
  for j in range(W):
    if row[j] == '#':
      memo[j] = 1

for i in range(len(d)):
  for j in range(W):
    if memo[j] == 1:
      print(d[i][j],end='')
  print()


Measured memory_bytes: 4596
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long LL;
const int N=100500,mo=1e9+7;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int Bv[N][2];
int d[N];
LL c[3][3]={{1,1,1},{0,1,2},{1,1,2}};
LL c1[3][3],a[3];
void CHEN()
{
	fo(i,0,2)fo(j,0,2)fo(k,0,2)c1[i][k]=(c1[i][k]+c[i][j]*c[j][k])%mo;
	fo(i,0,2)fo(j,0,2)c[i][j]=c1[i][j],c1[i][j]=0;
}
void CHEN1()
{
	fo(i,0,2)fo(j,0,2)c1[0][i]=(c1[0][i]+a[j]*c[j][i])%mo;
	fo(i,0,2)a[i]=c1[0][i],c1[0][i]=0;
}
void ksm(int w)
{
	c[0][0]=1,c[0][1]=1,c[0][2]=1;c[1][0]=0,c[1][1]=1,c[1][2]=2;
	c[2][0]=1,c[2][1]=1,c[2][2]=2;
	for(;w;w>>=1,CHEN())if(w&1)CHEN1(); 
}
int main()
{
	int q,w;
	read(n),read(m);
	fo(i,1,m)read(d[i]);
	d[0]=-1;
	a[0]=1;
	fo(i,1,m)
	{
		ksm(d[i]-d[i-1]-1);
		a[2]=(a[2]+2LL*a[1]+a[0])%mo;
		a[1]=(a[1]+a[0])%mo;
	}
	ksm(n-d[m]-1);
	printf("%lld\n",a[2]);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main
{
	public static void main(String[] args)throws Exception
	{
		Scanner scan=new Scanner(System.in);
		
		while(true)
		{
			int H=scan.nextInt();		
			int W=scan.nextInt();

			if(H==0&&W==0)
			{
				break;				
			}
			else
			{
				for(int i=1;i<=H;i++)
				{	
					if(i==1)
					{
						for(int a=1;a<=W;a++)
						{
							System.out.print("#");
						}
						System.out.println("");
					}
					else if(i==H)
					{
						for(int b=1;b<=W;b++)
						{
							System.out.print("#");
						}
						System.out.println("");
					
					}
					else
					{
						for(int c=1;c<=W;c++)
						{
							if(c==1)
							{
								System.out.print("#");
							}
							else if(c==W)
							{
								System.out.println("#");
							}
							else
							{
								System.out.print(".");
							}	
						}
					}
				}System.out.print("\n");
			
			}
			
		}
		
	}

}

Measured memory_bytes: 34392
n = str(input())
k = int(input())
m = len(n)
dp = [[[0,0] for __ in range(k+2)] for _ in range(m+1)]
dp[0][0][0] = 1
for i in range(m):
    d = int(n[i])
    for j in range(k+1):
        for s in range(2):
            for c in range(10):
                if (not s ) and c>d:
                    continue
                dp[i+1][j+(c!=0)][s or (c<d)] += dp[i][j][s]
print(dp[m][k][0]+dp[m][k][1])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,s;
char c;
int main()
{
	scanf("%d%d",&n,&m);
	fz1(i,n){
		scanf(" ");
		fz1(j,m){
			scanf("%c",&c);
			if(c=='#')s++;
		}
	}
	if(s==n+m-1) puts("Possible"); else puts("Impossible");
	return 0;
} 

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n,m; cin >> n >> m;
    vector<ll> h(n);
    rep(i,0,n) cin >>h[i];
    bool ans[n] = {}; // falseで良い
    rep(i,0,m){
        ll a,b; cin >> a >> b;
        a--;b--;
        if(h[a]>=h[b]) ans[b] = true;
        if(h[b]>=h[a]) ans[a] = true;
    }
    ll cnt = 0;
    rep(i,0,n){
        if(!ans[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k, c;
    cin >> n >> k >> c;

    string s;
    cin >> s;

    vector<int> a[2];
    for (int h = 0; h < 2; h++) {
        a[h] = vector<int>(k);
        int i = 0, l = 0;
        for (;;) {
            while (s[i] != 'o') i++;
            a[h][l++] = i;
            if (l == k) break;
            i += c + 1;
        }
        reverse(s.begin(), s.end());
    }

    reverse(a[1].begin(), a[1].end());
    for (int l = 0; l < k; l++) {
        a[1][l] = n - 1 - a[1][l];
    }

    int l0 = 0, l1 = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != 'o') continue;

        while (l0 < k && a[0][l0] < i) l0++;
        while (l1 < k && a[1][l1] <= i) l1++;
        int r = l0 + (k - l1);
        constexpr int INF = 1 << 29;
        int i0 = l0 == 0 ? -INF : a[0][l0 - 1];
        int i1 = l1 == k ? +INF : a[1][l1];
        if (i1 - i0 <= c) r--;
        if (r < k) cout << i + 1 << '\n';
    }

    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<priority_queue<int>> graph(n, priority_queue<int>());
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push(h[b]);
        graph[b].push(h[a]);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (graph[i].empty()) ans++;
        else if (graph[i].top() < h[i]) ans++;
    }
    cout << ans << endl;
}


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

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

	int S = 1; for (int i = 0; i < D; i++) S *= 100;
	if (N <= 99) {
		cout << S * N << endl;
	}
	else {
		cout << S * 101 << endl;
	}
	return 0;}


Measured memory_bytes: 256
tax_in_eight, tax_in_ten = gets.chomp.split(' ').map(&:to_i)

answer = -1

(1..1000).each do |price|
  if (price * 0.08).truncate == tax_in_eight && (price * 0.1).truncate == tax_in_ten
    answer = price
    break
  end
end

puts answer 


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int x;
  cin >> x;
  
  int i = 1;
  while(true){
    if(x*i%360 == 0)
      break;
    i++;
  }
  
  cout << i << endl;
  
  return 0;
  
}

Measured memory_bytes: 3628
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int N;
	cin >> N;
    
	rep(h,1,3501){
        rep(n,1,3501){
            
            double w = (1.0*h*n*N) / (4*h*n - h*N - n*N);
                
                 
            if(1 <= w && w <= 3500 && w == (ll)w){
                cout << h << " " << n << " " << w << endl;
                ret 0;         
            }           
        }
	}


	return  0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


def solve():
    N, K = LI()
    S = SI()


    point = 0
    for i in range(N):
        if i != 0:
            if S[i] == S[i-1]:
                point += 1

    rest_len = N-point
    # rest_len_aft_k = rest_len - 2*K
    # dprint(rest_len, rest_len_aft_k)
    # if rest_len_aft_k <= 1:
    #     print(N)
    # else:
    print(min(point + 2*K, N-1))

solve()

Measured memory_bytes: 3316
//???1601-2 ????±????(616342287) 12:28:09
#include <iostream>
#include <fstream>
#include <stack>
#include <vector>
#include <cstring>
using namespace std;
int a[11];
int b[11];
int c[11];
int flag;
void dfs(int x,int y,int z)
{
  if(x==10)
  {
    flag=1;
    return;
  }
  if(a[x]<b[y]&&a[x]<c[z])
      return;
  if(a[x]>b[y])
  {
      b[y+1]=a[x];
      dfs(x+1,y+1,z);
      b[y+1]=0; 
  }
  if(a[x]>c[z])
  {
      c[z+1]=a[x];
      dfs(x+1,y,z+1);
      c[z+1]=0; 
  }
}
int main()
{
//  freopen("3.txt","r",stdin);
  int n;
  cin >> n;
  while(n--)
  {
  flag=0;
  memset(b,0,sizeof(b));
  memset(c,0,sizeof(c));
  for(int i=0;i<10;i++)
      cin >> a[i];
  dfs(0,0,0);
  if(flag)
      cout << "YES" << endl;
  else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3052
n , k = map(int, input().split())
if k == 2:
    print(n-1)
elif k == n-1:
    print(2)
elif (n-k)%(k-1) == 0:
    print((n-k)//(k-1) +1)
else:
    print((n-k)//(k-1) + 2)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
int main() {
    int n, m, c;
    std::cin >> n >> m >> c;
    std::vector<int> b(m);
    for (auto &bi: b) std::cin >> bi;
    int ans = 0;
    std::vector<int> a(m);
    for (int i = 0; i < n; i++) {
        int x = c;
        for (auto bi: b) {
            int ai;
            std::cin >> ai;
            x += ai * bi;
        }
        if (x > 0) {
            ans++;
        }
    }
    std::cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a < b)cout << "a < b" << endl;
    else if(a > b)cout << "a > b" << endl;
    else if(a == b)cout << "a == b" << endl;
    return 0;
    
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin >> a >> b;
    a--;
    ll fa=0;
    if(a%2==0) fa=a;
    if(((a+1)/2)%2==0) fa^=1;

    ll fb=0;
    if(b%2==0) fb=b;
    if(((b+1)/2)%2==0) fb^=1;

    ll ans=fa^fb;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back
lli ans = 0;
lli temp;
// Code taken from https://www.geeksforgeeks.org/find-divisors-natural-number-set-1/

void printDivisors(lli n) 
{ 
    // Note that this loop runs till square root 
    for (lli i=1; i<=(lli)sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i){
                lli x = i-1;
                if(x > 0 && (temp/x) == temp%x){
                    //cout<<x<<"\n";
                    ans+=x;
                }
            }
  
            else{
                lli x = i-1;
                if(x > 0 && (temp/x) == temp%x){
                    ans+=x;
                }
                lli y = (n/i) - 1;
                if(y > 0 && (temp/y) == temp%y){
                    ans+=y;
                }
                //cout<<x<<" "<<y<<"\n";
            }
        } 
    } 
} 
int main() {
    lli n;
    cin>>n;
    temp = n;
    printDivisors(n);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string s,t;
//Saber en que posiciones t es subcadena de s
//La complejidad de su funcionamiento es O(|s| + |t|)

//Arreglo de la Función de Error. Debemos cuidar que el tamaño sea igual al peor tamaño de T , más 5.
//Si |T| <= 10⁵ , entonces :
int FE[10005];


//Calculamos la función de error
void FuncionError(){

	//Ya vimos que para la 0, su Fe es -1
	FE[0] = -1;

	//Vamos ir caracter por caracter
	for(int i = 0; i < t.size();){

		//Tomamos el caracter i para resolver la solución para la posición i+1.

		//Ya que queremos saber para i+1, el anterior es i, por lo tanto nos vamos
		//a su función de error.
		int pos = FE[i];

		//Iteramos mientras que la letra siguiente no sea igual a la siguiente de la función
		//de error. Adicionalmente, si pos se vuelve negativo, o sea -1, deja de moverse
		//hacia atras.
		while(pos >= 0 && t[pos] != t[i])
			pos = FE[pos]; //Usa la función de error para moverse hacia atras

		//Como s[pos] == s[i] , es como si los dos se movieran en el automata.
		//Y como el prefijo que termina en 'pos' es sufijo del prefijo que termina en i.
		//Y como s[pos] == s[i], entonces el prefijo que termina en 'pos+1' es sufijo
		//del que termina en i+1.
		FE[++i] = ++pos;

	}
}


//Imprime las posiciones en las que t se encuentra en s.
//Debimos haber calculado la función de error desde antes de llamar esta función.
void Aparece(){

	//Ya que no hemos matcheado nada, empezamos en el estado inicial
	int pos = 0;

	//Vamos caracter por caracter
	for(int i = 0; i < s.size(); i++){

		//Buscamos sobre 't' el primer caracter que sea igual al siguiente de 's'
		//Aplica la misma regla de cuando llegamos a -1, es decir, dejamos de movernos
		//hacia atrás.
		while(pos >= 0 && s[i] != t[pos] )
			pos = FE[pos]; //De nuevo usamos la función de error

		//Ya que encontramos un caracter igual, o llegamos a -1, avanzamos sobre
		//el "autómata", que en sí es un arreglo
		pos++;

		//Preguntamos si ya procesamos todos los caracteres de t
		if(pos == t.size()){
			//Si es así, es porque en i hemos pasados por todos los caracteres
			//Por lo tanto t termina en la posición i.
			//Así, si termina en i , entonces inicio en i - |t| + 1.
			cout << i - t.size() + 1 << '\n';

			//Al estar en el último estado, no habrá nada que acepte el "autómata",
			//entonces, eventualmente se moverá con la función de errro. Por lo tanto
			//no hay problema con moverse desde este punto.
			pos = FE[pos];

		}
	}
}


int main()
{
    cin>>s>>t;
    FuncionError();
    Aparece();
    return 0;
}



Measured memory_bytes: 3952
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
struct edge {int to, cost;};

signed main() {
	int n; cin >> n;
	if (n == 1) {
		puts("Hello World");
	}
	else {
		int a, b; cin >> a >> b;
		cout << a + b << endl;
	}
	}

Measured memory_bytes: 764
#pragma region GNUC
//以下を参考にした
//https://yukicoder.me/wiki/auto_vectorization
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif
#pragma endregion

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
#include <random>
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

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

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

void solve(){
	int Left = 0;
	int Right;
	int Bot = 0;
	int Top;
	int N;
	cin >> Right >> Top >> N;
	int x,y,a;
	for(int i=0;i<N;++i){
		cin >> x >> y >> a;
		switch(a){
		case 1:
			Left = max(Left,x);
			break;
		case 2:
			Right = min(Right,x);
			break;
		case 3:
			Bot = max(Bot,y);
			break;
		case 4:
			Top = min(Top,y);
			break;
		}
	}
	if( Left > Right || Bot > Top){
		cout << 0;
	}else{
		cout << (Right-Left)*(Top-Bot);
	}
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数点以下の桁数を指定
	
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> m;
    ll ans = 0;
    for (auto &&i : v) scanf("%d", &i), m[i]++, ans += i;
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int b, c;
        cin >> b >> c;
        ans += m[b]*(c-b);
        m[c] += m[b];
        m[b] = 0;
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 8064
n=int(input())
a=list(map(int,input().split()))
num=1000
num2=0
num3=-1
for i in range(n-1):
    if a[i]<a[i+1] and num3==-1:
        num2+=num//a[i]
        num-=a[i]*(num//a[i])
        num3=a[i+1]
    elif num3!=-1:
        if a[i]<a[i+1]:
            num3=a[i+1]
        if a[i]>a[i+1]:
            num+=a[i]*num2
            num2=0
            num3=-1
num+=max(a[-1],a[-2])*num2
print(num)


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

int main(){
  string s;
  cin >> s;
  
  int ans = 1;
  if (s.at(0) == s.at(1))
    ans = 0;
  else if (s.at(0) == s.at(2))
    ans = 0;
  else if (s.at(1) == s.at(2))
    ans = 0;
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int N; std::cin >> N;
  std::vector<std::vector<int>> G(2e5);
  for(int i = 0; i < N; ++i) {
    int x, y; std::cin >> x >> y; --x; --y; y += 1e5;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  std::vector<bool> used(2e5, false);
  auto dfs = [&](auto&& f, int v, int p)->std::pair<int,int> {
    if(used[v]) return {0,0};
    used[v] = true;
    std::pair<int,int> res;
    if(v < 1e5) ++res.first; else ++res.second;
    for(int c: G[v]) if(c != p) {
      auto tmp = f(f, c, v);
      res.first += tmp.first;
      res.second += tmp.second;
    }
    return res;
  };
  int64_t ans = -N;
  for(int i = 0; i < 2e5; ++i) {
    auto p = dfs(dfs, i, -1);
    ans += (int64_t)p.first*p.second;
  }
  fin(ans);
  return 0;
}


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

int zettai(int x){
  if(x < 0) x *= (-1);
  return x;
}
 
int main() {
  int N, T = 0;
  cin >> N;
  vector<int> w(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> w.at(i);
    sum += w.at(i);
  }
  int minw = 100000;
  for(int i = 0; i < N; i++){
    int sumt = 0;
    for(int j = 0; j < i; j++){
      sumt += w.at(j);
    }
    minw = min(zettai(2*sumt - sum), minw);
  }
  cout << minw << endl;
}
      
      

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
int n;
pair<ll, ll> arr[N];
int main()
{
    FIO
    cin>>n;
    ll ans = -OO;
    vector<ll> sums, diffs;
    for (int i = 0; i < n; i++)
    {
        cin>>arr[i].first>>arr[i].second;
       sums.push_back(arr[i].first + arr[i].second);
       diffs.push_back(arr[i].first - arr[i].second);
    }
    sort(sums.begin(), sums.end()); sort(diffs.begin(), diffs.end());
    cout<<max(sums[n-1] - sums[0], diffs[n-1] - diffs[0]);
    
    return 0;
}

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

int main () {
    int N,K;
    cin >> N >> K;
    map<int, int> chk;
    for (int i = 1; i<=N; i++) chk[i] = 0;
    for (int i = 0; i<K; i++) {
        int tmp;
        cin >> tmp;
        for (int j = 0; j<tmp; j++) {
            int tcnt;
            cin >> tcnt;
            chk[tcnt]++;
        }
    }
    int res = 0;
    for(auto x: chk) {
        if(x.second == 0) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3612
fun main(args: Array<String>){
    var n = readLine()!!.toInt()
    var v = readLine()!!.split(" ").map(String::toInt)
    var c = readLine()!!.split(" ").map(String::toInt)
    var f = 0

    for(bit in 0..1.shl(n)){
        var tmp = 0
        for(i in 0..n-1){
            if(bit.shr(i).and(1) == 1) tmp += v[i] - c[i]
        }

        if(tmp > f) f = tmp
    }
    println(f)
}

Measured memory_bytes: 37728
from itertools import combinations
N, M, X = [int(i) for i in input().split()]
ans = float("inf")
CA = [[int(i) for i in input().split()] for _ in range(N)]
for i in range(1, N + 1):
    for j in combinations(list(range(N)), i):
        ary = [0 for _ in range(M)]
        c = 0
        for k in j:
            c += CA[k][0]
            for i, l in enumerate(CA[k][1:]):
                ary[i] += l
        if all([x >= X for x in ary]):
            ans = min(c, ans)
print(ans if ans < float("inf") else -1)



Measured memory_bytes: 68824
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c = readInts()
print('Yes' if a <= c <= b or a >= c >= b else 'No')


Measured memory_bytes: 5148
N, M = [int(i) for i in input().split(" ")]
p = list()
y = list()
yd = {}
for i in range(0, M):
    pi, yi = [int(i) for i in input().split(" ")]
    p.append(pi)
    y.append(yi)
    if pi in yd.keys():
        yd[pi].append(yi)
    else:
        yd[pi] = [yi]

ydid = {}
for i in yd.keys():
    num = 1
    for j in sorted(yd[i]):
        ydid[j] = num
        num = num + 1

for i in range(0, M):
    print("{:06}{:06}".format(p[i], ydid[y[i]]))


Measured memory_bytes: 40220
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    int i;
    for(i=0;i<N;i++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    int count = 1;
    for(i=0;i<d.size()-1;i++){
        if(d.at(i) > d.at(i+1)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}
/*int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    int i,j;
    for(i=0;i<N;i++){
        cin >> d.at(i);
    }
    for(i=0;i<N;i++){
        for(j=0;j<N-i-1;j++){
            if(d.at(j) < d.at(j+1)){
                int swap = d.at(j);
                d.at(j) = d.at(j+1);
                d.at(j+1) = swap;
            }
        }
    }
    int count = 1;
    for(i=0;i<N-1;i++){
        if(d.at(i) > d.at(i+1)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}*/

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

typedef long long ll;

int main(){
    vector<ll> v1(3), v2(3);
    cin >> v1.at(0) >> v1.at(1) >> v1.at(2);
    ll ans = 0;
    while(v1.at(0)%2 == 0 && v1.at(1)%2 == 0 && v1.at(2)%2 == 0){
        v2.at(0) = (v1.at(1) + v1.at(2)) / 2;
        v2.at(1) = (v1.at(0) + v1.at(2)) / 2;
        v2.at(2) = (v1.at(1) + v1.at(1)) / 2;
        for(int i=0; i<3; i++){
            v1.at(i) = v2.at(i);
        }
        ans++;
        if(v2.at(0) == v2.at(1) && v2.at(1) == v2.at(2)){
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> as(n); cin >> as;
    int total = accumulate(as.begin(), as.end(), 0ll);
    sort(as.rbegin(), as.rend());
    int num = 0;
    for(int i = 0; i < n; i++){
        if(as[i] * 4 * m < total){
            break;
        }
        num++;
    }
    cout << (num >= m ? "Yes" : "No") << '\n';
}


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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var da = arr.Select(Convert.ToDouble).ToArray();

            Console.WriteLine($"{arr[0] / arr[1]} {arr[0] % arr[1]} {da[0] / da[1]:0.000000000}");
        }
    }
}



Measured memory_bytes: 18596
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int n,a;cin>>n>>a;
  n%=500;
  if(n<=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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


#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define FILE_IO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
//#define int long long
using namespace std;
const int MOD = 1000000007;

signed main() {
	FAST_IO;
	//FILE_IO;

	int n, m;
	cin >> n >> m;
	int a[m];
	unordered_map<int, bool> broken;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		broken[--a[i]] = true;
	}
	if (broken[0] && broken[1]) cout << 0;
	else {
		int dp[n]; // dp(i) : Number of ways to reach staircase i
		memset(dp, 0, sizeof(dp));
		if (!broken[0]) {
			dp[0] = 1;
			dp[1] = 2;
		}
		else dp[1] = 1;
		if (broken[1]) dp[1] = 0;
		for (int i = 2; i < n; i++) {
			if (!broken[i]) dp[i] = dp[i - 1] % MOD + dp[i - 2] % MOD;
		}
		cout << dp[n - 1] % MOD;
	}
	return 0;
}

Measured memory_bytes: 4900
n=int(input())
ans = [0] * 100000
for x in range(1,101):
    for y in range(1,101):
        for z  in range(1,101):
            ans[x*x+y*y+z*z+x*y+y*z+z*x]+=1
for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 10080
#include<bits/stdc++.h>
using namespace std;
const int N=200010,M=4e5+5;
const int INF=0x3f3f3f3f;
int n,m;
namespace graph{
	int hed[N],h[N],cnt=1,to[M],nxt[M],cap[M],flow[M];
	int S,T;
	int d[N];bool vis[N];
	void adde(int u,int v,int _cap){
		++cnt;to[cnt]=v,cap[cnt]=_cap,nxt[cnt]=hed[u],flow[cnt]=0;hed[u]=cnt;
		++cnt;to[cnt]=u,cap[cnt]=0,nxt[cnt]=hed[v],flow[cnt]=0;hed[v]=cnt;
	}
	queue<int>Q;
	bool bfs(){
		memset(vis,0,sizeof(vis));
		memset(d,0,sizeof(d));
		Q.push(S);vis[S]=1;
		while(!Q.empty()){
			int u=Q.front();Q.pop();
			for(int i=hed[u];i;i=nxt[i]){
				int v=to[i];
				if(!vis[v]&&cap[i]>flow[i]){
					vis[v]=1,d[v]=d[u]+1;
					Q.push(v);
				}
			}
		}
		return vis[T];
	}
	int dfs(int u,int F){
		if(u==T||!F)return F;
		int flownow=0;
		for(int &i=h[u];i;i=nxt[i]){
			int v=to[i];if(d[v]!=d[u]+1)continue;
			int f=dfs(v,min(F,cap[i]-flow[i]));
			flownow+=f;F-=f;
			flow[i]+=f;flow[i^1]-=f;
			if(!F)break;
		}
		if(!flownow)d[u]=0;
		return flownow;
	}
	int max_flow(){
		int fw=0;
		while(bfs()){
			for(int i=1;i<=T;i++){
				h[i] = hed[i];
			}
			// cout << "?" << endl;
			fw+=dfs(S,INF);
		}
		return fw;
	}
}

int x[N],y[N],p[N],q[N];
int ncnt=0;
int main(){
	using namespace graph;
	cin >> n;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]),p[i]++;
	for(int i=1;i<=n;++i)if(!x[i]){
		++ncnt;
		for(int j=i;!x[j];j=p[j])x[j]=ncnt;
	}
	for(int i=1;i<=n;i++)scanf("%d",&q[i]),q[i]++;
	for(int i=1;i<=n;++i)if(!y[i]){
		++ncnt;
		for(int j=i;!y[j];j=q[j])y[j]=ncnt;
	}
	S = ncnt+1,T = ncnt+2;
	int sum = 0;
	for(int i=1;i<=n;i++){
		if(p[i]==q[i]){
			if(p[i]==i)continue;sum+=2;
			adde(S,x[i],1),adde(y[i],T,1),adde(x[i],y[i],2);
		}else{
			sum++;
			if(p[i]==i)adde(S,y[i],1);
			else if(q[i]==i)adde(x[i],T,1);
			else adde(x[i],y[i],1);
		}
	}
	cout << sum - max_flow() << endl;
}

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

int main(void){
	int N, M, X;
	cin >> N >> M >> X;
	int A[M];
	rep(i,M) cin >> A[i];

	int c[N+1];
	rep(i,N+1) c[i] = 0;
	rep(i,M) c[A[i]] = 1;
	int l = 0, r = 0;
	for (int i = 0; i < X; i++) {
		l += c[i];
	}
	for (int i = X+1; i < N; i++) {
		r += c[i];
	}

	cout << min(l,r) << endl;

	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
string s;

ll knap[2505][55];

int main(){
	fast_io();
	knap[0][0] = 1;
	int n,a;
	cin >> n >> a;
	cu(i,0,n){
		int x;
		cin >> x;		
		fd(i,2500,0){
			fu(l,0,50){
				if(knap[i][l] && i + x <= 2500){
					knap[i + x][l+1] += knap[i][l];
				}
			}
		}
	}
	ll ans = 0;
	fu(i,1,50){
		ans += knap[i * a][i];	
	}
	cout << ans << '\n';
}
		

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  rep(i, m) {
    string s;
    cin >> s;
    mp[s]--;
  }
  int ans = 0;
  for (auto e : mp)
    chmax(ans, e.second);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    a, b = tuple(map(int,input().split()))
    print(gcd(a, b))

def gcd(x, y):    
    # x > y となるように並べ替え
    if x < y:
        (x, y) = (y, x)
    return x if y == 0 else gcd(y, x%y)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5600