akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		for(int i = 1; ; i++){
		    try {
			    input = br.readLine();
		        
		    } catch (IOException e) {
	    	}
	    	String[] inputs = input.split(" ");
	    	int a = Integer.parseInt(inputs[0]);
	    	String op = inputs[1];
	    	int b = Integer.parseInt(inputs[2]);
	    	// a op bの順に計算式を書くから、inputsの番号はこの順番になる
	    	if(op.equals("?")){
    		    break;
	    	}   
	    	if(op.equals("+")){
	    	    System.out.println(a + b);
	    	}
	    	if(op.equals("-")){
	    	    System.out.println(a - b);
	    	}
	    	if(op.equals("*")){
	    	    System.out.println(a * b);
	    	}
	    	if(op.equals("/")){
	    	    System.out.println(a / b);
	    	}
		}
	}
}



Measured memory_bytes: 24396
using System;
using System.Text; 
using System.Collections.Generic;
using System.Linq;

public class Remainder
{
    static long N;
    static long K;
    static public void Main ()
    {
        var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        N = NK[0];
        K = NK[1];
        
        var ans = 0L;
        //aのKの余りによって場合分け
        for(int i = 0;i < K;i++){
            //aの余りと足してKの倍数になる数字
            var comp = (K-i)%K;
            if((comp*2)%K == 0){
                //あまりが一緒の積を計算
                ans += CheckModP(i)*CheckModP(comp)*CheckModP(comp);
            }
            
        }
        
        Console.WriteLine(ans);

    }
    
    //Pは0以上K-1以下の値
    static long CheckModP(long P){
        var res = N/K;
        if(P != 0 && (N%K) >= P){
            res++;
        }
        return res;
    }

}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;

int n;
int d,x;
int ans;

int main(){

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

cin>>n>>d>>x;

ans=x;

for(int i=0; i<n; i++){
  int a;
  cin>>a;
  int c=1;
  while(c<=d){
    ans++;
    c+=a;
  }
}

cout<<ans<<endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	  ll n,m;
	   cin>>n>>m;
	   
	   cout<<min(n%m,abs(m-n%m));
	}
	
	return 0;
}


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

int n, k, a[104];

int main() {
	cin >> n >> k;
	for (int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);

	for (int i=0; i<n; i++) {
		if (k < a[i]) {
			cout << i << '\n';
			return 0;
		}
		k -= a[i];
	}
	if (k) cout << n-1 << '\n';
	else cout << n << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int k,s,z;
cin>>k>>s;
int m=0;
for(int i=0;i<=k;i++){
for(int j=0;j<=k;j++){
	z=s-i-j; 
	if(s==(i+j+z))
if(z>=0&&z<=k)
m+=1;
}}
cout<<m;
return 0;
}

Measured memory_bytes: 256
/* 
 * File:   main.cpp
 * Author: æè¯º
 *
 * Created on 2011å¹´8æ27æ¥, ä¸å12:34
 */

#include <cstdlib>
#include <cstdio>
using namespace std;

