akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()
    val cnt = (1..n).count { it.toString().length % 2 == 1 } 
    println(cnt)
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 36596
//
//AtCoder Beginner Contest 163
//D - Sum of Large Numbers
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()

using ll = long long;

const int mod = 1000000007;

ll sum(ll l, ll r){
    return (l+r)*(r-l+1)/2;
}

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

    ll ans=0;
    for(ll i=k; i<=n+1; i++){
        ll l=sum(0,i-1);
        ll r=sum(n-i+1,n);
        ans += r-l+1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>;

int main() {
    int n,m; cin>>n>>m;
    int k;
    vi city(n+1);

    rep(i,m*2) {
        cin>>k;
        rep2(j,n){
            if(k==j){
                city.at(j)++;
                break;
            }
        }
    }
    rep2(i,n) cout<<city.at(i)<<endl;
}


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

int main() {
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas" << endl;
  if(d == 24) cout << "Christmas Eve" << endl;
  if(d == 23) cout << "Christmas Eve Eve" << endl;
  if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
a = int(input())
b = [int(i) for i in input().split()]

numbers = min(b)

b = [i - min(b) for i in b]

theend = False

while theend == False:
  
    if b.count(0) == a:
        theend = True
        break

    indexnotzero = 0

    for i in range(len(b)):
        if b[i] == 0:
            continue
        else:
            indexnotzero = i
            break

    if indexnotzero == len(b) - 1:
        numbers += b[len(b) - 1]
        break

    try:
        length = b.index(0, indexnotzero)
    except ValueError:
        length = len(b)
    minimum = min(b[indexnotzero:length])

    numbers += minimum

    b[indexnotzero:length] = [i - minimum for i in b[indexnotzero:length]]

print(numbers)

Measured memory_bytes: 3064
import numpy as np
n=int(input())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype="int32")
dp[1]=np.abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=np.min(dp[i-2:i]+np.abs(h[i]-h[i-2:i]))
print(dp[-1])

Measured memory_bytes: 22840
#include <bits/stdc++.h>
#define int long long
#define ii pair<int,int>

using namespace std;
const int N = 1e3+3, INF = 1e9;
int h, w, sx, sy, dx, dy, A[N][N], dist[N][N];
int f[5] = {-2, -1, 0, 1, 2};
int gx[4] = {1, -1, 0, 0},
    gy[4] = {0, 0, 1, -1};

bool is_valid(int x, int y) {
    int t = (x>=0 && x<h && y>=0 && y<w);
    if(!t)  return 0;
    return A[x][y];
}

main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
//    freopen("in.txt", "r", stdin);
    cin >> h >> w;
    cin >> sx >> sy >> dx >> dy;
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            char c; cin >> c;
            A[i][j] = (c=='.');
            dist[i][j] = INF;
        }
    }
    sx--; sy--; dx--; dy--;
    dist[sx][sy] = 0;
    priority_queue<pair<int, ii>, vector<pair<int, ii>>, greater<pair<int, ii>>> pq;
    pq.push({0, {sx, sy}});
    while(!pq.empty()) {
        pair<int, ii> cp = pq.top(); pq.pop();
        int val = cp.first,
            x   = cp.second.first,
            y   = cp.second.second;
        if(dist[x][y] < val)    continue;
        for(int i=0; i<5; i++) {
            for(int j=0; j<5; j++) {
                int nx = x + f[i],
                    ny = y + f[j];
                if(!is_valid(nx, ny))
                    continue;
                if(dist[nx][ny] > dist[x][y] + 1) {
                    dist[nx][ny] = dist[x][y] + 1;
                    pq.push({dist[nx][ny], {nx, ny}});
                }
            }
        }
        for(int i=0; i<4; i++) {
            int nx = x + gx[i],
                ny = y + gy[i];
            if(!is_valid(nx, ny))
                continue;
            if(dist[nx][ny] > dist[x][y]) {
                dist[nx][ny] = dist[x][y];
                pq.push({dist[nx][ny], {nx, ny}});
            }
        }
    }
    cout << (dist[dx][dy] == INF ? -1 : dist[dx][dy]);
}


