akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 爆弾を表す文字 */
	private static final char BOMB = '#';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			char[][] s = new char[h][];
			IntStream.range(0, h).forEach(i -> s[i] = scanner.next().toCharArray());
			IntStream.range(0, h).forEach(i -> IntStream.range(0, w).forEach(j -> calcCount(i, j, h, w, s)));
			IntStream.range(0, h).forEach(i -> System.out.println(s[i]));
		}
	}

	/**
	 * x,yが爆弾でないとき、周りの爆弾の合計数を計算
	 * 
	 * @param x X座標
	 * @param y Y座標
	 * @param h 縦幅
	 * @param w 横幅
	 * @param s マスを表す配列
	 */
	private static void calcCount(final int x, final int y, final int h, final int w, char[][] s) {
		if (BOMB != s[x][y]) {
			int count = 0;
			if (x > 0) {
				if (y > 0) {
					count += (BOMB == s[x - 1][y - 1]) ? 1 : 0;
				}
				count += (BOMB == s[x - 1][y]) ? 1 : 0;
				if (y < w - 1) {
					count += (BOMB == s[x - 1][y + 1]) ? 1 : 0;
				}
			}
			if (y > 0) {
				count += (BOMB == s[x][y - 1]) ? 1 : 0;
			}
			if (y < w - 1) {
				count += (BOMB == s[x][y + 1]) ? 1 : 0;
			}
			if (x < h - 1) {
				if (y > 0) {
					count += (BOMB == s[x + 1][y - 1]) ? 1 : 0;
				}
				count += (BOMB == s[x + 1][y]) ? 1 : 0;
				if (y < w - 1) {
					count += (BOMB == s[x + 1][y + 1]) ? 1 : 0;
				}
			}
			s[x][y] = (char) ('0' + count);
		}
	}
}


Measured memory_bytes: 26964
#include<iostream>
using namespace std;
int main(){
	int H[300],W[300],i,j;
	for(;;){
	cin>>i>>j;
if(i==0&&j==0){
		break;
		}
	for(int o=0;o<i;o++){
		for(int n=0;n<j;n++){

			cout<<"#";
		}
		cout<<endl;
	}
	cout<<endl;
	}
}

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

bool dp[80][80][12805] = {};
#define inRange(x,a,b) (a <= x && x <= b)

int main(){
    int h, w;
    cin >> h >> w;
    int a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int x;  cin >> x;
            a[i][j] -= x;
            a[i][j] = abs(a[i][j]);
        }
    }
    dp[0][0][6400+a[0][0]] = dp[0][0][6400-a[0][0]] = true;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int k = 0; k <= 12804; k++){
                if(!dp[i][j][k])    continue;
                if(i+1 < h){
                    if(inRange(k+a[i+1][j], 0, 12804))   dp[i+1][j][k+a[i+1][j]] = true;
                    if(inRange(k-a[i+1][j], 0, 12804))   dp[i+1][j][k-a[i+1][j]] = true;
                }
                if(j+1 < w){
                    if(inRange(k+a[i][j+1], 0, 12804))   dp[i][j+1][k+a[i][j+1]] = true;
                    if(inRange(k-a[i][j+1], 0, 12804))   dp[i][j+1][k-a[i][j+1]] = true;
                }
            }
        }
    }
    for(int i = 0; i <= 6400; i++){
        if(dp[h-1][w-1][6400+i] || dp[h-1][w-1][6400-i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 79872
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

const int N=1e6+5;

int n,a[N],freq[N],ans;

bool b[N];

int main()
{
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];freq[a[i]]++;b[a[i]]=1;
    }
    if (b[1])
    {
        cout << 0+(freq[1]==1) << endl;return 0;
    }
    for (int i=0;i<N;i++)
    {
        if (b[i])
        {
            for (int j=2;j*j<=i;j++)
            {
                if (i%j==0)
                {
                    if (b[j]||b[i/j]){freq[i]=0;break;}
                }
            }
        }
        if (freq[i]>1)freq[i]=0;
        ans+=freq[i];
    }
    cout << ans << endl;
    return 0;
}


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

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

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int n;
    cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    int ma = pow(3, n);
    int b = 0;
    REP(i, n) {
        b += (a[i] % 2 == 0);
    }
    if (b) ma -= (1 << (b));
    else ma--;
    cout << ma << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N; cin >> N;
  vector<ll> A(N), B(N);
  for(ll i = 0; i < N; i++) cin >> A[i] >> B[i];
  vsort(A);
  vsort(B);
  if (N % 2) {
  	cout << B[(N - 1) / 2] - A[(N - 1) / 2] + 1 << endl;
  } else {
	cout << (B[N / 2] + B[(N - 1) / 2]) - (A[N / 2] + A[(N - 1) / 2]) + 1 << endl;
  }
}