int main(int argc, char** argv) {
    int n;
    while (1 == scanf("%d", &n) && n) {
        int just;
        int t;
        bool need = false;
        for (int i = 0; i < n; ++i, just = t) {
            scanf("%d", &t);
            if (i == 0)printf("%d", t);
            else if (t == just + 1) {
                need = true;
                continue;
            } else {
                if (need)printf("-%d", just);
                printf(" %d", t);
                need = false;
            }
        }
        if (need)printf("-%d", just);
        printf("\n");
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 0
import Data.Maybe
import Data.List

main = do 
 a <- getLine
 let arr = [[c]|c<-a]
 let maxi =  maximum.map length. groupBy (\x y-> f x && f y ) $arr 
 if maxi == 1 then 
  if (length .catMaybes $
  [findIndex ("A"==) arr,findIndex("C"==) arr,findIndex ("T"==) arr,
  findIndex ("G"==) arr] )>= 1 then
  print 1 else print 0
 else  print maxi
 
 
f :: String -> Bool
f x =  x=="A" || x=="C" ||x=="G" ||x=="T"

Measured memory_bytes: 380
#include<iostream>
#include<algorithm>

using namespace std;

const int MOD = 100000;
int w, h, dp[100][100][4];

int rec( int y, int x, int j){
  if( y >= h || x >= w) return 0;
  if( ~dp[y][x][j]) return dp[y][x][j];
  if( y == h - 1 && x == w - 1) return 1;

  int ret;
  if(!y && !x) ret = rec( y + 1, x, 0) + rec( y, x + 1, 1);
  else if( j == 0 ) ret = rec( y + 1, x, 0) + rec( y, x + 1, 3);
  else if( j == 1 ) ret = rec( y + 1, x, 2) + rec( y, x + 1, 1);
  else if( j == 2 ) ret = rec( y + 1, x, 0);
  else if( j == 3 ) ret = rec( y, x + 1, 1);

  return dp[y][x][j] = ret % MOD;
}
int main(){
  while( cin >> w >> h, w){
    fill_n( **dp, 100 * 100 * 4, -1);
    cout << rec( 0, 0, 0) << endl;
  }
}

Measured memory_bytes: 1324
N = int(input())
if N < 2:
    print('1')
elif N < 4:
    print('2')
elif N < 8:
    print('4')
elif N < 16:
    print('8')
elif N < 32:
    print('16')
elif N < 64:
    print('32')
else:
    print('64')

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <unordered_map>

int main()
{
  int N = 0, count = 0;
  std::unordered_map<std::string, int> prise;

  std::cin >> N;
  for (int i = 0; i < N; i++)
  {
    std::string tmp;
    std::cin >> tmp;
    const auto it = prise.emplace(std::move(tmp), i);
    if (it.second)
    {
      count++;
    }
  }
  std::cout << count << std::endl;
}

Measured memory_bytes: 17152
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
int v[100001],ans[400001],sum[400001];
void dfs(int k,int l,int r)
{
    if(l==r) {ans[k]=v[l];return;}
    int mid=(l+r)/2;
    dfs(k*2,l,mid);
    dfs(k*2+1,mid+1,r);
    ans[k]=ans[k*2]+ans[k*2+1];
    return;
}
void push_down(int k,int l,int r)
{
//	cout<<"k:"<<k<<" ans:"<<ans[k]<<" sum:"<<sum[k]<<endl;
    int mid=(l+r)/2;
    sum[k*2]+=sum[k];
    ans[k*2]+=sum[k]*(mid-l+1);
    sum[k*2+1]+=sum[k];
    ans[k*2+1]+=sum[k]*(r-mid);
    sum[k]=0;
//	cout<<k<<" "<<l<<" "<<r<<" "<<ans[k*2]<<" "<<ans[k*2+1]<<endl;
    return;
}
void change(int k,int l,int r,int x,int y,int v)
{
    if(x<=l&&r<=y)
    {
        
        ans[k]+=(r-l+1)*v;
        sum[k]+=v;
//		cout<<l<<" "<<r<<" "<<ans[k]<<" "<<sum[k]<<endl;
        return;
    }
    push_down(k,l,r);
    int mid=(l+r)/2;
    if(x<=mid) change(k*2,l,mid,x,y,v);
    if(mid<y) change(k*2+1,mid+1,r,x,y,v);
    ans[k]=ans[k*2]+ans[k*2+1];
    return;
}
int query(int k,int l,int r,int x,int y)
{
    if(x<=l&&r<=y) return ans[k];
    int res=0;
    push_down(k,l,r);
    int mid=(l+r)/2;
    if(x<=mid) res=query(k*2,l,mid,x,y);
    if(mid<y) res+=query(k*2+1,mid+1,r,x,y);
    return res;
} 
int n,m;
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int l=read(),r=read();
		change(1,1,n,l,r,1);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(query(1,1,n,i,i)==m) 
			ans++;
	}printf("%d\n",ans);
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
  void yesno(bool a){if(a){cout << ("Yes");}else{cout << ("No");}}


  const int mod = 1000000007;
int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


   	int n;
   	cin >> n;

   	vector<int> arr(n);

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

   	vector<int> suff(n);

   	suff[n-1] = arr[n-1];

   	for(int i = n-2; i >=0; i--)
   	{
   		suff[i] = (suff[i+1]%mod + arr[i]%mod)%mod;
   	}

   	int ans = 0;

   	for(int i = 0; i < n - 1; i++)
   	{
   		ans += (arr[i]%mod)*(suff[i+1]%mod)%mod;
   		ans %= mod;
   	}	

   	ans %= mod;

   	cout << ans;

    return 0;
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> pa;
typedef long double ld;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=5e5+5;
int n,L;
ld ans;
ld allx,ally,x[maxn],y[maxn];
pair<ld,ld>p[maxn],q[maxn];
int main(){
	read(n);read(L);
	rep(i,1,n){
		int t,v;read(t),read(v);
		x[i]=v,y[i]=1ll*t*v;
	}
	int h=0,t=0;
	rep(i,1,n){
		allx+=x[i];
		ally+=y[i];
		while(allx>L){
			if(q[h].w1<=allx-L){
				ally-=q[h].w2;
				allx-=q[h].w1;
				h++;
			}else{
				ally-=1ll*(allx-L)*(q[h].w2/q[h].w1);
				q[h].w2-=(allx-L)*(q[h].w2/q[h].w1);
				q[h].w1-=allx-L;
				allx=L;
			}
		}
		while(h<t&&q[t-1].w2/q[t-1].w1>y[i]/x[i]){
			x[i]+=q[t-1].w1;
			y[i]+=q[t-1].w2;
			t--;
		}
		q[t++]=mp(x[i],y[i]);
		printf("%.10f\n",double(ally/allx));
	}
	return 0;
}

Measured memory_bytes: 43008
S = input()

N = len(S)
ans = 0

for i in range(N):
    for j in range(i, N):
        #cは調べる文字列の一部分
        #ACGTの中にその文字があるかどうか調べる
        #すべてあればそれはACGT文字
        if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            #j-i+1はその文字列の長さ
            ans = max(ans, j - i + 1)
print(ans)


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

int N;
int P[200005], D[200005];
set<int> inP;
int mx;

bool valid(int i) {
	auto a = inP.upper_bound(i);
	if (a != inP.end() && P[i] > P[*a]) return 0;
	if (a != inP.begin()) {
		a--;
		if (P[*a] > P[i]) return 0;
	}
	return 1;
}

int main() {
	scanf("%d", &N);

	for (int i = 0; i++ < N; ) scanf("%d", P+i), D[P[i]] = i;

	int r = 1; inP.insert(D[1]);
	for (int l = 0; l++ < N; ) {
		while (r < N && valid(D[r+1])) inP.insert(D[++r]);
		mx = max(mx, (int)inP.size());
		inP.erase(D[l]);
	}

	printf("%d\n", N - mx);
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,k;
    cin >> n >> k;
    vi l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end(),greater<int>());
    ll ans = 0;
    rep(i,k) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back

int main(){

    ll n ;
    cin >> n ;
    vector<ll> v(n) ;
    ll i , j , k , ans = 0 ;
    for (i =0 ; i< n ; i++) cin >> v[i] ;

    for (i =0 ; i< n; i++) {
        for (j = i+1 ; j< n ; j ++) {
            for (k = j + 1 ; k < n ; k++) {
                if (v[i] == v[j] or v[j] == v[k] or v[k] == v[i]) continue ;
                vector<ll> x = {v[i],v[j],v[k]} ;
                sort(x.begin(),x.end()) ;
                if (x[0] == x[1] or x[1]==x[2]) continue ;
                if (x[0]+x[1]>x[2])ans++ ;
            }
        }
    }
    cout << ans << endl ;

    return 0 ;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

// ABC 146 F

using P = pair<int, int>;

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

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

    int num = (n - 2) * (n - 1) / 2;
    if (num < k)
    {
        cout << "-1\n";
        return 0;
    }

    vector< P > edge;
    rep (i, n - 1)
    {
        edge.emplace_back(i + 1, n);
    }

    int start = 1;
    int a = 2;
    while (num > k)
    {
        if (a == n)
        {
            a = ++start + 1;
        }
        edge.emplace_back(start, a++);
        --num;
    }

    cout << edge.size() << "\n";
    for (auto& e : edge)
    {
        cout << e.first << " " << e.second << "\n";
    }
    return 0;
}



Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 400020


int main() {
	long long n, t;
	long double x, y, z;
	long long a[N];
	long long b[N];
	vector<pair<long double, pair<long long, long long> > >c;
	vector<long long>add;
	vector<long long>add2;
	long long dp[N][50];
	long long s, ans, k, xx, yy;
	scanf("%lld %lld", &n, &t);
	f(i, n) {
		scanf("%lld %lld", &a[i], &b[i]);
		x = (long double)a[i];
		y = (long double)b[i];
		if (a[i]!=0) {
			z = (y + 1) / x;
			c.push_back(make_pair(z, make_pair(a[i], b[i])));
		}
		else {
			add.push_back(b[i]);
		}
	}
	sort(c.begin(), c.end());
	sort(add.begin(), add.end());
	add2.push_back(0);
	f(i, add.size())add2.push_back(add[i] + add2[i] + 1);
	f(i, 40)dp[0][i] = 1000000010;
	dp[0][0] = 0;
	f(i, c.size()) {
		dp[i + 1][0] = 0;
		f(j, 39) {
			dp[i + 1][j + 1] = min(dp[i][j + 1], (dp[i][j] + 1)*(c[i].second.first + 1) + c[i].second.second);
		}
	}
	k = c.size();
	ans = 0;
	yy = -1;
	for (long long i = 39; i >= 0; i--) {
		if (t >= dp[k][i]) {
			if ((yy + 1) < add2.size()) {
				while (add2[yy + 1] <= (t - dp[k][i])) {
					yy++;
					if ((yy + 1) >= add2.size())break;
				}
			}
			ans = max(ans, i + yy);
		}

	}
	printf("%lld\n", ans);



	return 0;
}


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

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

constexpr ll MOD = 1000000007LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (N > M) {
        swap(N, M);
    }
    if (N == 1) {
        if (M == 1) {
            cout << 1 << endl;
        } else if (M == 2) {
            cout << 0 << endl;
        } else {
            cout << M - 2 << endl;
        }
    } else if (N == 2) {
        cout << 0 << endl;
    } else {
        cout << (N - 2) * (M - 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,k,q = map(int, input().split())

score = [k-q]*n

for i in range(q):
	dat = int(input())-1
	score[dat] = score[dat] + 1

#print(score)

for i in range(n):
	if score[i] > 0:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 6584
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

M = int(input())

print(48-M)

Measured memory_bytes: 38384
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int[] dd = new int[8];
	int[] qu = new int[9], aa = new int[9], aa_ = new int[9]; int k_, l_;
	void sort(int[] aa, int n) {
		Arrays.sort(aa, 0, n);
		for (int i = 0, j = n - 1; i < j; i++, j--) {
			int tmp = aa[i]; aa[i] = aa[j]; aa[j] = tmp;
		}
	}
	int c_;
	void update(int k, int l) {
		if (l_ > l)
			return;
		for (int h = 0; h < k; h++)
			aa[h] = dd[qu[h]];
		int m = Math.min(l, 9);
		for (int h = k; h < m; h++)
			aa[h] = dd[c_];
		sort(aa, m);
		boolean better = false;
		if (l_ < l)
			better = true;
		else
			for (int h = 0; h < l; h++)
				if (aa_[h] != aa[h]) {
					if (aa_[h] < aa[h])
						better = true;
					break;
				}
		if (!better)
			return;
		k_ = k;
		l_ = l;
		for (int h = 0; h < m; h++)
			aa_[h] = aa[h];
	}
	void solve(int c, int n, int k) {
		while (c > c_ && dd[c] == 0)
			c--;
		if (c == c_) {
			if (n % c == 0) {
				int l = k + n / c;
				update(k, l);
			}
			return;
		}
		for (int h = 0; h < c_; h++) {
			solve(c - 1, n, k);
			if (n < c || k == 9)
				break;
			n -= c;
			qu[k++] = c;
		}
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] d2c = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
		while (m-- > 0) {
			int d = sc.nextInt();
			int c = d2c[d];
			dd[c] = Math.max(dd[c], d);
		}
		c_ = 2;
		while (dd[c_] == 0)
			c_++;
		solve(7, n, 0);
		m = Math.min(l_, 9);
		for (int h = 0; h < m; h++)
			if (aa_[h] > dd[c_])
				print(aa_[h]);
		for (int h = k_; h < l_; h++)
			print(dd[c_]);
		for (int h = 0; h < m; h++)
			if (aa_[h] < dd[c_])
				print(aa_[h]);
		println();
	}
}


Measured memory_bytes: 36180
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef pair<int,int> pii;

priority_queue<vector<int>> vs;

template<class V,int NV> class SegTree_1 {
public:
    std::vector<V> val;
    static V const def=303030;
    V comp(V l,V r){ return min(l,r);};
    
    SegTree_1(){val=vector<V>(NV*2,def);};
    V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
        if(r<=x || y<=l) return def;
        if(x<=l && r<=y) return val[k];
        return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
    }
    void update(int entry, V v) {
        entry += NV;
        val[entry]=v;
        while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
    }
};

