akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

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

    int n;
    long long int t[100];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    long long int sai;
    sai = t[0];
    bool flag = true;
    int num = 1;
    for(int i = 1; i < n; i++){
        while(flag){
            if(sai>t[i]){
                if(sai*num%t[i]==0){
                    flag=false;
                    sai = sai*num;
                }
            }else{
                if(t[i]*num%sai==0){
                    flag=false;
                    sai=t[i]*num;
                }
            }
            num++;
        }
        flag=true;
        num=1;
    }
    cout << sai << '\n';

    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    int ret = n/15;
    cout << n*800 - 200*ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  string mm="abcdefghijklmnopqrstuvwxyz";
  for (int i=0;i<26;i++){
    bool check=true;
    for (int j=0;j<S.size();j++){
      if (mm[i]==S[j]){
        check=false;
      }
    }
    if (check){
      cout << mm[i] << endl;
      break;
    }
    if (i==25){
      cout << "None" << endl;
    }
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int n[100000] = {};
  for (int i = 0; i < N; i++)
    n[A[i]]++;
  long ans = 1;
  for (int i = 0; i < N / 2; i++)
  {
    ans *= 2;
    ans %= 1000000007;
  }
  if (N % 2 == 0)
  {
    for (int i = 1; i <= N - 1; i += 2)
    {
      if (n[i] != 2)
        ans = 0;
    }
  }
  else
  {
    if (n[0] != 1)
      ans = 0;
    for (int i = 2; i <= N - 1; i += 2)
    {
      if (n[i] != 2)
        ans = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;
const long long INF = 1LL<<60; // 仮想的な無限大の値
vector<bool> seen;

Graph G;

string s;
string t;
string fault = "UNRESTORABLE";

bool match(int pos){
    //異なる文字列発見したらNGで終了
    for(int i=0;i < t.length();i++){
        if(s[pos + i] != t[i] && s[pos + i] != '?') return false;
    }
    return true;
}

string create(int k){
    string ans = s;
    for(int i= 0;i < t.length();i++){
        ans[k + i] = t[i];
    }
    for(int i =0;i < s.length();i++){
        if(ans[i] == '?'){
            ans[i] = 'a';
        }
    }

    return ans;
}


int main() {
    
    //一致する文字前後のはてなの数を数える
    cin >> s >> t;
    bool end = false;
    if(s.length() < t.length()) {
        cout << fault;
        return 0;
    }
    int pos=0;
    bool isT = false;
    string ans;
    for(int i=s.length()-t.length();i >= 0;i--){
        

        isT = match(i);
        if(isT) {
            ans = create(i);
            break;
        }
        //---------------
        // int j=0;
        // //比較開始点記録
        // pos = i;
        // while(s[i] == t[j] || s[i] == '?'){
            
        //     if (j == s.length()) end = true;//比較元の上限超え
        //     if(end) break;
        //     //Tの末尾まで来たら部分文字列確定
        //     if(j == t.length() - 1) {
        //         //見つけた部分文字列置換
        //         s.replace(pos,t.length(),t);
        //         isT = true;
        //         j =0;
        //         break;
        //     }
        //     j++;
        //     i++;

        // }
        // //次の比較へ
        // i++;
        // if(isT) break;
        // //文字列末尾までチェック終了
        // if(end) break;
    
    }


    if(isT){
        //replace(s.begin(), s.end(), '?', 'a');  
        cout << ans << endl;
    }else{
        cout << fault << endl;
    }

    
    return 0;

}

Measured memory_bytes: 256
### constant

MINM =  8 * 60
MAXM = 18 * 60
MEET = 30

INF = 1 << 30

### subroutines

def hm2min(hm)
  h, m = hm.split(':').map(&:to_i)
  h * 60 + m
end

def min_costs_from(tts, ncts, nmins, from)
  mcf = ncts.times.map{nmins.times.map{INF}}
  mcf[from] = nmins.times.map{0}

  tts.each do |smid, gmid, scid, gcid, cost|
    if mcf[scid][smid] < INF
      gcost = mcf[scid][smid] + cost
      if mcf[gcid][gmid] > gcost
        for m in (gmid...nmins)
          mcf[gcid][m] = gcost if mcf[gcid][m] > gcost
        end
      end
    end
  end

  mcf
end

def min_costs_to(rtts, ncts, nmins, to)
  mct = ncts.times.map{nmins.times.map{INF}}
  mct[to] = nmins.times.map{0}

  rtts.each do |smid, gmid, scid, gcid, cost|
    if mct[gcid][gmid] < INF
      scost = mct[gcid][gmid] + cost
      if mct[scid][smid] > scost
        for m in (0..smid)
          mct[scid][m] = scost if mct[scid][m] > scost
        end
      end
    end
  end

  mct
end

### main

loop do
  n = gets.to_i
  break if n == 0

  chash = {}
  mhash = {}
  tts = []

  n.times do
    sct, shm, gct, ghm, cost = gets.strip.split

    smin = hm2min(shm) - MINM
    gmin = hm2min(ghm) - MINM
    next if smin < 0 || gmin > MAXM - MINM

    chash[sct] = chash[gct] = true
    mhash[smin] = mhash[gmin] = true

    tts << [sct, smin, gct, gmin, cost.to_i]
  end
  #p tts

  cts = chash.keys.sort
  cts.each_with_index{|c, i| chash[c] = i}
  ncts = cts.length
  #p cts

  mins = mhash.keys.sort
  mins.each_with_index{|m, i| mhash[m] = i}
  nmins = mins.length
  #p mins

  tts = tts.map do |sct, smin, gct, gmin, cost|
    [mhash[smin], mhash[gmin], chash[sct], chash[gct], cost]
  end.sort

  cid0 = chash['Hakodate']
  cid1 = chash['Tokyo']

  mcf0 = min_costs_from(tts, ncts, nmins, cid0)
  mcf1 = min_costs_from(tts, ncts, nmins, cid1)

  mcf = ncts.times.map{|cid| nmins.times.map{|mid|
      sum = mcf0[cid][mid] + mcf1[cid][mid]
      sum < INF ? sum : INF
    }}

  rtts = tts.sort{|a, b| c = b[1] <=> a[1]; (c != 0) ? c : b[0] <=> a[0]}

  mct0 = min_costs_to(rtts, ncts, nmins, cid0)
  mct1 = min_costs_to(rtts, ncts, nmins, cid1)

  mct = ncts.times.map{|cid| nmins.times.map{|mid|
      sum = mct0[cid][mid] + mct1[cid][mid]
      sum < INF ? sum : INF
    }}

  min_cost = INF

  for cid in (0...ncts)
    for fmid in (0...nmins)
      cost_f = mcf[cid][fmid]
      next if cost_f >= INF
      fmin = mins[fmid]

      for tmid in ((fmid + 1)...nmins)
        next if mins[tmid] - fmin < MEET
        cost_t = mct[cid][tmid]
        break if cost_t >= INF

        cost = cost_f + cost_t
        min_cost = cost if min_cost > cost
      end
    end
  end

  puts (min_cost < INF) ? min_cost : 0
end

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

#define INF 1E18



int main(){
    int n;
    cin>>n;
    int a[4];
    rep(i,4){
        a[3-i] = n%10;
        n /= 10;
    }

    for(int i=0; i<(1<<3); ++i){
        int ans = a[0];
        for(int j=0; j<3; ++j){
            if((i>>j)&1) ans += a[j+1];
            else ans -= a[j+1];
        }
        if(ans == 7){
            cout<<a[0];
            for(int k=0; k<3; ++k){
                if((i>>k)&1) cout<<'+'<<a[k+1];
                else cout<<'-'<<a[k+1];
            }
            cout<<"=7"<<endl;
            return 0;
        }
    }

    return 0;
}


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

int main(){
    int n,k; cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        double a=1.0/n;
        int b=i;
        while(b<k){
            b*=2;
            a/=2;
        }
        ans+=a;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

using namespace std;

int main() {
  int N, A, B; cin >> N >> A >> B;

  int ans = 0;
  for (int i = 1; i < N+1; i++) {
    int s = 0;
    int n = i;

    while(n / 10) {
      s += n % 10;
      n /= 10;
    }
    s += n;

    if(A <= s && s <= B) {
      ans += i;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a, l;

string changes(ll num) {
	stringstream ss;
	ss << num;
	return ss.str();
}

ll changei(string num) {
	ll res;
	stringstream ss;
	ss << num;
	ss >> res;
	return res;
}

int main() {
	while (cin >> a >> l&&a + l) {
		string s = "";
		rep(i, l)s += "0";
		rep(i, l) {
			s[i] += a % 10;
			a /= 10;
		}
		reverse(ALL(s));
		//cout << s << endl;
		ll ans = -1;
		ll cnt = 0;
		vector<ll> vl;
		vl.push_back(changei(s));
		while (ans == -1) {
			cnt++;
			string ss, tt;
			sort(ALL(s));
			ss = s;
			reverse(ALL(s));
			tt = s;
			ll n1, n2;
			n1 = changei(ss);
			n2 = changei(tt);
			//cout << "!!" << cnt << " " << ss << " " << tt << endl;
			ll num = n2 - n1;
			rep(i, vl.size()) {
				if (num == vl[i]) {
					s = changes(num);
					ans = i;
					break;
				}
			}
			if (ans != -1)break;
			vl.push_back(num);
			s = changes(num);
			reverse(ALL(s));
			while (s.size() < l)s += "0";
			reverse(ALL(s));
		}
		cout << ans << " " << s << " " << cnt - ans << endl;
	}
}


Measured memory_bytes: 3224
import math

def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

pr = primes(100000)
d=[0]*100001
ans=[0]*100001

for j in pr:
    d[j]=1

for k in pr:
    tmp = (k+1)//2
    if d[tmp]==1:
        ans[k]=1

import numpy as np
cum = np.cumsum(ans)

q=int(input())
for _ in range(q):
    l,r = map(int,input().split())
    i1 = cum[l-1]
    i2 = cum[r]
    print(i2 - i1)

Measured memory_bytes: 33016
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vint l(m), r(m);
    rep(i, m) cin >> l[i] >> r[i];

    vint sum(n+1, 0);
    rep(i, m) {
        sum[l[i]-1]++;
        sum[r[i]]--;
    }
    // show_ary(sum);
    rep(i, n) sum[i+1] += sum[i];

    // show_ary(sum);


    int ans = 0;
    rep(i, n) if (sum[i] == m) ans++;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
# Initializing variables
s, t = input().split()
a, b = input().split()
a = int(a)
b = int(b)
u = input()

# Calculating remaining balls
if u == s:
    print(str(int(a-1)) + " " + str(b))
else:
    print(str(a) + " " + str(int(b-1)))



Measured memory_bytes: 3060
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

class Union_Find {
    public:
    std::vector<int> par;
    Union_Find() {}
    Union_Find(int n){
        par.resize(n, 0);
        for(int i = 0; i < n; i++){
            par[i] = i;
        }
    }

    void simplify(int x) {
        std::vector<int> path;
        while (par[x] != x) {
            path.push_back(x);
            x = par[x];
        }
        for (int p : path) {
            par[p] = x;
        }
    }
    
    int find(int x){
        simplify(x);
        return par[x];
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x != y) {
            par[y] = x;
            // 改造する時は「根になっているノードの親を変更する」という原則が守られていることに注意。
        }
    }
};

const int MAX_N = 200050;
int N, M;
int X[MAX_N], Y[MAX_N], Z[MAX_N];

bool is_parent[MAX_N] = {};

Union_Find uf = Union_Find(MAX_N);

int main(int argc, char **argv) {
    std::cin >> N >> M;
    
    for (int i = 1; i <= M; i++) {
        std::cin >> X[i] >> Y[i] >> Z[i];
    }

    for (int i = 1; i <= M; i++) {
        uf.unite(X[i], Y[i]);
    }

    for (int i = 1; i <= N; i++) {
        is_parent[uf.find(i)] = true;
    }

    int ret = 0;
    for (int i = 1; i <= N; i++) {
        if (is_parent[i]) {
            ret++;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 2304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        try {
            String[] tmp = br.readLine().split(" ");
            int N = Integer.valueOf(tmp[0]), K = Integer.valueOf(tmp[1]);

            tmp = br.readLine().split(" ");
            int[] arr = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = Integer.valueOf(tmp[i]);
            }

            int[] dp = new int[N];
            Arrays.fill(dp, Integer.MAX_VALUE);
            dp[0] = 0;
            
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < Math.min(N, i + K + 1); j++) {
                    dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
                }
            }

            System.out.println(dp[N- 1]);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }
}

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

int main(){
    int N, K;
    int A[200000], bucket[200000];

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

    //Aの要素の最大値
    int maxA = 0;
    for (int i = 0; i < N; i++){
        if(maxA < A[i]) maxA = A[i];
    }
    
    //bucketを用意
    for (int i = 0; i <= maxA; i++){
        bucket[i] = 0;
    }
    //bucketに詰める
    for (int i = 0; i < N; i++){
        bucket[A[i]] += 1;
    }
    //debug
    /*for (int i = 0; i <= maxA; i++){
        cout << bucket[i] << endl;
    }*/
    //bucket内のポケットの数を数える
    int bucketnum = 0;
    for (int i = 0; i <= maxA; i++){
        if (bucket[i] != 0){
            bucketnum += 1;
        }
    }
    //cout << bucketnum << endl;
    if (bucketnum)
    sort(bucket, bucket + maxA + 1);

    /*for (int i = 0; i <= maxA; i++){
        cout << bucket[i] << endl;
    }*/
    int num = 0;
    for (int i = 0; i <= maxA; i++){
        if (bucketnum - K <= 0) break;
        if (bucket[i] != 0){
            num += bucket[i];
            bucket[i] = 0;
            bucketnum -= 1;
        }
    }
    cout << num << endl;

}

Measured memory_bytes: 1792
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i64 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i64 = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = max(0, a - b * 2);
    println!("{}", ans);
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	   String s = sc.nextLine(); 
	   String[] ss = s.split("");
	  sc.close();
	int n = s.length();
	
	 int z = ct(n,zero(n,s),ss);
	int o = ct(n,one(n,s),ss);
   int ans = Math.min(z,o);
	

	
	System.out.println(ans);
	 

	}
  static String[] zero(int n,String s) {
	StringBuilder aa = new StringBuilder();

		for(int i=0; i<n; i++) {
			if(i%2==0) {aa.append("0");}
			if(i%2==1) {aa.append("1");}
		}
		
	
	 String aaa = aa.toString();  
	String[]a =aaa.split("");
	 return a;
 }
 
 static String[] one(int n,String s) {
		
		StringBuilder bb = new StringBuilder();

		for(int i=0; i<n; i++) {
				if(i%2==0) {bb.append("1");}
				if(i%2==1) {bb.append("0");}
			}
		
		  String bbb = bb.toString();
		  String[]b =bbb.split("");
		 return b;
	 }
 static int ct (int n,String[]a,String[]ss) {
	 int c =0;
	 for(int i=0; i<n; i++) {
		 if(a[i].equals(ss[i])) {
		    c++;
		 }
	 }
	 
	 return c;
 }


}

Measured memory_bytes: 53764
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld n;
  cin >> n;
  lld s = 0;
  for (lld i = 1; i <= n; i++) {
    lld q = n / i;
    s += (q + 1) * q / 2 * i;
  }
  cout << s << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

int main() {
    int n, W;
    cin >> n >> W;
    vec v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];

    // dp[n番目まで確定][w合計]
    mat dp(110, vec(20000, 0));

    rep(i, n) {
        int ni = i+1;

        for (int j = 0; j <= 11000; j++) {
            chmax(dp[ni][j], dp[i][j]);
            chmax(dp[ni][j + w[i]], dp[i][j] + v[i]);
        }
    }

    int res = -1;
    for (int j = W; j >= 0; j--) {
        chmax(res, dp[n][j]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,f;
  cin >> N;

for (int i = 1; i<=N; i *= 10)
  f += (N / i) % 10;

if (N % f == 0)
  cout <<"Yes"<<endl;
else
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    int d; cin >> d;
    mp[d]++;
  }
  int m; cin >> m;
  bool ok = true;
  for(int i = 0; i < m; i++) {
    int t; cin >> t;
    mp[t]--;
    if(mp[t] < 0) ok = false;
  }
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, K;
    cin>>n>>K;
    vi a(n);
    for(int i=0; i<n; i++) {
        cin>>a[i];
    }
    vi dp(K+1);
    for(int i=1; i<=K; i++) {
        bool flag = 0;
        for(int j=0; j<n; j++) {
            if(i-a[j]>=0) {
                if(dp[i-a[j]] == 0) {
                    flag = 1;
                    break;
                }
            }
        }
        dp[i] = flag;
    }
    cout << (dp[K] ? "First\n" : "Second\n");
    return 0;
}



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

int main() {
    int Q; cin >> Q;
    while (Q--) {
        LL A, B; cin >> A >> B;
        LL ans = 0;
        LL sqrtAB;
        {
            LL l = 0, r = 1000000000;
            while (l + 1 < r) {
                LL m = (l + r) / 2;
                if (m * m < A * B) l = m; else r = m;
            }
            sqrtAB = l;
        }
        ans = sqrtAB * 2;
        if (sqrtAB * (sqrtAB + 1) >= A * B) ans--;
        if ((A * B - 1) / A != (A * B - 1) / (A + 1)) ans--;
        if ((A * B - 1) / B != (A * B - 1) / (B + 1)) ans--;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
  int n;
  int x[20];
  int i, cnt;
  
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &x[i]);
  
  for (i = 0; i < n-2; i++)
    if (x[i] < x[i+1] && x[i+1] < x[i+2] || x[i] > x[i+1] && x[i+1] > x[i+2])
      cnt++;
  
  printf("%d\n", cnt);
  
  return 0;
}


Measured memory_bytes: 256
import cmath
pi = cmath.pi
exp = cmath.exp

N=2**18

def make_exp_t(N, base):
    exp_t = {0: 1}
    temp = N
    while temp:
        exp_t[temp] = exp(base / temp)
        temp >>= 1
    return exp_t

fft_exp_t = make_exp_t(N, -2j*pi)
ifft_exp_t = make_exp_t(N, 2j*pi)

def fft_dfs(f, s, N, st, exp_t):
    if N==2:
        a = f[s]; b = f[s+st]
        return [a+b, a-b]
    N2 = N//2; st2 = st*2
    F0 = fft_dfs(f, s   , N2, st2, exp_t)
    F1 = fft_dfs(f, s+st, N2, st2, exp_t)
    w = exp_t[N]; wk = 1.0
    for k in range(N2):
        U = F0[k]; V = wk * F1[k]
        F0[k] = U + V
        F1[k] = U - V
        wk *= w
    F0.extend(F1)
    return F0

def fft(f, N):
    if N==1:
        return f
    return fft_dfs(f, 0, N, 1, fft_exp_t)

def ifft(F, N):
    if N==1:
        return F
    f = fft_dfs(F, 0, N, 1, ifft_exp_t)
    for i in range(N):
        f[i] /= N
    return f

n,m,*a=map(int,open(0).read().split())
b=[0]*N
for i in a:b[i]+=1
i=N
c=0
for a in ifft([t*t for t in fft(b,N)],N)[::-1]:
  a=int(a.real+.5)
  i-=1
  if a:
    t=min(m,a)
    c+=i*t
    m-=t
    if not m:break
print(c)

Measured memory_bytes: 123228
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String p = scan.next();
		
		String ring = s + s;
		
		if (ring.contains(p)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");			
		}
	}
}

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

int main(){
  while(1){
    int n,m,suma,sumb,ave;
    cin >> n >>m;
    suma=0;
    sumb=0;

    vector<int>veca(n);
    vector<int>vecb(m);
    if(n==0 && m==0)break;

    for(int i=0;i<n;i++){
    cin >> veca.at(i);
    suma+=veca.at(i);
  }
    for(int i=0;i<m;i++){
    cin >> vecb.at(i);
    sumb+=vecb.at(i);
  }

    if((suma+sumb)%2==1){
      cout << -1 <<endl;
    }
    else {
      ave = (suma + sumb)/2;

      sort(veca.begin(),veca.end());
      sort(vecb.begin(),vecb.end());

      string s;
      s="No";
      //cout<<"[][]  "<<2*abs(suma-ave)<<endl<<endl;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        //suma - veca.at(i) + vecb.at(j)
        //sunb - vecb.at(j) + veca.at(i)
        // if(suma - veca.at(i) + vecb.at(j) == sunb - vecb.at(j) + veca.at(i)
        //cout<<"i = "<<i<<" j = "<<j<<" "<<veca.at(i)<<" "<<vecb.at(j)<<endl;
        if(veca.at(i)-vecb.at(j)==suma-ave){
          cout << veca.at(i) <<" "<< vecb.at(j) <<endl;
          s="Yes";
        }
        if(s=="Yes")break;
      }
      if(s=="Yes")break;
    }
    if(s=="No"){
      cout << -1 <<endl;
    }
    }




  }

}