Measured memory_bytes: 19388
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <string>
#define  debug	0
#define  MAXN  100010
using namespace std;
int count=0;
int hashTable[MAXN]={0};
map<int,int>id;
int getid(int n)
{	extern int count;
	if(id.find(n) == id.end())
	{	id[n]= count++;
	}
	return id[n];
}
int main()
{				
#if debug 
freopen("data.txt","r",stdin);
#endif
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) 
	{	int number,idd;
		scanf("%d",&number);
		idd = getid(number);
		hashTable[idd] = !hashTable[idd];
	}
	int cnt=0;
	extern int count;
	for(int i=0;i<count;i++)
	{
		if(hashTable[i])cnt++;
	}
	printf("%d\n",cnt);
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int , int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
int main (){
    int n, m;
    cin >> n >> m ;
    vector<vector<int>> sw (m) ;
    vector<int> p (m) ;
    int ans = 0 ;
    rep(i, m){
        int k ;
        cin >> k ;
        rep(j, k){
            int s ;
            cin >> s; 
            sw[i].push_back(s) ;
        }
    }
    rep(i, m){
        cin >> p[i] ;
    }
    rep(i, 1 << n){
        bool can = true ;
        rep(j, m){
            int num = 0; 
            rep(k, sw[j].size()){
                if(i >> (sw[j][k] - 1) & 1){
                    num++ ;
                }
            }
            if(num % 2 != p[j]){
                can = false; 
                break ;
            }
        }  
        if(can){
            ans++ ;
        }      
    }
    cout << ans << endl ;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <cstdlib>
#include <iomanip>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <iterator>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <cstring>
#include <sstream>
#include <stack>
#include <random>

using namespace std;

#define vi vector<int> 
#define vvi vector<vi>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define io ios::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size()) 
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define loop(i,b) for (int i = 0; i < b; ++i)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define INF numeric_limits<int>::max()
#define LLINF numeric_limits<ll>::max()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define F first
#define S second
#define MOD 1000000007
#define cflout(x) cout << fixed << setprecision(8) << x << endl
#define setzero(x) memset(x, 0, sizeof(x))

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

random_device _random_device;
default_random_engine _generator(_random_device());
uniform_int_distribution<long long unsigned> _distribution(0, 0xFFFFFFFFFFFFFFFF);

inline long long unsigned get_random_number() {
    return _distribution(_generator);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

inline ll nxt() {
	ll x;
	cin >> x;
	return x;
}

namespace aux {	
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) {
		v.emplace_back(x);
    }
    return v;
}
}


int n;

int p[100500];

vi pos;
int ans;

int main() {
	io;
	n = nxt();
	loop(i, n) {
		p[i+1] = nxt();
	}

	if (p[1] == 1) swap(p[1], p[2]), ans++;

	loop(i, n) {
		if (p[i+1] == i+1) pos.pb(i+1);
	}

	int i = 0;
	while (i < pos.size()) {
		if (i < pos.size()-1 && pos[i+1]-pos[i] == 1) {
			swap(p[pos[i]], p[pos[i+1]]);
			ans++;
			i += 2;
		} else {
			swap(p[i], p[i-1]);
			ans++;
			i++;
		}
	}

	cout << ans << endl;



	return 0;
}


















Measured memory_bytes: 1276
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
int n,k[10001],ans=0,fl=0;
while(cin >> n && n){
fl = 0;
ans = 0;
for(int i=0;i<n;i++){
cin >> k[i];
}
for(int i=1;i<=2;i++){
for(int j=0;j<n;j++){
if(i == 1&&k[j] > 0){
ans++;
}
if(i == 2&&k[j] >= 2&& fl == 0){
ans++;
fl = 1;
}
}
}
if(fl == 0){
cout << "NA" << endl;
}else{
cout << ans << endl;
}
}
return 0;
}


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


int main()
{
	int a, d,t=90;
	double x=0,y = 0;
	double pi = acos(-1);

	while (1)
	{
		scanf("%d,%d", &d,&a);
		if (d == 0 && a == 0)
		{
			break;
		}
		//t -= a;
		x += d*cos(t*pi / 180);
		y += d*sin(t*pi / 180);
		t -= a;
		
	}
	
	printf("%d\n%d\n", (int)x,(int)y);

	return 0;
}


Measured memory_bytes: 604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
    public static void main(String args[]) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        int i=1;
        while(true){
            int data= Integer.parseInt(reader.readLine());
            if(data==0)
                break;
             
            builder.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(data)).append("\n");
        }
        System.out.print(builder);
    }
}

Measured memory_bytes: 30364
#include <bits/stdc++.h>
#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;
    cin >> N;
    vector<int> P(N);
    iota(P.begin(), P.end(), 0);
    double x[N], y[N];
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }


    int n = 0;
    double sum = 0.0;
    do {
        for(int i = 0; i < N-1; i++){
            sum += sqrt( (x[P[i+1]]-x[P[i]])*(x[P[i+1]]-x[P[i]]) + (y[P[i+1]]-y[P[i]])*(y[P[i+1]]-y[P[i]]) );
        }
        n++;
    } while(next_permutation(P.begin(), P.end()));

    cout << fixed << setprecision(10) << sum / n << endl;


    return 0;
}

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

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

	vector<int> ac(n);
	vector<int> pena(n);

	rep(i, m){
		int p;
		string s;
		cin >> p >> s;
		if(ac.at(p-1))
			continue;
		if(s == "AC"){
			ac.at(p-1)++;
		}else{
			pena.at(p-1)++;
		}
	}

	int ans_ac = 0;
	int ans_wa = 0;
	rep(i,n) {
		ans_ac += ac.at(i);
		if(ac.at(i)){
			ans_wa += pena.at(i);
		}
	}

	cout << ans_ac << " " << ans_wa << endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
