akhauriyash/Code-Regression huggingface dataset:
#pragma region template 1.0
#pragma region def
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion enddef

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll K = 1; K * K <= N; ++K)
    {
        if (N % K == 0)
        {
            ll n = N;
            while (K > 1 and n % K == 0)
            {
                n /= K;
            }
            if (n % K == 1)
            {
                ++ans;
            }
            n = N;
            ll k = N / K;
            while (n % k == 0)
            {
                n /= k;
            }
            if (k > K and n % k == 1)
            {
                ++ans;
            }
        }
        if ((N - 1) % K == 0)
        {
            if (K > 1)
            {
                ++ans;
            }
            if ((N - 1) / K > K)
            {
                ++ans;
            }
        }
    }
    OUT(ans);
}
#pragma endregion template

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 5 * 2)
input = sys.stdin.readline
N, M = map(int, input().split())
Ps = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    Ps[x - 1].append(y - 1)

mem = [-1] * N


def rec(n):
    if mem[n] > -1:
        return mem[n]
    elif len(Ps[n]) == 0:
        mem[n] = 0
        return mem[n]
    else:
        mem[n] = max([rec(Ps[n][i]) for i in range(len(Ps[n]))]) + 1
        return mem[n]


for i in range(N):
    rec(i)
print(max(mem))

Measured memory_bytes: 135344
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int k;
  cin >> k;
  
  vector<ll> a(k);
  rep(i, k) cin >> a[i];
  if (a[k - 1] != 2) {
    cout << -1 << endl;
    return 0;
  }

  pair< ll, ll > sec[100010];
  sec[k - 1].first = 2; sec[k - 1].second = 3;
  for (int i = k - 2; i >= 0; i--) {
    ll l = sec[i + 1].first, r = sec[i + 1].second;
    l = ((l - 1LL) / a[i] + 1LL) * a[i];
    r = (r / a[i] + 1LL) * a[i] - 1;
    //cout << l << " " << r << endl;
    if (!(l <= r)) {
      cout << -1 << endl;
      return 0;
    }
    sec[i].first = l; sec[i].second = r;
  }
  cout << sec[0].first << " " << sec[0].second << endl;

  return 0;
  
}


Measured memory_bytes: 2560
A1,A2,A3 = input().split()

A1 = int(A1)
A2 = int(A2)
A3 = int(A3)

A = sorted(list((A1,A2,A3)))

cost = 0

for i in range(len(A)-1):
    cost += abs(A[i] - A[i+1])
print(cost)

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//6/9コンテスト

public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sa=100;
		int konkai=1000;
		List<Integer> list= new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		//System.out.println(list.get(1));
		for(int i=0;n-1>i;i++) {
			int one=0;
			int two=0;
			for(int l=0;i+1>l;l++) {
				one=one+list.get(l);
			}
			for(int t=0;n-1-i>t;t++) {
				two=two+list.get(n-1-t);
			}

			konkai=Math.abs(one-two);
			if(konkai<sa) {
				sa=konkai;
			}

		}
		System.out.println(sa);



	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=305,INF=1<<30;

ll dp[MAX][MAX];
ll pre[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K,M;
    cin>>N>>K>>M;
    
    dp[0][0]=1;
    
    pre[0][0]=1;
    
    for(int k=0;k<=N;k++){
        for(int l=0;l<=N;l++){
            for(int m=l;m<=N;m++){
                pre[k+1][m]+=pre[k][l]*(m+1);
                pre[k+1][m]%=M;
            }
        }
    }
    
    for(int k=0;k<=N;k++){
        for(int l=1;l<=N;l++){
            pre[k][l]+=pre[k][l-1];
            pre[k][l]%=M;
        }
    }
    
    for(int i=0;i<K;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;j+k<=N;k++){
                dp[i+1][j+k]+=dp[i][j]*pre[k][j];
                dp[i+1][j+k]%=M;
            }
        }
    }
    
    cout<<dp[K][N]<<endl;
}



Measured memory_bytes: 5080
loop do
	h, w = gets.chomp.split.map(&:to_i)
	break if [w, h].all?(&:zero?)
	tile_map = Array.new
	h.times do |i|
		tile_map[i] = gets.chomp.split('')	
	end

	x = y = 0
	tile_already_arrived = Array.new
	h.times { tile_already_arrived << Array.new(w, false) }
	is_loop = false

	while true
		tile = tile_map[y][x]
		if tile_already_arrived[y][x] == true
			is_loop = true
			break
		else
			tile_already_arrived[y][x] = true
			case tile
			when '>' 
				x += 1
			when '<'
				x -= 1
			when 'v'
				y += 1
			when '^'
				y -= 1
			when '.'
				goal = [x,y]
				break
			end
		end
	end

	if is_loop
		puts "LOOP"
	else
		puts "#{goal[0]} #{goal[1]}"
	end