Measured memory_bytes: 3188
# -*- coding: utf-8 -*-

n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    t, x, y = [int(x) for x in input().split()]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('Yes')

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

int main(){
	int x,y;
	vector<int> asc;
	while(cin >> x >> y){
		if(x == 0 && y == 0) return 0;
		asc.push_back(x);
		asc.push_back(y);
		sort(asc.begin(),asc.end());
		cout << asc[0] << " " << asc[1] << endl;
		asc.clear();
	}
}

Measured memory_bytes: 1212
from bisect import bisect
from itertools import accumulate
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    a.sort()
    b.sort()
    c.sort()
    ainb = [bisect(b, ea) for ea in a]
    bc = [n - bisect(c, eb) for eb in b]
    bcaccum = tuple(accumulate(bc))
    tr = 0
    for eainb in ainb:
        if eainb != 0:
            tr += bcaccum[eainb - 1]
    r = bcaccum[-1] * n - tr

    print(r)

if __name__ == '__main__':
    main()


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

int main()
{
    int N;
    std::cin>>N;
    std::vector<int> H(N);
    for(int i=0;i<N;i++)std::cin>>H[i];
    int maximum = 0;
    int tmp_max = 0;
    for(int i=0;i<N-1;i++){
        if(H[i]>=H[i+1])tmp_max++;
        else tmp_max = 0;
        maximum = std::max(maximum,tmp_max);
    }
    std::cout<<maximum<<std::endl;

    return 0;
}

