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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<array<int, 4>> v;
    for (int i = 0; i < n; i++) {
        int x, y; char c; cin >> x >> y >> c;
        x *= 2, y *= 2;
        if (c == 'R') v.push_back({x, y, 1, 0});
        if (c == 'L') v.push_back({x, y, -1, 0});
        if (c == 'U') v.push_back({x, y, 0, 1});
        if (c == 'D') v.push_back({x, y, 0, -1});
    }
    set<int> q = {0};
    auto f = [&](auto g, int s, int t) {
        map<int, int> m;
        for (int i = 0; i < n; i++) {
            if (!m.count(v[i][t])) m[v[i][t]] = v[i][s];
            else {
                m[v[i][t]] = g(m[v[i][t]], v[i][s]);
            }
        }
        vector<pair<int, int>> vp;
        for (auto &it: m) vp.emplace_back(it);
        for (int i = 0; i < vp.size(); i++) {
            for (int j = i+1; j < vp.size(); j++) {
                q.emplace((vp[j].second-vp[i].second)/(vp[i].first-vp[j].first));
            }
        }
    };
    f([&](int a, int b){return max(a, b);}, 0, 2);
    f([&](int a, int b){return min(a, b);}, 0, 2);
    f([&](int a, int b){return max(a, b);}, 1, 3);
    f([&](int a, int b){return min(a, b);}, 1, 3);
    long long ans = 4e18;
    auto g = [&](int t) {
        if (t < 0) return;
        int xmax, xmin, ymax, ymin;
        xmax = xmin = v[0][0] + t * v[0][2];
        ymax = ymin = v[0][1] + t * v[0][3];
        for (int i = 0; i < n; i++) {
            xmax = max(xmax, v[i][0] + t * v[i][2]);
            xmin = min(xmin, v[i][0] + t * v[i][2]);
            ymax = max(ymax, v[i][1] + t * v[i][3]);
            ymin = min(ymin, v[i][1] + t * v[i][3]);
        }
        long long xdiff = xmax - xmin;
        long long ydiff = ymax - ymin;
        ans = min(ans, xdiff * ydiff);
    };
    for (auto &x: q) g(x);
    cout << setprecision(12) << (double) ans / 4 << "\n";
    return 0;
}

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

int main() {
    long long n, a, b, c, q, k, x, y;
    vector<vector<pair<long long,long long>>> children;
    vector<long long> dists;
    vector<bool> visited;
    queue<pair<long long,long long>> moves;
    pair<long long,long long> curr;
    
    cin >> n;
    
    for (long i=0; i<=n; i++) {
        children.push_back({});
        dists.push_back(0);
        visited.push_back(false);
    }
    
    for (long i=0; i<n-1; i++) {
        cin >> a >> b >> c;
        children[a].push_back(make_pair(b,c));
        children[b].push_back(make_pair(a,c));
    }
    
    cin >> q >> k;
    
    visited[k] = true;
    moves.push(make_pair(k,0));
    
    while (moves.size()>0) {
        curr = moves.front();
        moves.pop();
        
        for (auto i : children[curr.first]) {
            if (!visited[i.first]) {
                moves.push(make_pair(i.first, curr.second+i.second));
                dists[i.first] = curr.second+i.second;
                visited[i.first] = true;
            }
        }
    }
    
    for (long i=0; i<q; i++) {
        cin >> x >> y;
        cout << dists[x]+dists[y] << endl;
    }
    
    return 0;
}

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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int n, m;
	cin >> n;
	vector<int> v(n);
	rep(i, 0, n) cin >> v[i];

	cin >> m;
	vector<int> vv(m);
	rep(i, 0, m)cin >> vv[i];
	sort(v.begin(), v.end());

	bool judge = true;
	rep(i, 0, m) {
		bool judge1 = true;
		/*rep(j, 0, v.size()) {
			if (v[j] == vv[i]) {
				v.erase(v.begin() + j);
				judge1 = false;
				break;
			}
		}*/

		int left = 0, right = v.size();

		while (left <= right) {
			int mid = (left + right) / 2;
			if (v[mid] == vv[i]) {
				v.erase(v.begin() + mid);
				//cout << 1 << endl;
				judge1 = false;
				break;
			}
			else if (v[mid] < vv[i]) left = mid+1;
			else if (v[mid] > vv[i])right = mid-1;
		}
		if (judge1) {
			cout << "NO" << endl;
			judge = false;
			break;
		}
	}

	if (judge)cout << "YES" << endl;
	
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int lim=3005;