end

Measured memory_bytes: 6836
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


ll gcd(ll N,ll M,ll L){
  while(M!=N)
  if(M>N) M=M-N;
  else N=N-M;

  while(M!=L)
  if(M>L) M=M-L;
  else L=L-M;
  
  return L;
}

int main(){
  ll K,sum=0;
  cin >> K;
  for(ll i=1; i<=K; i++){
    for(ll j=1; j<=K; j++){
      for(ll k=1; k<=K; k++){
        sum+=gcd(i,j,k);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>

int main() {
  std::string s;
  int count;
  std::cin >> s;
  if (s[0] == '1') count++;
  if (s[1] == '1') count++;
  if (s[2] == '1') count++;
  std::cout << count << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

ll a,b,c,d;
ll f(ll x){
	ll t2 = b/x;
	ll t1 = (a-1)/x;
	return max((ll)0,t2-t1);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>a>>b>>c>>d;
	cout<<(b-a+1)-(f(c)+f(d)-f((c*d)/__gcd(c,d)))<<endl;










	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int main()
{
	cin >> N;
	if (N == 1)
	{
		cout << 1.0 << endl;
	} else if (N % 2 == 0)
	{
		cout << 0.5 << endl;
	} else {
		cout << ((double) (N / 2 + 1)) / N << endl;
	}
	return 0;
}

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

int main(){
    string S;
    cin >> S;

    for(int i=0; i<S.size(); i++){
        if(S[i]=='?'){
            S[i] = 'D';
        }
    }

    rep(i,S.size()) cout << S[i];
}

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



int main() {
	//??£?¨?
	string point_pieces;
	int pieces[9];
	int check;
	vector<char> anss;
	while (cin >> point_pieces) {
		//point_pieces?????????????????????
		for (int i = 0; i < 9; i++) {
			if (point_pieces[i] == 'o')pieces[i] = 1;
			else if (point_pieces[i] == 'x')pieces[i] = 0;
			else if (point_pieces[i] == 's')pieces[i] = -100;
		}
		//?????¢????¢?????????? o???????????£????????????check????????????s???????????£????????????check????????????????????£??????????????£??????-????????????
		check = -1;
		for (int i = 0; i < 3; i++) {
			if (pieces[i * 3] + pieces[i * 3 + 1] + pieces[i * 3 + 2] == 3)check = 0;
			else  if (pieces[i * 3] + pieces[i * 3 + 1] + pieces[i * 3 + 2] == 0)check = 1;
		}
		for (int i = 0; i < 3; i++) {
			if (pieces[i] + pieces[i + 3] + pieces[i + 6] == 3)check = 0;
			else if (pieces[i] + pieces[i + 3] + pieces[i + 6] == 0)check = 1;
		}
		if (pieces[0] + pieces[4] + pieces[8] == 3)check = 0;
		else if (pieces[0] + pieces[4] + pieces[8] == 0)check = 1;
		if (pieces[2] + pieces[4] + pieces[6] == 3)check = 0;
		else if (pieces[2] + pieces[4] + pieces[6] == 0)check = 1;
		//check?????????
		if (check == 0)cout << 'o' << endl;
		else if (check == 1)cout << 'x' << endl;
		else cout << 'd' << endl;
	}
	
}

Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> G(n,0);
    repi(i,m,0){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a]++;
        G[b]--;
    }
    repi(i,n,1){
        G[i] += G[i-1];
    }
    repi(i,n-1,0){
        if(G[i]%2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	std::string a, b, c, d;
	std::cin >> a >> b >> c;
	d = a + b + c;
	int e;
	e = std::stoi(d);
	if (e % 4 == 0) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
}

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

namespace ABC085C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int Yen = int.Parse(str[1]);

            int x = 0;
            int y = 0;
            int z = 0;
            Boolean flag = false;

            for (int xi=0; xi <= n; xi++)
            {
                for (int yi = 0; yi <= n-xi; yi++)
                {
                    if (Yen - (10000*xi+5000*yi+1000*(n-xi-yi)) == 0)
                    {
                        flag = true;
                        x = xi;
                        y = yi;
                        z = n - x - y;
                        break;
                    }
                }
            }

            if (!flag)
            {
                x = y = z = -1;
            }

            Console.WriteLine("{0} {1} {2}", x, y, z);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
struct play{
	int c,t;
};play h[1010];
bool cmp2(play a,play b)
{
	return a.c<b.c;
}
int main(){
	int n,m,cnt=0,top=1,cost=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&h[i].c,&h[i].t);
	}
	sort(h+1,h+1+n,cmp2);
	while(7)
	{
		if(h[top].t>m)top++;
		else
		{
			printf("%d\n",h[top].c);
			return 0;
		}
		if(top>n)
		{
			printf("TLE\n");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma warning( disable : 4996 )
#define ll long long
#define pb push_back
#define endl '\n'
#define fastIO cin.tie( 0 );ios_base::sync_with_stdio( false )
#define pii pair<int, int>
#define eps 1e-13
#define N 14

using namespace std;

inline void init()
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    char tmp = s[k - 1];
    for ( int i = 0; i < s.size(); ++i ) {
        if ( s[i] != tmp )
            s[i] = '*';
    }
    cout << s;
}

inline void solve()
{
    cout << endl;
}

int main()
{
    fastIO;
    init();
    solve();

    return 0;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
a = deque([int(input()) for _ in range(M)])

before1 = 1
before2 = 0
ai = a.popleft() if len(a) else 0

for i in range(1, N+1):
    if i == ai:
        before2 = before1
        before1 = 0
        ai = a.popleft() if len(a) else ai
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current

print(before1)


Measured memory_bytes: 8056
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ct(m,0);
    rep(i,n){
        int nu;
        cin >> nu;
        rep(j,nu){
            int an;
            cin >>an;
            ct[an-1]++;
        }
    }
    int ans=0;
    rep(i,m){
        if(ct[i]==n)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;



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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mx=3007;
string s1,s2;
int dp[mx][mx];

int solve(int i, int j)
{
    if(i==s1.size()||j==s2.size())
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
        //cout<<i<<" "<<j<<endl;
    if(s1[i]==s2[j])
            return  dp[i][j]=solve(i+1,j+1)+1;
    int ans1=solve(i+1,j),ans2=solve(i,j+1);

    return dp[i][j]=max(ans1,ans2);

}


int main()
{
    memset(dp,-1,sizeof dp);
    int i ,j;
    cin>>s1>>s2;
    //cout<<solve(0,0)<<endl;
    int x=solve(0,0);
    i=0;j=0;
    while(i<s1.size()&&j<s2.size())
    {
        if(s1[i]==s2[j])
        {cout<<s1[i];
        i++;j++;}
        else if(dp[i+1][j]>dp[i][j+1])
            i++;
        else
            j++;
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 35840
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

vector<bool> W(100010);


int main() {
    int N,K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    for(int i = 0; i <= K; i++){
        if(W.at(i) == 0){
            for(int j = 0; j < N; j++){
                if(i + a.at(j) < 100010){
                    W.at(i + a.at(j)) = 1;
                }
            }
        }
    }
    if(W.at(K)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	char str[200100];
	scanf("%s",str);
	int a=-1,z=0;
	for (int i = 0; str[i]!='\0'; ++i)
	{
		if(str[i]=='A'&&a == -1) a=i;
		if(str[i]=='Z') z=i;
	}
	printf("%d\n",z-a+1);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MAXN 10010
using namespace std;

const int c[]={0,2,5,5,4,5,6,3,7,6};

int n,m,a[10];
string f[MAXN];

bool g(string &a,string &b)
{
	if (a.length()!=b.length()) return a.length()>b.length();
	for (int i=0;i<a.length();i++)
		if (a[i]!=b[i]) return a[i]>b[i];
	return true;
}

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		{
			int k=i-c[a[j]];
			if (k<0) continue;
			if (k>0&&f[k]=="") continue;
			string p="";p.push_back(a[j]+'0');
			if (a[j]>=f[k][0]-'0') p=p+f[k];
			else p=f[k]+p;
			if (g(p,f[i])) f[i]=p;
		}
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

int CalcBFS(int a, int b, std::vector<std::string>S, int hmax, int wmax)
{
	int res = 0;
	std::deque<std::pair<int, int>> Q;
	std::vector<std::vector<int>>d(hmax, std::vector<int>(wmax, -1));

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

	d[a][b] = 0;
	Q.push_back(std::make_pair(a, b));
	while (!Q.empty())
	{
		auto cur = Q.front();
		Q.erase(Q.begin());
		int y = cur.first;
		int x = cur.second;

		for (int i = 0; i < 4; i++)
		{
			int ny = y + dy[i];
			int nx = x + dx[i];
          
			if (ny < 0 || nx < 0 || ny >= hmax || nx >= wmax){ continue; }
			if (S[ny][nx] == '#' || d[ny][nx] != -1){ continue; }
			for (int j = 0; j < Q.size(); j++){				
				if (ny == Q[j].first && nx == Q[j].second){ continue; }
			}

			d[ny][nx] = d[y][x] + 1;
			Q.push_back(std::make_pair(ny, nx));
		}
	}

	for (int i = 0; i < hmax; i++)
	{
		for (int j = 0; j < wmax; j++)
		{
			res = std::max(res, d[i][j]);
		}
	}

	return res;
}

int main()
{
	int H = 0, W = 0, ans = 0;
	std::cin >> H >> W;

	std::vector<std::string> S(H);
	for (int i = 0; i < H; i++)
	{
		std::cin >> S[i];
	}
	int row = S.size();
	int col = 0;
	for (int i = 0; i < H; i++){
		col = std::max((int)(S[i].length()) , col);
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S[i][j] == '#') continue;
			ans = std::max(ans, CalcBFS(i, j, S, row, col));
		}
	}
	std::cout << ans << std::endl;

	return 0;
}

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

int main()
{
   int a,b,sum;
   scanf("%d %d",&a,&b);
   if(a>b)
   {
       sum=a-1;
   }
   else
   {
       sum=a;
   }
   printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
n = input()

R = [input() for i in range(n)]
  
max = R[1] - R[0]
min = R[0]
  
for i in range(1,n):
    if R[i] - min > max:
        max = R[i] - min
    if R[i] < min:
        min = R[i]
  
print max

Measured memory_bytes: 18980
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N, K;
  cin >> N >> K;
  
  string ans = "NO";
  if (divCeil(N, 2) >= K) ans = "YES";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////

    int N, K;
    cin >> N >> K;
    int p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    
    
    sort(p, p + N);

    int total = 0;
    
    for(int i = 0; i < K; i++){
        total = total + p[i];
    }
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 3660
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    A, B, N = map(int, read().split())
    m = N % B
    x1 = N
    x2 = N - m - 1
    if x2 > 0:
        ans = max((A * x1) // B - A * (x1 // B), (A * x2) // B - A * (x2 // B))
    else:
        ans = (A * x1) // B - A * (x1 // B)
    print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
N = int(input())
X = input()
memo = [-1] * (N+1)
memo[0] = 0

def popcount(k):
    return bin(k).count('1')

def calc(k):
    pop = popcount(k)
    #print('  ', k, pop)
    key = k
    if memo[key] < 0:
        k %= pop
        if k == 0:
            memo[key] = 1
        else:
            memo[key] = calc(k) + 1
    return memo[key]

K = int(X, 2)
one = popcount(K)
if one == 0:
    K_MOD = K
elif one == 1:
    K_MOD   = 0
    K_MOD_M = K
else:
    K_MOD   = K % one
    K_MOD_M = K % (one-1)
K_MOD_P = K % (one+1)

T_M = [1]*(N+1)
T_P = [1]*(N+1)
for i in range(1,N+1):
    if one > 1:
        T_M[i] = (T_M[i-1]*2) % (one-1)
    T_P[i] = (T_P[i-1]*2) % (one+1)

for i in range(N):
    if X[i] == '1':
        pop = one - 1
        k = K_MOD_M - T_M[N-i-1]
    else:
        pop = one + 1
        k = K_MOD_P + T_P[N-i-1]

    if pop == 0:
        print(0)
    else:
        k %= pop
        print(calc(k)+1)


Measured memory_bytes: 85236
def fact(n):
    if n < 0:
        return 0
    if n == 0:
        return 1
    if n == 1:
        return 1
    return n * fact(n-1)

def combination(n, k):
    if n < k:
        return 0
    return fact(n) / ( fact(n-k) * fact(k))

n, m = [int(x) for x in input().split()]
answer = int(combination(n, 2) + combination(m, 2))
print(answer)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
//#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;

const int N = 1005, MOD = 998244353;

int n, m, k;
int a[N];
int ind[N];
char A[N][N];
int ANS;

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> A[i][j];
    ANS = MOD;
    for (int B = 0; B < (1 << n - 1); B++){
        for (int i = 1; i <= n; i++)
            a[i] = 0;
        ind[1] = 1;
        int ans = 0;
        for (int i = 2; i <= n; i++){
            ind[i] = i;
            if ((B & (1 << i - 2)) > 0)
                ind[i] = ind[i - 1];
            else
                ans++;
        }
        for (int i = 1; i <= m; i++){
            bool ok = 0;
            for (int j = 1; j <= n; j++){
                a[ind[j]] += A[j][i] - '0';
                if (a[ind[j]] > k)
                    ok = 1;
            }
            if (ok == 0)
                continue;
            ans++;
            for (int j = 1; j <= n; j++)
                a[j] = 0;
            for (int j = 1; j <= n; j++){
                a[ind[j]] += A[j][i] - '0';
                if (a[ind[j]] > k){
                    ans = MOD;
                    break;
                }
            }
        }
        ANS = min (ANS, ans);
    }
    cout << ANS << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    ll L, R;
    cin >> L >> R;

    // 整数が2019連続していたら、必ず2019の倍数が含まれるので2019で割り切れる

    ll min = 5000;
    if(R-L >= 3000) cout << 0 << endl;
    else {
        for(ll i=L; i<=R; ++i) {
            for(ll j=L; j<=R; ++j) {
                if(i==j) continue;
                ll v = i*j % 2019;
                if(v < min) min = v;     
            }          
        }
        cout << min << endl;
    }

}


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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;

    if (a <= b)
    {
        for (int i = 0; i < b; i++)
        {
            ans += a * pow(10, i);
        }
    }
    else if (a > b)
    {
        for (int i = 0; i < a; i++)
        {
            ans += b * pow(10, i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
interface Main{
	static void main(String[]$){
		Scanner s=new Scanner(System.in);
		final int D=1000000007,N=s.nextInt(),M=s.next().length();
		s.close();
		long[]p=new long[M+N+2],a=new long[M+N+2];
		p[M]=1;
		for(int i=1;i<=N;i++){
			a[0]=(p[0]+p[1])%D;
			for (int j=1;j<=M+i;j++)a[j]=(p[j-1]*2+p[j+1])%D;
			System.arraycopy(a,0,p,0,M+N+2);
		}
		System.out.println(a[0]);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define TASK "task"

using namespace std;

void rwFile() {
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
}

void solveA() {
    int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << arr[k - 1];
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveA();
}


Measured memory_bytes: 256
from math import *

def check(a,b,mid):
    if mid>pi/2-ep:
        return 0
  #  aa=tanh(90-mid)*b
    if a*tan(mid)<=b:
        ans=a*a*b
        aa=a*tan(mid)*a*a
        ans-=(aa)/2.0
    else:
        
        ans=(a*b*b/tan(mid))/2.0
    return ans
        
a,b,x=map(int,input().split())

low=0
high=pi/2
ep=0.0000000001
while low<high and high-low>=ep:
    mid=(low+high)/2
   # print(mid)
    st=check(a,b,mid)
   # print(st)
    
    if st<x:
        high=mid
    else:
        low=mid
print(low/pi*180)
    


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    
    for(int i = 0; i < N; i++){
        if(A[i]%2 == 0){
            if(A[i]%3 != 0 && A[i]%5 != 0){
                cout << "DENIED";
                return 0;
            }
        }
    }
    
    cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),res=-1;
		
		for(int i=1;i<=1000;i++) {
			if((int)(i*0.08)==a && (int)(i*0.1)==b) {
				res=i;
				break;
			}
		}
		System.out.println(res);
	}
}


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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 1000000007;

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], int n) {
    string result = "{";
    REP(i, 0, n) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

string bin_string(int x) {
    const int d = 64;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

vector<int> getZ(string s) {
    int n = s.size();
    vector<int> z(n);
    int x = 0, y = 0;
    REP(i, 1, n) {
        z[i] = max(0LL, min(z[i-x], y-i+1));
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
            x = i;
            y = i+z[i];
            ++z[i];
        }
    }
    return z;
}

int powa(int base, int exp) {
    if (exp<=0) return 1;
    if (base<=0) return 0;
    int val = powa(base, exp>>1);
    val = val*val % MOD;
    if (exp&1) {
        val = val*base % MOD;
    }
    return val;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n;
    cin >> n;
    vector<pair<int,int>> claims[n];
    REP(i, 0, n) {
        int a;
        cin >> a;
        REP(j, 0, a) {
            int x,y;
            cin >> x >> y;
            claims[i].push_back({x-1, y});
        }
    }

    int res=-1;
    REP(s, 0, 1<<n) {
        bool contra = false;
        REP(h, 0, n) {
            if (s&1<<h) {
                for (auto pr : claims[h]) {
                    int x, y;
                    tie(x, y) = pr;
                    if (((s&1<<x)!=0) != y) {
                        contra = true;
                        break;
                    }
                }
                if (contra) break;
            }
        }
        if (!contra) res = max(res, (int)popcount(s));
    }
    cout << res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[200005];
int main(void){
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5+87, C = 1<<20, M=1e9+7;
int a[N],n,s0[N];
vector<int> p[C];
int go(vector<int> & v)
{
    if (v.empty())
        return 0;
    ll dp[2] = {1,1};
    for (int i = 1; i < v.size(); ++i) {
        int j = v[i], k = v[i-1];
        int o = s0[j] - s0[k];
        dp[0] = (dp[0] + dp[1] * o) % M;
        dp[1] = (dp[1] + dp[0]) % M;
    }
    if (v.back() == n)
        return dp[0];
    return dp[1];
}
ll solve2()
{
    for (int i = 1; i <= n; ++i) {
        p[a[i]].push_back(i);
        s0[i] = s0[i-1] + (a[i] == 0);
    }
    ll ans=0;
    if (a[n] == 0) {
        ans = 1;
        for (int i = 0; i < p[0].size()-1; ++i)
            ans = 2*ans%M;
        for (int i = 1; i < C; ++i) {
            int w = go(p[i]);
            ans += w;
        }
    } else {
        ans = go(p[a[n]]);
    }
    return ans;
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] ^= a[i-1];
//        cerr << a[i] << " \n"[i==n];
    }
    ll ans = solve2();
    cout << ans % M << endl;
}


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

using namespace std;

int main(void) {
    string s;
    cin >> s;

    int diff = 100000;
    for (int i = 0; i < s.length() - 2; i++) {
        int X = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        diff = min(diff, abs(753 - X));
    }

    cout << diff << endl;
}

Measured memory_bytes: 256
//abc179_e.cpp
//Sat Sep 19 22:12:48 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (ll i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,x,m;
	cin >> n >> x >> m;

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

	ll amari[m];
	rep(i,m){
		amari[i] = i*i%m;
//		cout << i << " " << amari[i] << endl;
	} 

	ll ans = 0;
	ll when[m];
	fill(when,when+m,-1);
	ll prev = -1;
	vector<ll> sum;
	sum.push_back(0);
	rep(i,m){
		if (i==0){
			prev = x;
			when[x] = i;
			sum.push_back(prev);
		}else {
			prev = amari[prev];
			if (when[prev]==-1){
				when[prev] = i;
				sum.push_back(sum[i]+prev);
			}else {
				// if (i==1){
				// 	cout << sum[1]*n << endl;
				// 	return 0;
				// }
				int loopstart = when[prev];
				int loopend = i-1;
				ll loopsum = sum[i]-sum[loopstart];
				ll sumbefloop = sum[loopstart];
				if (n<i){
					cout << sum[n] << endl;
					return 0;
				}
				ll tmp = n-loopstart;
				ll z = tmp/(i-loopstart);
				ans = sumbefloop+loopsum*z;
				ll v = tmp%(i-loopstart);
				ans += sum[loopstart+v]-sum[loopstart];
				cout << ans << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int SIZE = 3e3+9;

int n;
ll a[SIZE];
ll dp[SIZE][SIZE]; // [i, j] で先手が得られる最大の得点
ll sum[SIZE]; // [1, i] の総和

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i-1] + a[i];
    }

    for(int len = 1; len <= n; len++) {
        for(int i = 1; i <= n; i++) {
            int j = i + len - 1;
            if(j > SIZE)    continue;
            if(len == 1) {
                dp[i][j] = a[i];
                continue;
            }
            ll d1 = sum[j] - sum[i-1] - dp[i][j-1];
            ll d2 = sum[j] - sum[i-1] - dp[i+1][j];
            dp[i][j] = max(d1, d2);
        }
    }
    cout << dp[1][n] - min(dp[1][n-1], dp[2][n]) << endl;
}

Measured memory_bytes: 70016
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e9;
int main() {
	int n; cin >> n;
	map<string, int> mg;
	int ans = 0;
	rep(i, n) {
		string s; cin >> s;
		mg[s]++;
		if (mg[s] == 1)
			ans++;
	}
	cout << ans;
}


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

# 各桁を合計する関数
def sum_digits(num):
    sum = 0
    while num > 0:
        sum += num % 10
        num = num // 10
    return sum

result = 0

for i in range(1, N+1):
    if A <= sum_digits(i) <= B:
        result += i

print(result)

Measured memory_bytes: 2940
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (h1, m1, h2, m2, k) = (v[0], v[1], v[2], v[3], v[4]);
    let t1 = h1 * 60 + m1;
    let t2 = h2 * 60 + m2;
    let mut ans = t2 - t1 - k;
    if k < 0 {
        ans = 0;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> BA(N);
  for (int i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    BA.at(i) = make_pair(b, a);
  }
  
  sort(BA.begin(), BA.end());

  string ans = "Yes";
  if (BA.at(0).second > BA.at(0).first) ans = "No";
  for (int i = 1; i < N; i++)
  {
    BA.at(i).second += BA.at(i - 1).second;
    if (BA.at(i).second > BA.at(i).first)
    {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9+7;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return (a / g) * b;
}

ll a[100001] = {};
int main() {
	ll n,m; cin >> n >> m;
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n) a[i] /= 2;

	ll cnt = 0;
	while (!(a[0] % 2)) {
		a[0] /= 2;
		cnt++;
		m /= 2;
	}

	rep(i, 1, n) {
		ll c = 0;
		while (!(a[i] % 2)) {
			a[i] /= 2;
			c++;
		}

		if (c != cnt) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; ++i) if (a[i] % 2 == 0) {
		cout << 0 << endl;
	}

	ll l = 1;
	rep(i, 0, n) {
		l = lcm(l, a[i]);
		if (l > m) {
			cout << 0 << endl;
			return 0;
		}
	}

	cout << (m / l + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <vector>

int main(int argc, const char * argv[]) {
    
    int n = 0;
    std::cin >> n;
    
    std::vector<int> heights;
    
    for(int i=0;i<n;i++)
    {
        int tmp = 0;
        std::cin >> tmp;
        heights.push_back(tmp);
    }
    
    //最初の階段は１段下げておく
    if(heights.at(0) > 1)
    {
        heights.at(0) -= 1;
    }
    
    std::string answer = "Yes";
    for(int i=1;i<n;i++)
    {
        int diff = heights.at(i) - heights.at(i-1);
        
        if(diff >= 1)
        {
            //1段以上差があるときは余裕を持って下げておく
            heights.at(i) -= 1;
        }
        else if(diff == 0)
        {
            //高さが同じ時は何もしない
        }
        else
        {
            answer = "No";
            break;
        }
        
    }
    
    
    std::cout << answer;
    
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  rep(i,n) ans = min(ans * 2, ans + k);
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

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

	N = N % 10
	switch N {
	case 3:
		fmt.Println("bon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	default:
		fmt.Println("hon")
	}
}


Measured memory_bytes: 1768
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

template<typename T>
inline T pow(T a, long long n) {
    T ret = 1; while (n) { if (n & 1) ret *= a; n >>= 1; a *= a; }
    return ret;
}

int digit_sum(long long n, int base = 10) {
    int res = 0;
    while (n > 0) res += n % base, n /= base;
    return res;
}

int main() {
    long long k; cin >> k;
    set<long long> se;
    for (int d = 0; d < 15; d++) for (int pref = 1; pref < 1000; pref++) {
        se.emplace(pref * pow(10LL, d) - 1);
    }
    se.erase(0);
    vector<pair<long long, int>> cand;
    for (auto x: se) cand.emplace_back(x, digit_sum(x));
    reverse(begin(cand), end(cand));
    vector<long long> res;
    pair<long long, int> pre = {pow(10LL, 18), 1};
    for (auto &p: cand) {
        if (p.first * pre.second <= pre.first * p.second) {
            res.emplace_back(p.first);
            pre = p;
        }
    }
    reverse(begin(res), end(res));
    for (int i = 0; i < k; i++) cout << res[i] << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
long long gcd(long long a,long long b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
int main()
{
ios_base::sync_with_stdio(false);
int t;
cin>>t;
while(t)
{
    --t;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<b||d<b)
    {
        cout<<"No";
    }
    else
    {
        if(c>=b-1)
        {
            cout<<"Yes";
        }
        else
        {
            a=a%b;
            if(a>c)
            {
                cout<<"No";
            }
            else
            if(gcd(d,b)==b)
            {
                cout<<"Yes";
            }
            else
            {
                ll r=gcd(b,d);
                a=a%b;
                ll x1=(c-a)/r,x2=(b-1-a)/r;
                if(x1==x2) 
                    cout<<"Yes";
                else
                    cout<<"No";
            }
        }
    }
    cout<<"\n";
}
}

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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int [n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int firstNum = a[n-1];
        if (n == 2) {
            System.out.println(Math.max(a[0], a[1]) + " " + Math.min(a[0], a[1]));
        } else {
            int halfN = firstNum;
            int smallNum = 0;
            int currentDiff = halfN;
            for (int i = 0 ; i < n - 1 ; i++) {
                int diff = Math.abs(halfN - 2 *a[i]);
                if (diff < currentDiff) {
                    currentDiff = diff;
                    smallNum = a[i];
                }
                //diffが最小になるようなa[i]を求める。

            }
            System.out.println(firstNum + " " + smallNum);

        }
    }

}

Measured memory_bytes: 51716
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ass <- replicateM n readInts
  putStr $ solve ass

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: [[Int]] -> String
solve ass = solve' ass 0 0 0

solve' :: [[Int]] -> Int -> Int -> Int -> String
solve' [] _ _ _ = "Yes"
solve' ([t, x, y]:ass) s u v
  | d <= t - s && even (t - s - d) = solve' ass t x y
  | otherwise = "No"
  where d = (abs (x - u)) + (abs (y - v))





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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(lint i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


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

void Main()
{
    string S;
    cin >> S;
    lint ans, l;
    l = S.length();
    ans = 0;
    REP(i, l / 2){
        if(S[i] != S[l-1-i]){
            ans++;
        }
    }

    cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const ll MOD = 1000000000007;
const int MAX = 60;

ll C[MAX][MAX];

void com(){
    C[0][0]=1;
    for(int i=1;i<51;i++){
        for(int j=0;j<i+1;j++){
            if(j==0||j==i) C[i][j]=1;
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,cnt,x;
    cin>>n>>a>>b;
    vector<ll> v(n);
    double ans;
    ll res=0;
    rep(i,n) cin>>v[i];
    sort(all(v));
    for(int i=n-1;i>=n-a;i--){
        ans+=(double)v[i];
    }
    ans/=a;
    cnt=(int)(upper_bound(all(v),v[n-a])-lower_bound(all(v),v[n-a]));
    x=(int)(upper_bound(all(v),v[n-a])-v.begin()-(n-a));
    // cout<<cnt<<" "<<x<<endl;
    com();
    // cout<<C[2][1]<<" "<<C[3][1]<<endl;
    if(upper_bound(all(v),v[n-a])==v.end()){
        for(int i=a;i<b+1;i++){
            res+=C[cnt][i];
        }
    }
    else if(cnt>x){
        res=C[cnt][x];
    }
    else res=1;
    cout<<fixed<<setprecision(10)<<ans<<endl<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)


bool solve(int n, string s) {
  int red{}, blue{};
  for (auto c : s) {
    if (c == 'R')
      ++red;
    else
      ++blue;
  }
  return red <= blue ? false : true;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (solve(n, s))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll i,j,cnt=0;
    string s;
    cin>>s;
        for(i=0; s[i]; i++)
        {
            if(s[i]=='o') cnt++;
            }
        cout<<700+cnt*100<<endl;

    return 0;
}





Measured memory_bytes: 3544
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String b = sc.next();

		if(b.contentEquals("A")) 	System.out.println("T");

		if(b.contentEquals("T")) 	System.out.println("A");

		if(b.contentEquals("G")) 	System.out.println("C");

		if(b.contentEquals("C")) 	System.out.println("G");

	}

}


Measured memory_bytes: 21840
#include<stdio.h>

int main(void) {
	int i;

	i = 'A' - 'a';
	
	int N;

	scanf("%d", &N);

	int K;

	scanf("%d", &K);

	char S[N];

	scanf("%s", S);
	
	S[K - 1] -= i;
	
	printf("%s", S);

	return 0;
}

Measured memory_bytes: 128