Measured memory_bytes: 640
/*
 * e.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_T = 100;
const int MAX_D = 10;
const int MAX_H = 50;
const int MAX_W = 50;

const int dxs[] = {1, 0, -1, 0}, dys[] = {0, 1, 0, -1}; // E,N,W,S

/* typedef */

typedef pair<int,int> pii;
typedef set<pii> spii;

struct Stat {
  int x, y, di, i, d;
  Stat() {}
  Stat(int _x, int _y, int _di, int _i, int _d):
    x(_x), y(_y), di(_di), i(_i), d(_d) {}
};

/* global variables */

bool nbrs[MAX_H + 1][MAX_W + 1][4];
bool used[MAX_H + 1][MAX_W + 1][4][MAX_T + 1][MAX_D + 1];
int ds[MAX_T + 1], dis[MAX_T + 1];

/* subroutines */

/* main */

int main() {
  int n, x0, y0, t;
  cin >> n >> x0 >> y0 >> t;

  for (int i = 0; i < n; i++) {
    int xs, ys, xe, ye;
    cin >> xs >> ys >> xe >> ye;
    if (xs == xe) {
      if (ys > ye) swap(ys, ye);
      for (int y = ys; y < ye; y++)
	nbrs[y][xs][1] = nbrs[y + 1][xs][3] = true;
    }
    else {
      if (xs > xe) swap(xs, xe);
      for (int x = xs; x < xe; x++)
	nbrs[ys][x][0] = nbrs[ys][x + 1][2] = true;
    }
  }

  for (int i = 0; i < t; i++) {
    char ch;
    cin >> ds[i] >> ch;
    switch (ch) {
    case 'E': dis[i] = 0; break;
    case 'N': dis[i] = 1; break;
    case 'W': dis[i] = 2; break;
    case 'S': dis[i] = 3; break;
    }
  }
  ds[t] = 1;
  dis[t] = -1;
  
  queue<Stat> q;
  for (int di = 0; di < 4; di++)
    if (nbrs[y0][x0][di]) {
      q.push(Stat(x0, y0, di, 0, ds[0]));
      used[y0][x0][di][0][ds[0]] = true;
    }

  spii ans;
  
  while (! q.empty()) {
    Stat u = q.front(); q.pop();

    int cdi = -1;
    if (u.d == 0) {
      cdi = dis[u.i];
      u.d = ds[++u.i];
    }

    u.d--;
    int rudi = (u.di + 2) % 4;

    for (int vdi = 0; vdi < 4; vdi++)
      if (nbrs[u.y][u.x][vdi] && vdi != rudi) {
	if (cdi >= 0 && cdi != u.di && cdi != vdi) continue;
	if (u.i >= t) {
	  ans.insert(pii(u.x, u.y));
	  continue;
	}
	int vx = u.x + dxs[vdi], vy = u.y + dys[vdi];
	if (! used[vy][vx][vdi][u.i][u.d]) {
	  q.push(Stat(vx, vy, vdi, u.i, u.d));
	  used[vy][vx][vdi][u.i][u.d] = true;
	}
      }
  }

  for (spii::iterator sit = ans.begin(); sit != ans.end(); sit++)
    printf("%d %d\n", sit->first, sit->second);
  return 0;
}