ll dp[lim][lim];

int n;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	
	for(int i=1;i<=n;i++) cin>>dp[i][i];

	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			dp[i][j]=max(dp[i][i]-dp[i+1][j],dp[j][j]-dp[i][j-1]);
		}
	}
	
	for(int i=2;i<=n;i++){
		for(int j=i;j<=n;j++) dp[j+1-i][j]=max(dp[j+1-i][j+1-i]-dp[j+2-i][j],dp[j][j]-dp[j+1-i][j-1]);
	}
	//printf("CHECK %lld %lld\n",dp[1][2],dp[2][3]);
	cout<<dp[1][n];
	return 0;
}

Measured memory_bytes: 70016
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace CF317
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var sr = new InputReader(Console.In);
            //var sr = new InputReader(new StreamReader("input.txt"));
            var task = new Task();
            using (var sw = Console.Out)
            //using (var sw = new StreamWriter("output.txt"))
            {
                task.Solve(sr, sw);
                //Console.ReadKey();
            }
        }
    }

    internal class Task
    {
        private List<Tuple<long, HashSet<long>>> sets = new List<Tuple<long, HashSet<long>>>();

        public void Solve(InputReader sr, TextWriter sw)
        {
            var n = sr.NextInt32();
            var lens = sr.ReadArray(Int32.Parse);
            Array.Sort(lens, (a, b) => -a.CompareTo(b));
            var ans = 0L;
            for (var i = 0; i < lens.Length; i+=2) {
                ans += Math.Min(lens[i], lens[i + 1]);
            }

            sw.WriteLine(ans);
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

Measured memory_bytes: 3032
#include <stdio.h>
#include <math.h>

int main(void){
  int n, x[10000], sum, i, j, flag;

  sum = 0;

  scanf("%d", &n);

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

  for (i = 0; i < n; i++){
    flag = 0;
    for (j = 2; j <= sqrt(x[i]); j++){
      if (x[i] % j == 0){
        flag = 1;
      }
    }
    if (flag == 0){
      sum++;
    }
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 2080
import sys
from math import sin, cos, radians, sqrt

input = sys.stdin.readline


def main():
    A, B, H, M = map(int, input().split())

    theta_A = radians(30 * (H + M / 60))
    x_A = A * cos(theta_A)
    y_A = A * sin(theta_A)

    theta_B = radians(6 * M)
    x_B = B * cos(theta_B)
    y_B = B * sin(theta_B)

    ans = sqrt((x_A - x_B)**2 + (y_A - y_B)**2)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int k = in.nextInt();
			long[] an = in.nextLongArray(n);
			Arrays.sort(an);
			long[] gcds = new long[n];
			gcds = an.clone();

			for (int i = 0; i < n - 1; i++) {
				gcds[i+1] = gcd(gcds[i], gcds[i+1]);
			}
			String ans = "";
			if (k % gcds[n-1] == 0 && k <= an[n-1]) {
				ans = "POSSIBLE";
			} else {
				ans = "IMPOSSIBLE";
			}

			out.println(ans);

		}
	}

	public static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 36092
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N, Q;
	cin >> N >> Q;

	vector<vector<ll>> edge(N,vector<ll>());

	rep(i, N - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;

		edge[a].emplace_back(b);
		edge[b].emplace_back(a);

	}

	vector<ll> count(N, 0);

	rep(i, Q) {
		ll p, x;
		cin >> p >> x;
		p--;
		count[p] += x;
	}

	vector<ll> ans(N, -1);

	queue<pair<ll,ll>> QUE;//pos,orignum

	QUE.push(make_pair(0,0));

	while (QUE.size() != 0) {

		pair<ll,ll> P = QUE.front();
		QUE.pop();

		if (ans[P.first] != -1) continue;

		ans[P.first] = P.second + count[P.first];

		rep(i, edge[P.first].size()) {
			QUE.push(make_pair(edge[P.first][i], ans[P.first]));
		}

	}

	rep(i, N) {
		cout << ans[i] << " ";
	}


}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define N 1000000007;

//char型のポインタ(=配列と意味は同じ)をString型と定義([0]から数える)
typedef char* String;

//S[0]から始まる文字列の長さを求める関数
int string_len(String str){
    int len=0;
    while(str[len]!=0){
        len++;
    }
    return len;
}

//文字列を標準入力から読み込み、それをString型のメモリを確保し直してくれる関数
//S[0]~S[n-1]までが入力で、S[n]は0になる
//文字列長さの上限は1000まで
String string_input(void){
    int i,len;
    char buf[100001];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=string_len(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

//char→int
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(void){
    //0桁目~n-1桁目まで
    String S=string_input();
    int n=string_len(S);

    //10^iの、13で割ったあまり
    int r[6]={1,10,9,12,3,4};

    //下からi桁目は、S[n-1-i]
    //DP[i][j]に、下からi桁目までで13で割ってjになるものがいくつあるのかを格納
    //iは0~n-1まで、jは0~12まで
    int DP[n][13];
    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++) DP[i][j]=0;
    }

    //DP[0]を埋める
    if(S[n-1]!='?'){
        DP[0][ctoi(S[n-1])]=1;
    }
    else{
        for(int i=0;i<10;i++) DP[0][i]=1;
    }

    //DP[1]以降を埋める
    for(int i=1;i<n;i++){
        //その桁を考慮することによってどれだけあまりが増えるか
        int add;
        char c=S[n-1-i];
        int ci;
        if(c!='?'){
            ci=ctoi(c);
            add=(ci*r[i%6])%13;
            for(int j=0;j<13;j++) DP[i][(j+add)%13]=(DP[i][(j+add)%13]+DP[i-1][j])%N;
        }
        else{
            for(int k=0;k<10;k++){
                ci=k;
                add=(ci*r[i%6])%13;
                for(int j=0;j<13;j++) DP[i][(j+add)%13]=(DP[i][(j+add)%13]+DP[i-1][j])%N;
            }
        }
    }
    
    printf("%d\n",DP[n-1][5]);

    return 0;
}

//0始まりの習慣をつけたほうがいい(heap除く)
//DPするのがどういうときだかわかんねえ……

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

K, A, B = map(int, input().split())

def main():
    if (B - A < 2 or A > K - 1):
        print(K+1)
    else:
        count = K - A + 1
        ans = A
        if count % 2 != 0:
            count -= 1
            ans += 1
        ans += count//2 * (B - A)
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	int sum=0;
	cin>>a>>b;
	if(a<=0&&b>=0)
	{
		cout<<"Zero"<<endl;
	}
	else if(a>0&&b>0)
	{
		cout<<"Positive"<<endl;
	}
	else if(a<0&&b<0)
	{
		sum=b-a+1;
		if(sum%2==0) cout<<"Positive"<<endl;
		else cout<<"Negative"<<endl;
	}
	return 0;
}

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