public static void main(String[] args) {
	try(Scanner sc = new Scanner(System.in)){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
	
	if(a < b && b < c)
		System.out.println(a + " " + b + " " + c );
	else if(a < b && c < b)
		if(a < c)
			System.out.println(a + " " + c + " " + b );
		else
			System.out.println(c + " " + a + " " + b );
	else if(b < a && a < c)
		System.out.println(b + " " + a + " " + c );
	else if(b < c && c < a)
		System.out.println(b + " " + c + " " + a );
	else if(c < b && b < a)
		System.out.println(c + " " + b + " " + a );
	else if(a == b && a < c)
		System.out.println(a + " " + b + " " + c );
	else if(a ==b && c < a)
		System.out.println(c + " " + b + " " + a );
	else if(a == c && a < b)
		System.out.println(a + " " + c + " " + b );
	else if(a == c && b < a)
		System.out.println(b + " " + c + " " + a );
	else if(b == c && b < a)
		System.out.println(c + " " + b + " " + a );
	else if(b == c && a < b)
		System.out.println(a + " " + b + " " + c );
	}
}
}



Measured memory_bytes: 26208
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int ai,ao,at,aj,al,as,az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;
    int ans = ao;
    if(ai%2 && aj%2 && al%2){
        ans += ai + aj + al;
    }else if(ai%2==0 && aj%2==0 && al%2==0){
        ans += ai + aj + al;
    }else if(ai<2 && aj<2 && al<2){
        ans += 0;
    }else{
        ans += ai + aj + al - 1;
    }
    cout << ans << endl;

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://agc008.contest.atcoder.jp/tasks/agc008_c

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<string> titles(n);
    vector<int> seconds(n);

    rep(i, n) {
        cin >> titles[i];
        cin >> seconds[i];
    }

    string x;
    cin >> x;
    int index = find(titles.begin(), titles.end(), x) - titles.begin();

    int ans = 0;
    for (int i = index + 1; i < n; i++) {
        ans += seconds[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
N, A, B, C, D = gets.split.map(&:to_i)
diff = (A - B).abs

mid = (C+D).to_f / 2
w = D - mid
if mid == 0.0
    puts A == B ? 'YES' : 'NO'
end

n = diff / mid
if n > N - 1
    d = diff - (N - 1) * mid
elsif N % 2 == 0
    i = ((n + 1) / 2).round * 2 - 1
    d = diff - i * mid
else
    i = (n / 2).round * 2
    d = diff - i * mid
end


if d.abs <= w * (N - 1)
    puts 'YES'
else
    puts 'NO'
end

Measured memory_bytes: 2044
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 11;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int dis[10][10];
int main() {
	int H, W, i, j, k;
	scanf("%d %d", &H, &W);
	for (i = 0; i < 10; i++) for (j = 0; j < 10; j++) scanf("%d", &dis[i][j]);
	for (k = 0; k < 10; k++) for (i = 0; i < 10; i++) for (j = 0; j < 10; j++) dis[i][j] = min(dis[i][k] + dis[k][j], dis[i][j]);

	int ans = 0;
	for (i = 0; i < H*W; i++) {
		int t;
		scanf("%d", &t);
		if (t >= 0) ans += dis[t][1];
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

class TopologicalSort {
    int V;
    vector <vector<int>> G;
    vector <bool> used;
    vector <int> indeg; // 入次数
    vector <int> ret;

    void bfs(int s) {
        queue<int> q;
        q.push(s);
        used[s] = 1;
        while (!q.empty()) {
            int cur = q.front(); q.pop();
            ret.push_back(cur);
            for (int to : G[cur]) {
                indeg[to]--;
                if (indeg[to] == 0 && !used[to]) {
                    used[to] = 1;
                    q.push(to);
                }
            }
        }
    }

public:
    TopologicalSort(vector<vector<int>> &edge) {
        V = edge.size();
        G = edge;
        used.assign(V, false);
        indeg.assign(V, 0);
    }

    vector<int> build() {
        for (int i = 0; i < V; i++) for (int v : G[i]) indeg[v]++;
        for (int i = 0; i < V; i++) if (indeg[i] == 0 && !used[i]) bfs(i);
        return ret;
    }
};


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/4/GRL_4_B
void AOJ_GRL_4_B() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> edge(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
    }
    TopologicalSort ts(edge);
    vector <int> dag = ts.build();
    for (int i : dag) cout << i << '\n';
}

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


Measured memory_bytes: 4260
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int l[] = new int [N];
		int r[] = new int [N];
		for(int i=0;i<N;i++){
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans = 0;

		for(int j=0;j<N;j++){
			ans += r[j] - l[j] + 1;
		}

		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 25956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int a;
		int b;

		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		if ((a * b) % 2 == 0) {
			System.out.print("No");
		} else {
			System.out.print("Yes");
		}
	}

}

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

namespace atcoder_Calc1
{
    class MinorChange
    {
        static void Main() 
        {

            //入力は小英字の文字列
            string str1 = Console.ReadLine();
            string str2 = Console.ReadLine();
            int answer = 0;

            if (str1.Length != str2.Length)
            {
                return;
            }

            for(int i = 0; i < str1.Length; i++)
            {
                if (str1[i] != str2[i]) { answer++; }
            }

            Console.WriteLine(answer);

        }

    }
}


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

namespace ABC127A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            
            if (ab[0] >= 13)
            {
                Console.WriteLine(ab[1]);
            }else if(ab[0] >= 6)
            {
                Console.WriteLine(ab[1] / 2);
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  for (int i = 0; i <= b; i++) {
    if (i*a % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>


using namespace std;

int main()
{
int a,b,c,d;
cin >> a >> b >> c >> d;

for(int i=0;a>0 && c>0;i++){
	if(i%2==0){
		c = c - b;
	}
	else{
		a = a - d;
	}

}

if(a<=0){
	cout << "No" << '\n';
}
else{
	cout << "Yes" << '\n';
}
	


	return 0;
}

Measured memory_bytes: 3560
n,m = map(int,input().split())
g = 1
def fact(k):
  a = []
  for i in range(1,int(k **(0.5))+1):
    if k%i ==0:
      a.append(i)
      a.append(int(k/i))
  b = list(set(a))
  b.sort()
  return b

g = fact(m)
for i in range(len(g)):
  if g[len(g)-i-1] <= m/n:
    print(g[len(g)-i-1])
    break
    
    
    
      

  

Measured memory_bytes: 3064
from collections import deque
N=int(input())

G=[[] for _ in range(N+1)]
edge={}

for i in range(N-1):
    a,b=map(int, input().split())
    G[a].append(b)
    G[b].append(a)
    edge[(a,b)]=i
    edge[(b,a)]=i
que=deque()
que.append(1)
visited=[-1]*(N+1)
visited[1]=0
ans=[0]*(N-1)
while que:
    v=que.pop()
    j=1
    for u in G[v]:
        if visited[u]<0:
            if j==visited[v]:
                j+=1
            visited[u]=j
            ans[edge[(u,v)]]=j
            que.appendleft(u)
            j+=1
print(max(ans))
for a in ans:
    print(a)


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

int main(){
 	int x,X,y,Y;
  	cin >> x >> y >> X >> Y;
  	cout << X - (Y - y) << " " << Y + (X - x) << " " << X - (Y - y) - (X - x) << " " << Y + (X - x) - (Y - y) << endl;
}

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


int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
char arr[n][n];
char arr1[m][m];
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);

    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);


    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int count=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        count++;
                }

            }
            if(count==(m*m))
            {
                printf("Yes\n");
                return 0;
            }

        }
    }


    printf("No\n");

}

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

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e5+5;