Measured memory_bytes: 6392
#include<bits/stdc++.h>
#define ll long long
const int MAXN=1e5+5;
const int MOD=1e9+7;
using namespace std;

int main(){
	int a, b, k;
	int tmp;
	int cnt=0;
	scanf("%d%d%d",&a,&b,&k);
	tmp=min(a, b);
	for(int i=tmp;i>=1;i--){
		if(a%i==0&&b%i==0){
			cnt++;
		}
		if(cnt==k){
			printf("%d", i);
			break;
		}
	
	}
	return 0;
}


Measured memory_bytes: 256
import static java.lang.Math.abs;
import static java.lang.Math.atan2;
import static java.lang.Math.sqrt;
import static java.util.Arrays.deepToString;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int y = sc.nextInt();
			int m = sc.nextInt();
			int d = sc.nextInt();
			
			final int premeiji = 0;
			final int meiji = 1;
			final int taisho = 2;
			final int showa = 3;
			final int heisei = 4;

			int res = -1;
			if (y < 1868 || 
				(y == 1868 && m < 9) ||
				(y == 1868 && m == 9 && d < 8)) {
				res = premeiji;
			}
			else if (y < 1912 || 
					(y == 1912 && m < 7) ||
					(y == 1912 && m == 7 && d < 30)) {
				res = meiji;
			}
			else if (y < 1926 || 
					(y == 1926 && m < 12) ||
					(y == 1926 && m == 12 && d < 25)) {
				res = taisho;
			}
			else if (y < 1989 || 
					(y == 1989 && m < 1) ||
					(y == 1989 && m == 1 && d < 8)) {
				res = showa;
			}
			else {
				res = heisei;
			}
			
			if (res == premeiji) {
				System.out.println("pre-meiji");
			} else {
				int yy = 0;
				String nengou = "";
				if (res == meiji) { nengou = "meiji"; yy = y - 1868 + 1; }
				if (res == taisho) { nengou = "taisho"; yy = y - 1912 + 1; }
				if (res == showa) { nengou = "showa"; yy = y - 1926 + 1; }
				if (res == heisei) { nengou = "heisei"; yy = y - 1989 + 1; }
				System.out.printf("%s %d %d %d\n", nengou, yy, m, d);
			}
		}
	}
	boolean premeiji(int y, int m, int d) {
		if (y < 1868) return true;
		if (y >= 1869) return false;
		if (m < 9) return true;
		if (m >= 10) return false;
		if (d < 8) return true;
		return false;
	}
}