int main(void)
{
    char s[100];
    long k;
    //long a,b;
    long i;

    scanf("%s",s);
    scanf("%ld",&k);

    //b=pow(10,15);
    //a =pow(2,5*b);
    //printf("%ld",a);

    //printf("%s\n%ld\n",s,k);

    for(i=0;i<100;i++){
        if(s[i]!='1'){
            break;
        }
        if((i+1)==k){
            break;
        }    
    }

    printf("%c\n", s[i]);

}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>

#define SIZE 101
#define INF 100000000

using namespace std;


typedef pair<int, int> Pa;


int tim[100][100]; // t p time
bool pra[100][100];

int main()
{
	int M, T, P, R;
	
	pair<Pa, int> pa;

	while (true) {
		cin >> M >> T >> P >> R;
		if (T == 0) break;

		for (int i = 0; i <= T; i++) {
			for (int j = 0; j <= P; j++) {
				tim[i][j] = 0; 
				pra[i][j] = false;
			}
		}
		vector<pair<Pa, int>> v(T + 1);

		for (int i = 0; i <= T; i++) {
			v[i].second = i;
		}

		for (int i = 0; i < R; i++) {
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			if (j == 0) {
				v[t].first.first++;
				v[t].first.second += - m + tim[t][p];
			} else {
				tim[t][p] -= 20;
			}
		}

		sort(v.begin(),v.end());
		for (int i = T; i >= 1; i--) {
			//cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
			cout << v[i].second;
			if (i == 1) break;
			if (v[i].first.first == v[i - 1].first.first && v[i].first.second == v[i - 1].first.second)cout << "=";
			else cout << ",";
		}
		cout << endl;
		
	}
	

	return (0);
}