int n,k,p[N],q[N],ip[N],iq[N],tr[N];
int tmp[N];

void multi(int *a,int *b,int *c){
	fo(i,1,n)tmp[i]=a[b[i]];
	fo(i,1,n)c[i]=tmp[i];
}

void inverse(int *a,int *b){
	fo(i,1,n)tmp[a[i]]=i;
	fo(i,1,n)b[i]=tmp[i];
}

bool pd[N];
int cir[N],u;
int ans[N];

int main(){
	n=get();k=get();
	fo(i,1,n)p[i]=get();
	fo(i,1,n)q[i]=get();
	if (k==1){
		fo(i,1,n)printf("%d ",p[i]);putchar('\n');
		return 0;
	}
	if (k==2){
		fo(i,1,n)printf("%d ",q[i]);putchar('\n');
		return 0;
	}
	fo(i,1,n)ip[p[i]]=i,iq[q[i]]=i;
	fo(i,1,n)tr[i]=i;
	multi(q,ip,tr);
	multi(tr,iq,tr);
	multi(tr,p,tr);
	int tim=(k-1)/6,pos=(k-1)%6+1;
	fo(i,1,n)
	if (!pd[i]){
		u=0;
		for(int x=i;!pd[x];x=tr[x])pd[cir[++u]=x]=1;
		fo(j,1,u)ans[cir[j]]=cir[(j+tim-1)%u+1];
	}
	fo(i,1,n)tr[i]=ans[i];
	if (pos==1)fo(i,1,n)ans[i]=p[i];
	if (pos==2)fo(i,1,n)ans[i]=q[i];
	if (pos==3)multi(q,ip,ans);
	if (pos==4){multi(tr,q,tr);fo(i,1,n)ans[i]=ip[i];}
	if (pos==5){multi(tr,q,tr);multi(tr,ip,tr);fo(i,1,n)ans[i]=iq[i];}
	if (pos==6){multi(iq,p,ans);multi(tr,q,tr);multi(tr,ip,tr);}
	multi(tr,ans,ans);
	inverse(tr,tr);
	multi(ans,tr,ans);
	fo(i,1,n)printf("%d ",ans[i]);putchar('\n');
	return 0;
}

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