SegTree_1<int,1<<20> ev,od;
set<vector<int>> cand;
vector<int> indice;

void add(int L,int R) {
    vector<int> ret;
    if(R<=L) return;
    
    int left;
    if(L%2==0) left=ev.getval(L,R);
    else left=od.getval(L,R);
    int x=indice[left];
    
    int right;
    if((x+1)%2==0) right=ev.getval(x+1,R);
    else right=od.getval(x+1,R);
    int y=indice[right];

    //左の値
    ret.push_back(left);
    //右の値
    ret.push_back(right);
    //左端
    ret.push_back(L);
    //左の切れ目
    ret.push_back(x);
    //右の切れ目
    ret.push_back(y);
    //右端
    ret.push_back(R);
    //sort
    cand.insert(ret);
}

int N;

void solve() {
    int N;
    cin>>N;
    vector<int> A(N);
    indice.resize(N+1);
    for(int i = 0;i < N;i++) {
        cin>>A[i];
        if(i%2==0) {
            ev.update(i,A[i]);
            od.update(i,1<<20);
        }
        else {
            od.update(i,A[i]);
            ev.update(i,1<<20);
        }
        indice[A[i]]=i;
    }
    
    vector<int> Q;
    
    add(0,N);
    while(cand.size()) {
        vector<int> v=*cand.begin();
        cand.erase(cand.begin());
        Q.push_back(v[0]);
        Q.push_back(v[1]);
        //左
        add(v[2],v[3]);
        //真ん中
        add(v[3]+1,v[4]);
        //右
        add(v[4]+1,v[5]);
        //それぞれ再帰的にやらないと、制約条件を満たさない
    }
    
    for(int i = 0;i < N;i++)
    {
        cout << Q[i] << " ";
    }
    cout << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 24052
import sys
a,b,c,d = map(int,input().split())
for i in range(1000):
    if i % 2 == 0:
        c -= b
        if c <= 0:
            print("Yes")
            sys.exit()
    else:
        a -= d
        if a <= 0:
            print("No")
            sys.exit()

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

int main() {
    int N;
    long long M;
    cin >> N >> M;
    vector<long long> A(N), sum(N+1, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) sum[i+1] = sum[i] + A[i];
    
    auto f = [&](long long K)->bool {
        long long cnt = 0;
        for (int i = 0; i < N; i++) {
            long long L = K - A[i];
            cnt += (A.end() - lower_bound(A.begin(), A.end(), L));
        }
        return M <= cnt;
    };
    
    long long ok = 0, ng = 200200;
    while (abs(ok-ng) > 1) {
        long long mid = (ok + ng) / 2;
        if (f(mid)) ok = mid;
        else ng = mid;
    }
    
    long long ans = 0, cnt = 0;
    for (int i = 0; i < N; i++) {
        long long K = ok - A[i];
        int id = lower_bound(A.begin(), A.end(), K) - A.begin();
        int p = N - id;
        ans += (sum[N] - sum[id]) + (p * A[i]);
        cnt += p;
    }
    
    ans -= (ok * (cnt - M));
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  char s = S[0];
  ll cnt = 0;
  for (int i = 1; i < 4; ++i) {
    if (s == S[i])
      cnt++;
  }
  if (cnt >= 2 || cnt == 0) {
    cout << "No" << endl;
    return 0;
  }
  char s2 = S[1];
  if (s2 == s) {
    s2 = S[2];
    if (s2 == s || s2 != S[3]) {
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;
    return 0;
  }
  cnt = 0;
  for (int i = 2; i < 4; ++i) {
    if (s2 == S[i])
      cnt++;
  }
  if (cnt >= 2 || cnt == 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#
int main()
{
  int x,y,d,z;

  scanf("%d%d",&x,&y);
  if(x<y){
    z=x;
    x=y;
    y=z;
 }
  while(y>0){
    d=x%y;
    x=y;
    y=d;
  }
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> v;
    REP(i, 1, A) {
        if (A % i == 0 && B % i == 0)v.push_back(i);
    }
    sort(v.begin(), v.end(), greater<int>());
    cout << v[K - 1] << endl;

    return 0;
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

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

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint comb(int n, int m) {
    return perm(n) / (perm(n - m) * perm(m));
}

// 定数 //
#define pi acos(-1)
// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    double N;
    cin >> N;

    cout << fixed << setprecision(10) << pow(N / 3, 3) << endl;

}

Measured memory_bytes: 512
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder()
  let n=o.n(),obj={}
  for(let i=0;i<n;i++){
    obj[o.s()] = 1;
  }
  o.o(Object.keys(obj).length)
}
m();

Measured memory_bytes: 85468
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< long long > vll;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define nl "\n"
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

unsigned long long factorial[1000004]; 
    /*factorial[0] = 1; 
    for (int i = 1; i <= n; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod3; 
    }*/




long long power(unsigned long long x, 
                         int y, int p) 
{ 
    long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 



  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
unsigned long long nc(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
 
  
    return (factorial[n]* modInverse(factorial[r], p) % p * modInverse(factorial[n - r], p) % p) % p; 
} 



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    ll ans = (power(10,n,mod) + power(8,n,mod))%mod;
    ans -= (2*power(9,n,mod))%mod;
    if(ans<0){
        ans+=mod;
    }
    //ans += power(8,n,mod);
    ans %=mod;
    cout<<ans<<nl;

    


	return 0;
}


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

int main() {
  ll n,ans=0,count=0;
  cin>>n;
  string t;
  vector<string> s;
  for(int i=0; i<n; i++) {
    cin>>t;
    sort(t.begin(),t.end());
    s.push_back(t);
  }
  sort(s.begin(),s.end());
  for(int i=1; i<n; i++){
    if(s[i-1] == s[i]) {
      count++;
      ans += count;
    }
    else count = 0;
  }
  cout << ans;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

double A, B, H, M;

int main() {
    cout << fixed << setprecision(10);

    cin >> A >> B >> H >> M;

    double min = M*6;
    double min_rad = M_PI * min / 180;

    double hour = H*30 + M*30/60;
    double hour_rad = M_PI * hour / 180;

    double diff = abs(min_rad - hour_rad);

    double theta = (diff < M_PI) ? diff : 2*M_PI - diff;

    cout << sqrt(A*A + B*B - 2*A*B*cos(theta)) << endl;

    return 0;
}


Measured memory_bytes: 4144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007;
#define INF 1000000001

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};
	



int main(void) {
	int N,K;	
	inp(N);
	inp(K);
	vector<int> a;
	rep(i,N){
		int num;
		inp(num);
		a.push_back(num);
	}
	int Min = 100001;
	rep(n,N) Min = min(Min,a[n]);
	vector<int> dp(K+1);//残りi個で順番が来た時 0:勝ち 1:負け
	rep(i,Min)dp[i] = 1;
	rep2(i,Min,K+1){
		int judge = 0;
		rep(n,N){
			if(i-a[n]>=0) judge+=dp[i-a[n]];
		}
		if(judge==0) dp[i] = 1;//相手が負けるとこに移動できない→負け
		else dp[i] = 0;
	}
	
/* 	rep(i,K) cout << dp[i] << ',';
	cout << dp[K] << endl; */
	if(dp[K]==0) out("First");
	else out("Second");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
// Begin Header {{{
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<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	rep(i,5){
		int a;
		cin >> a;
		if(a==0){
			cout << i+1 << endl;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
  int N;
  scanf("%d", &N);
  vector<int> h(N), a(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &h[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }

  map<int, ll> h2a;
  h2a[0] = 0;
  for (int i = 0; i < N; i++) {
    auto it = h2a.lower_bound(h[i]);
    it--;
    ll ans = it->second + a[i];
    it = h2a.emplace(h[i], ans).first;
    it++;
    while (it != h2a.end() && it->second <= ans) {
      it = h2a.erase(it);
    }
  }
  printf("%lld\n", h2a.rbegin() -> second);
}


Measured memory_bytes: 14336
#!/usr/bin/env python3
from itertools import product
n, m = list(map(int, input().split()))
xyz = [list(map(int, input().split())) for i in range(n)]

dp = [[0 for i in range(m+1)] for j in range(n+1)]


# eval
# eval_list = ["+xyz[i-1][0]+xyz[i-1][1]+xyz[i-1][2]",
#              "+xyz[i-1][0]+xyz[i-1][1]-xyz[i-1][2]",
#              "+xyz[i-1][0]-xyz[i-1][1]+xyz[i-1][2]",
#              "+xyz[i-1][0]-xyz[i-1][1]-xyz[i-1][2]",
#              "-xyz[i-1][0]+xyz[i-1][1]+xyz[i-1][2]",
#              "-xyz[i-1][0]+xyz[i-1][1]-xyz[i-1][2]",
#              "-xyz[i-1][0]-xyz[i-1][1]+xyz[i-1][2]",
#              "-xyz[i-1][0]-xyz[i-1][1]-xyz[i-1][2]", ]

ans = 0
for a, b, c in product([1, -1], repeat=3):
    total = []
    for x, y, z in xyz:
        s = x*a+y*b+z*c
        total.append(s)
    total.sort(reverse=True)
    ans = max(ans, sum(total[:m]))
print(ans)


Measured memory_bytes: 18032
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            string c = Console.ReadLine();
            if (char.IsUpper(c[0])) { Cout("A"); }
            else Cout("a");

            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


Measured memory_bytes: 25800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n;
  cin >> n;
  vector<int> v=input(n);
  vector<int> copy(n);
  rep(i,n){
    copy[i] = v[i];
  }
  /*rep(i,n){
    cout << copy[i] << " ";
  }
  cout << endl;*/
  
  sort(v.begin(),v.end());
  /*rep(i,n){
    cout << v[i] << " ";
  }
  cout << endl;*/
  
  int count=0;
  rep(i,n){
    if(v[i]!=copy[i]){
      count++;
    }
  }
  
  if(count<=2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;

int main() {
	while(true) {
		int n, r;
		cin >> n >> r;
		if(n==0 && r==0) break;

		vector<int> cards;
		for(int i=0; i<n; i++)
			cards.push_back(i+1);
		int p, c;
		for(int i=0; i<r; i++) {
			cin >> p >> c;
			for(int j=0; j<c; j++) {
				int temp;
				temp = cards[n-p+1-c];
				cards.erase(cards.begin()+n-p+1-c);
				cards.push_back(temp);
			}
		}
		cout << cards[n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for(int i = (s); i < (e); i++)
#define FOE(i, s, e) for(int i = (s); i <= (e); i++)
#define FOD(i, s, e) for(int i = (s); i >= (e); i--)
#define ll long long

int LINK[400005], ed[400005], l[400005];
int n, m, x, y, z, k, w;
int group[200005][2];

int bd(int x, int y) {
	LINK[w] = l[x]; l[x] = w; ed[w++] = y;
}

int v[200005];
int gp;

map< pair<int, int>, int> M;

void DFS(int x, int t) 
{
	v[x] = 1;
	group[x][t] = gp;
	for (int i = l[x]; i != -1; i = LINK[i])
	{
		if (v[ed[i]] == 1) continue;
		DFS(ed[i], t);
	}
}

void solve(int m, int t)
{
	w = 0;
	memset(l, -1, sizeof(l));
	FOR(i, 0, m) { scanf("%d%d", &x, &y); bd(x, y); bd(y, x); }

	memset(v, 0, sizeof(v));
	gp = 0;
	FOE(i, 1, n) if (v[i] == 0) { gp++; DFS(i, t); }

}

int main ()
{
	int K, L;
	scanf("%d %d %d", &n, &K, &L);
	solve(K, 0);
	solve(L, 1);
	
	FOE(i, 1, n) M[make_pair(group[i][0], group[i][1])]++;

	FOE(i, 1, n)
	{
		x = M[make_pair(group[i][0], group[i][1])];
		printf("%d ", x);
	}
	
	return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  ll N, ans = 0;
  cin >> N;
  vi A(N + 1), B(N + 2);
  for (ll i = 0; i < N + 1; i++) {
    cin >> A[i];
  }
  for (ll i = N; i >= 0; i--) {
    B[i] = B[i + 1] + A[i];
  }

  ll x = 1;
  for (ll i = 0; i < N + 1; i++) {
    // cout << x << endl;
    if (x < A[i]) {
      ans = -1;
      break;
    }

    ans += A[i];
    x -= A[i];
    ans += min(B[i] - A[i], x);
    if (B[i] - A[i] >= x) x *= 2;
  }
  cout << ans << endl;
}



Measured memory_bytes: 4844
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    int N;
    cin >> N;
    string st[N];
    bool ok = true;
    for (int i = 0; i < N; i++) {
        string W;
        cin >> W;
        st[i] = W;
        if (i > 0) {
            int num = st[i - 1].size();
            if (W[0] != st[i - 1][num - 1]) {
                ok = false;
            }
            for (int j = 0; j < i; j++) {
                if (W == st[j]) {
                    ok = false;
                }
            }
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N, K = il()
A = il()
d = {}
c = 0
for a in A:
    try:
        d[a] += 1
    except KeyError:
        d[a] = 1
k = K - len(d)
if k >= 0:
    print(0)
    exit()
sd = sorted(d.items(), reverse=True, key=lambda x: x[1])
s = 0
for _, v in sd[k:]:
    s += v
print(s)


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int a, b;
    cin >> a >> b;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
        cout << a * b << "\n";
    else
        cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int NMAX = 100005;
const int KMAX = 30;

vector<int> G[NMAX];

array<int, KMAX> dfs(int node, int prev) {
    array<int, KMAX> ret;
    fill(ret.begin(), ret.end(), 0);
    ret[0] = 1;
    for (int to: G[node]) {
        if (to != prev) {
            array<int, KMAX> son = dfs(to, node);
            for (int i = 0; i < KMAX; ++i) {
                ret[i] += son[i];
            }
        }
    }
    for (int i = KMAX - 1; i >= 0; --i) {
        if (ret[i] > 1) {
            fill(ret.begin(), ret.begin() + i + 1, 0);
            for (int j = i + 1; j < KMAX; ++j) {
                if (ret[j] > 0) {
                    ret[j] = 0;
                } else {
                    ret[j] = 1;
                    break;
                }
            }
            break;
        }
    }
    return ret;
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    array<int, KMAX> ans = dfs(1, -1);
    int fans = 0;
    for (int i = 0; i < KMAX; ++i) {
        if (ans[i] > 0) {
            fans = i;
        }
    }
    cout << fans << '\n';
}


Measured memory_bytes: 18304
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int area = a * b;
    int rectagle = a * 2 + b * 2;
    System.out.println(area + " " + rectagle);
    if (scanner != null) {
      scanner.close();
    }
  }
}



Measured memory_bytes: 26120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
    ll k;
    cin >> k;

    auto q = queue<ll>();
    ll cnt = 0;
    for (auto i = 1; i <= 9; i++)
    {
        q.push(i);
    }

    while (!q.empty())
    {
        auto size = q.size();
        for (auto i = 0; i < size; i++)
        {
            auto cur = q.front();
            q.pop();
            cnt++;

            if (cnt == k)
            {
                cout << cur << endl;
                return 0;
            }

            auto last_digit = cur % 10;
            if (last_digit != 0)
            {
                q.push(cur * 10 + last_digit - 1);
            }
            q.push(cur * 10 + last_digit);
            if (last_digit != 9)
            {
                q.push(cur * 10 + last_digit + 1);
            }
        }
    }

    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  for (int i =0; i<N; i++) {
    int a,b;
    cin >> a >> b;
    x.at(i) = a; y.at(i) = b;
  }
  
  double ans =0;
  for (int i =0; i<N; i++) {
    for (int j =i+1; j<N; j++) {
      double r = sqrt((x.at(i) - x.at(j)) * (x.at(i) - x.at(j)) + (y.at(i) - y.at(j)) * (y.at(i) - y.at(j))); 
      ans += r;
    }
  }
  ans = ans * 2 / N;
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3780
//بسم الله الرحمن الرحيم
//* In The Name 0f ALLAH *//* The Most Beneficent *//* The Most Merciful *//*
#include<bits/stdc++.h>
using namespace std;
#define el << endl
typedef long int li;
typedef long long ll;
#define inf 1e9+123
#define tc int T; cin>>T; while(T--)
#define GOOD_BYE return 0;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
const int mx = 1e5+123;
const ll MAX = 1e9+5;
//......TEMPLATE TERMINATES HERE......*//*......LET'S BEGIN (-_^)......//
int n,h[mx],k;
int dp[mx];
int frog(int i){

    if(i>=n) return 0;
    if(dp[i]!=-1) return dp[i];
    int r=inf;
    for(int j=1;j<=k;j++)
        if(i+j<=n)
            r=min(r,abs(h[i]-h[i+j])+frog(i+j));
    return dp[i]=r;
}

void fn(){

    memset(dp,-1,sizeof(dp));
    cin >> n >> k;
    for(int i=1;i<=n;++i)
        cin >> h[i];
    cout << frog(1) el;
}

int main(){

    //file();
    optimize();
    //tc
        fn();

    GOOD_BYE
}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 12160
N = int(input())
A, B = map(int, input().split())

ret = [(A, B)]
for i in range(1, 12) :
  if i % 2 == 0 :
    B = A + B
  else :
    A = A - B
  ret.append((A, B))
  
print(*ret[N % 12])


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll H, W;
	cin >> H >> W;
	vector<ll> count(26, 0);
	REP(i, H){
		string S;
		cin >> S;
		REP(j, W){
			count[S[j]-'a']++;
		}
	}
	priority_queue<ll> pq;
	REP(i, 26) pq.push(count[i]);
	vector<ll> need(3, 0);
	need[0] = (H/2)*(W/2);
	if(H%2==1) need[1] += (W/2);
	if(W%2==1) need[1] += (H/2);
	if(H%2==1&&W%2==1) need[2]++;

	REP(i, need[0]){
		ll tmp = pq.top();
		pq.pop();
		tmp -= 4;
		if(tmp<0){
			cout << "No" << endl;
			return 0;
		}
		pq.push(tmp);
	}
	REP(i, need[1]){
		ll tmp = pq.top();
		pq.pop();
		tmp -= 2;
		if(tmp<0){
			cout << "No" << endl;
			return 0;
		}
		pq.push(tmp);
	}
	REP(i, need[2]){
		ll tmp = pq.top();
		pq.pop();
		tmp -= 1;
		if(tmp<0){
			cout << "No" << endl;
			return 0;
		}
		pq.push(tmp);
	}
	cout << "Yes" << endl;
	//vprint(need);
    return 0;
}

Measured memory_bytes: 256