Measured memory_bytes: 1228
#include <iostream>

using namespace std;

int main(void)
{
    string str;
    string ans;
    cin >> str;
    if(str[0] >= 'a' && str[0] <= 'z') ans = 'a';
    if(str[0] >= 'A' && str[0] <= 'Z') ans = 'A';
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3600
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toLong)
    val aAccumulation = mutableListOf(0L)
    val countMap = mutableMapOf<Long,Long>()
    countMap[0]=1L
    var ans = 0L
    for (i in 1..n) {
        val accumlation = aAccumulation[i - 1] + aList[i - 1]
        aAccumulation.add(accumlation)
        if(countMap.containsKey(accumlation)){
            ans += countMap[accumlation]!!
            countMap[accumlation] = countMap[accumlation]!!+1L
        }else{
            countMap[accumlation] = 1L
        }
    }
    println(ans)
}


Measured memory_bytes: 106268
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long 
    ll dp[101][100010];
    int main(){
        ll n,w;
        cin>>n>>w;
       ll val[n+2],wg[n+2];
       
        for(int i=0;i<n;i++)
        cin>>wg[i]>>val[i];
        
        for(int i=0;i<=w;i++)
        dp[0][i]=0;
        for(int i=0;i<=n;i++)
        dp[i][0]=0;
        
        for(int i=1;i<=n;i++){
            for(int j=1;j<=w;j++){
               if(wg[i-1]<=j)
               dp[i][j]=max(dp[i-1][j],dp[i-1][j-wg[i-1]]+val[i-1]);
               else
               {
                   dp[i][j]=dp[i-1][j];
               }
               
            }
        }
      
        cout<<dp[n][w]<<endl;
     
        
    }

Measured memory_bytes: 79104
from functools import lru_cache
n = list(map(int, list(input())))
k = int(input())

@lru_cache(10**9)
def rec(keta, cnt, tight):
    if cnt > k:
        return 0
    if keta==len(n):
        if cnt==k:
            return 1
        else:
            return 0
    ret = 0
    for i in range(10):
        if tight and i > n[keta]:
            break
        ret += rec(keta+1, cnt+int(i!=0), tight and i==n[keta])
    return ret

ans = rec(0,0, True)
print(ans)

Measured memory_bytes: 41832
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  while (cin >> n, n) {
    vector<pair<double, string>> arr(n);
    rep(i, n) {
      string S;
      double p, a, b, c, d, e, f, s, m;
      cin >> S >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      double income = f * s * m - p;
      double t = a + b + c + d + e;
      double time_cost = t + (t - a - b - c) * (m - 1);
      arr[i] = make_pair((double)income / time_cost, S);
    }
    sort(all(arr));
    reverse(all(arr));
    // for (auto a : arr) {
    //   cout << a.first << ' ' << a.second << endl;
    // }
    int len = arr.size();
    rep(i, len) {
      if (i != len - 1 && arr[i].first == arr[i + 1].first) {
        set<string> st;
        while (i < len - 1 && arr[i].first == arr[i + 1].first) {
          st.insert(arr[i].second);
          st.insert(arr[i + 1].second);
          i++;
        }
        for (auto x : st) {
          cout << x << endl;
        }
      } else {
        cout << arr[i].second << endl;
      }
    }
    cout << '#' << endl;
  }

  return 0;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//code
	int a,b,c,d,x,y;
	cin>>a>>b>>c>>d;
	
	x=(a+d-1)/d;
	y=(b+c-1)/b;
	
	if(x>=y)
		cout<<"Yes";
	else
		cout<<"No";
 	return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  uint64_t A = 1LL, R = 1000000007; 
  for (int i=1; i<=N; i++) A = i * A % R;
  
  printf("%lld\n", A);

}