Measured memory_bytes: 17232
fun main(args: Array<String>) {
    val X = readInputLine().toInt()

    val isPrime = BooleanArray(200001) { true }

    for (i in 2..100000) {
        if (isPrime[i]) {
            for (j in i * 2..101000 step i) {
                isPrime[j] = false
            }
        }
    }

    for (i in X..101000) {
        if (isPrime[i]) {
            println(i)
            return
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 33944
using System;

class A {
    public static void Main() {
        var line = Console.ReadLine().Split();
        var a = int.Parse(line[0]);
        var b = int.Parse(line[2]);
        switch (line[1][0]) {
            case '+': Console.WriteLine(a + b); break;
            case '-': Console.WriteLine(a - b); break;
        }
    }
}


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

long long rec(int i_step, std::vector<bool> &is_broken, std::vector<long long> &n_path) {
	long long n_path_ret;
	if(i_step == 0) n_path_ret = 1;
	else if(i_step < 0) n_path_ret = 0;
	else if(n_path[i_step] >= 0) n_path_ret = n_path[i_step];
	else if(is_broken[i_step]) n_path_ret = 0;
	else {
		n_path_ret = (rec(i_step - 1, is_broken, n_path) + rec(i_step - 2, is_broken, n_path)) % 1000000007;
	}
	if(i_step >= 0) n_path[i_step] = n_path_ret;
	return n_path_ret;
}

int main(void) {
	int n, m;
	std::cin >> n >> m;
	std::vector<bool> is_broken(n+1, false);
	for(int i = 0; i < m; ++i) {
		int a;
		std::cin >> a;
		is_broken[a] = true;
	}

	// recursive
	std::vector<long long> n_path(n+1, -1);
	long long n_path_all = rec(n, is_broken, n_path) % 1000000007;

	std::cout << n_path_all << std::endl;

	return 0;
}


Measured memory_bytes: 5760
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,m;
  cin >> n >> m;

  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
n,h = map(int,input().split())
mxa = 0
dmg = 0
cnt = 0
di = []
for i in range(n):
    a,b = map(int,input().split())
    di.append(b)
    if a > mxa:
        mxa = a
di.sort(reverse=True)
for j in di:
    if j >= mxa:
        dmg += j
        cnt += 1
        if dmg >= h:
            break
if dmg < h:
    cnt += (h-dmg)//mxa
    if (h-dmg)%mxa != 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 12980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

static const int INF = 0x3f3f3f3f;

int dp[401][401];

int main() {
        int n, a, b;
        scanf("%d%d%d", &n, &a, &b);
        for (int i = 0; i < 401; i ++) {
                for (int j = 0; j < 401; j ++) {
                        dp[i][j] = INF;
                }
        }
        dp[0][0] = 0;
        for (int i = 0; i < n; i ++) {
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                for (int y = 400; y >= 0; y --) {
                        for (int x = 400; x >= 0; x --) {
                                if (dp[x][y] < INF) {
                                        dp[x + a][y + b] = min(dp[x + a][y + b], dp[x][y] + c);
                                }
                        }
                }
        }
        int res = INF;
        for (int i = 0; i < 401; i ++) {
                for (int j = 0; j < 401; j ++) {
                        if (dp[i][j] < res && i > 0) {
                                if (i * b == j * a) res = dp[i][j];
                        }
                }
        }
        if (res == INF) res = -1;
        printf("%d\n", res);
        return 0;
}



Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main(void){
    int a,b,C;
    cin>>a>>b>>C;
    double S,L,h;
    S=a*b*sin(C*M_PI/180)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(C*M_PI/180));
    h=2*S/a;
    printf("%lf\n%lf\n%lf\n",S,L,h);
    return 0;
}



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

using namespace std;

string s;
int mulai[5050];

int main() {
  int k;
  cin >> s >> k;
  int n = s.size();
  set<string> st;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j <= n && j <= i+10; ++j) {
      string now = s.substr(i, j-i);
      st.insert(now);
      while (st.size() > k) {
        auto it = --st.end();
        st.erase(it);
      }
    }
  }
  cout << *(--st.end()) << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int A[n];
    bool B[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
        if(A[i] == i + 1) B[i] = false;
        else B[i] = true;
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(i < n - 1){
            if(B[i]) continue;
            else{
                swap(A[i], A[i + 1]);
                if(A[i + 1] == i + 2);
                else B[i + 1] = true;
            }
        }else{
            if(B[i]) continue;
            else{
                swap(A[i - 1], A[i]);
            }
        }
        cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int N,ans=0; cin>>N;
  vector<int> S(N);
  vector<vector<pair<int,int>>> A(N);
  rep(i,N){
    cin>>S[i];
    rep(j,S[i]){
      int x,y; cin>>x>>y;
      A[i].push_back(make_pair(x-1,y));
    }
  }  
  for(int64_t temp=0;temp<(1<<15);temp++){
    int c=0;
    bool K=true;
    bitset<15> s(temp);
    rep(i,N){
      if(s.test(i)){
        rep(j,S[i]){
          if((A[i][j].second==1 && s.test(A[i][j].first)) ||( A[i][j].second==0 && !s.test(A[i][j].first)));
          else K=false;
        }
        c++;
      }
    }
    if(K)ans=max(ans,c);
  }
   cout<<ans<<endl;                                            
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s;
    cin >> s;
    int count = 0;
    if (s[0] == 'o') count++;
    if (s[1] == 'o') count++;
    if (s[2] == 'o') count++;
    cout << 700 + 100 * count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a,b;
  cin>>a>>b;
  
  a=a+b;
  if(a>=24) a=a-24;
  cout<<a<<'\n';
}


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

int main()
{
    string s;
    cin>>s;
    long long int k,i;
    cin>>k;
    long long int ct=0;
    long long int n=s.size();
    char last=s[0];
    long long int tt=1;
    for(i=1;i<n;i++)
    {
        if(s[i]==last)
        {
            tt++;
        }
        else
        {
            ct+=tt/2;
            last=s[i];
            tt=1;
        }
    }
    ct+=tt/2;
    if(tt==n)
    {
        cout<<(n*k)/2;
        return 0;
    }
    else
    {
        if(s[0]!=s[n-1])
        {
            cout<<ct*k;
            return 0;
        }
        long long int temp1=1,temp2=1;
        for(i=1;i<n;i++)
        {
            if(s[i]==s[i-1])
            {
                temp1++;
            }
            else
                break;
        }

        for(i=n-2;i>=0;i--)
        {
            if(s[i]==s[i+1])
            {
                temp2++;
            }
            else
                break;
        }

        cout<<(ct*k)-(((temp1/2)+(temp2/2)-((temp2+temp1)/2))*(k-1));
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	var l, r []int

	fmt.Scan(&n, &m)
	for i := 0; i < m*2; i++ {
		var tmp int
		fmt.Scan(&tmp)
		if i%2 == 0 {
			l = append(l, tmp)
		} else {
			r = append(r, tmp)
		}
	}

	sort.Ints(l)
	sort.Ints(r)

	if r[0]-l[m-1] >= 0 {
		fmt.Println(r[0] - l[m-1] + 1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 6528
import sys
h, w, k = map(int, input().split())
a = []
z = 1
point = 0
for i in range(h):
    s = input()
    x = []
    flag = 400
    for j in range(w):
        x.append(z)
        if s[j] == "#":
            z += 1
            flag = j

    a.append(x)
    
    
    if flag != 400:
        if flag != w - 1:
            for e in range(w - 1 - flag):
                a[i][flag + 1 + e] = a[i][flag]


        
        if point != i:
            for k in range(i - point):
                for l in range(w):
                    a[k + point][l] = a[i][l]

        point = i + 1


    if i == h - 1:
        if point != i + 1:
            for m in range(i + 1 - point):
                for n in range(w):
                    a[point + m][n] = a[point - 1][n]

for p in range(h):
    for q in range(w):
        print(a[p][q], end=" ")
    print()
        
            
    



        


        


    







        



Measured memory_bytes: 7504
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

fn main() {
  let N: u64 = read();
  let p: Vec<u64> = read_vec();

  let mut min_elem: u64 = 200000 + 1;
  let mut ans = 0;
  for i in 0..p.len() {
    if(p[i] < min_elem) {
      min_elem = p[i];
      ans += 1;
    }
  }

  println!("{}", ans);
}


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

int main(){
 int cnt=0;
 string s;
 cin >> s;
for(int i=0;i<s.size();i++){
 if(s[i]=='2') cnt++;
 //else if(cnt>0){cnt=0;a++;}
}
 cout << cnt << endl;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

vector<int> S;
int A[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	int sum = 0;
	S.push_back(0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
		sum %= M;
		S.push_back(sum);
		//cout << sum << endl;
	}
	sort(S.begin(), S.end());
	ll ans = 0;
	ll cnt = 0;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == S[i + 1]) {
			cnt++;
		}
		else {
			ans += (cnt * (cnt + 1)) / 2;
			cnt = 0;
		}
	}
	ans += (cnt * (cnt + 1)) / 2;
	cout << ans << endl;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a<b){
    cout << a*c << endl;
  }else{
    int n=a-b;
    cout << b*c+n*d << endl;
  }
}

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

int main(){
	int i,j;
	int count = 9;

	for(i = 0; i < count; i++)
	{
		for (j = 0; j < count; j++)
		{
			cout << i+1 << "x" << j+1 << "=" << (i+1)*(j+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#define INF 10000
using namespace std;
int main(){
  int a,b;
  cin >>a>>b;
  if(a==1)a=INF;
  if(b==1)b=INF;
  if(a<b)cout<<"Bob"<<endl;
  else if(a>b)cout<<"Alice"<<endl;
  else cout<<"Draw"<<endl;
}


Measured memory_bytes: 256
/* ファイル名：ITP1_5_A.c	*/
/* 内容：たてH cm よこ W cm の長方形を描く	*/
/* 長方形はH × W 個の '#' で描く			*/
/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:たてH cm よこ W cm の長方形を描く	*/
int main( void )
{
	/* 内部変数定義*/
	/* 入力	*/
	int H;	/* たて	*/
	int W;	/* よこ	*/
	
	/*処理*/
	int i;	/* ループ用変数1	*/
	int j;	/* ループ用変数2	*/
	
	/* 無限ループ	*/
	while(1){
		scanf("%d %d",&H,&W);	/* たてとよこを取得	*/
		
		/* たてとよこに0が入力された場合	*/
		if((H == 0) 
		&& (W == 0)){
			break;	/* 処理を終了する*/
		}
		/* たてとよこに0以外が入力された場合 */
		else{
			/* たての長さだけループ	*/
			for(i = 0; i < H; i++){
				/* よこの長さだけループ	*/
				for(j = 0; j < W; j++){
					printf("#");	/* '#' を出力		*/
				}
				
				printf("\n");/* 行の最後で改行を出力	*/
			}
			
			printf("\n");/* 次のデータセットの出力の為改行	*/
		}
	}
	return 0;
}



Measured memory_bytes: 2048
<?php
$num = trim(fgets(STDIN));

$s = trim(fgets(STDIN));
$s = str_replace(array("\r\n","\r","\n"), '', $s);
$s = explode(" ", $s);

$count = 0;

while(true) {
	for ($i = 0; $i < $num; $i++) {
    	if ($s[$i] % 2 == 0) {
        	$s[$i] /= 2;
        } else {
        	break 2;
        }
    }
  	$count += 1;
}

echo $count;
?>

Measured memory_bytes: 3956
N = int(input())
D = [0] + [24] + list(map(int, input().split()))
D.sort()
for i in range(1, N+1, 2):
    D[i] = 24 - D[i]
D.sort()
answer = 24
for i in range(N+1):
    answer = min(answer, abs(D[i+1]-D[i]))
print(answer)

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 2e15+7;
const ll mod = 1e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = ll> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

bool UnionFind::same(int x,int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

ll ans = 0;

void dfs(ll s,ll l) {
	if (l%s) {
		ans += (l/s) * s * 2;
		dfs(l%s,s);
	} else {
		ans += (l/s) * s * 2 - s;
		return;
	}
}

int main() {
	ll n = in(),x = in();
	ans = n;
	ll mi = min(n-x,x);
	ll ma = max(n-x,x);
	dfs(mi,ma);
	cout << ans << endl;
}


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

int main()
{
    string S,T;
    cin >> S >> T;
    int count = 0;
    for(int i = 0;i < 3; i++){
    if(S.at(i)== T.at(i)){
        count+=1;
    }
    }
    cout << count << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int n;cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	sort(ALL(a));
	ll ans = abs(a[0] - a[n - 1]);
	int l = 0;
	int r = n - 1;
	for(int i = 0; i < n - 2; i++) {
		if (i % 2 == 0){
			l++;
			ans += abs(a[l] - a[r]);
		}
		else{
			r--;
			ans += abs(a[l - 1] - a[r]);
		}
	}
	l = 0;r = n - 1;
	ll tmp = abs(a[0] - a[n - 1]);
	for(int i = 0; i < n - 2; i++) {
		if (i % 2 == 0){
			r--;
			tmp += abs(a[l] - a[r]);
		}
		else{
			l++;
			tmp += abs(a[l] - a[r + 1]);
		}
	}
	cout << max(tmp,ans) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
s=input()
ans=s
while len(s)>0:
  s=ans
  i=0
  while i<len(s):
    if s[i:i+2]=='()':
      s=(s[:i]+s[i+2:] if i!=0 else s[i+2:])
      i=-1
    i+=1
  l=s.count('(')
  r=s.count(')')
  if l>r :
    ans=ans+')'*(l-r)
  elif r>l:
    ans='('*(r-l)+ans
  elif len(s)>0:
    ans='('+ans
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

string f[3]={"TAKAHASHIKUN","Takahashikun","takahashikun"};

int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           int k=s.size();
           int v=0;
           rep(i,0,k)if(s[i]=='o')v++;
           v+=15-k;
           YES(v>=8);
}

Measured memory_bytes: 3588
import java.util.Scanner;
import javax.swing.tree.TreeNode;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Vector;
import static java.lang.System.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int[] l = new int[n];
		for(int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		int ans = 0;
		Arrays.sort(l);
		for(int i = 0; i < n - 2; i++) {
			for(int j = i + 1; j< n - 1; j++) {
				for(int k = j + 1; k < n; k++) {
					if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i] && l[i]+l[j] > l[k] && l[j]+l[k] > l[i] && l[k]+l[i] > l[j]) {
						++ans;
					}
				}
			}
		}
		
		System.out.println(ans);
	}
	
}



Measured memory_bytes: 27808
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define rep(i,n) for(LL i=0;i<n;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) ((int)s.size())
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 10000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion


//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

void y_n(bool p) {
	if (p)_y();
	else _n();
}

void Y_N(bool p) {
	if (p) _Y();
	else _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}


/************************************************************************/
signed main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<pair<st, pi>>a(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second.first;
		a[i].second.first *= -1;
		a[i].second.second = i + 1;
	}
	sort(all(a));
	rep(i, n) {
		cout << a[i].second.second << endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];

    sort(L.begin(), L.end());

    int ans = 0;
    for (int i = 0; i < L.size(); i++) {
        for (int j = i + 1; j < L.size(); j++) {
            for (int k = j + 1; k < L.size(); k++) {
                if (L[i] + L[j] <= L[k]) break;
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, N, A[int(1e3 + 5)], B[int(1e3 + 5)];
int DP[int(2e4 + 5)];

int main(){
  scanf("%d%d", &H, &N);
  for (int i = 0; i < N; i++) scanf("%d%d", A + i, B + i);
  fill(DP + 1, DP + 20005, 1e9);

  for (int i = 0; i < N; i++){
    for (int j = 0; j + A[i] < 2e4 + 5; j++){
      DP[j + A[i]] = min(DP[j + A[i]], DP[j] + B[i]);
    }
  }

  int ans = DP[H];
  for (int i = H; i < 2e4 + 5; i++) ans = min(ans, DP[i]);
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 384
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, q = map(int, input().split())


treeList = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  treeList[a].append(b) # a<bとは限らないため、双方向にする
  treeList[b].append(a)

ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x


def treeTrace(crnt, prnt):
    for chld in treeList[crnt]:
        if prnt == chld:
            continue
        ans[chld] += ans[crnt]

        treeTrace(chld, crnt)

treeTrace(0, -1)

for s in ans:
    print(int(s), end =" ")


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

int main() {
  int a ;
  cin >> a   ;
  if (a == 0) {
    cout << "0" << endl;
  }
  else if (a%3==1) {
    cout << "1" << endl;
  }
  else if (a%3 == 2){
    cout << "2" << endl;
  }
  else {
    cout << "3" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, flag = 0, keep = -1, count = 1;
	cin >> n;

	for(int i = 0; i < n; i++) {
		int input;
		cin >> input;
		if(i != 0) {
			if(flag == 0) {
				if(keep < input) {
					flag = 1;
				} else if(keep > input) {
					flag = -1;
				}
			} else if(flag == 1) {
				if(keep > input) {
					count++;
					flag = 0;
				}
			} else if(flag == -1) {
				if(keep < input) {
					count++;
					flag = 0;
				}
			}
		}
		keep = input;
	}
	cout << count << endl;

	return 0;
}

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

vector<vector<int>> graph(8, vector<int>(8, 0));
int n, m, a, b;

int dfs(int s, vector<int> visited)
{
  bool all_visited = true;
  for (int i = 0;i < n;i++)
  {
    if(visited[i] == 0)
      all_visited = false;
  }

  if(all_visited) return 1;

  int ret=0;

  visited[s] = 1;
  for (int i=0;i < n;i++) 
  {
    if(graph[s][i] == 0) continue;
    if(visited[i] ==1) continue;

    visited[i] = 1;
    ret += dfs(i, visited);
    visited[i] = 0;
  }
  return ret;
}

int main()
{
  cin >> n >> m;
  for (int i=0;i < m;i++)
  {
    cin >> a >> b;
    a--;b--;
    graph[a][b] = 1;
    graph[b][a] = 1;
  }
  vector<int> visited(8, 0);
  visited[0] = 1;
  cout << dfs(0, visited) << endl;
  return 0;
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I_1000000007 (1000000007)
#define I_998244353   (998244353)
#define I_INF             (1<<28)
#define L_INF           (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  string S;
  int K;

  void init() {
    cin >> K >> S;
  }

  void solve() {
    if(S.size() <= K) cout << S << "\n";
    else {
      cout << S.substr(0, K) << "...\n";
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

string K;
int D;
modint dp[10001][100][2];

signed main() {
  cin >> K >> D;
  int n = K.size();

  dp[0][0][0] = 1;

  for(int i=1; i<=n; i++) {
    int s = (int)(K[i-1] - '0');
    for(int sum=0; sum<D; sum++) {
      for(int d=0; d<=9; d++) dp[i][(sum+d)%D][1] += dp[i-1][sum][1];
      for(int d=0; d<s; d++)  dp[i][(sum+d)%D][1] += dp[i-1][sum][0];
      dp[i][(sum+s)%D][0] += dp[i-1][sum][0];
    }
  }
  cout << dp[n][0][1] + dp[n][0][0] - 1<< endl;
}


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

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

    if(D==25){
        cout << "Christmas";  
    }
    if(D==24){
        cout << "Christmas Eve";
    }
    if(D==23){
        cout << "Christmas Eve Eve";
    }
    if(D==22){
        cout << "Christmas Eve Eve Eve";
    }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

struct Node {
  int to;
  int cost;

  bool operator> (const Node &other) const {
    return cost > other.cost;
  }
};

int main() {
  int v, e;
  int r;
  cin >> v >> e >> r;

  V<V<Node>> graph(v);

  rep(i, e) {
    int s, t, d;
    cin >> s >> t >> d;
    graph[s].push_back({t, d});
  }

  int inf = 1e9;
  V<bool> seen(v, false);
  priority_queue<Node, V<Node>, greater<Node>> todo;
  V<int> dist(v, inf);
  todo.push({r, 0});
  dist[r] = 0;

  while(!todo.empty()) {
    Node current = todo.top();
    todo.pop();

    if(current.cost > dist[current.to]) {
      continue;
    }

    seen[current.to] = true;

    for(auto next : graph[current.to]) {
      if(seen[next.to]) continue;

      if(dist[current.to] + next.cost < dist[next.to]) {
        dist[next.to] = dist[current.to] + next.cost;
        todo.push({next.to, dist[next.to]});
      }
    }
  }

  rep(i, v) {
    if(dist[i] == inf) {
      cout << "INF" << endl;
    } else {
      cout << dist[i] << endl;
    }
  }
}



Measured memory_bytes: 12980
<?php

function str_to_int (&$num) {
  $num = intval($num);
}

$card_sum = trim(fgets(STDIN));
$card_num_str = trim(fgets(STDIN));
$card_num_ary = explode(' ', $card_num_str);
$card_num_ary = array_map("intval", $card_num_ary);
rsort($card_num_ary);

$alice_point = 0;
$bob_point = 0;

foreach ($card_num_ary as $v) {
  $alice_point += array_shift($card_num_ary);
  $bob_point += array_shift($card_num_ary);
}
echo $alice_point - $bob_point;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1e9 + 7;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N;
    cin >> N;
    ll power = 1;
    for(int i = 1; i <= N; i++) {
        power *= i;
        power = power % MOD;
    }

    cout << power % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int arr[100][100];
	int h, w, n,i,j,k,r=0,c=0;
	scanf("%d %d", &h, &w);
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &j);
		for (k = 0; k < j; k++)
		{
			arr[r][c] = i+1;
			if (r % 2 == 0)
			{
				c++;
				if (c == w)
				{
					r++; c--;
				}
			}
			else if (r % 2 == 1)
			{
				c--;
				if (c == -1)
				{
					r++; c++;
				}
			}
		}
	}
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			printf("%d%c", arr[i][j], j == (w-1) ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
//Compiler version g++ 6.3.0
int fact(LL n){
  if(n==1||n==0){
    return 1; 
  }  
  else{
    return fact(n-1)*n;}
}
int main()
{
 LL n;
 cin>>n;
 LL k=0;
 LL h=n;
 if(n%1000==0){
   k=n/1000;  
 }
 else{
   k=n/1000+1;}
 cout<<1000*k-h<<endl; 
  return 0;
 }
       


Measured memory_bytes: 3648
#include <iostream>

int main() {
  int h, r;

  std::cin >> h >> r;

  if (false) {
  } else if (h + r < 0) {
    std::cout << -1 << std::endl;
  } else if (h + r == 0) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << 1 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    bool f = true;

    for(int i = 0; i < N; i++){
        int a;
        cin >> a;

        if(a % 2 == 0){
            if(a%3 != 0 && a%5 != 0){
                f = false;
            }
        }
    }

    if(f){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }

    return 0;
}


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

int main(){
  int N,K, res=0;
  cin >> N >> K;
  for(int i= 0; i<N; i++){
    int x;
    cin >> x;
    res +=min(x,K-x)*2;
  }
  cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,m; cin >> n >> m;
    int num = m/n;
    int ans = 1;
    gnr(i,1,num+1){
        if(m % i != 0) continue;
        else {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int s[maxn][22],a[maxn];
int n;
inline int qsum(int l,int r,int k){
	return s[r][k]-s[l-1][k];
}
inline bool chk(int l,int r){
	for (int i=0;i<=20;i++){
		if (qsum(l,r,i)>1) return false;
	}
	return true;
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		for (int j=0;j<=20;j++){
			s[i][j]=((a[i]>>j)&1);
			s[i][j]+=s[i-1][j];
		}
	}
	int p=1;
	ll ans=0;
	for (int i=1;i<=n;i++){
		while(chk(p,i)==false) p++;
		ans+=(i-p+1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 21656
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, r: f64);
    println!("{}", 2. * r * std::f64::consts::PI);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2188