Measured memory_bytes: 10388
class Node
  attr_accessor :child, :visited
  def initialize
    @child = {}
  end
end

## recursive version
# def f(i, j, g)
#   unless $known[i][j]
#     max = 0
#     g[j].child.each{|k, w|
#       next if i == k
#       ret = f(j, k, g)
#       max = ret if max < ret
#     }
#     $known[i][j] = g[i].child[j] + max
#   end
#   return $known[i][j]
# end

## Loop version
def f(i, j, g)
  return $m[j][1] + g[i].child[j] if $m[j] && $m[j][0] != i
  unless $known[i][j]
    stack = [i, j]
    max = {}
    done = {}
    done[i] = true
    max[i] = 0
    while stack.size > 1
      s = stack[-2]
      t = stack[-1]
      max[t] ||= 0
      unless $known[s][t]
        flag = true
        g[t].child.each{|u, w|
          next if done[u]
          next if s == u
          done[u] = true
          if $known[t][u]
            max[t] = $known[t][u] if max[t] < $known[t][u]
          else
            stack << u
            flag = false
            break
          end
        }
        if flag
          $known[s][t] = g[s].child[t] + max[t]
          max[s] = $known[s][t] if max[s] < $known[s][t]
          stack.pop
        end
      else
        max[s] = $known[s][t] if  max[s] < $known[s][t]
        stack.pop
      end
    end
  end
  return $known[i][j]