Measured memory_bytes: 256
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define int ll 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int n, h;
int dp[N];	
void solve () {
	cin >> h >> n;
	dp[0] = 0;
	for (int i = 1; i <= h; i ++) dp[i] = mod;
	for (int i = 1; i <= n; i ++) {
		int x, cost;
		cin >> x >> cost;
		for (int j = 0; j <= h; j ++) {
			if (dp[j] != mod ) {
				dp[min (h, j + x)] = min (dp[j] + cost, dp[min (h, j + x)]);
			}
		}	
	}
	cout << dp[h];		
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//  cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

const int MAXN = 200005;
const int MOD = 1000000007;

long long modpow(long long a, long long p){
	if(p == 0)return 1;
	if(p % 2 == 1)return a * modpow(a, p - 1) % MOD;
	
	long long r = modpow(a, p / 2);
	return r * r % MOD;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}

long long fact[MAXN], invfact[MAXN];
long long C(int n, int r){
	return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD;
}
long long Cinv(int n, int r){
	return invfact[n] * fact[r] % MOD * fact[n - r] % MOD;
}

int N, ai, bi;
vector <int> g[MAXN];

long long dp[MAXN], subtree[MAXN], sz[MAXN];

void init(int u, int parent = -1){
	sz[u] = 1;
	for(int v : g[u]){
		if(v == parent)continue;
		
		init(v, u);
		sz[u] += sz[v];
	}
	
	subtree[u] = 1;
	int r = sz[u] - 1;
	
	for(int v : g[u]){
		if(v == parent)continue;
		
		subtree[u] = subtree[u] * C(r, sz[v]) % MOD * subtree[v] % MOD;
		r -= sz[v];
	}
}
void solve(int u, int parent = -1){
	if(parent == -1){
		dp[u] = subtree[u];
	}else{
		dp[u] = dp[parent] * Cinv(N - 1, sz[u]) % MOD * C(N - 1, N - sz[u]) % MOD;
	}
	
	for(int v : g[u]){
		if(v == parent)continue;
		solve(v, u);
	}
}

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N - 1; i++){
		scanf("%d %d", &ai, &bi);
		ai--, bi--;
		
		g[ai].push_back(bi);
		g[bi].push_back(ai);
	}
	
	for(int i = 0; i <= N; i++){
		if(i == 0)fact[i] = 1;
		else fact[i] = i * fact[i - 1] % MOD;
	}
	for(int i = N; i >= 0; i--){
		if(i == N)invfact[i] = modinv(fact[i]);
		else invfact[i] = invfact[i + 1] * (i + 1) % MOD;
	}
	
	init(0);
	solve(0);
	
	for(int i = 0; i < N; i++)
		printf("%lld\n", dp[i]);
		
	return 0;
}


Measured memory_bytes: 23168
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int x;
    cin>>x;
    ll s1=(x/500)*1000;
    ll s2=((x%500)/5)*5;
    cout<<s1+s2<<'\n';
}

