akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+7;
int n,m,cnt,hd[N],v[N*2],nxt[N*2];
void add(int x,int y){v[++cnt]=y,nxt[cnt]=hd[x],hd[x]=cnt;}
int dfs(int x,int fa)
{
	int l=0;
	for(int i=hd[x];i;i=nxt[i])
	if(v[i]!=fa)l^=dfs(v[i],x)+1;
	return l;
}
int main()
{
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++)scanf("%d%d",&x,&y),add(x,y),add(y,x);
	if(dfs(1,0))puts("Alice");else puts("Bob");
}

Measured memory_bytes: 6784
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 07:49:36 2020

@author: naoki
"""
N = int(input())
xl = [list(map(int, input().split())) for _ in range(N)]

left_right = [[row[0]-row[1], row[0]+row[1]] for row in xl]
left_right = sorted(left_right, key = lambda x:int(x[1]))
count = 0
now = -100000000000
for row in (left_right):
    if row[0] < now:
        continue
    else:
        count += 1
        now = row[1]
print(count)


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

const ll N = 3*MAX5;
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, l;
string s, t, d, c;

ll par[N], sz[N];
ll comp;
// <------------- Implement Functions Here ----------> //

void make(ll n) {
	for(ll i=1;i<=n;i++) {
		par[i] = i;
		sz[i] = 1;
	}
}

ll find(ll x) {
	return x == par[x]?x:par[x] = find(par[x]);
}

void merge(ll x, ll y) {
	ll u = find(x);
	ll v = find(y);

	if(u == v) return;

	if(sz[u] < sz[v]) swap(u,v);
	sz[u] += sz[v];
	par[v] = u; 
	comp--;
}



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	make(n);
	cin >> m ;
	comp = n;
	for(ll i=0;i<m;i++) {
		cin>>x>>y>>z;
		merge(x,y);
	}

	cout<<comp;

	newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#define MAX_N 100
#define INF 10000000

using namespace std;

int a;
int b[10000];

void solve() {
	int count = 0;
	for (int i = 0; i < a; i++) {
		while (b[i] % 2 == 0) {
			count++;
			b[i]=b[i] / 2;
		}
	}
	cout << count << endl;
}

int main() {
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> b = a;
	sort(b.begin(), b.end());
	int max = b[n - 1];
	int maxsecond = b[n - 2];
	rep(i, n) {
		if (a[i] == max) cout << maxsecond << endl;
		else cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
N, X = map(int, input().split(" "))
gram_list = []
for n in range(N):
    gram_list.append(int(input()))

dnt_cnt = 0
for i in gram_list:
    X = X - i
    dnt_cnt += 1

while X >= min(gram_list):
    X = X - min(gram_list)
    dnt_cnt += 1

print(dnt_cnt)

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

int main(){
  int N;
  cin >>N;
  if(N == 0){
    cout << 0 << endl;
    return 0;
  }
  string ans="";
  while(N != 0){
    if(abs(N)%2 == 1){
      ans = "1"+ans;
      N = (N-1)/(-2);
    }
    else{
      ans = "0"+ans;
      N = N/(-2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 	int cnt = 0;
	string s, t;
  	cin >> s >> t;
  	for(int i = 0; i < s.size(); ++i){
      if(s[i] == t[i])
        continue;
      else
        ++cnt;
    }
  	cout << cnt << endl;
  return 0;
}

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

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for (int i = 0; i < N; i++){
    cin >> m.at(i);
  }
  sort(m.begin(), m.end());
  
  int x = 0;
  for (int i = 0; i < N; i++){
    x+=m.at(i);
  }
  
  cout << (X-x)/m.at(0)+N << endl;
}

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


void solve(long long N, std::vector<long long> A){
    vector<pair<ll, int>> v;
    for(int i = 0;i < N;i++){
        v.push_back({A[i], i});
    }
    sort(v.begin(), v.end(), greater<pair<ll, int>>());
    vector<vector<ll>> dp(N+1, vector<ll>(N+1));
    for(int i = 0;i < N;i++){
        for(int j = 0;j <= i;j++){
            int l = j;
            int r =  N - (i - j) - 1;
            dp[i + 1][j + 1] = max(dp[i][j] + v[i].first * abs(v[i].second - l), dp[i + 1][j + 1]);
            dp[i + 1][j] = max(dp[i][j] + v[i].first * abs(v[i].second - r), dp[i + 1][j]);
        }
    }
    /*
    for(int i = 0;i < N+1;i++){
        for(int j = 0;j < N+1;j++)cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    **/
    cout<<*max_element(dp.back().begin(), dp.back().end())<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 34704
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];

int main() {
	int n;
	cin >> n;
	int ans = (n + 1) / 2;
	cout << ans << endl;
	return 0;
}


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

int main(void) {
  int N, L;
  cin >> N >> L;

  vector<string> ss(N);
  for (int i = 0; i < N ; i++) cin >> ss.at(i);
  sort(ss.begin(), ss.end());

  for (int i = 0; i < N ; i++) cout << ss.at(i);
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
c0,c1,c2,c3 = 0,0,0,0
for i in range(n):
  ch = str(input())
  if ch == 'AC':
    c0 += 1
  elif ch == 'WA':
    c1 += 1
  elif ch == 'TLE':
    c2 += 1
  elif ch == 'RE':
    c3 += 1
print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(c0,c1,c2,c3))

Measured memory_bytes: 9148
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, m;
int a[N];
vector < pair <int, int> > g[N];

bool was[N];
vector <int> cmp;
void dfs(int v) {
	was[v] = 1;
	for (auto to : g[v]) {
		if (!was[to.f]) dfs(to.f);
	}
	cmp.pb(v);
}
void dfs1(int v, int cost) {
	was[v] = 1;
	a[v] = cost;
	for (auto to : g[v]) {
		if (was[to.f]) {
			if (a[to.f] != cost + to.s) cout << "No", ioi
		}
		else dfs1(to.f, cost + to.s);
	}
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int v, u, cost;
		cin >> v >> u >> cost;
		g[v].pb({u, cost});
	}		
	for (int i = 1; i <= n; i++) {
		if (!was[i]) dfs(i);
	}
	reverse(all(cmp));
	memset(was, 0, sizeof(was));
	for (auto it : cmp) {
		if (!was[it]) dfs1(it, 0);
	}
	cout << "Yes";
	ioi
}


Measured memory_bytes: 11384
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let ab = i::uv2(n);
    let mut a_max = 0;
    let mut b_max = 0;
    for (a, b) in ab {
        if a > a_max {
            a_max = a;
            b_max = b;
        }
    }
    println!("{}", b_max + a_max);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn u4() -> (usize, usize, usize, usize) {
        (read(), read(), read(), read())
    }

    pub fn u5() -> (usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read())
    }

    pub fn u6() -> (usize, usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn iv3(n: usize) -> Vec<(i64, i64, i64)> {
        (0..n).map(|_| iv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv4(n: usize) -> Vec<(usize, usize, usize, usize)> {
        (0..n)
            .map(|_| uv(4))
            .map(|a| (a[0], a[1], a[2], a[3]))
            .collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


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

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	ans += h[0];
	for (int i = 1; i < n; ++i) {
		if (h[i] > h[i - 1]) ans += h[i] - h[i - 1];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[] count=new int[26];
		try (Scanner scan=new Scanner(System.in)){
		while(scan.hasNextLine()) {
			String str=scan.nextLine();
			for(int i=0;i<str.length();i++) {
				if(0<=str.charAt(i)-'a' && str.charAt(i)-'a'<26)
				count[str.charAt(i)-'a']++;
				else if(0<=str.charAt(i)-'A' && str.charAt(i)-'A'<26)
				count[str.charAt(i)-'A']++;
			}
		}
		for(int i=0;i<26;i++) {
			System.out.printf("%c : %d\n",i+'a',count[i]);
		}
		}
}
}


Measured memory_bytes: 26320
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
 
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> d;
    
    int sum = 0;
    char last = '\n';
    for(int i =0; i < N; i++){
        char tmp;
        cin >> tmp;
        if(tmp != last){
            sum++;
        }
        last = tmp;
    }
    cout << sum << endl;

}


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

int main(){
  int n,m;cin>>n>>m;
  vector<long long> dp(n+1,0);
  int curr;
  for(int i=0;i<m;++i){
    cin>>curr;
    dp[curr]=-1;
  }
  
  dp[0] = 1;
  dp[1] = dp[1]==-1 ? 0:1;
  
  for(int i=2;i<=n;++i){
    if(dp[i]==-1){
      dp[i]=0;
    }else{
      dp[i]=((dp[i-1]%1000000007)+(dp[i-2]%1000000007))%1000000007;
    }
  }

  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>

using namespace std;

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


int main(){
	
	int in;
	while(scanf("%d",&in)!=EOF){
		
		int sum = 0;
		int d = in;
		for(int i=0;i<600;i+=d){
			sum += i*i*d;
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1172
import java.io.*;
public class Main {
   public static void main(String[] args) throws IOException{
	   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	   String s;
	   while(true){
		   s = br.readLine();
		   if(s.equals("END OF INPUT")) break;
		   String[] ss = s.split(" ");
		   for(int i=0;i<ss.length;i++) System.out.print(ss[i].length());
		   System.out.println();
	   }
   }
}

Measured memory_bytes: 17112
n = int(input())
l = list(map(int,input().split()))

if n <= 2:
  print(0)
  exit()

cnt=0
for i in range(n-2):
  for j in range(i,n-1):
    for k in range(j,n):
      if ((l[i]!=l[j]) and (l[j]!=l[k]) and (l[k]!=l[i])) and (l[i]+l[j]>l[k]) and (l[k]+l[j]>l[i]) and (l[k]+l[i]>l[j]):
        cnt += 1
        
print(cnt)


Measured memory_bytes: 9236
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var K = int.Parse(Console.ReadLine());
        var x = Console.ReadLine().Split();
        var answer = 0;
        for (int i = 0; i < N; i++){
            var xi = int.Parse(x[i]);
            answer += xi < K - xi ? xi * 2 : (K - xi) * 2;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27492
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)


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

int main(){
    
    fastio;

    ll t; t=1;
    while(t--){
        ll x,y,z; cin>>x>>y>>z;
        cout<<z<<" "<<x<<" "<<y;
    }
    return 0;
}

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

int dp[100001];
/// dp[i] 價值為 i 的情況下的最小重量

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N, W;
    cin >> N >> W;

    for (int i = 1; i <= 100000; i++)
        dp[i] = 1e18;

    int sum = 0;
    for (int i = 1; i <= N; i++)
    {
        int w, v;
        cin >> w >> v;

        sum += v;
        for (int j = sum; j >= v; j--)
            dp[j] = min(dp[j], dp[j - v] + w);
    }

    for (int i = sum; i >= 0; i--)
        if (dp[i] <= W)
            cout << i << '\n', exit(0);

    return 0;
}


Measured memory_bytes: 4380
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else if (a >= 6 && a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << "0" << endl;
	}
}


Measured memory_bytes: 256
import java.io.*;

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

        String line = new String();
        String line2,line3;
        String cut,rem;
        String result = new String();
outer:
        while(true){

                line=reader.readLine();
                if(line.equals("-")){
                    break outer;
                }
                int len = line.length();
            
            line2 = reader.readLine();
            int m = Integer.parseInt(line2);
            result = line;
            for(int j = 0;j < m;j++){
                
                line3 = reader.readLine();
                int h = Integer.parseInt(line3);
                cut = result.substring(h);
                rem = result.substring(0,h);
                result = cut+rem;
                }

            
            System.out.println(result);
        }
        }
    }





Measured memory_bytes: 24504
program Project1;

{$APPTYPE CONSOLE}

uses
SysUtils;
var
n,i,j,t,a,b,c,d,sum,temp:integer;
begin
try
  { TODO -oUser -cConsole Main : abc83}
  read(n);
  read(a);
  readln(b);

  sum:=0;
  for i := 1 to n do begin
    temp:=((i mod 10) div 1)+((i mod 100) div 10)+((i mod 1000) div 100)+((i mod 10000) div 1000)+(i div 10000);
    if (temp>=a)and(temp<=b) then begin
      sum:=sum+i;
    end;
  end;
  Writeln(sum);

  readln;
except
  on E: Exception do
    Writeln(E.ClassName, ': ', E.Message);
end;
end.

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

void optimize() {
    std::ios::sync_with_stdio(false);
    std::cout.tie(NULL);
    std::cin.tie(NULL);
}

int main() {
    optimize();
    int n;
    std::cin >> n;
    std::vector<std::string> ans;
    std::map<std::string, int> vote;
    int mx = 0;
    for(int i = 0; i < n; ++i) {
        std::string str;
        std::cin >> str;
        vote[str]++;
        mx = std::max(mx, vote[str]);
    } 
    for(auto &iter : vote) {
        if(iter.second == mx) {
            ans.push_back(iter.first);
        }
    }
    sort(ans.begin(), ans.end());
    for(auto &iter : ans) {
        std::cout << iter << '\n';
    }
    return 0;
}

Measured memory_bytes: 25584
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  long long ans = 0;
  for (int mask = 0; mask < (1 << s.length()-1); ++mask) {
    string ss = "";
    ss += s[0];
    REP(i, s.length()-1) {
      if (mask & (1 << i)) {
        ss += '+';
      }
      ss += s[i+1];
    }
    string temp_s = "";
    REP(i, ss.length()) {
      if (ss[i] != '+') {
        temp_s += ss[i];
      } else {
        ans += stoll(temp_s);
        temp_s = "";
      }
    }
    ans += stoll(temp_s);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	map<ll,ll> m;
	rep(i,0,n){
		ll x;
		cin >> x;
		m[x]++;
	}
	ll ans=0;
	for(auto it=m.begin(); it!=m.end(); it++){
		ll x=it->first;
		ll y=it->second;
		//trace2(x,y);
		if(x>y) ans+=y;
		if(x<y){
			ans+=y-x;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6272
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e6+10, M = 1e6+10;

int main() {
	int n;
	cin>>n;
	if(n == 2) cout<<"2\n";
	else if(n == 1) cout<<"0\n";
	else {
		ll ans = powmod(10ll, n) % mod;
		//cout<<ans<<"\n";
		ans = (ans - powmod(8ll, n) % mod + mod) % mod;
		ll tmp = 0, a = 1, b = 1;
		for(int i = 1;i <= n;i++) {
			a = a * (n - i + 1) % mod;
			b = b * i % mod;
			tmp = (tmp + a * powmod(b, mod - 2) % mod * powmod(8ll, n - i) % mod);
		}
		ans = (ans - tmp * 2 % mod + mod) % mod;
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
const u32 P=998244353;
u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
u32 sum(u32 a, u32 b) {return inc(a, b);}
u32 dif(u32 a, u32 b) {return dec(a, b);}
u64 power(u64 a, u32 b) {
	u64 ans=1;
	for(; b; a=a*a%P, b>>=1) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=1<<14;
int n, m, len;
u32 f[N], g[N], h[N], w[N];
u64 fac[N], ifac[N];
void dft(u32 *x) {
	int bits=__builtin_ctz(len);
	for(int i=1, j=0; i<len; ++i) {
		int k=bits;
		while(j>>--k&1) j^=1<<k;
		j^=1<<k;
		if(i<j) std::swap(x[i], x[j]);
	}
	for(int i=1; i<len; i*=2)
		for(int j=0; j<len; j+=i+i)
			for(int k=0; k<i; ++k) {
				u32 z=1llu*w[i+k]*x[i+j+k]%P;
				x[i+j+k]=dif(x[j+k], z);
				inc(x[j+k], z);
			}
}
void idft(u32 *x) {
	u64 inv=power(len, P-2);
	std::reverse(x+1, x+len);
	dft(x);
	for(int i=0; i<len; ++i) x[i]=x[i]*inv%P;
}
int main() {
	n=rd(), m=rd();
	fac[0]=1;
	for(int i=1; i<=n; ++i) fac[i]=fac[i-1]*i%P;
	ifac[n]=power(fac[n], P-2);
	for(int i=n; i>=1; --i) ifac[i-1]=ifac[i]*i%P;
	for(len=1; len<=2*n; len*=2);
	u64 omega=power(3, P/len);
	w[len/2]=1;
	for(int i=len/2+1; i<len; ++i) w[i]=omega*w[i-1]%P;
	for(int i=len/2; --i; ) w[i]=w[i*2];
	for(int i=0; i<=n; ++i) g[i]=ifac[i];
	dft(g);
	f[0]=1;
	while(m--) {
		for(int i=0; i<=n; ++i) h[i]=(f[i]+2*f[i+1]+f[i+2])*ifac[i]%P;
		for(int i=n+1; i<len; ++i) h[i]=0;
		dft(h);
		for(int i=0; i<len; ++i) h[i]=1llu*g[i]*h[i]%P;
		idft(h);
		for(int i=1; i<=n; ++i) f[i]=dif(h[i]*fac[i]%P, (1llu*i*f[i]+(i+2llu)*f[i+1]+f[i+2])%P);
	}
	u32 ans=0;
	for(int i=0; i<=n; ++i) ans=(ans+ifac[i]*ifac[n-i]%P*f[i])%P;
	ans=ans*fac[n]%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int h,aa[600000];

void mh(int i){
  int l,r,big,t;

  l = i*2;
  r = i*2 + 1;

  if(l<=h && aa[l]>aa[i])big = l;
  else big = i;
  if(r<=h && aa[r] > aa[big])big = r;

  if(big!=i){
    t=aa[i];
    aa[i]=aa[big];
    aa[big]=t;
    mh(big);
  }
}

void bmh(void){
  int i;
  for(i=h/2;1<=i;i--){
    mh(i);
  }
}

int main(){
  int i;
  
  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d",&aa[i]);
  }

  bmh();

  for(i=1;i<=h;i++){
    printf(" %d",aa[i]);
  }
  printf("\n");

  return 0;
}



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

using ll=long long;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;


vi comp;
vll csize;

void init(int n) {
    comp = vi(n);
    csize = vll(n, 1);
    for (int i=0; i<n; ++i)
        comp[i] = i;
}

int find(int i) {
    int c = i;
    if (comp[i] != i) {
        c = find(comp[i]);
        comp[i] = c;
    }
    return comp[i];
}

ll getsize(int i) {
    return csize[i];
}

void unite(int i, int j) {
    i = find(i);
    j = find(j);
    csize[j] += csize[i];
    comp[i] = j;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    init(n);
    vpii edges(m);
    for (int i=0; i<m; ++i)
        cin >> edges[i].first >> edges[i].second;

    vll inconv(m);
    inconv[m-1] = n*ll(n-1)/2;
    for (int i=m-1; i>0; --i) {
        int ai, bi;
        tie(ai, bi) = edges[i];
        --ai; --bi;
        ll delta = 0;
        if (find(ai) != find(bi)) {
            delta = getsize(find(ai))*getsize(find(bi));
            unite(ai, bi);
        } 
        inconv[i-1] = inconv[i] - delta;
    }
    for (auto xi: inconv)
        cout << xi << "\n";
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,d;
    cin >> a>> b>> c>> d;

    if( abs(a - c) <= d || ( abs( a - b) <= d && abs(b -c) <= d) ){

        cout << "Yes" << endl;
    }else{

        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
S = list(set(list(input())))
S.sort(reverse=False)
n = 97

for i in range(len(S)):
  if S[i] != chr(n):
    print(chr(n))
    exit()
  n += 1

if len(S) == 26:
	print('None')
else:
	print(chr(n))

Measured memory_bytes: 3956
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int X;

vector<int> v;

int main(){
    rep(i, 31) v.push_back(pow(i, 2));
    rep(i, 10) v.push_back(pow(i, 3));
    rep(i, 5) v.push_back(pow(i, 4));
    v.push_back(32);
    v.push_back(64);
    v.push_back(128);
    v.push_back(256);
    v.push_back(512);
    v.push_back(243);
    v.push_back(729);
  
  	scanf("%d", &X);

    for(int i=X;i>=0;--i){
        auto itr = find(v.begin(), v.end(), i);
        if(itr != v.end()){
            printf("%d", i);
            return 0;
        }
    }

	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict, deque

v, n = map(int, input().split())
es = [[int(x) for x in input().split()] for _ in range(n)]

outs = defaultdict(list)
ins = defaultdict(int)
#print(ins)
for v1, v2 in es:
    outs[v1].append(v2)
    ins[v2] += 1
    #print(ins)
#print("be",ins)
q = deque(v1 for v1 in range(v+1) if ins[v1] == 0)
#print("af",ins)
res = []
#print(outs)
#print(ins)
while q:
    #print(q)
    v1 = q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        #print("-->",v2)
        ins[v2] -= 1
        if ins[v2] == 0:
            #print("<--",v2)
            q.append(v2)
#print(res[1:])
#print(outs)
#print(ins)

dp = [0]*(v+1)
for i in res[1:]:
    for j in outs[i]:
        dp[j] = dp[i] + 1
        #print(i, j, dp)

print(max(dp))

Measured memory_bytes: 50300
#include <stdio.h>
#include <string.h>

void swap(char *x, char *y){
  char t[3];
  strcpy(t, x);
  strcpy(x, y);
  strcpy(y, t);
}

int main(){
  int n, i, j, f, min;
  char in[37][3], bs[37][3];
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%s", in[i]);

  for(i = 0; i < n; ++i) strcpy(bs[i], in[i]);

  for(i = 0; i < n; ++i)
    for(j = n - 1; j > i; --j)
      if(bs[j][1] < bs[j - 1][1])
	swap(bs[j], bs[j - 1]);

  for(i = 0; i < n; ++i) printf(i != 0 ? " %s" : "%s", bs[i]);
  printf("\nStable\n");

  for(i = 0; i < n; ++i){
    min = i;
    for(j = i + 1; j < n; ++j)
      if(in[j][1] < in[min][1]) 
	min = j;
    if(min != i)
      swap(in[min], in[i]);
  }
  f = 0;
  for(i = 0; i < n; ++i){
    printf(i != 0 ? " %s" : "%s", in[i]);
    if(in[i][0] != bs[i][0]) f = 1;
  }
  puts("");
  puts(f ? "Not stable" : "Stable");
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>oks(n+1,true);
    for(int i=0;i<m;i++){
        int a;cin >> a;
        oks[a]=false;
    }
    vector<long long int>dp(n+1);

    dp[0]=1;
    for(int now=0;now<n;now++){
        for(int next=now+1;next<=min(n,now+2);next++){
            if(oks[next]){
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int N=3e5+5;
int h,w,n;
int rc[N],rw[N];
vector<int> totc,totw;
set<pair<int,int>> rcw;
int maxr,maxw;

int main()
{
    ios::sync_with_stdio(false);
    cin>>h>>w>>n;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        rc[x]++;
        rw[y]++;
        maxr=max(rc[x],maxr);
        maxw=max(rw[y],maxw);
        rcw.insert({x,y});
    }
    for(int i=0;i<=h;i++)
    {
        if(rc[i]==maxr) 
            totc.push_back(i);
    }
    for(int i=0;i<=w;i++)
    {
        if(rw[i]==maxw) 
            totw.push_back(i);
    }    
    
    for(int i=0;i<totc.size();i++)
        for(int j=0;j<totw.size();j++)
        {
            if(!rcw.count({totc[i],totw[j]}))
            {
                cout<<maxr+maxw<<endl;
                return 0;
            }
        }
    cout<<maxr+maxw-1<<endl;
    
    return 0;
}

Measured memory_bytes: 23752
import sys
from itertools import product
import bisect
N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()

d = {}
for i, s in enumerate(S):
    s = int(s)
    if s not in d:
        d[s] = [i]
    else:
        d[s].append(i)

ans = 0
for a, b, c in product(range(10), repeat=3):
    x = -1
    for i in [a, b, c]:
        if i not in d:
            break
        y = bisect.bisect_right(d[i], x)
        if y == len(d[i]):
            break
        x = d[i][y]
    else:
        ans += 1

print(ans)

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

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            char[] charArray = new char[26] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

            char[] s_ = S.ToCharArray().Distinct().ToArray();

            char[] restArray = charArray.Except(s_).ToArray();


            Console.WriteLine(restArray.Count() == 0 ? "None" : restArray[0].ToString());

        }
    }
}


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

using namespace std;
using ll = long long;
ll mo=1e9+7;
vector<vector<vector<ll>>> from(4,vector<vector<ll>>(4,vector<ll>(4,0)));
auto to = from;
int main() {
    int n;cin>>n;
    from[3][3][3] = 1;
    for(int len=0;len<n;++len){
        for(int i=0;i<4;++i)for(int j=0;j<4;++j)for(int k=0;k<4;++k)to[i][j][k] = 0;
        for(int i=0;i<4;++i){
            for(int j=0;j<4;++j){
                for(int k=0;k<4;++k){
                    if(from[i][j][k] == 0) continue;
                    for(int cur=0;cur<4;++cur){
                        if(j == 0 && k == 2 && cur==1)continue;
                        if(j == 1 && k == 0 && cur == 2)continue;
                        if(j == 0 && k == 1 && cur == 2)continue;
                        if(i == 0 && k == 1 && cur == 2)continue;
                        if(i == 0 && j == 1 && cur == 2)continue;
                        to[j][k][cur] += from[i][j][k];
                        to[j][k][cur] %= mo;
                    }
                }
            }
        }
        swap(to,from);
    }
    ll ans = 0;
    for(int i=0;i<4;++i)for(int j=0;j<4;++j)for(int k=0;k<4;++k) ans += from[i][j][k]%mo;
    cout << ans%mo <<endl;
    return 0;
}



Measured memory_bytes: 256
from collections import Counter
from itertools import combinations
from functools import reduce
from operator import mul

n = int(input())
name_starts = [input()[0] for _ in range(n)]

letters = 'MARCH'
counts = Counter(c for c in name_starts if c in letters)

print(sum(reduce(mul, (counts[c] for c in combo)) for combo in combinations(letters, 3)))

Measured memory_bytes: 4508
#include<cstdio>
#include<cstring>

using namespace std;

char s[100005];

int main()
{
    scanf("%s",s);
    int cnt=0;
    int length=strlen(s);
    for(int i=0;i<strlen(s);i++)
    {
        if(i%2==0)
        {
            if(s[i]=='p')
                cnt--;
        }
        else
        {
            if(s[i]=='g')
                cnt++;
        }
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		String ans[] = {"AC", "WA"};
		int an = 0;
		int n = s.length();
		int count = 0;
		if(s.charAt(0) != 'A')an = 1;
		for(int i = 1; i < n; ++i){
			if(Character.isUpperCase(s.charAt(i))){
				if(i == 1 || i == n - 1){
					an = 1;
					break;
				}
				else{
					if(s.charAt(i) == 'C'){
						if(count >= 1){
							an = 1;
							break;
						}
						count++;
					}
				}	
			}
		}
		if(count == 0)an = 1;
		System.out.println(ans[an]);
	}
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define DI(v,i) distance((v).begin(),(auto(i)))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k ;
    string s ;
    cin >> k >> s ;
    int n = SZ(s) ;
    if(n<=k){
        cout << s <<endl ;
    }
    else{
        cout << s.substr(0,k)<<"..."<<endl ;
    }
    

    return 0;
}



Measured memory_bytes: 3656
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(N:i32); println!("{}",(N+111-1)/111*111);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fname "C"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<double, double> dd;
const int Nmax = 100;
int n, A, arr[Nmax];

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	scanf("%d %d", &n, &A);
	REP1(i, n) scanf("%d", &arr[i]);
	ll ans = 0;
	REP1(l, n) {
		int T = A*l;
		//bug(T);
		//vector<ll> current(T + 1, -1), next(T + 1);
		vector< vector<ll> > current(T + 1, vector<ll>(l + 1, -1)), next(T + 1, vector<ll>(l + 1, -1));
		current[0][0] = 1;
		REP1(i, n) {
			next[0][0] = 1;
			REP1(j, T) {
				REP1(k, l) {
					if (arr[i] <= j && current[j][k] != -1 && current[j - arr[i]][k - 1] != -1)
						next[j][k] = current[j][k] + current[j - arr[i]][k - 1];
					else if (arr[i] <= j && current[j - arr[i]][k - 1] != -1)
						next[j][k] = current[j - arr[i]][k - 1];
					else if (current[j][k] != -1)
						next[j][k] = current[j][k];
					else next[j][k] = -1;
				}
			}
			//bug(i); bug(next[T][l]);
			current = next;
		}
		if (next[T][l] != -1) ans += next[T][l];
		//bug(ans);
	}
	cout << ans;
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
VL a, b;
vector<vector<bool>> wf;

void floyd_warshall(set<ll> st) {
    wf.assign(51, vector<bool>(51, false));
    FOREACH(s, st) REP(i, 51) { wf[i][i % s] = 1; }
    REP(i, 51) REP(j, 51) REP(k, 51) {
        wf[i][j] = (wf[i][j]) || (wf[i][k] && wf[k][j]);
    }
}

signed main() {
    cin >> N;
    REP(i, N) { a.emplace_back(IN()); }
    REP(i, N) { b.emplace_back(IN()); }
    set<ll> st;
    REP(i, N) {
        if(a[i] != b[i]) break;
        if(i == N - 1) {
            cout << 0 << "\n";
            return 0;
        }
    }
    FOR(i, 1, 51) st.insert(i);
    ll ans = 0;
    bool judge = false;
    floyd_warshall(st);
    REP(j, N) if(!wf[a[j]][b[j]]) {
        judge = true;
        break;
    }
    if(judge) {
        cout << -1 << "\n";
        return 0;
    }
    FORR(i, 50, 0) {
        judge = false;
        st.erase(i);
        floyd_warshall(st);
        REP(j, N) if(!wf[a[j]][b[j]]) {
            judge = true;
            break;
        }
        if(judge) {
            ans += 1LL << i;
            st.insert(i);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	_ = getInt()
	S := getString()

	x := 0
	max := 0
	for _, v := range S {
		if v == 'I' {
			x++
		}
		if v == 'D' {
			x--
		}
		if x > max {
			max = x
		}
	}

	out(max)
}


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

  int beg = 0, end = 0, sum = 0;

	rep(i,N){	
		cin >> beg >> end;
		sum += end - beg + 1;
	}

	cout << sum << endl;
}


Measured memory_bytes: 256