int main () {
    int a, b, c, maxa, result ;
    result = 0 ;
    scanf ( "%d %d %d", &a, &b, &c ) ;
    if ( a % 2 == b % 2 && a % 2 != c % 2 ) {
        a++ ;
        b++ ;
        result++ ;
    }
    else if ( a % 2 == c % 2 && a % 2 != b % 2 ) {
        a++ ;
        c++ ;
        result++ ;
    }
    else if ( c % 2 == b % 2 && c % 2 != a % 2 ) {
        b++ ;
        c++ ;
        result++ ;
    }
    maxa = ( a > b ? a : b ) ;
    maxa = ( maxa > c ? maxa : c ) ;
    result += ( ( maxa* 3 - a - b - c ) / 2 ) ;
    printf ( "%d\n", result ) ;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, X, Y, tmp, tmp2;
  cin >> N >> X >> Y;
  vector<ll> dist(N,0);
  for(ll i=1;i<N;i++)for(ll j=i+1;j<N+1;j++){
    if(i <= X && Y <= j){
      tmp = j-i - Y+X + 1;
      dist[tmp]++; // i X Y j
    }else if(i <= X && Y >= j && X <= j){  // i X j Y
      tmp2 = X-i + Y-j + 1;
      tmp = min(j-i, tmp2);
      dist[tmp]++;
    }else if(i > X && Y <= j && Y >= i){ // X i Y j
      tmp2 = j-Y + i-X + 1;
      tmp = min(j-i,tmp2);
      dist[tmp]++;
    }else if(X <= i && j <= Y){
      tmp2 = Y-j + i-X + 1;
      tmp = min(j-i,tmp2);
      dist[tmp]++;
    }else dist[j-i]++;
  }
  REP2(i,1,N) cout << dist[i] << "\n";
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int a, b ;
  cin >> a >> b ;
  
  if(b%a==0)
    cout << a+b << endl ;
  else
    cout << b-a << endl ;
  
  return 0 ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static long fact[] = new long[300000];
	static long factInv[] = new long[300000];

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		final int MOD = 1_000_000_000 + 7;

		//まずは2^n - 1
		long result = repeatablePow(2, n, MOD) - 1;

//		System.out.println(result);

		fact[0] = 1;
		factInv[0] = 1;
		for(int i = 0; i < fact.length - 1; i++){
			fact[i+1] = fact[i]*(i+1) % MOD; // n!(mod M)
	        factInv[i+1] = (int)(factInv[i]*repeatablePow(i+1, MOD-2, MOD) % MOD);
		}

		result -= combination2(n, a, MOD);
//		result -= repeatablePow(2, a, MOD) - repeatablePow(2, a - 1, MOD);
//		System.out.println(result);

		result -= combination2(n, b, MOD);
//		System.out.println(result);

		while(result < 0){
			result += MOD;
		}

		System.out.println(result);

	}

	static long repeatablePow(int x, int n, int mod){
		if(n == 0){
			return 1;
		}
		long result = repeatablePow((int)((long)x*x%mod), n/2, mod);
		if(n % 2 == 1){
			result = result*x%mod;
		}
		return result;
	}


	static long combination2(int n, int b, int mod){
		if(b == 1){
			return n;
		}

		long result = 1;

		for(int i = 1; i <= b ; i++){
			result *= (n - i + 1);
			result %= mod;
		}

		result *= factInv[b];

		return result % mod;
	}
//	static long combination(int a, int b, int mod){ //aCbをmod計算
//	    if(a == 0 && b == 0)return 1;
//	    if(a < b || a < 0)return 0;
//
//	    long tmp = factInv[a - b]* factInv[b] % mod;
//	    return tmp * fact[a] % mod;
//	}

}


Measured memory_bytes: 29268
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
a = a[:4]
b = []
for i in [0,1,2,3]:
  for j in [0,1,2,3]:
    if i != j:
      b.append(int(str(a[i]) + str(a[j])))
b.sort()
print(b[2])