int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
  string key;
  string s[102];
  int n;
  cin>>key;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
    s[i]+=s[i];
    
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<20;j++){
      int count=0;
      for(int k=0;k<key.size();k++){
	if(s[i][j+k]==key[k]){
	  count++;
	}
      }
      if(count==key.size()){
	ans++;
	break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1216
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int a;
	cin >> a;
	int ans = a + a * a + a * a * a;
	cout << ans;
}

Measured memory_bytes: 3556
#include<stdio.h>
	int main(){
		int a,b,i,n,k=0;
		while(1){
			n=0;
			scanf("%d %d ",&a,&b);
			if(a==0&&b==0)break;
if(k!=0)
			printf("\n");
			for(i=a;i<=b;i++){
				if(i%4==0&&i%100!=0){
					printf("%d\n",i);
					n++;
				}
				if(i%400==0){
					printf("%d\n",i);
					n++;
				}
				
			}if(n==0)printf("NA\n");
			k++;
		}
		return 0;
}

Measured memory_bytes: 0
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int D;
int c[32];
int s[512][32];
int ans[512];

void inp(){
    cin>>D;
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
}

void ans_inp(){
    for(int i=1;i<=D;i++){
        cin>>ans[i];
    }
}

void ans_ran(){
    for(int i=1;i<=D;i++){
        ans[i]=rand()%26+1;
    }
}

int man_calc(bool disp){
    int l[32]={0};
    int man=0;
    for(int i=1;i<=D;i++){
        int n=ans[i];
        l[n]=i;
        man+=s[i][n];
        for(int j=1;j<=26;j++){
            man-=c[j]*(i-l[j]);
        }
        if(disp) cout<<man<<endl;
    }
    return man;
}

void ans_disp(){
    for(int i=1;i<=D;i++){
        cout<<ans[i]<<endl;
    }
}

void change_ans(int i,int n){
    ans[i]=n;
}

void solve_C(){
    int M;
    cin>>M;
    for(int i=0;i<M;i++){
        int from,to;
        cin>>from>>to;
        change_ans(from,to);
        cout<<man_calc(false)<<endl;
    }
}

void random_solve(){
    srand(1234);
    ans_ran();
    for(int i=0;i<=100000;i++){
        int bef=man_calc(false);
        int ci=rand()%D+1;
        int tn=rand()%26+1;
        int fn=ans[ci];
        change_ans(ci,tn);
        int aft=man_calc(false);
        if(bef>aft){
            change_ans(ci,fn);
        }
    }
    ans_disp();
    //cout<<man_calc(false)<<endl;
}

signed main(){
    inp();
    random_solve();
    return 0;
}



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

int main(){
  vector<bool> a(4, false);
  for (int i=0; i<4; i++){
    int N; cin >> N;
    if (N==1) a[0] = true;
    else if (N==9) a[1] = true;
    else if (N==7) a[2] = true;
    else if (N==4) a[3] = true;
  }
  cout << ((a[0]&&a[1]&&a[2]&&a[3])? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

const int MAX = 1e5 + 10;
int N, M, Q;
vector<int> graph[MAX];
int v[MAX], d[MAX], c[MAX];
int nowColor[MAX];
bool already[MAX][15];

void dfs(int V, int dis, int color, int prev) {
	if (already[V][dis]) return;
	already[V][dis] = true;
	if (nowColor[V] == 0) nowColor[V] = color;
	if (dis == 0) return;
	for (int e : graph[V]) {
		if (e != prev) {
			dfs(e, dis - 1, color, V);
		}
	}
}

int main() {
	memset(nowColor, 0, sizeof(nowColor));
	memset(already, false, sizeof(already));
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a;--b;
		graph[a].emplace_back(b);
		graph[b].emplace_back(a);
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; ++i) {
		scanf("%d%d%d", v + i, d + i, c + i);
		--v[i];
	}
	for (int i = Q - 1; i >= 0; --i) {
		dfs(v[i], d[i], c[i], -1);
	}
	for (int i = 0; i < N; ++i) {
		printf("%d\n", nowColor[i]);
	}
}


Measured memory_bytes: 9464
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

    int w, h;
    cin >> w >> h;
    
    int sumC = 0, sumR = 0;
    vector<int> col(w);
    vector<int> row(h);
    for ( int i=0; i<w; ++i ) {
	cin >> col[i];
	sumC += col[i];
    }
    for ( int i=0; i<h; ++i ) {
	cin >> row[i];
	sumR += row[i];
    }

    if ( sumR != sumC ) {
	cout << "0" << endl;
	return 0;
    }
    
    for ( int i=0; i<w; ++i ) {

	sort( row.rbegin(), row.rend() );

	for ( int j=0; j<h; ++j ) {
	    if ( !col[i] || !row[j] ) break;
	    --row[j];
	    --col[i];
	}

	if ( col[i] > 0 ) {
	    cout << "0" << endl;
	    return 0;
	}
    }
    cout << "1" << endl;
    
    return 0;
}



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

using namespace std;

const int MAXK=1e5+1e4;
const int MAXN=110;

int dp[MAXK];
int A[MAXN];
int N, K;
void calcDP(){
	for(int i=0;i<=K;i++){
		if(A[0]>i)
			dp[i]=1;
		else{
			dp[i]=1;
			for(int j=0;(i-A[j])>=0 && j<N;j++){
				if(dp[i-A[j]]==1)
					dp[i]=0;
			}
		}
	}
	
}

int main(){
	
	cin>>N>>K;
	for(int i=0;i<N;i++)
		cin>>A[i];
	calcDP();
	if(dp[K]==0)
		cout<<"First";
	else
		cout<<"Second";
}

Measured memory_bytes: 640
while True:
  l = [int(i) for i in input().split()]
  if l == [0,0,0]:
    break
  l.sort()
  r = (l[0]**2+l[1]**2)**(1/2)/2
  n = int(input())
  for i in range(n):
    r1 = int(input())
    if r < r1:
      print('OK')
    else:
      print('NA')

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> V(N + 1);
  for (int i = 0; i < N + 1; i++) {
    V.at(i) = i;
  }
  vector<long> R(N + 2);
  for (int i = 1; i < N + 2; i++) {
    R.at(i) = R.at(i - 1) + V.at(i - 1);
  }
  int ans, tmp;
  for (int i = 1; i < N + 2; i++) {
    if (R.at(i) >= N) {
      tmp = R.at(i) - N;
      ans = i - 1;
      break;
    }
  }
  for (int i = 1; i <= ans; i++) {
    if (i == tmp) continue;
    cout << i << "\n";
  }
}

