akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(a == b)
  {
    printf("%d\n", a+b);
  }
  else
  {
    if(a<b)
    {
      a=b;
    }
    printf("%d\n", a+a-1);
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
*/


int main() {
	int N;
	string S;
	cin >> N >> S;
	if (N % 2 != 0) {
		cout << "No" << endl;
	}
	else {
		int cnt = 0;
		for (int i = 0; i < N / 2; i++) {
			if (S[i] == S[i + N / 2]) {
				cnt++;
			}
		}
		if (cnt == N/2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

ll dp[21][2097152],a[21][21],n;

ll fun(int m, int w){
	if(w>=n)	return 1;
	if(dp[w][m]!=-1)	return dp[w][m];
	dp[w][m]=0;
	int power=1;
	for(int i=0;i<n;i++){
		if(power&m || a[i][w]==0){
			power*=2;	continue;
		}
		dp[w][m]+=fun(m+power,w+1);	dp[w][m]%=mod;
		power*=2;
	}
	return dp[w][m];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j;	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>a[i][j];
		}
		for(j=0;j<2097152;j++){
			dp[i][j]=-1;
		}
	}
	cout<<fun(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 344320
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

input:
5 4
0 1
1 2
2 3
3 4

output:
1
2
3
"""

import sys

sys.setrecursionlimit(int(1e5))


def dfs_Tarjan(current):
    global timer
    children = 0
    visited[current] = True
    disc[current] = low[current] = timer
    timer += 1

    for adj in adj_table[current]:
        if not visited[adj]:
            parent[adj] = current
            children += 1
            dfs_Tarjan(adj)
            low[current] = min(low[current], low[adj])
            # current vertex is the root of DFS tree
            if parent[current] == -1 and children > 1:
                art_set.add(current)
            elif parent[current] != -1 and low[adj] >= disc[current]:
                art_set.add(current)

        elif adj != parent[current]:
            low[current] = min(low[current], disc[adj])

    return None


def dfs_init():
    for v in range(v_num):
        if not visited[v]:
            dfs_Tarjan(v)

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    adj_table = tuple([] for _ in range(v_num))
    for edge in edges:
        source, target = map(int, edge)
        adj_table[source].append(target)
        adj_table[target].append(source)

    timer = 0
    art_set = set()
    parent = [-1] * v_num
    visited = [False] * v_num
    disc, low = ([float('inf')] * v_num for _ in range(2))

    dfs_init()
    if art_set:
        print(*sorted(art_set), sep='\n')

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  vector<int> v = {a, b, c, d, e};

  auto maxVal = *max_element(v.begin(), v.end());
  auto minVal = *min_element(v.begin(), v.end());

  if((maxVal-minVal) <= k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        int[] a = new int[N];
        for (int i = 0; i < N; i++) a[i] = Integer.parseInt(sc.next());

        int[] b = new int[N];
        int p = 1;
        for (int i = 0; i < N; i++) {
            if (a[i] == p) {
                p++;
            } else {
                b[i] = 1;
            }
        }

        if (p == 1) {
            System.out.println(-1);
        } else {
            System.out.println(IntStream.of(b).filter(i -> i == 1).count());
        }
    }
}


Measured memory_bytes: 52780
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;
typedef long long int ll;

ll gcd(ll n, ll m){
    if(n%m>0){
        return gcd(m,n%m);
    }else{
        return m;
    }
}

int main(){
    ll a,b;
    while (cin >> a ,cin >> b) {
        ll g = gcd(max(a,b),min(a,b));
        ll l = a*b/g;
        cout <<g<<" "<<l<<endl;
    }
}

Measured memory_bytes: 1160
N, Y = map(int, input().split())

def cal():
	for i in range(N + 1):
		for j in range(N + 1 - i):
			senyen = N - i - j
			if senyen < 0: continue
			if 10000 * i + 5000 * j + 1000 * senyen == Y:
				return [i, j, senyen]
			elif 10000 * i + 5000 * j + 1000 * senyen > Y:
				break
	return [-1, -1, -1]
	
ans = cal()
print(*ans)

Measured memory_bytes: 38768
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    ll ans = 0;
    while (B <= A)
    {
        B = B * 2;
        ans++;
    }

    while (C <= B)
    {
        C = C * 2;
        ans++;
    }

    cout << (K >= ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

typedef long long ll;

int main()
{
	int c[4][4];
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			cin >> c[i][j];
		}
	}
	int a[4], b[4];
	a[1] = 0;
	b[1] = c[1][1];	
	b[2] = c[1][2];	//b[i] = c[1][i] + a[1];
	b[3] = c[1][3];
	a[2] = c[2][1] - b[1];	//a[i] = c[i][1] + b[1];
	a[3] = c[3][1] - b[1];
	bool f = false;
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			if (c[i][j] != a[i] + b[j]) f = true;
		}
	}
	if (!f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    string S;
    map<string, int> ans;
    cin >> N >> S;
    vector<vector<int>> num_set(N + 1, vector<int>(10, 0));
    vector<vector<int>> num_set_rev(N + 1, vector<int>(10, 0));

    for (int i = N - 1; i >= 0; i--)
    {
        if (i != N - 1)
        {
            num_set.at(i) = num_set.at(i + 1);
            num_set_rev.at(N - i - 1) = num_set_rev.at(N - i - 2);
        }
        num_set.at(i).at(S[i] - '0')++;
        num_set_rev.at(N - i - 1).at(S[N - i - 1] - '0')++;
    }
    for (int i = 1; i < N - 1; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                int num1 = num_set_rev.at(i - 1).at(j);
                int num2 = num_set.at(i + 1).at(k);
                if(num1 == 0 || num2 == 0) continue;
                string tmp = to_string(j) + S[i] + to_string(k);
                ans[tmp]++;
            }
        }
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 4608
s = list(input())
t = list(input())
ans = "UNRESTORABLE"
len_s = len(s)
len_t = len(t)
for i in range(len_s-len_t+1):
  j = len_s-len_t-i
  for S,T in zip(s[j:j+len_s],t):
    if S != T and S != "?":
      break
  else:
    ans = ""
    for k,TT in enumerate(t):
      s[j+k] = TT
    break
if ans == "UNRESTORABLE":
  print(ans)
else:
  for i in s:
    if i == "?":
      ans += "a"
    else:
      ans += i
  print(ans)

Measured memory_bytes: 3064
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		if (n == 1) {
			int kara = Integer.parseInt(sc.next());
			System.out.println("POSSIBLE");
		} else {
			int INF = 5000 * 1000 + 1;
			List<List<Integer>> p = new ArrayList<>(n);
			for (int i = 0; i < n; i++) {
				p.add(new ArrayList<Integer>());
			}
			int nump;
			for (int i = 0; i < n - 1; i++) {
				nump = Integer.parseInt(sc.next()) - 1;
				p.get(nump).add(i + 1);
			}
			int[] x = new int[n];
			for (int i = 0; i < n; i++) {
				x[i] = Integer.parseInt(sc.next());
			}
			int[] dp = new int[n];
			Deque<node> node = new ArrayDeque<>();
			node.addFirst(new node(n - 1, 0));
			node tmps;
			List<Integer> tmpp;
			int next;
			boolean flg = true;
			tansa: while (!node.isEmpty()) {
				tmps = node.removeFirst();
				//	System.out.println(tmps.id + "," + tmps.num);
				if (tmps.id == 0) {
					//	flg = true;
					break;
				}
				dp[tmps.id] = tmps.num;
				tmpp = p.get(tmps.id - 1);
				if (tmpp.size() == 0) {
					node.addFirst(new node(tmps.id - 1, 0));
				//				System.out.println("add1 " + (tmps.id - 1) + ",0," + x[tmps.id - 1]);
					continue;
				}
				next = x[tmps.id - 1];
				int big;
				int small;
				int[] dps = new int[next + 1];
				for (int i = 0; i < tmpp.size(); i++) {
					nump = tmpp.get(i);
					big = Math.max(x[nump], dp[nump]);
					small = Math.min(x[nump], dp[nump]);
					//		System.out.println("big,small "+big+","+small);
					for (int j = next; j >= 0; j--) {
						if (dps[j] >= INF || j < small || dps[j - small] >= INF) {
							if (j == next) {
								flg = false;
								break tansa;
							}
							dps[j] = INF;
						} else if (big <= j && dps[j - big] < INF) {
							dps[j] = Math.min(dps[j - big] + small, dps[j - small] + big);
						} else {
							dps[j] = dps[j - small] + big;
						}
						//	System.out.println(i+","+j+":"+dps[j]);
					}
				}
				node.addFirst(new node(tmps.id - 1, dps[next]));
				//	System.out.println("add2 " + (tmps.id - 1) + "," + dps[next] + "," + x[tmps.id - 1]);
			}
			if (flg == true) {
				System.out.println("POSSIBLE");
			} else {
				System.out.println("IMPOSSIBLE");
			}
		}
	}

	static int nibun(int[] p, int n) {
		int cen;
		int l = 0;
		int r = p.length - 1;
		while (l != r) {
			cen = (l + r + 1) / 2;
			if (p[cen] > n) {
				r = cen - 1;
			} else {
				l = cen;
			}
		}
		return l;
	}
}

class node {
	int id;
	int num;

	node(int id, int num) {
		this.id = id;
		this.num = num;
	}
}


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

bool solve() {
    int N;
    cin >> N;
    int a, l = N+1, r = -1;
    vector<int> n(N+1);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        n[a]++;
        l = min(l, a);
        r = max(r, a);
    }
    if ( (r+1)/2 != l ) return false;
    if ( r % 2 == 0 ) {
        if ( n[l] != 1 ) return false;
    } else {
        if ( n[l] != 2 ) return false;
    }
    for ( int i = l+1; i <= r; i++ ) {
        if ( n[i] < 2 ) return false;
    }
    return true;
}

int main() {
    string ans = solve() ? "Possible" : "Impossible";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
function main()
  
  (N, M) = map(x -> parse(Int, x), split(readline()))
  A = map(x -> parse(Int, x), split(readline()))
  
  sum_A = sum(A)
  
  if N < sum_A
    println(-1)
  else
    println(N - sum_A)
  end
  
end

main()

Measured memory_bytes: 166772
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var C = input[1];
            var bro = new bool[31, 100001];
            for (int i = 0; i < N; i++)
            {
                input = ReadArrayInt();
                var s = input[0];
                var t = input[1];
                var c = input[2];
                for (int j = s; j <= t; j++) bro[c, j] = true;
            }

            var ans = 0;
            for (int i = 1; i <= 100000; i++)
            {
                var cnt = 0;
                for (int j = 1; j <= 30; j++) if (bro[j, i]) cnt++;
                if (cnt > ans) ans = cnt;
            }            

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 20160
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
	string n;
	cin >> n;
	int ans = 0;
	rrep(i, n.size()) {
		if (i == 1) {
			if (n[1] == '0') {
				cout << n[0];
				cout <<n[1] << endl;
				return 0;
			}
			rep(j, 2) {
				ans += int(n[j] - '0');
			}
			break;
		}
		else if (n[i] != '0') {
			for (int j = 0; j <= i; j++) {
				ans += int(n[j] - '0');

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

Measured memory_bytes: 256
S = input()

l = 0
r = len(S)-1
cnt = 0

while l < r:
    if S[l] == S[r]:
        l += 1
        r -= 1
    elif S[l] == "x":
        l += 1
        cnt += 1
    elif S[r] == "x":
        r -= 1
        cnt += 1
    else:
        print(-1)
        exit()
        
print(cnt)

Measured memory_bytes: 9172
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n = 0;
	static int[] a = null;
	static boolean hasNot0 = false;
	
	public static void main(String[] args) {
		n = sc.nextInt();
		a = new int[n];
		for(int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			if(a[i] != 0) hasNot0 = true;
		}
		
		if(n % 3 == 0) System.out.println(canArrange() ? "Yes" : "No");
		else if(hasNot0) System.out.println("No");
		else System.out.println("Yes");
	}
	
	static boolean canArrange() {
		Arrays.sort(a);
		int c = getSetSize(a);
		if(c > 3) return false;
		else if(c == 3) {
			int[] b = new int[n];
			for(int i = 0; i < n; ++i) {
				b[i] = (i < n / 3) ? a[0] : (i < n / 3 * 2) ? a[n / 3] : a[n / 3 * 2];
			}
			return Arrays.equals(a, b) && (b[0] ^ b[n / 3] ^ b[n / 3 * 2]) == 0;
		} else if(c == 2) {
			if(a[0] > 0) return false;
			int[] b = new int[n];
			for(int i = 0; i < n; ++i) {
				b[i] = (i < n / 3) ? a[0] : a[n / 3];
			}
			return Arrays.equals(a, b);
		} else return a[0] == 0;
	}
	
	static int getSetSize(int[] x) {
		Set<Integer> set = new HashSet<>();
		for(int i = 0; i < n; ++i) set.add(x[i]);
		return set.size();
	}
}

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

int di[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dj[8] = {1, 0, -1, 0, 1, -1, -1, 1};


int main() {
  int H,W; cin >> H >> W;
  string S[100];
  for ( int i = 0; i < H; i++ ) cin >> S[i];
  
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      int cnt = 0;
      if ( S[i][j] == '#' ) continue;
      if ( S[i][j] == '.' ) {
	for ( int d = 0; d < 8; d++ ) {
	  int ni = i + di[d];
	  int nj = j + dj[d];
	    if ( 0 <= ni && ni < H && 0 <= nj &&
		 nj < W && S[ni][nj] == '#'  ) cnt++;
	}
	S[i][j] = (char)cnt + '0';
      }
    }
  }

  for ( int i = 0; i < H; i++ ) {
    cout << S[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll x,a;
    cin>>x>>a;
    if(x<a)
        cout<<0<<endl;
    else
        cout<<10<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; i++)std::cin >> a[i];
sort(a.begin(),a.end());
int ans=200*200*100;
int now=0;
int r=a[0];

do {
  now=0;
  for (int i = 0; i < n; i++)now+=(a[i]-r)*(a[i]-r);
  if(ans>now)ans=now;
  else break;
  r+=1;
} while(1);

std::cout << ans << '\n';


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
# define maxn 100000
int main() {
  long long n;
  int mini(10);
  cin>>n;
  for(long long i(1);i*i<=n;i++){
    if (n%i==0) mini=min(mini,max((int)(to_string(i).length()),(int)(to_string(n/i).length())));
  }
  cout<<mini;
}


Measured memory_bytes: 380
#include<iostream>
#include<vector>
#include<string>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
template <class T> inline void chmin(T& a, T b) { if(a > b) a = b;}

int main(){
	std::string s, t;
	std::cin >> s >> t;
	int sz = s.size();
	int tz = t.size();
	int res = 1e9;
	for(int i=0; i<=sz-tz; i++){
		int cnt = 0;
		for(int j=0; j<tz; j++){
			if(t[j] != s[i+j]) cnt++;
		}
		chmin(res, cnt);
	}
	std::cout << res << std::endl;
	return 0;
	
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	private static int selectionSort(int a[]) {
		int cnt = 0;
		for (int i = 0; i < a.length - 1; ++i) {
			int min = i;
			for (int j = i + 1; j < a.length; ++j) {
				if (a[j] < a[min])
					min = j;
			}
			if (min != i) {
				int t = a[min];
				a[min] = a[i];
				a[i] = t;
				cnt++;
			}
		}
		return cnt;
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i)
			a[i] = scan.nextInt();
		int cnt = selectionSort(a);
		for (int t = 0; t < a.length; ++t) {
			System.out.print(a[t]);
			if (t != a.length - 1) 
				System.out.print(" ");
		}
		System.out.println();
		System.out.println(cnt);
	}
//	public static void main(int a) {
//		
//	}
}



Measured memory_bytes: 26420
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <assert.h>

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define trace(x) cerr << #x << " = " << x << endl;



/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////////////////////////////////////////////
#define int long long
const int N = 3002;
int dp[N][N][4];
int a[N][N];
int r , c , k;
int calc(int i , int j , int taken){

	if(i >= r || j >= c)
		return 0;

	int &ans = dp[i][j][taken];
	if(ans!=-1)
		return ans;
	ans = 0;
	if(taken > 0)
		ans = max(ans , a[i][j] + calc(i+1 , j , 3));
	else ans = max(ans , calc(i + 1 , j , 3));
	if(taken > 0)
		ans = max(ans , a[i][j] + calc(i , j + 1 , taken-1));
	ans = max(ans , calc(i, j + 1 , taken));

	return ans;
}
void solve(){

	cin>>r>>c>>k;

	while(k--){

		int x , y , v;
		cin>>x>>y>>v;
		--x;
		--y;
		a[x][y] = v;
	}
	memset(dp , -1 , sizeof dp);
	int ans = calc(0 , 0 , 3);

	cout<<ans<<endl;
}
signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t ; ++i)
        solve();
}


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

bool isMonth(int &x){
    return (1 <= x && x <= 12);
}

int main(){
    string S;
    cin >> S;
    int X = std::stoi(S.substr(0, 2));
    int Y = std::stoi(S.substr(2, 2));
    if(!isMonth(X) && isMonth(Y)){
        cout << "YYMM";
    }else if(isMonth(X) && !isMonth(Y)){
        cout << "MMYY";
    }else if(isMonth(X) && isMonth(Y)){
        cout << "AMBIGUOUS";
    }else{
        cout << "NA";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

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

    vector <ll> H(N);

    for (int i=0;i<N;i++){
        cin >> H[i];
    }
    ll ans=0;
    sort(H.begin(),H.end());

    if(N>K){
        for(int i=0;i<K;i++){
            H[N-1-i] = 0;
        }

        

        for(int i=0;i<N;i++){
            ans += H[i];
        }

    }
    cout << ans;    


}

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

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

const long long INF = 1LL << 60;
long long dp[100010];

int h[100010];
long long rec(int i)
{
	if (dp[i] < INF) return dp[i];

	if (i == 0) return 0;
	
	long long res = INF;
	chmin(res, rec(i-1) + abs(h[i]-h[i-1]));
	if (i > 1) chmin(res, rec(i-2) + abs(h[i]-h[i-2]));

	return dp[i] = res;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> h[i];

	for (auto &x: dp) x = INF;
	cout << rec(n-1) << endl;
}



Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;


int N;
int F[100][14];
int P[100][15];

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < 10; ++j) scanf("%d", &F[i][j]);

    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < 11; ++j)
            scanf("%d", &P[i][j]);

    int res = -(1<<30);
    for(int b = 1; b < (1<<10); ++b) {
        int cc = 0;
        for(int i = 0; i < N; ++i) {
            int c = 0;
            for(int j = 0; j < 10; ++j) 
                if(((b>>j)&1) && F[i][j]) c++;
            cc += P[i][c];
        }
        if(res < cc) res = cc;
    }
    printf("%d\n", res);
}


Measured memory_bytes: 256
import math
def hoge(arr):
  res = [ 0 for _ in range(len(arr))]
  for i in range(len(arr) - 1):
    if(arr[i] == "R" and arr[i+1] == "L"):
      res[i] += math.ceil((i + 1) / 2)
      res[i+1] += (i + 1) // 2
      res[i] += (len(arr) - (i+1)) // 2
      res[i+1] += math.ceil((len(arr) - (i+1)) / 2)
  return res

import re
s = input()
result = re.findall('(R+L+)', s)
for r in result:
  print(*hoge(r), sep=" ", end=" ")



Measured memory_bytes: 7408
#include <stdio.h>

int main(void)
{
	int h, w, k;
	char strs[10][1000];
    int chocolates[10][1000];
	int i, j, l, m;
	int pwr, cut[10], count[10], row;
    int ans, ans_tmp;
    int progressed;

	scanf("%d %d %d ", &h, &w, &k);
	for(i = 0; i < h; i++){
    	scanf("%s ", strs[i]);
    }
  
	for(i = 0; i < h; i++){
    	for(j = 0; j < w; j++){
        	chocolates[i][j] = (strs[i][j] == '1');
        }
    }

	pwr = 1 << (h-1);
	ans = 10000000;
	for(i = 0; i < pwr; i++){
        ans_tmp = 0;
    	for(j = 0; j < 9; j++){
        	cut[j] = (i >> j) & 1;
        	ans_tmp += cut[j];
        }            
      
        for(m = 0; m < h; m++){
            count[m] = 0;
        }
        progressed = 0;
      
    	for(j = 0; j < w; j++, progressed = 1){
        	row = 0;
        	for(l = 0; l < h; l++){
        		count[row] += chocolates[l][j];
            	row += cut[l];
            }

            for(l = 0; l < h; l++){
            	if(count[l] > k){
                    if(progressed){
              			for(m = 0; m < 10; m++){
							count[m] = 0;
        				}
                		ans_tmp++;
                        progressed = 0;
                        j--;
                    	break;
                    }
                    else{
                        j = w + 10;
                        progressed = 0;
                        break;
                    }
            	}
            }
        }
      
    	if(j != w+11 && ans_tmp < ans){
    		ans = ans_tmp;
        }
    }

	printf("%d", ans);


	return 0;
}

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

LL power(LL p) {
  LL n = 1;
  for (LL i = 0; i < p; i++) {
    n = n * 2;
  }
  return n;
}
  

int main() {
  LL H;
  cin >> H;
  LL p = 0;
  while (H > 0) {
    H = H/2;
    p++;
  }
  
  LL ans = power(p) - 1;
  cout << ans << endl;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	cin >> input;
	vector<bool> alphabet(26, false);

	for (int i = 0; i < input.size(); i++)
	{
		int tmp = input[i] - 'a';
		if (alphabet[tmp])
		{
			cout << "no" << endl;
			return;
		}
		alphabet[tmp] = true;
	}
	cout << "yes" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    
    if (0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3108
/*トポロジカルソート*/
#include<iostream>
#include<vector>
#include<queue>

using Graph = std::vector<std::vector<size_t>>;

int main(){
    
    size_t v, e;
    std::cin >> v >> e;

    Graph g(v);
    std::vector<size_t> in(v, 0);

    for(size_t i = 0; i < e; i++){
        size_t s, t;
        std::cin >> s >> t;

        g.at(s).emplace_back(t);
        in.at(t)++;
    }

    std::queue<size_t> set;

    for(size_t i = 0; i < in.size(); i++){
        if(in.at(i) == 0) set.emplace(i);
    }

    std::vector<size_t> ans;

    while(!set.empty()){
        auto vertex = set.front(); set.pop();
        ans.emplace_back(vertex);

        for(const auto& e : g.at(vertex)){
            in.at(e)--;
            if(in.at(e) == 0) set.emplace(e);
        }
    }

    if(ans.size() == v){
        std::cout << 0 << std::endl;
    }else{
        std::cout << 1 << std::endl;
    }
    
    return 0;
}

/*
for(size_t i = 0; i < v; i++){
    std::cout << "in size: " << in.at(i) << ", out vertex: ";
    for(size_t j = 0; j < g.at(i).size(); j++){
        std::cout << g.at(i).at(j) << ", ";
    }std::cout << std::endl;
}
*/



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    FOR(i,1,n){
        if(s[i]==s[i-1]&&s[i]=='x'){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3352
#include <iostream>
#include <queue>


using ll = long long;
using namespace std;
using P = pair<int, int>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

int main() {
    ll n, k;
    cin >> n >> k;
    GPQ<P> pq;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        pq.emplace(a, b);
    }
    ll v = 0;
    while(!pq.empty()){
        P p = pq.top(); pq.pop();
        v += p.second;
        if(v >= k){
            cout << p.first << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1400
def solve()
  n, k, q = gets.split(" ").map!(&:to_i)
  a = []
  res = [k-q]*n
  q.times do |i|
    a.push((gets.to_i) - 1)
  end
  (a.length).times do |i|
    res[a[i]] = res[a[i]] + 1
  end
  n.times do |i|
    puts res[i] > 0 ? "Yes" : "No"
  end
end
solve()


Measured memory_bytes: 3836
#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;
typedef long long ll;
ll arr[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string ch;
    cin>>ch;
    for(int i=0;i<ch.size();i++)
    {
        cout<<"x";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #define N 100005
    #define F first
    #define S second
    using namespace std;
     
    typedef long long ll;
    #define PI pair<ll, ll>
    ll n, cnt, k, sz, mx, g, g2, s[N], c[N];
    bool v[N];
    pair<ll, ll> a[N], b[N];
    void f(ll p, ll q) {
    	s[p] += q;
    	if (q == 1 && s[p] == 1) cnt++;
    	else if (q == -1 && s[p] == 0) cnt--;
    }
    int main()
    {
    	ll i, j;
    	cin >> n >> k;
    	for (i = 0; i < n; i++) {
    		scanf ("%lld %lld", &a[i].S, &a[i].F);
    	}
    	sort(a, a + n);
    	for (i = n - 1; i >= n - k; i--) {
    		b[sz] = PI(a[i].F, a[i].S);
    		g += a[i].F;
    		if (s[a[i].S] == 0) v[sz] = 1;
    		sz++;
    		f(a[i].S, 1);
    	}
    	g += cnt * cnt;
    	mx = g;
    	j = sz - 1;
    	for (i = n - k - 1; i >= 0; i--) {
    		if (s[a[i].S] >= 1) continue;
    		for (; j >= 0; j--) {
    			if (v[j]) continue;
    			g = g - b[j].F + a[i].F + (cnt + 1) * (cnt + 1) - cnt * cnt;
    			f(b[j].S, -1);
    			f(a[i].S, 1);
    			b[j] = a[i];
    			mx = max(mx, g);
    			break;
    		}
    		j--;
    	}
        cout << mx;
        return 0;
    }

Measured memory_bytes: 4992
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
int n;
int minM=1000000;
int X;
int ans=0;
int main()
{
    cin>>n>>X;
    for (int i=0; i<n; ++i)
    {
        int mi;
        cin>>mi;
        if (mi<minM)
           minM=mi;
        X-=mi;
        ans++;
    }
    ans+=X/minM;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	long long int s; std::cin >> s;
	constexpr long long int max = 1000000000LL;
	if (s < max) {
		std::cout << "0 0 1 0 0 " << s << "\n";
	}
	else {
		auto h = (s + max - 1) / max;
		auto a = h * max - s;
		std::cout << "0 0 " << max << " 1 " << a << " " << h << "\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2e5+10;

int n,a[N];
LL sum[N],s[4],ans=1000000000000000;

LL Get(int l,int mid,int r) {
	LL s1=sum[mid]-sum[l-1];
	LL s2=sum[r]-sum[mid];
	return abs(s1-s2);
}

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	int L=1,R=3;
	LL mx=Get(3,3,n); 
	for (int i=4;i<n;i++) {
		if (Get(3,i,n)<mx) R=i,mx=Get(3,i,n);
	}
	for (int i=2;i<=n-2;i++) {
		while (L<i&&Get(1,L,i)>Get(1,L+1,i)) L++;
		while (R<n&&Get(i+1,R,n)>Get(i+1,R+1,n)) R++;
		s[0]=sum[L]; s[1]=sum[i]-sum[L];
		s[2]=sum[R]-sum[i]; s[3]=sum[n]-sum[R];
		sort(s,s+4);
		ans=min(ans,s[3]-s[0]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  dunk((n+1)/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long k;cin>>k;

    queue<long long> q;
    for(long long i=1;i<=9;i++)
        q.push(i);

    long long ans;
    while(k--){
        ans=q.front();
        q.pop();

        long long m=ans%10;
        
        if(m>0) q.push(ans*10+m-1);
        q.push(ans*10+m);
        if(m<9) q.push(ans*10+m+1);
    }
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 5080
use proconio::input;

fn main() {
  input! {
    n: usize,
    s: String,
  }

  let mut cnt : [i64; 3] = [0; 3];
  let cs = s.chars().collect::<Vec<_>>();

  for &c in &cs {
    match c {
      'R' => cnt[0] += 1,
      'G' => cnt[1] += 1,
      'B' => cnt[2] += 1,
      _ => (),
    }
  }

  let mut count = 0;
  for i in 0..n {
    for j in 0..i {
      let k = 2 * i - j;
      if k >= n {
        continue;
      }
      if cs[i] != cs[j] && cs[j] != cs[k] && cs[k] != cs[i] {
        count += 1;
      }
    }
  }
  println!("{}", cnt[0] * cnt[1] * cnt[2] - count);
}

Measured memory_bytes: 2184
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#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 repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  for(int i=sqrt(n);i>=1;i--){
    if(n%i==0){
      string s=to_string(n/i);
      COUT(sz(s));
      return 0;
    }
  }
}

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

int main(){
    string s;
    const char* c;
    int count[26]={0};

    while(true){
        getline(cin,s);
        if(s=="")break;
        c=s.c_str();
        for(int i=0;c[i]!='\0';i++){
            if(c[i]>='a'&&c[i]<='z')count[c[i]-'a']++;
            else if(c[i]>='A'&&c[i]<='Z')count[c[i]-'A']++;
        }
    }
    
    for(int j=0;j<26;j++){
        cout<<(char)(j+97)<<" : "<<count[j]<<endl;
    }

    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL d(n);
  rep(i,n) cin >> d[i];
  ll ans = 0;
  rep(i,n){
    FOR(j,i+1,n){
      ans += d[i] * d[j];
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<functional>

using namespace std;

int N;

int main() {
	cin >> N;
	priority_queue<double, vector<double>, greater<double> > que;
	for (int i = 0; i < N; i++) { 
		double x;
		cin >> x;
		que.push(x);
	}
	while (que.size() > 1) {
		double v1, v2;
		v1 = que.top(); que.pop();
		v2 = que.top(); que.pop();
		que.push((v1 + v2) / 2.0);
	}
	cout << que.top() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << val << "\n";
using namespace std;
using ll = long long;

int main(void){
    CIN(ll, a);
    CIN(ll, b);
    CIN(ll, c);
    
    ll ans = (a+b >= c-1) ? b+c : b + a+b+1;
    
    COUT(ans);
}

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

using namespace std;

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

    string s;
  	cin >> s;

  	if(s.size() <= k)
    {
      cout << s << endl;
      return 0;
    }

    while(s.size() != k)
    {
      s.pop_back();
    }

    s.append(3u, '.');
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    int ans = n / 2;
    if(n % 2 == 0) ans--;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
x1, x2, x3, x4, x5 = map(int, input().split())
Re = 0
if x1!=1:
    Re = Re+1
if x2 != 2:
    Re = Re+2

if x3!=3:
    Re = Re+3
if x4 != 4:
    Re = Re+4
if x5 != 5:
    Re = Re+5
print(Re)

Measured memory_bytes: 9196
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1){
    int n,w;
    cin>>n>>w;
    if(!n)break;
    vector<int> cnt(100);
    int mxi = 0;
    REP(i,n){
      int v;
      cin>>v;
      ++cnt[v/w];
      mxi = max(mxi, v/w);
    }
    int mx = *max_element(begin(cnt),end(cnt));
    double sum = 0.01;
    REP(i,mxi+1){
      sum += double(mxi-i)/mxi*double(cnt[i])/mx;
    }
    cout<<setprecision(10)<<fixed<<sum<<endl;
  }
  return 0;
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const double PI = acos(-1);
const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

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

    ll ans = 0;
    FOR(i, K, N+2) {
        ll min = (0 + i-1) * i / 2;
        ll max = (N + (N - (i-1))) * i / 2;
        ans += max - min + 1;
        ans %= mod;
    }
    cout << ans << endl;
}


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

int main(){
	int N, L;
	string tmp;
	vector<string> v;
	cin >> N >> L;
	for(int i=0;i<N;i++){
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<N;i++){
		cout << v[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using std::sort;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::pair;
using std::reverse;
typedef long long ll;


#define pb push_back
#define mp std::make_pair
#define all(x) (x).begin(),(x).end()

int main() {
  int N;
  cin>>N;
  int ans = 0;
  int h;int maxh = 0;
  
  for(int i = 0;i < N;i++){
    cin>>h;

    if(h >= maxh){
      maxh = h;
      ans++;
    }
  }
  
  cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int cost = 1e9;

	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;

		if(b <= t && a < cost) cost = a;
	}

	if(cost == 1e9) cout << "TLE" << endl;
	else cout << cost << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string ans;

  for(int i=0;i<=n/4;i++)
  {
    if((n-4*i)%7==0) {ans="Yes"; break;}
    else   ans="No";


  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int x,y,i,j;
	while(scanf("%d%d",&x,&y),x,y){
		int masu[20][20]={ 0 };
		int dp[20][20]={0};
		int ans=0;
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				scanf("%d",&masu[i][j]);
			}
		}
		for(i=0;i<=y;i++)masu[i][0]=1;
		for(j=0;j<=x;j++)masu[0][j]=1;
		
		for(j=1;j<=x;j++){
			if(masu[1][j]==0)dp[1][j]=1;
		}
		for(i=2;i<=y;i++){
			for(j=1;j<=x;j++){
				if(masu[i][j]==0){
					if(masu[i-1][j-1]==0)dp[i][j]+=dp[i-1][j-1];
					if(masu[i-1][j]==0)	 dp[i][j]+=dp[i-1][j];
					if(masu[i-1][j+1]==0)dp[i][j]+=dp[i-1][j+1];
					if(masu[i-2][j]==2){
						dp[i][j]+=dp[i-2][j];
					}
				}
				if(masu[i][j]==1){
					dp[i][j]=0;
				}
				if(masu[i][j]==2){
					if(masu[i-1][j]==0)dp[i][j]=dp[i-1][j];
					if(masu[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				}
			}
		}
		/*
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				printf("%d",dp[i][j]);
			}
			puts("");
		}
		*/
		for(i=1;i<=x;i++){
			ans+=dp[y][i];
			if(masu[y-1][i]==2)ans+=dp[y-1][i];
		}
		
		printf("%d\n",ans);
	}
	
	return 0;
}

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

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

//変数
ll A, B, K;

ll GCD(ll x, ll y) {
	ll tmp;
	if (y > x) {
		tmp = x;
		x = y;
		y = tmp;
	}
	while (x%y != 0) {
		tmp = y;
		y = x%y;
		x = tmp;
	}
	return y;
}

//解法
void solve() {

	ll ans = GCD(A, B);
	ll tmp = 1;

	while (1) {
		if (ans%tmp == 0) {
			K--;
			if (K == 0) {
				cout << ans / tmp;
				break;
			}
		}
		tmp++;
	}


	return;
}

int main() {

	//入力
	cin >> A>>B>>K;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
N = int(input())
S = input()

W_accum = [0]
E_accum = [0]
for i in range(N):
    if S[i] == "W":
        W_accum += [W_accum[-1] +1]
    else:
        W_accum += [W_accum[-1]]
    E_accum += [i+1 - W_accum[-1]]

ans = N
for i in range(N):
    curr = W_accum[i] + (E_accum[-1] - E_accum[i+1])
    ans = min(curr, ans)
print(ans)

Measured memory_bytes: 24908
S = input()
ans = 0
pattern = [format(i, 'b').zfill(len(S) - 1) for i in range(2 ** (len(S) - 1))]

for i in pattern:
    temp = ''
    pm = i.translate(str.maketrans({'0': '-', '1': '+'}))
    for j in range(2 * len(S) - 1):
        if j % 2 == 0:
            temp += S[j // 2]
        else:
            temp += pm[j // 2]
    temp = temp.replace('-', '')
    ans += eval(temp)

print(ans)

Measured memory_bytes: 3064