akhauriyash/Code-Regression huggingface dataset:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    maxl = len(str(N))
    output = 0
    for n in range(1, N+1):
        if n%10 == 0: continue
        s = str(n)
        if s[0] == s[-1]:
            for j in range(1, maxl+1):
                if j == 1:
                    output += 1
                    continue
                if j == 2:
                    if 10*int(s[-1]) + int(s[0]) <= N:
                        output += 1
                    continue
                if j < maxl:
                    output += 10 ** (j-2)
                    continue
                #when j == maxl
                if int(s[-1]) < int(str(N)[0]):
                    output += 10 ** max(0, j-2)
                elif s[-1] == str(N)[0]:
                    output += int(str(N)[1:maxl-1]) + 1
                    if int(s[0]) > int(str(N)[-1]): output -= 1
        else:
            for j in range(2, maxl+1):
                if j < maxl:
                    output += 10 ** (j-2)
                    continue
                # when j == maxl
                if int(s[-1]) < int(str(N)[0]):
                    output += 10 ** (j-2)
                if s[-1] == str(N)[0]:
                    if j == 2:
                        if 10*int(s[-1]) + int(s[0]) <= N:
                            output += 1
                    else:
                        output += int(str(N)[1:maxl-1]) + 1
                        if int(s[0]) > int(str(N)[-1]): output -= 1
    print(output)
    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
using System;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split();
            int h = int.Parse(input1[0]);
            int n = int.Parse(input1[1]);
            string[] input2 = Console.ReadLine().Split();
            int aSum = 0;

            for (var i = 0; i < n; i++)
            {
                aSum += int.Parse(input2[i]);
            }

            if (aSum >= h)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 16096
#include<stdio.h>
#include<stdlib.h>

void swap(int x, int y) {
    int tempX = x;
    int tempY = y;
    x = tempY;
    y = tempX;
}