Measured memory_bytes: 120372
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int n;
    cin >> n;
    map<int, int> even, odd;
    int v;
    REP(i, n)
    {
        cin >> v;
        if (i % 2 == 0)
        {
            ++even[v];
        }
        else
        {
            ++odd[v];
        }
    }
    vector<pii> e, o;
    for (const auto& p : even)
    {
        e.push_back(make_pair(p.second, p.first));
    }
    for (const auto& p : odd)
    {
        o.push_back(make_pair(p.second, p.first));
    }
    sort(e.rbegin(), e.rend());
    sort(o.rbegin(), o.rend());
    if (e[0].second != o[0].second)
    {
        if (e[0].first < o[0].first)
        {
            swap(e[0], o[0]);
        }
        cout << ((n / 2) - e[0].first) + ((n / 2) - o[0].first) << endl;
    }
    else
    {
        int a = ((n / 2) - e[0].first) + ((n / 2) - o[1].first);
        int b = ((n / 2) - e[1].first) + ((n / 2) - o[0].first);
        cout << min(a, b) << endl;
    }
    return 0;
}


Measured memory_bytes: 6136
#include<stdio.h>
int main()
{
	int a,b[9],i;
	while(1){
		scanf("%d",&a);
		if(a==0){
			break;
		}
		for(i=0;i<9;i++){
			scanf("%d",&b[i]);
			a-=b[i];
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int n;
  cin >> n;
  cout << fixed << setprecision(10) << 1.0 * 2 * n * acos(-1) << endl;
}

Measured memory_bytes: 3764
import sys
import math
u = int(input())
n=str(u)

if n[-1]=='0':
    print('pon')
elif n[-1]=='3':
    print('bon')
elif int(n[-1])<5 and int(n[-1])%2==0:
    print('hon')
elif int(n[-1])>=5 and int(n[-1])%2==1:
    print('hon')
else:
    print('pon')




Measured memory_bytes: 9192
// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)...}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__) << '\n'
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin { 
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }	
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on





auto Main() {
	int k;
	string s;
	cin>>k>>s;

	if(s.size()<=k) cout<<s;
	else cout << s.substr(0,k) << "...";
	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


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

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    for(int i=1;i<n;i++){
        ans = (ans + (double)v[i])/2;
    }
    cout<<setprecision(7)<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int a, b, c;
   cin >> a >> b >> c;
    
   int x = 0;
   for(int i = a;i <= b;i++){
        
       if(c%i == 0){
           x++;
       }
   }
   cout << x << endl;
     
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,K;
	cin>>n>>K;
	vector<int> h(n+1);
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	vector<int> dp(n+1);
	dp[1]=0;
	for(int i=2;i<=n;i++){
		int c=INT_MAX;
		for(int j=1;j<=K;j++){
			if((i-j)<1){
				break;
			}
			c=min(c,dp[i-j]+abs(h[i]-h[i-j]));
		}
		dp[i]=c;
	}
	cout<<dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> lights;
    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        vector<int> light;
        for (int j = 0; j < k; ++j) {
            int s; cin >> s;
            light.push_back(s - 1);
        }
        lights.push_back(light);
    }

    vector<int> switches;
    for (int i = 0; i < M; ++i) {
        int x; cin >> x;
        switches.push_back(x);
    }

    int count = 0;
    for (int bits = 0; bits < (1 << N); ++bits) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int s = 0;
            for (const auto& l : lights[i]) {
                if (bits & (1 << l)) {
                    ++s;
                }
            }

            if ((s % 2) != switches[i]) {
                ok = false;
                break;
            }
        }

        if (ok) {
            ++count;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
import collections
S = list(map(int, input()))[::-1]
mod_list = [0 for _ in range(len(S)+1)]
x = 0
d = 0
for i, s in enumerate(S):
    x += s * pow(10, d, 2019)
    d += 1
    mod_list[i] = x%2019
c = collections.Counter(mod_list)
ans = 0
for i in range(2020):
    ans += c[i] * (c[i]-1)//2
print(ans)

Measured memory_bytes: 88508
def solution():
    user_input = input()
    animals, legs = [int(x) for x in user_input.split()]

    if 4*animals < legs:
        print("No")
        return
    
    if 2*animals > legs:
        print("No")
        return

    turtles = animals 
    cranes = 0 

    while cranes <= animals:
        if 4*turtles + 2*cranes == legs:
            print("Yes")
            return
        
        turtles -= 1
        cranes += 1

    print("No")
        
        
        
solution()

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

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

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<ll> ini(5, 0);
  rep(i, n){
    string s; cin >> s;
    if(s[0] == 'M') ini[0]++;
    else if(s[0] == 'A') ini[1]++;
    else if(s[0] == 'R') ini[2]++;
    else if(s[0] == 'C') ini[3]++;
    else if(s[0] == 'H') ini[4]++;
  }
  
  ll sum = 0;
  REP(i, 0, 2){
    REP(j, i+1, 3){
      REP(k, j+1, 4){
        sum += ini[i] * ini[j] * ini[k];
      }
    }
  }
  
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
  char str[7];
    scanf("%s", str);
    if (strcmp("Sunny", str) == 0)
    {
        printf("Cloudy");
    }
    else if (strcmp("Cloudy", str) == 0)
    {
        printf("Rainy");
    }
    else if (strcmp("Rainy", str) == 0)
    {
        printf("Sunny");
    }
    return 0;
}

Measured memory_bytes: 128
a, b, c, x, y = map(int, input().split())

price = a * x + b * y

if (a + b) // 2 >= c:
    if x >= y:
        price = min(2 * x * c, 2 * y * c + (x - y) * a)

    else:
        price = min(2 * x * c + (y - x) * b,  2 * y * c)

print(price)

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

#define int long long
int n,ans,T=5e8+4,MOD=1e9+7;;
vector<int> edge[223456];
int d[223456];
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
int dfs1(int pa,int idx){
  int res=0;
  for(int p:edge[idx]){
    if(p==pa)continue;
    int A=dfs1(idx,p);
    ans-=pw(T,n-A);
    res+=A;
  }
  return d[idx]=res+1;
}
void dfs2(int pa,int idx){
  for(int p:edge[idx]){
    if(p==pa)continue;
    int A=d[idx]-d[p];
    (ans-=pw(T,n-A))%=MOD;
    d[p]+=A;
    dfs2(idx,p);
  }
}

signed main(){
  cin>>n;
  ans=n*T+pw(T,n)*(n-2);
  for(int i=1;i<n;i++){
    int a,b;cin>>a>>b;a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs1(-1,0);
  dfs2(-1,0);
  cout<<(ans+MOD)%MOD<<endl;
}


Measured memory_bytes: 22528
package main

import (
    "bufio"
    "fmt"
    "os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
    var s, t string
    if sc.Scan() {
        s = sc.Text()
    }
    if sc.Scan() {
        t = sc.Text()
    }

  if s == t[:len(s)]{
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
}

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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int x;
  cin >> x;
  if (x == 0) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }


  return 0;
}


Measured memory_bytes: 3592