end

$known = Hash.new{|h, k| h[k] = {}}
$m = {}
n = gets.to_i
g = Array.new(n){Node.new}

(n-1).times{
  s, t, w = gets.split.map(&:to_i)
  g[s].child[t] = w
  g[t].child[s] = w
}

n.times{|i|
  max = 0
  g[i].child.each{|j, w|
    ret = f(i, j, g)
    if max < ret
      max = ret
      $m[i] = [j, max]
    end
  }
  puts max
}

Measured memory_bytes: 18844
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

type key struct {
	i1, i2 int
}

var N, M, ans int

func main() {
	fmt.Scan(&N, &M)
	m := make(map[key]int)

	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	for i := 0; i < M; i++ {
		reader.Scan()
		t, _ := strconv.Atoi(reader.Text())
		reader.Scan()
		v, _ := strconv.Atoi(reader.Text())
		m[key{t, v}]++
		m[key{v, t}]++
	}

	for j := 2; j < N; j++ {
		if m[key{1, j}]+m[key{j, N}] == 2 {
			fmt.Println("POSSIBLE")
			return
		}
	}
	fmt.Println("IMPOSSIBLE")
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] > a[j][0]
}


Measured memory_bytes: 29184
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::string s,t;
	std::cin >> s >> t;
	rep(i,n) {
		std::cout << s[i] << t[i];
	}
	std::cout << ENDL;

	return 0;
}


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