Measured memory_bytes: 5928
while True:
    a,op,b = input().split(" ")
    a = int(a)
    b = int(b)
    op = str(op)
    if op == "?":
        break
    elif b == 0:
        enzan = {"+":a+b, "-":a-b, "*":a*b}
        print(enzan[op])
    else:
        enzan = {"+":a+b, "-":a-b, "*":a*b, "/":a//b}
        print(enzan[op])


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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 long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

// graph //
int V,E,r,from,to,weight;

struct Edge{
    int from,to,cost;
    Edge(int from,int to,int cost) : from(from),to(to),cost(cost){}
};

vector<Edge> edges;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> V >> E >> r;
    REP(i,E){
        cin >> from >> to >> weight;
        edges.emplace_back(from,to,weight);
    }

    vector<ll> dist(V,INF);
    dist[r] = 0;
    REP(i,V){
        bool update = false;
        for(auto e : edges){
            if(dist[e.to] > dist[e.from] + e.cost && dist[e.from] != INF){
                update = true;
                dist[e.to] = dist[e.from] + e.cost;
                if(i == V-1){
                    cout << "NEGATIVE CYCLE" << '\n';
                    return 0;
                }
            }
        }
        if(!update) break;
    }

    REP(i,V){
        if(dist[i]==INF) cout << "INF" << '\n';
        else cout << dist[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a[4],b[4]={1,4,7,9};

int main(){
	for(auto &i:a) cin>>i;
	sort(a,a+4);
	bool B=1;
	for(int i=0;i<4;i++) if(a[i]!=b[i]) B=0;
	cout<<(B?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

N, Q = map(int, input().split())
l, q = [], []
u = set()

for _ in range(N):
    S, T, X = map(int, input().split())
    l += [(S-X, 1, X), (T-X, 0, X)]
for i in range(Q):
    l += [(int(input()), 2, i)]
l.sort()

for _, m, x in l:
    if m==0:
        u.remove(x)
    elif m==1:
        heappush(q, x)
        u.add(x)
    else:
        while q:
            if q[0] not in u:
                heappop(q)
            else:
                break
        print(q[0] if q else -1)


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

int p[55555];
int pn = 0;
int p2[55555];
int p2n = 0;

int main() {
    for (int i = 2; i <= 55555; i++) {
        bool flg = true;
        for (int j = 0; j < pn; j++) {
            if (i % p[j] == 0) {
                flg = false;
                break;
            }
        }
        if (flg) {
            p[pn] = i;
            pn++;

            if (i % 5 == 2) {
                p2[p2n] = i;
                p2n++;
            }
        }
    }

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        if (i != 0) cout << ' ';
        cout << p2[i];
    }
    cout << endl;

    return 0;
}

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

int calc_score(int h, int w, int k, vector<vector<char>> &c);
int drop(int h, int w, vector<vector<char>> &c);

int main()
{

	int h,w,k;
	cin >> h >> w >> k;

	vector<vector<char>> c_orig(h,vector<char>(w));
	for (int i=0;i<h;++i)
	{
		for (int j=0;j<w;++j)
		{
			cin >> c_orig[i][j];
		}
	}

	int max_score=0;
	for (int i=1;i<h;++i)
	{
		for (int j=0;j<w;++j)
		{
			//fprintf(stderr,"push %d, %d\n",i,j);
			int total_score=0;
			int score;
			int round=0;
			vector<vector<char>> c=c_orig;
			c[i][j]='0';
			for (;;)
			{
				drop(h,w,c);
				score=calc_score(h,w,k,c);
				if (score==0)
				{
					break;
				}
				total_score+=(1<<round)*score;
				++round;
			}
			if (total_score>max_score)
			{
				max_score=total_score;
			}
		}
	}
	cout << max_score << endl;
}

int drop(int h, int w, vector<vector<char>> &c)
{
	//fprintf(stderr,"drop in\n");
	for (int i=0;i<w;++i)
	{
		int current_j=h-1;
		for (int j=h-1;j>=0;--j)
		{
			while ((current_j>=0)&&(c[current_j][i]=='0'))
			{
				--current_j;
			}
			c[j][i]= (current_j>=0) ? c[current_j--][i] : '0';
		}
	}
	//fprintf(stderr,"drop out\n");
	return 0;
}

int calc_score(int h, int w, int k, vector<vector<char>> &c)
{
	int score=0;

	for (int i=0;i<h;++i)
	{
		char cc=c[i][0];
		int count=1;
		for (int j=1;j<w;++j)
		{
			if (c[i][j]==cc)
			{
				++count;
			}
			else
			{
				if (count>=k)
				{
					// scored
					score+=(cc-'0')*count;
					for (int k=0;k<count;++k)
					{
						c[i][j-1-k]='0';
					}
				}
				cc=c[i][j];
				count=1;
			}
		}
		if (count>=k)
		{
			// scored
			score+=(cc-'0')*count;
			for (int k=0;k<count;++k)
			{
				c[i][w-1-k]='0';
			}
		}
	}
	return score;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long 
using namespace std;
const ll N=22;
const ll mod=1e9+7;
ll a[N];
ll dp[N][1<<N];
ll mat[N][N];
ll n;
ll women=0;
ll ways(ll i,ll n)
{
	if(i==n)
	{
		if(women==(1<<n)-1)
     	return 1;
     	else
     	return 0;
	}
    if(dp[i][women]!=-1)
    return dp[i][women];
	ll ans=0;
	for(int j=0;j<n;j++)
	{
		if(mat[i][j]==1&&!(women&(1<<j)))
		{
			women|=(1<<j);
			ans+=ways(i+1,n)%mod;
			women&=(~(1<<j));
		}
	}
	return dp[i][women]=ans%mod;
}
int main()
{
	   ios_base::sync_with_stdio(false);
	   cin.tie(NULL);
	   memset(dp,-1,sizeof(dp));
	   cin>>n;
	   for(int i=0;i<n;i++)
	   for(int j=0;j<n;j++)
	   cin>>mat[i][j];
	   
	   cout<<ways(0,n)<<endl;
	   
	   
	   return 0;
}


Measured memory_bytes: 721280
#include<iostream>
using namespace std;
int main(){
    string s;
    cin >> s;
    int mx=0,counter=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i) == 'A' or s.at(i) == 'C' or s.at(i) == 'G' or s.at(i) == 'T'){
            counter++;
        }else{
            mx = max(mx, counter);
            counter = 0;
        }
    }
    mx = max(mx, counter);
    cout << mx << endl;
}


Measured memory_bytes: 256
use v5.18;
use warnings;
use List::Util qw( sum0 min reduce );
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

use constant INF => 10 ** 9;

my @inputs = splited_read_line;
my $N = shift @inputs;
my %T = map { $_ => shift @inputs } qw( A B C );
my @l = map { read_line } 0 .. $N - 1;

sub dfs {
  my ($depth, $str) = @_;
  return $str if $depth == $N;
  map { dfs($depth + 1, $str . $_) } qw( A B C ), ' ';
}

my $ans = min map {
  my @r = split //, $_;
  my $concat_cnt = 0;
  my %ts;
  for my $i (0 .. $#r) {
    for my $t (qw[ A B C ]) {
      if ( $r[$i] eq $t ) {
        $concat_cnt++ if exists $ts{$t};
        $ts{$t} += $l[$i];
      }
    }
  }
  ( grep { !exists $ts{$_} } qw( A B C ) )
    ? INF
    : $concat_cnt * 10 + sum0 map { abs($T{$_} - $ts{$_}) } qw( A B C );
} dfs(0, '');

say $ans;

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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

vector<ll> h(MAX), g[MAX];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll x;
    cin >> x;

    for(ll i=-5000;i<=5000;i++)
    {
        for(ll j=i+1;j<=5000;j++)
        {
            if(j*j*j*j*j - i*i*i*i*i == x)
            {
                cout << j << " " << i << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

ll my_pow(ll x, ll cnt) {
  ll res = x;
  while (--cnt) {
    res *= 2;
  }
  return res;
}

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

  double ans = 0.0;
  int N2 = min(N, K - 1);
  for (int i = 1; i <= N2; i++) {
    int cnt = 0;
    int tmp = i;
    while (tmp < K) {
      tmp *= 2;
      cnt++;
    }

    ans += (1.0 / (double) N) * (1.0 / (double) my_pow(2, cnt));
  }
  if (N >= K) {
    ans += (double) (N - K + 1) / (double) N;
  }

  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M=1e9+7;
const ll inf=1e18+5;
using namespace std;
ll t;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){ 
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}


void solve(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	if(n>=(int)s.length()) cout<<s<<"\n";
	else{
		for(ll i=0;i<(int)s.length();i++){
			if(i<n) cout<<s[i];
			else break;
		}
		cout<<"...\n";
		 
	}
 }
int main(){
	fast();
	solve();
	return 0;
}



Measured memory_bytes: 3656
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;

int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(n);
	ll a[n],max=0;
	for(ll i=0;i<n;i++){
	    in(a[i]);
	    if(max<a[i])max=a[i];
	}
	ll hash[max+1]={0};
	for(ll i=0;i<n;i++){
	    hash[a[i]]++;
	}
	ll tot=0,flag=0;
	for(ll j=0;j<=max;j++){
	    if(hash[j]>1){
	        tot+=(hash[j]*(hash[j]-1))/2;
	        flag=1;
	    }
	    //cout<<hash[j]<<endl;
	}
	//cout<<tot<<endl;
	if(flag==1){
	    //cout<<"1\n";
	    for(ll i=0;i<n;i++){
	        //cout<<"2\n";
    	    if(hash[a[i]]>1){
    	        ll ans=tot-(hash[a[i]]*(hash[a[i]]-1))/2;
        	    hash[a[i]]--;
        	    ans+=(hash[a[i]]*(hash[a[i]]-1))/2;;
        	    cout<<ans<<endl;
        	    hash[a[i]]++;
    	    }else{
    	        cout<<tot<<endl;
    	    }
    	}   
	}else{
	    for(ll i=0;i<n;i++)cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    ll ans = INF;
    rep(i, N) {
        ll r = i;
        ll l = i + K - 1;
        if (l >= N)
            break;

        ll can1 = abs(A[r]) + abs(A[r] - A[l]);
        ll can2 = abs(A[l]) + abs(A[l] - A[r]);

        ans = min(ans, min(can1, can2));
    }

    cout << ans << endl;
}

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

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;

    cout << static_cast<char>(toupper(s1[0])) << static_cast<char>(toupper(s2[0])) << static_cast<char>(toupper(s3[0])) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long i64;
typedef long long ll;

#define MAX_V 100
#define MAX_E MAX_V - 1
#define pii pair<int,int>
using namespace std;

int cost[MAX_V][MAX_V];
struct point {
	int x, y;

};
bool comp(const point &left, const point &right) {
	int leftMin = min(left.x, left.y);
	int rightMin = min(right.x, right.y);
	return leftMin < rightMin;
}
void twoDPlanTowNPoints() {
	int N;
	cin >> N;
	point ab[101];
	point cd[101];
	for (size_t i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		ab[i].x = -a;
		ab[i].y = -b;
	}
	for (size_t i = 0; i < N; i++)
	{
		int c, d;
		cin >> c >> d;
		cd[i].x = c;
		cd[i].y = d;
	}
	sort(ab, ab + N, comp);
	sort(cd, cd + N, comp);
	int res = 0;
	bool use[101];
	fill(use, use + N, false);
	for (size_t i = 0; i < N; i++)
	{
		//int best = 300;
		//int besti = -1;
		for (int j = 0; j < N; j++)
		{
			point p = ab[j];
			p.x = -p.x;
			p.y = -p.y;
			if (!use[j] && p.x < cd[i].x && p.y < cd[i].y) {
				use[j] = true;
				res++;
				break;
				//int tm = min(best, min((cd[i].x - p.x), (cd[i].y - p.y)));
				//if (best > tm) {
				//	best = tm;
				//	besti = j;
				//}
			}
		}
		//if (besti != -1) {
		//	res++;
		//	use[besti] = true;
		//}
	}
	cout << res << endl;
}
int main() {
	twoDPlanTowNPoints();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	long long int a,b;
	int n;
	vector<int> r;
	while (cin >> a >> b >> n)
	{
		int sum=0;
		a = a % b;
		for (int i=0; i<n; i++)
		{
			a*=10;
			sum += (a/b)%10;
		}
		r.push_back(sum);
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}

}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

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

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}else if(a*b==15){
		cout<<"*"<<endl;
	}else{
		cout<<"x"<<endl;
	}
}

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

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>
#include<limits.h>

char lot[32][16], lot2[32][16];

int newlot(int, int, int);
void move(int, int, int *);

int main()
{
	int i, j, k, n, m, s, d, bufm, flag;
	int nlot[32][16];
	char buf[16];

	while(1){

		scanf("%d", &n);

		if(n==0)
			break;

		memset(lot, 0, sizeof(lot));
		memset(nlot, 0, sizeof(nlot));

		scanf("%d%d%d", &m, &s, &d);

		for(i=1; i<=d; i++){
			lot[i][0] = '0';
			scanf("%s", buf);
			strcat(lot[i], buf);
		}

		for(i=1; i<=d; i++){
			for(j=1; j<=n-1; j++){
				nlot[i][j] = newlot(i, j, n);
			}
		}

		flag = 0;

		bufm = m;
		memcpy(lot2, lot, sizeof(lot));
		for(k=1; k<=d; k++){
			move(k, n, &bufm);
		}
		if(bufm == s){
			printf("0\n");
			flag = 1;
		}
		if(flag)
			continue;

		for(i=1; i<=d; i++){
			for(j=1; j<=n-1; j++){
				if(nlot[i][j] == 0)
					continue;
				bufm = m;
				memcpy(lot2, lot, sizeof(lot));
				lot2[i][j] = '1';
				for(k=1; k<=d; k++){
					move(k, n, &bufm);
				}
				if(bufm == s){
					printf("%d %d\n", i, j);
					flag = 1;
				}
				if(flag) break;
			}
			if(flag) break;
		}
		if(flag)
			continue;

		printf("1\n");
	}

	return 0;
}

void move(int i, int n, int *m)
{
	if(*m == 1){
		if(lot2[i][*m] == '1')
			(*m)++;
	}else if(*m == n){
		if(lot2[i][*m-1] == '1')
			(*m)--;
	}else{
		if(lot2[i][*m] == '1')
			(*m)++;
		else if(lot2[i][*m-1] == '1')
			(*m)--;
	}
}

int newlot(int i, int j, int n)
{
	if(lot[i][j] == '1')
		return 0;
	if(n==2)
		return 1;

	if(j == 1){
		if(lot[i][j+1] == '0')
			return 1;
		else
			return 0;
	}else if(j == n-1){
		if(lot[i][j-1] == '0')
			return 1;
		else 
			return 0;
	}else{
		if(lot[i][j-1] == '0' && lot[i][j+1] == '0')
			return 1;
		else 
			return 0;
	}
	return -1;
}

Measured memory_bytes: 624
package main

import (
        "fmt"
)

func solution(s, t string) int {
        out := 1 << 31
        count := func(a, b string) int {
                c := 0
                for i := range a {
                        if a[i] != b[i] {
                                c++
                        }
                }
                return c
        }
        min := func(x, y int) int {
                if x < y {
                        return x
                }
                return y
        }
        for i := 0; i < len(s)-len(t)+1; i++ {
                out = min(out, count(s[i:len(t)+i], t))
        }

        return out
}

func main() {
        var s, t string
        fmt.Scan(&s, &t)
        fmt.Println(solution(s, t))
}

Measured memory_bytes: 1788