int main()
{
int x,y,r;

scanf("%d%d",&x,&y);

 if(x < 1 && 10^9 < y){
   exit(0);
}

 if(x<y){
   swap(x,y);
 }
  while(y>0){
    r = x%y;
    x = y;
    y = r;
  }

 printf("%d\n",x);
 return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;
    ll X[N], Y[N];
    vector<ll> xVec, yVec;
    REP(i, N)
    {
        ll x, y;
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;
        xVec.push_back(x);
        yVec.push_back(y);
    }

    sort(xVec.begin(), xVec.end());
    sort(yVec.begin(), yVec.end());

    // 全ての点を含む長方形の面積の最大値
    ll ans = (xVec[N - 1] - xVec[0]) * (yVec[N -1] - yVec[0]);

    // 長方形の辺となる候補を全探索
    // 右辺, 左辺 : x 座標の組
    // 上辺, 下辺 : y 座標の組
    // 辺の候補を決めたら、その長方形内に含まれる点の個数を数える
    // 全部でO(N^5) となるがN <= 50 なので間に合う
    for (int i = 0; i < N - 1; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            for (int k = 0; k < N - 1; ++k)
            {
                for (int l = k + 1; l < N; ++l)
                {
                    // 長方形に含まれる点の個数
                    int num = 0;
                    ll leftX = xVec[i];
                    ll rightX = xVec[j];
                    ll bottomY = yVec[k];
                    ll upperY = yVec[l];
                    for (int m = 0; m < N; ++m)
                    {
                        // 長方形の内部に点m が含まれるか判定
                        if (X[m] >= leftX && X[m] <= rightX && Y[m] >= bottomY && Y[m] <= upperY)
                        {
                            num++;
                        }
                    }
                    if (num >= K)
                    {
                        ans = min(ans, (rightX - leftX) * (upperY - bottomY));
                    }
                }   
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<vector<int>> happiness(N, vector<int>(3));
    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (i == 0) {
            happiness[i][0] = a;
            happiness[i][1] = b;
            happiness[i][2] = c;
        } else {
            happiness[i][0] = max(happiness[i - 1][1], happiness[i - 1][2]) + a;
            happiness[i][1] = max(happiness[i - 1][2], happiness[i - 1][0]) + b;
            happiness[i][2] = max(happiness[i - 1][0], happiness[i - 1][1]) + c;
        }
    }
    cout << *max_element(happiness[N - 1].begin(), happiness[N - 1].end()) << endl;
    return 0;
}

Measured memory_bytes: 5760
funcs = {
    'J': lambda s: s[-1:]+s[:-1],
    'C': lambda s: s[1:]+s[0],
    'E': lambda s: s[(len(s)+1)//2:]+s[len(s)//2:(len(s)+1)//2]+s[:len(s)//2],
    'A': lambda s: s[::-1],
    'P': lambda s: s.translate(str.maketrans('0123456789', '9012345678')),
    'M': lambda s: s.translate(str.maketrans('0123456789', '1234567890')),
}
n = int(input())
for i in range(n):
    s, t = [input().strip() for j in '01']
    for c in s[::-1]:
        t = funcs[c](t)
    else:
        print(t)



Measured memory_bytes: 5604
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		long K = long.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		long[]A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
		}
		int[]B1 = new int[40];
		int[]B2 = new int[40];
		for(var i=0;i<N;i++){
			long t = 1;
			for(var j=0;j<40;j++){
				long x = A[i]/t%2;
				if(x==0){
					B1[j]++;
				} else {
					B2[j]++;
				}
				t *= 2;
			}
		}
		long t2 = (long)Math.Pow(2,39);
		long ansf = 0;
		long ans = 0;
		for(var i=39;i>=0;i--){
			if(K >= t2 + ansf && B1[i] > B2[i]){
				ansf += t2;
				ans += B1[i] * t2;
			} else {
				ans += B2[i] * t2;
			}
			t2 /= 2;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 32220
N, K = map(int, input().split())
p = [int(x) for x in input().split()]

ksum = [0 for _ in range(N-K+1)]
ksum[0] = sum(p[:K])
for i in range(N-K):
    ksum[i+1] = ksum[i] - p[i] + p[i+K]

print((K+max(ksum))/2)

Measured memory_bytes: 31996
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
 
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount
 
#define INF INT_MAX/3
 
string s,t="AKIHABARA";
 
int main(){
  cin>>s;
  if(s.size()>t.size()){
    cout<<"NO"<<endl;
    return 0;
  }
  int j=0;
  rep(i,s.size()){
    if(j==t.size()){
      cout<<"NO"<<endl;
      return 0;
    }
    if(s[i]!=t[j]&&t[j]!='A'){
      cout<<"NO"<<endl;
      return 0;
    }else if(s[i]!=t[j]){
      j++; i--;
    }else if(s[i]==t[j])j++;
  }
  while(t[j]=='A')j++;
  if(j==t.size())cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[55];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    int mi=min_element(A,A+N)-A;
    int ma=max_element(A,A+N)-A;

    if(A[mi]==0&&A[ma]==0){
        cout<<0<<endl;
        return 0;
    }

    cout<<2*N<<endl;

    if(abs(A[ma])>=abs(A[mi])){
        cout<<ma+1<<" "<<1<<endl;
        cout<<ma+1<<" "<<1<<endl;
        for(int i=0;i<N-1;i++){
            cout<<i+1<<" "<<i+2<<endl;
            cout<<i+1<<" "<<i+2<<endl;
        }
    }
    else{
        cout<<mi+1<<" "<<N<<endl;
        cout<<mi+1<<" "<<N<<endl;
        for(int i=N-1;i>0;i--){
            cout<<i+1<<" "<<i<<endl;
            cout<<i+1<<" "<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
    int h, a;
    cin >> h >> a;
    if (h % a == 0){
        cout << h / a << endl;
    }else{
        cout << h / a + 1 << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <queue>

static std::vector<int64_t> memo;

int64_t search(int remain)
{
	if (memo[remain] >= 0) {
		return memo[remain];
	}

	int64_t count = 0;
	for (int i = 3; i <= remain; ++i) {
		if (i > remain) {
			break;
		}
		else if (i == remain) {
			++count;
			break;
		}
		else {
			count += search(remain - i);
		}
	}

	memo[remain] = count % 1000000007;

	return memo[remain];
}

int main()
{
	int S;
	std::cin >> S;
	memo.resize(S + 1, -1);
	std::cout << search(S) << std::endl;
	return 0;
}


Measured memory_bytes: 3612
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


N = int(input())
A = [int(x) for x in input().split()]

A2 = list(set(A))

k = len(A) - len(A2)

ans = len(A)-2*math.ceil(k/2)

print(ans)



Measured memory_bytes: 59496
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back


using namespace std;
using ll = long long;

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

const int mod = 1e9 +7;
int m;



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n >> m;
    bool a[n+1];
    rep(i,n+1) a[i] = false;
    rep(i,m) {
        int k;
        cin >> k;
        k--;
        a[k] = true;
        
    }
    ll dp[n+1];
    if(a[0]){
        dp[0]=0;
    }else dp[0]=1;
    if(a[1]){
        dp[1]=0;

    }else dp[1]=dp[0]+1;
    for(int i=2;i<n;++i){
        if(a[i]) dp[i]=0;
        else dp[i]=(dp[i-1]+dp[i-2])%mod;
    }

    cout << dp[n-1] << endl;
   
    

    return 0;
}


Measured memory_bytes: 1152
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n,m=MI()
	A=[1]*(n+1)
	ans=[0]*(n+1)
	ans[1]=1

	for _ in range(m):
		x,y=MI()
		if ans[x]==1:
			ans[y]=1
		if A[x]==1 and ans[x]==1:
			ans[x]=0
		A[x]-=1
		A[y]+=1
		#print(A,ans)

	print(sum(ans))









if __name__ == "__main__":
	main()


Measured memory_bytes: 75256
import numpy as np

n, k = map(int, input().split())
mx = {}
sushi = []
for _ in range(n):
    t, d  = map(int, input().split())
    if t not in mx:
        mx[t] = d
    elif mx[t] < d:
        mx[t] = d
    sushi.append([t,d])

# 美味しさでソート
taste_sorted_sushi = sorted(sushi, key=lambda x:x[1], reverse=True)

# 貪欲にK個選び分割する
selected_sushi = np.array(taste_sorted_sushi[:k], dtype=np.int64)

# 貪欲なK個の種類の分布を調べる
# K個の中で二つ以上あるものとそうでないものに分ける
S = set()
q = []
for s in selected_sushi:
    if s[0] in S:
        q.append(s[1])
    else:
        S.add(s[0])

q = sorted(q, reverse=True)
ans = sum(selected_sushi[:,1])+len(S)**2
tmp = ans

#print(selected_sushi, selected_sushi[:,1], 'ans', ans, S, q)

#print(S)
for i in range(k,n):
    if not q:
        break
    if taste_sorted_sushi[i][0] not in S:
        #print('ans',ans)
        #print('taste_sorted_sushi',taste_sorted_sushi[i])
        tmp = tmp-q.pop()+taste_sorted_sushi[i][1]-len(S)**2 + (len(S)+1)**2
        ans = max(ans, tmp)
        S.add(taste_sorted_sushi[i][0])

print(ans)

Measured memory_bytes: 39896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int INF=1000100010;
const int MAX_N=101;
struct edge{
    int to,cap,rev;
    edge(int to,int cap,int rev):
    to(to),cap(cap),rev(rev){}
    };

vector<edge> g[MAX_N];
int dist[MAX_N];
int used[MAX_N];
void add_edge(int src,int dst,int cap){
    g[src].pb(edge(dst,cap,g[dst].size()));
    g[dst].pb(edge(src,0,g[src].size()-1));
}
void bfs(int s){
    memset(dist,-1,sizeof(dist));
    queue<int> q;
    dist[s]=0;
    q.push(s);
    while(!q.empty()){
        int v=q.front();q.pop();
        rep(i,g[v].size()){
            edge &e=g[v][i];
            if(e.cap>0&&dist[e.to]<0){
                dist[e.to]=dist[v]+1;
                q.push(e.to);
            }
        }
    }
}
int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    rep(i,g[v].size()){
        edge &e=g[v][i];
        if(e.cap>0&&dist[v]<dist[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        bfs(s);
        if(dist[t]<0) return flow;
        memset(used,0,sizeof(used));
        int f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}
int main(){
    int n,e;
    cin>>n>>e;
    int s,t,c;
    rep(i,e){
        cin>>s>>t>>c;
        add_edge(s,t,c);
    }
    cout<<max_flow(0,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b)
    {
        return b;
    }
    return a; 
}

template<class T>
bool chmin(T &a, const T &b) {
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0; 
}

int main() {
    ll x, y; cin >> x >> y;

    rep(i, x+1) {
        if (2*(i) + 4*(x-(i)) == y || 
            4*(i) + 2*(x-(i)) == y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[0]*n
for i in range(n):
  if v[i]-c[i]>0:
    d[i]=v[i]-c[i]
s=0
for i in range(n):
  s=s+d[i]
print(s)

Measured memory_bytes: 3060
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    String a=sc.next();
    String b=sc.next();
    if(a.length()==b.length()-1&&b.indexOf(a)==0)
    {
      System.out.println("Yes");
    }
    else
    {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35720
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b; 
    if(a%b == 0){
        cout << 0;
    }
    else
    {
        cout << 1;
    }
    
    cout << endl;
}


Measured memory_bytes: 256
fn main() {
    let first_line = read_all_and_parse::<usize>();
    let sunuke_cnt = first_line[0];
    let okasi_cnt = first_line[1];
    let mut sunukes = vec![0;sunuke_cnt];
    let mut counter = 0;
    loop {
        read();
        for sunuke_id in read_all_and_parse::<usize>() {
            sunukes[sunuke_id - 1] += 1;
        }
        counter += 1;
        if counter == okasi_cnt {
            break;
        }
    }
    let mut counter = 0;
    for okasi_motteru in sunukes {
        if okasi_motteru == 0 {
            counter += 1;
        }
    }
    println!("{}", counter);
}
fn read() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}
fn read_as_vec() -> std::vec::Vec<String> {
    read().split(' ').map(|s| s.to_string()).collect()
}
fn read_and_parse<T: std::str::FromStr + std::fmt::Debug>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let line = line.trim();
    line.parse::<T>().ok().unwrap()
}
fn read_all_and_parse<T: std::str::FromStr + std::fmt::Debug>() -> Vec<T> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let line = line.trim();
    line.split(' ').map(|s| s.parse::<T>().ok().unwrap()).collect()
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000;
double p[maxn];
double dp[maxn][maxn];		//dp[i][j]代表到了第i个硬币有j个硬币是正面的概率 

//dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]) 
int main() {
	int n;cin>>n;
	for(int i = 1;i <= n;i++) cin>>p[i];
	
	dp[1][1] = p[1];
	dp[1][0] = 1-p[1];
	for(int i = 2;i <= n;i++) {
		for(int j = 0;j <= n;j++) {
			dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
 		}
	}
	double ans = 0;
	for(int i = n/2+1;i <= n;i++) {
		ans += dp[n][i];
	}
	printf("%.10lf\n",ans);
	return 0;
} 

Measured memory_bytes: 70528
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  int sz=ab.size();
  qab[0].reserve(sz);
  qab[1].reserve(sz);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc+1)&1) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0]&&!c[1-i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<math.h>
int main(){
int deg,a,b;
double rad,s,l,h;
double PI=acos(-1);
scanf("%d %d %d",&a,&b,&deg);
rad=deg*PI/180;
s=a*b*sin(rad)/2;
l=a*a+b*b-2*a*b*cos(rad);
l=sqrt(l);
l=l+a+b;
h=2*s/a;
printf("%lf\n%lf\n%lf\n",s,l,h);
return 0;
}


Measured memory_bytes: 2104
s = input()
k = int(input())

s_list = []
for i in range(0, len(s)):
    for j in range(1, 1+k):
        if len(s_list) < k:
            s_list.append(s[i:i+j])
            s_list = list(set(s_list))
            s_list.sort()
        elif s_list[k-1] > s[i:i+j]:
            s_list.append(s[i:i+j])
            s_list = list(set(s_list))
            s_list.sort()
            s_list = s_list[:k]
    else:
        continue

dict_list = list(set(s_list))
dict_list.sort()

print(dict_list[k-1])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int t[105];
double v[105];
double u[40005];
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  t[0] = 0;
  v[0] = 0;
  v[N+1] = 0;
  for( int i=1; i<=N; i++ ) cin >> t[i];
  for( int i=1; i<=N; i++ ) cin >> v[i];
  for( int i=1; i<=N; i++ ){
    t[i] += t[i-1];
  }
  for( int i=0; i<=t[N]*2; i++ ){
    u[i] = 0.5 * i;
  }
  for( int i=t[N]*2; i>=0; i-- ){
    u[i] = min( u[i], t[N] - i*0.5 );
  }
  for( int i=1; i<=N; i++ ){
    for( int j=0; j<t[i-1]*2; j++ ){
      u[j] = min( u[j], v[i] + t[i-1] - j*0.5 );
    }
    for( int j=t[i-1]*2; j<=t[i]*2; j++ ){
      u[j] = min( u[j], v[i] );
    }
    for( int j=t[i]*2+1; j<=t[N]*2; j++ ){
      u[j] = min( u[j], v[i] + j*0.5 - t[i] );
    }
  }
  double ret = 0;
  for( int i=1; i<=t[N]*2; i++ ){
    ret += (u[i-1] + u[i]) / 4;
  }
  printf( "%.12f\n", ret );
}

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

int main(){
    int n;
    cin>>n;
    if(n%111==0)cout<<n<<endl;
    else cout<<((n/111)+1)*111<<endl;

    return 0;
}

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

int main() {
  int n,l;
  cin>>n>>l;
  int ans=(2*l+n-1)*n/2;
  if (l<0&&l+n-1<0) ans-=l+n-1;
  else if (l>0&&l+n-1>0) ans-=l;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
using namespace std;

int r, c;
bool bio[10][10];
char s[10][10];

void dfs( int x, int y ){
	
	if ( y == c ) return;
	bio[x][y] = true;
	if ( x && s[x-1][y] == '#' && y && s[x][y-1] == '#' ){
		printf("Impossible\n");
		exit(0);
	}
	if ( x + 1 < r && s[x+1][y] == '#' && y + 1 < c && s[x][y+1] == '#' ){
		printf("Impossible\n");
		exit(0);
	}
	
	if ( x + 1 < r && s[x+1][y] == '#' ) dfs(x + 1, y);
	else dfs(x, y + 1);
	
}

int main(){
	
	scanf("%d %d", &r, &c);
	for ( int i = 0; i < r; i++ )
		scanf("%s", s[i]);
	dfs(0, 0);
	printf("Possible\n");
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b = s.nextInt();
		if(a>=-1000 && a<=1000 && b>=-1000 && b<=1000){
		if(a==b){
			System.out.println("a == b");
		}
		if(a>b){
			System.out.println("a > b");
		}
		if(a<b){
			System.out.println("a < b");
		}
		}
	}

}

Measured memory_bytes: 26216
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>

using namespace std;
typedef long long LL;

int main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

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

int main(){

    string S, T;
    cin >> S >> T;
    int n = S.size() - T.size()+1;

    int max_diff = 0;
    rep (i, n){
        int diff = 0;
        rep (j, T.size()){
            if (S[i+j] == T[j]) diff++;
        }
        max_diff = max(max_diff, diff);
    }
    cout << T.size()-max_diff << endl;

    return 0;
}

Measured memory_bytes: 3624
# include <bits/stdc++.h>
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#include <tr1/unordered_map>
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#include <map>
using namespace std;



int main()
{



     flash;
     ///////////////////////////////////////////////////////////////////////////////////////

     

ll n,m;
cin>>n>>m;
if(m==n)
{
	cout<<"Yes";
}
else
{
	cout<<"No";
}




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

     return 0;

}


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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> pair;
	rep(i, n) cin >> a[i];
	sort(all(a));
	pair.push_back(0);
	pair.push_back(0);
	rep(i, n-1){
		if(a[i] == a[i+1]) pair.push_back(a[i]), i++;
	}
	cout << (ll) pair[pair.size()-1] * pair[pair.size()-2] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int formula();
int digit();
int pls();
int p,result,cal;
string str;
char c;

int main(){
  cin>>str>>result;
  cal=str[0]-'0';
  for(int i=1;i<=(int)str.size();i++){
    if(i%2) c=str[i];
    else{
      if(c=='*') cal=cal*(str[i]-'0');
      else cal=cal+(str[i]-'0');
    }
  }
  p=0;
  int r=formula();
  if(cal==result&&r==result) cout<<'U'<<endl;
  else if(cal==result) cout<<'L'<<endl;
  else if(r==result) cout<<'M'<<endl;
  else cout<<'I'<<endl;
  return 0;
}

int formula(){
  int val=pls();
  while(str[p]=='+'){
    p++;
    val=val+pls();
  }
  return val;
}

int pls(){
  int val=digit();
  while(str[p]=='*'){
    p++;
    val=val*digit();
  }
  return val;
}

int digit(){
  int val=str[p]-'0';
  p++;
  return val;
}

Measured memory_bytes: 1196
#include<cstdio>
using namespace std;

bool f[11000];

int main()
{
    int n, i, j, tot=0, x;
    scanf("%d", &n);
    f[0] = 1;
    for (i = 1; i <= n; i++)
    {
        scanf("%d", &x);
        tot += x;
        for (j = tot; j >= x; j--)
            if (f[j - x]) f[j] = 1;
    }
    for (i = tot; i > 0; i--)
        if (i % 10 != 0 && f[i]) break;
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N){
    int ans=0;
    for(int i=1;i<=N; i++){
        int cnt=0;
        for(int j=1; j <=i; j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8 && i%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul

mod = 10 ** 9 + 7
INF = 10 ** 13
sys.setrecursionlimit(2147483647)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]



def prime_decomposition(n):
    D = defaultdict(int)
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            D[i] += 1
            n //= i
        if n == 1:
            break
    if n != 1:
        D[n] += 1
    return D

n = I()
ans = 0
DD = prime_decomposition(n)
for v in DD.values():
    now = 1
    while v >= now:
        v -= now
        ans += 1
        now += 1

print(ans)



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

int main()
{
	int n, s=0;
	cin >> n;
	int i=n;
	
	while (i!=0)
	{
		s+=i%10;
		i=i/10;
	}
	
	if (n%s==0)
	{
		cout << "Yes" << endl;
		return 0;
	}
	else
	{
		cout << "No" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int h,w,r=5000;
  string s[50];
  cin>>h>>w;
  for(int i=0;i<h;i++) cin>>s[i];
  for(int i=1;i<h-1;i++) for(int j=i+1;j<h;j++){
      int r0=0;
      for(int k=0;k<i;k++) for(int l=0;l<w;l++) if(s[k][l]!='W') r0++;
      for(int k=i;k<j;k++) for(int l=0;l<w;l++) if(s[k][l]!='B') r0++;
      for(int k=j;k<h;k++) for(int l=0;l<w;l++) if(s[k][l]!='R') r0++;
      r=min(r,r0);
    }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

vector<LL> b;

LL coef(LL n, LL m){
    LL ans = 0;
    if(m == 0 || n == m){
        return 1;
    }
    LL cnt = b[n] - b[m] - b[n-m];
    if(cnt == 0){
        return 1;
    }else{
        return 0;
    }
}

LL solveBit(vector<LL>& a){
    LL ans = 0;
    for(LL i = 0; i < a.size(); ++i){
        if(a[i] == 0) continue;
        ans += coef(a.size()-1, i);
        //cerr << "coef " << a.size()-1 << ", " << i+1 << " = " << coef(a.size()-1, i+1) << endl;
    }
    return ans % 2;
}


int main(){
    LL n;
    cin >> n;
    string s;
    cin >> s;
    vector<LL> a(n);
    vector<LL> c(n+1);
    b = vector<LL>(n+1);
    for(LL i = 0; i < 20; ++i){
        LL w = (1LL<<i);
        for(LL j = w; j <= n; j+=w){
            c[j]++;
        }
    }
    for(LL i = 1; i <= n; ++i){
        b[i] = b[i-1] + c[i];
    }
    for(LL i = 0; i < n; ++i){
        a[i] = s[i] - '1';
    }
    set<LL> as(a.begin(), a.end());
    LL ans = 0;
    if(as.size() == 3){
        for(LL i = 0; i < n; ++i){
            a[i] = a[i] % 2;
        }
        ans = solveBit(a);
    }else if(as.size() == 2){
        LL low = *as.begin();
        LL high = *as.rbegin();
        cerr << "low=" << low << ", hight=" << high << endl;
        ans = solveBit(a) * (high - low) + low;
    }else{ // as.size() == 1
        LL low = 0;
        LL high = *as.begin();
        cerr << "low0=" << low << ", hight=" << high << endl;
        ans = solveBit(a) * (high - low) + low;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 24964
from collections import defaultdict

S = input()
appear = list(S)

d = defaultdict(int)

for i in appear:
    d[i] += 1

a = list(d.values())

if len(d.items()) == 2:
    for i in a:
        if i != 2:
            print("No")
    print("Yes")

else:
    print("No")

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

int main()
{
    int d, sum = 0;

    while( cin >> d )
    {
        int x = d;
        while( x <= 600 )
        {
            int y = ( x - d ) * ( x - d );      //面積の縦の値(y)は、最初のxの値で計算。dが20-0=20なら、0*20から計算を始める。
            sum += d * y;
            x += d;
        }
        cout << sum << endl;
        sum = 0;
    }
    return 0;
}


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

int main(){
  int N; cin >> N;
  int A[200000];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int B[200000];
  int pos=N/2;
  for(int i=0; i<N; i++){
    pos+=(i*(i%2==0?1:-1));
    B[pos]=A[i];
  }
  if(N%2==1) reverse(B,B+N);
  for(int i=0; i<N; i++){
    cout << B[i] << (i!=N-1?" ":"");
  }
  cout << endl;
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int a[4];
bool flag = false;

void dfs(int i, int sum, string ans) {
    if (i == 3 && sum == 7 && !flag) {
        cout << ans + "=7" << endl;
        flag = true;
        return;
    }
    else if (i == 3) {
        return;
    }
    dfs(i+1, sum + a[i+1], ans + "+" + (char)('0' + a[i+1]));
    dfs(i+1, sum - a[i+1], ans + "-" + (char)('0' + a[i+1]));
}

int main() {
    string input;

    cin >> input;
    for (int i = 0; i < 4; i++) { a[i] = input[i] - '0'; }
    string ans;
    ans += (char)('0' + a[0]);
    dfs(0, a[0], ans);
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    while (sc.hasNextLine) {
      var tmpline = sc.nextLine()
      while (!(tmpline contains "the") && !(tmpline contains "this") &&
        !(tmpline contains "that")) {

        val line2 = tmpline.map(
          _ match {
            case ch if 'b' to 'z' contains ch => (ch - 1).toChar
            case ch if ch == 'a' => 'z'
            case ch => ch
          }
        )
        tmpline = line2
      }
      println(tmpline)

    }
  }
}

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

long long rec(long long n, long long d){
	
	if(n<=3)
		return d;
	else
		return rec((n+2)/3, d+1);
}

int main(){
	
	long long n;
	cin>>n;
	
	cout<<rec(n, 1)<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

bool possible(ll h,vi &a,ll k)
{
    if(h==0)
        return false;
    ll cuts=0;
    for(ll i=0;i<sz(a);i++)
    {
        cuts+=(a[i]+h-1)/h-1;
    }
    return cuts<=k;
}

int main()
{
    fast();
    ll n,k;
    cin>>n>>k;
    vi a(n);
    cin>>a;
    ll low=0;
    ll high=*max_element(all(a));
    while(high>low)
    {
        ll mid=(high+low)/2;
        if(possible(mid,a,k))
        {
            if(possible(mid-1,a,k))
            {
                high=mid-1;    
            }
            else
                low=high=mid;
        }
        else
        {
            low=mid+1;
        }
    }
    cout<<low<<nl;
}


Measured memory_bytes: 4744
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
  a.append(a[i]+A[i])
for i in range(m):
  b.append(b[i]+B[i])
ans=0
for i in range(n+1):
  if a[i]>k:
    break
  for j in range(m,-1,-1):
    if a[i]+b[j]<=k:
      ans=max(ans,i+j)
      m=j
      break
print(ans)

Measured memory_bytes: 47240
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, M, K, A;
    cin >> N >> M;
    int food[M] = {};

    for (int i = 0; i < N; i++) {
        cin >> K;
        for (int j = 0; j < K; j++) {
            cin >> A;
            food[A - 1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (food[i] == N) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

loop do
  m, f, r = readline.split(' ').map(&:to_i)
  break if m == -1 && f == -1 && r == -1

  rank = if m == -1 || f == -1
    'F'
  else
    case m + f
    when 80..100
      'A'
    when 65...80
      'B'
    when 50...65
      'C'
    when 30...50
      r >= 50 ? 'C' : 'D'
    else
      'F'
    end
  end
  puts rank
end



Measured memory_bytes: 6884
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[10001];
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                for(int k = 1; k <= n; k++){
                    int ind = i*i+j*j+k*k+i*j+j*k+k*i;
                    if(ind > n){
                        break;
                    }
                    a[ind]++;
                }
            }
        }
        for(int i = 1; i <= n; i++){
            System.out.println(a[i]);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 28764
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct UnionFind {
    vector<int> par;
	vector<int> cnt;

    UnionFind(int N) : par(N), cnt(N) {
        for (int i = 0; i < N; i++) {par[i] = i; cnt[i] = 1;}
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    void merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
		cnt[ry] = cnt[rx] + cnt[ry];
    }

	int count(int x) {
		return cnt[root(x)];
	}
};

int main() {
	int n, m, k;
	cin >> n >> m >> k;

	int a[N], b[N];

	rep(i, m) cin >> a[i] >> b[i];

	int c[N], d[N];
	rep(i, k) cin >> c[i] >> d[i];

	UnionFind tree(n + 10);
	rep(i, m) {
		tree.merge(a[i], b[i]);
	}

	vi fr[N];
	rep(i, m) {
		fr[a[i]].push_back(b[i]);
		fr[b[i]].push_back(a[i]);
	}

	vi bl[N];
	rep(i, k) {
		bl[c[i]].push_back(d[i]);
		bl[d[i]].push_back(c[i]);
	}

	for(int i = 1; i <= n; i++) {
		int c = tree.count(i) - fr[i].size() - 1;
		for(auto j : bl[i]) {
			if(tree.issame(i, j)) c--;
		}
		cout << c;
		if(i < n) cout << ' ';
		else cout << endl;
	}
	return 0;
}


Measured memory_bytes: 14584
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
 
using namespace std;
 
int main (){
	string s;
	cin>>s;
	cout<<s.substr(0, 4)<<" "<<s.substr(4)<<endl;
}

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

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

  vector<int> a(n);
  for (auto&& e : a)
    cin >> e;

  vector<int64_t> c(n + 1);
  for (const auto& e : a)
    c[e]++;

  int64_t ans = 0;
  for (const auto& e : c)
    ans += e * (e - 1) / 2;

  for (const auto& e : a)
    cout << ans - (c.at(e) - 1) << endl;
}


Measured memory_bytes: 4992
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        M: usize,
        S: usize,
    }

    let mut edges = vec![vec![]; N];
    let mut mx: usize = 0;

    for _ in 0..M {
        input! {
            fr: Usize1,
            to: Usize1,
            cost: i64,
            dist: i64,
        }
        edges[fr].push((to, -cost, dist));
        edges[to].push((fr, -cost, dist));
        mx += cost as usize;
    }

    for i in 0..N {
        input! {
            C: i64,
            D: i64,
        }
        edges[i].push((i, C, D));
    }

    let mut minDist = vec![vec![INF as i64; mx + 1]; N];
    let mut que = BinaryHeap::new();

    minDist[0][min(S, mx)] = 0;
    que.push((0, 0, min(S, mx) as i64));

    while !que.is_empty() {
        let (mut dist, now, cnt) = que.pop().unwrap();
        dist = -dist;

        if minDist[now][cnt as usize] < dist {
            continue;
        }

        for &(to, cost, d) in &edges[now] {
            if cnt + cost < 0 {
                continue;
            }
            let c: i64 = min(cnt + cost, mx as i64);
            if minDist[to][c as usize] > dist + d {
                minDist[to][c as usize] = dist + d;
                que.push((-(dist + d), to, c));
            }
        }
    }

    for i in 1..N {
        println!("{}", minDist[i].iter().min().unwrap());
    }
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){
        in(r...);
        return true;
    }else{
        return false;
    }
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define YN(x) out((x) ? "YES" : "NO"), indent()
#define Yn(x) out((x) ? "Yes" : "No"), indent()
#define yn(x) out((x) ? "yes" : "no"), indent()
main(){
    INCANT;
    int a, b, c;
    in(a, b, c);
    Yn(a < c && c < b || a > c && c > b);
}

Measured memory_bytes: 256