string s;
int cnt[2000],ans=1,n;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin >> n;
cin >> s;
for(int i=0;i<n;i++){
   cnt[s[i]]++;
}
for(int i='a';i<='z';i++){
   ans = ans*(cnt[i]+1)%mod;
}
ans = (ans-1+mod)%mod;
cout << ans << endl;

return 0;
}
///....


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

int main(){
	int n,m,i,j,a[100],b,c[100],tmp;
	while(cin >> n >> m && (n != 0 && m != 0)){
		memset(a,0,sizeof(a));
		for(i = 0;i < 100;i++){
			c[i] = i+1;
		}
		for(i = 0;i < n;i++){
			for(j = 0;j < m;j++){
				cin >> b;
				if(b == 1) a[j]++;
			}
		}
		for(i = 0;i < m-1;i++){
			for(j = m-1;j > i;j--){
				if(a[i] < a[j]){
					tmp = a[i];
					a[i] = a[j];
					a[j] = tmp;
					tmp = c[i];
					c[i] = c[j];
					c[j] = tmp;
				}
				else if(a[i] == a[j]){
					if(c[i] > c[j]){
						tmp = c[i];
						c[i] = c[j];
						c[j] = tmp;
					}
				}
			}
		}
		for(i = 0;i < m;i++){
			if(i != 0) cout << " ";
			cout << c[i];
		}
		cout << "\n";
	}

}

Measured memory_bytes: 864
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#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, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3080
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }
int main(){
int c[3][3];
for(int i = 0; i < 3;i++){
	for(int j = 0; j < 3; j++){
		cin >> c[i][j];
	}
}
int ans_1 = 0;
for(int i = 0; i < 3;i++){
	for(int j = 0; j < 3; j++){
		ans_1 += c[i][j];
	}
}
if(ans_1 == (c[0][0]+c[1][1]+c[2][2])*3)cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 15 11:06:14 JST 2020
 **/

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

template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

const int K = 2001;
signed main() {
    auto match = [](char c1, char c2) {
        return c1 == '?' || c2 == '?' || c1 == c2;
    };
    string a, b, c;
    cin >> a >> b >> c;
    vector<bool> ab_(8 * K, true), ac_(8 * K, true), bc_(8 * K, true);
    auto ab = ab_.begin() + 4 * K, ac = ac_.begin() + 4 * K, bc = bc_.begin() + 4 * K;
    REP(i, -4 * K, 4 * K) {
        REP(j, b.size()) {
            int k = i + j;
            if (0 <= k && k < a.size() && !match(a[k], b[j])) ab[i] = false;
        }
    }
    REP(i, -4 * K, 4 * K) {
        REP(j, c.size()) {
            int k = i + j;
            if (0 <= k && k < a.size() && !match(a[k], c[j])) ac[i] = false;
        }
    }
    REP(i, -4 * K, 4 * K) {
        REP(j, c.size()) {
            int k = i + j;
            if (0 <= k && k < b.size() && !match(b[k], c[j])) bc[i] = false;
        }
    }

    int ans = 1e9;
    REP(i, -2 * K, 2 * K) {
        REP(j, -2 * K, 2 * K) {
            if (ab[i] && ac[j] && bc[j - i]) {
                int l = min({0, i, j});
                int r = max({(int)a.size(), i + (int)b.size(), j + (int)c.size()});
                chmin(ans, r - l);
            }
        }
    }
    cout << ans << endl;
}


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

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
long *Array, *Work;
long Cnt,icount;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void mergesort(long first, long last)
{
	int middle;
	static long i, j, k, p, l;

	if (first < last) {
		middle = (first + last) / 2;
		mergesort(first, middle);
		mergesort(middle + 1, last);
		p = 0;
		for (i = first; i <= middle; i++) Work[p++] = Array[i];
		i = middle + 1;  j = 0;  k = first; l=i-k;
		while (i <= last && j < p){
			if (Work[j] <= Array[i]){
                Array[k++] = Work[j++];
                l--;
			}else{
                Array[k++] = Array[i++];
                Cnt+=l;
            }
        }
		while (j < p) Array[k++] = Work[j++];
	}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long n;

    fscanf(file, "%ld", &n);
    Array = malloc(succ(n)*sizeof(long));
    Work = malloc(succ(n/2)*sizeof(long));
    for (icount=Cnt=0; icount<n; icount++){
        fscanf(file, "%ld", &Array[icount]);
    }
    mergesort(0, pred(n));
    printf("%ld\n", Cnt);
    free(Array);
    free(Work);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Measured memory_bytes: 2736
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        int count = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");
        int[] num = new int[count];
        for(int i=0; i<count; i++){
            num[i] = Integer.parseInt(str[i]);
        }

        for(int i=0; i < count/2; i++){
            int k = count - (i+1);
            int swp = num[i];
            num[i] = num[k];
            num[k] = swp;
        }
        for(int i=0; i<count-1; i++){
            sb.append(num[i]).append(" ");
        }
        sb.append(num[count-1]);
        System.out.println(sb);

    }
}

Measured memory_bytes: 24148
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    while(1){
        int x,y;
        cin>>x>>y;
        if(x==0&&y==0)break;
        if(x<y){
            cout<<x<<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
    }
}


Measured memory_bytes: 1160