akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

const int inf = 2e9;
const int N = 1e2 + 15;
int n, m, a[N], b[N], dist, ord[N], d[N][N];
bool used[N];

main() {
    memset(d, 0x3f, sizeof(d));
    scanf("%d\n", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        ord[i] = i;
        d[i][i] = 0;
    }
    sort(ord + 1, ord + 1 + n, [&](int x, int y) {
        return a[x] < a[y];
    });
    b[1] = ord[n];
    dist = a[ord[n-1]] + 1;
    b[dist] = ord[n-1];
    used[b[1]] = used[b[dist]] = true;
    for(int i = 1; i <= n; ++i)
        if(!used[i])
            for(int j = 2; j < dist; ++j)
                if(!b[j] && max(j - 1, dist - j) == a[i]) {
                    used[i] = true;
                    b[j] = i;
                    break;
                }
    for(int i = 1; i <= n; ++i)
        if(!used[ord[i]])
            for(int j = 2; j < dist; ++j)
                if(max(j - 1, dist - j) + 1 == a[ord[i]]) {
                    used[ord[i]] = true;
                    d[b[j]][ord[i]] = d[ord[i]][b[j]] = 1;
                    break;
                }
    for(int i = 1; i <= dist; ++i)
        if(!b[i])
            return cout << "Impossible" << endl, 0;
    for(int i = 2; i <= dist; ++i)
        d[b[i]][b[i-1]] = d[b[i-1]][b[i]] = 1;
    for(int k = 1; k <= n; ++k)
        for(int i = 1; i <= n; ++i)
            for(int j = 1; j <= n; ++j)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    for(int i = 1; i <= n; ++i)
        if(a[i] != *max_element(d[i] + 1, d[i] + 1 + n))
            return cout << "Impossible" << endl, 0;
    cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - Hina Arare
https://beta.atcoder.jp/contests/abc089/tasks/abc089_b

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    N = int(input())
    arare = list(input().split())
    if 'Y' in arare:
        print('Four')
    else:
        print('Three')


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 2940
//In the name of Allah
//In the name of the compassionate of the merciful
//Ya Ali!
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename Type>
using ordered_multiset = tree<Type, null_type, less_equal<Type>, rb_tree_tag, tree_order_statistics_node_update> ;

typedef long long ll ;
typedef long double ld ;

const ll maxn = 1e5 + 10 ;
const ll INF = 3e18 ;

#define f first
#define s second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define endll "\n"
#define sortt(v) sort(v.begin() , v.end())
#define reversee(v) reverse(v.begin() , v.end())

// for sqrt on interval and array , always sq = maxn/80 ;
// cout << *ss.find_by_order(index) ; -> return the value that indexed in index position
// cout << ss.order_of_key(value) ; -> lower_bound in ordered_set
//ifstream fin("input.txt");
//ofstream fout("output.txt");
// fflush(stdout);
ll mod = 1e9 + 7 , p1 = 999999929 , p2 = 999999937 ;

ll n , a[maxn] , dp[110][maxn] , sum[110][maxn] , k ;

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

cin >> n >> k ;
for(int i = 1 ; i <= n ; i ++)cin >> a[i] ;

sum[1][-1] = 0 ;
for(ll i = 0; i <= k ; i ++){
   if(i <= a[1])dp[1][i] = 1;
   else dp[1][i] = 0 ;
   sum[1][i] = (sum[1][i-1]+dp[1][i])%mod ;
}

//cout << dp[1][k] << endl ;

for(int i = 2 ; i <= n ; i ++){
    sum[i][-1] = 0 ;
    for(int j = 0 ; j <= k ; j ++){
        dp[i][j] = (sum[i-1][j] - sum[i-1][max(0ll , j-a[i])-1] + mod)%mod ;
        sum[i][j] = (sum[i][j-1] + dp[i][j])%mod ;
    }
}
cout << dp[n][k]%mod ;
 return 0;
}
/*
                  _     _   __
            /_\  (_    (_)  __)
           /   \  _) . (_) (__
*/


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010, mod = 1e9 + 7;

int n, m;
int a[N];
int fact[N], infact[N];

int qp(int a, int b, int p)
{
    int res = 1;
    while (b)
    {
        if (b & 1) res = (LL)res * a % p;
        a = (LL)a * a % p;
        b >>= 1;
    }
    return res;
}

int C(int a, int b)
{
	int res = (LL)fact[a] * infact[a - b] % mod * infact[b] % mod;
	return res;
}

int calc()
{
	int res = 0;
	for (int i = m; i <= n; i ++ )
		res = (res + (LL)C(i - 1, m - 1) * a[i] % mod) % mod;
	return res;
}

int main()
{
	fact[0] = infact[0] = 1;
	for (int i = 1; i < N; i ++ )
	{
	    fact[i] = (LL)fact[i - 1] * i % mod;
	    infact[i] = (LL)infact[i - 1] * qp(i, mod - 2, mod) % mod;
	}
	
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	
	int res = 0;
	res += calc();
	reverse(a + 1, a + n + 1);
	res -= calc();
	
	res = (res % mod + mod) % mod;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k>a+b)cout<<a-(k-a-b);
	else if(k>=a && k<=a+b)cout<<a;
	else cout<<k;
	

//   TimeTaken();
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 

 class Main{

     static int[] dens=new int[10];
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line; int totalN=0,totalV=0,count=0;
             while((line=br.readLine())!= null){if(line.isEmpty())break;
                 String split[] = line.split(",");
                 int a = Integer.parseInt(split[0]);//val
                 int b = Integer.parseInt(split[1]);//num
                 totalV+=a*b;totalN+=b;count++;                 
             }
             double av=(double)totalN/(double)count;
             BigDecimal bi = new BigDecimal(String.valueOf(av));
             av=bi.setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
             br.close();
             System.out.println(totalV);
             System.out.println((int)av);
         }catch(Exception e){}         
     }
    
 }

Measured memory_bytes: 15124
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    B = [0] * (N + 1)
    ans = []
    for i in range(N, 0, -1):
        x = sum(B[i::i])
        if x % 2 == A[i]:
            continue
        else:
            B[i] = 1
            ans.append(str(i))
    print(len(ans))
    print(' '.join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17196
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(), x.end()
#define mem(arr,x) memset(arr, x, sizeof arr)
#define db(arr) for(auto x : arr) cout << x << " "; cout << "\n";
using namespace std;

// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll power(ll n,ll m){
	if(m==0) return 1;
	ll val=power(n,m/2);
	if(m%2==0) return (val*val); else return ((val*val)*n);
}

ll powermod(ll n,ll m,ll MOD){
	if(m==0) return 1;
	ll val=powermod(n,m/2,MOD);
	val %= MOD;
	if(m%2==0) return (val*val) % MOD; else return (((val*val) % MOD) * n) % MOD;
}

void solve(){
	int n, m;
	cin >> n >> m;
	int cx, cy;
	cin >> cx >> cy;
	--cx;
	--cy;
	int dx, dy;
	cin >> dx >> dy;
	--dx;
	--dy;
	vector < string > g(n);
	for(int i = 0; i < n; i++){
		cin >> g[i];
	}
	vector<vector<int>> dist(n, vector<int>(m, -1));
	vector<vector<pair<int, int>>> que(n * m * 2);
	auto add = [&](int x, int y, int d){
		if (x < 0 || x >= n || y < 0 || y >= m) return;
		if (g[x][y] == '#') return;
		if (dist[x][y] >= 0 && d >= dist[x][y]) return;
		dist[x][y] = d;
		que[d].push_back(make_pair(x, y));
	};
	add(cx, cy, 0);
	for (int d = 0; d + 1 < que.size(); d++) {
		for (int close = 0; close < que[d].size(); ++close) {
			int x = que[d][close].first;
			int y = que[d][close].second;
			for (int dx = -2; dx <= 2; dx++) {
				for (int dy = -2; dy <= 2; dy++){
					int new_x = x + dx;
					int new_y = y + dy;
					add(new_x, new_y, d + (abs(dx) + abs(dy) > 1 ? 1 : 0));
				}
			}
		}
	}
	cout << dist[dx][dy] << endl;
}

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);	
	#endif

	int t = 1;
	// cin >> t;

	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solve();
	}

	return 0;
}

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

int n,t;
long long int k;

int A[200001];
map <int,bool> visited;

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

    cin >> n >> k;

    for(int i=1;i<=n;i++)
    {
    	cin >> A[i];
    }

    vector <int> vec;
    int now = 1;
    while(1)
    {
    	if(visited[now])
    	{
    		break;
    	}
    	visited[now] = true;
    	vec.push_back(now);
    	now = A[now];
    }

    int idx = 0;
    for(idx = 0;idx<vec.size();idx++)
    {
    	if(now==vec[idx])
    	{
    		break;
    	}
    }

    if(k < idx)
    {
    	cout << vec[k] << '\n';
    }
    else
    {
    	vector <int> circle;
    	for(int j=idx;j<vec.size();j++)
    	{
    		circle.push_back(vec[j]);
    	}
    	k-=idx;
    	int m = circle.size();
    	cout << circle[k%m] << '\n';
    }

    return 0;
}

Measured memory_bytes: 13976
import math

a, b, x = map(int, input().split())

b_1 = x / (a ** 2)
area_1 = a * b_1
area_2 = (a * b) / 2

if b_1 == b:
    ans = 90
elif area_2 > area_1:
    # 三角形
    h = (a * b_1 * 2) / b
    ans = math.degrees(math.atan(h / b))
else:
    # 梯形
    upside_len = b_1 * 2 - b
    ans = math.degrees(math.atan(a / (b - upside_len)))

print(90 - ans)


Measured memory_bytes: 38384
n = input()

d_len = len(n)


def dfs(d):
    ret = 0
    if int(d) > int(n):
        return 0
    if all(i in d for i in ('357')):
        ret += 1
    for j in '357':
        ret += dfs(d + j)
    return ret


print(dfs('0'))

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

int main() {
    int n;
    cin >> n;
    int a[2][n];
    rep(i, n) cin >> a[0][i];
    rep(i, n) cin >> a[1][i];

    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        rep(j, n) {
            if (i == j)
                cnt += a[0][j] + a[1][j];
            else if (i > j)
                cnt += a[0][j];
            else
                cnt += a[1][j];
        }
        ans = max(ans, cnt);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll mod = 1e9+7;
ll gcd(ll a, ll b)
{
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}
int main(){
    ll a,b;
    cin >> a >> b;
    PRINT(a*b/gcd(a,b));
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static long mod = 1000000007;   // 10^9 + 7

		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int N = vs[0];
			int K = vs[1];
			string s = Console.ReadLine();

			int cnt = K * 2;
			int ans = 0;
			char tmp = s[0];
			for (int i = 1; i < s.Length; i++) {
				if (tmp == s[i]) {
					ans++;
				} else if (cnt > 0) {
					cnt--;
					ans++;
				}
				tmp = s[i];
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 13408
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;cin >> n >> m;
    ll s[n],t[m];
    for (int i = 0; i < n; ++i)
    {
    	cin >> s[i];
    }
    for (int i = 0; i < m; ++i)
    {
    	cin >> t[i];
    }
    ll dp[n+1][m+1];memset(dp,0,sizeof(dp));/*dp[0][0]=1;*/
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=1;j<=m;j++)
    	{
    		_(dp[i][j],dp[i-1][j]);
    		_(dp[i][j],dp[i][j-1]);
    		_(dp[i][j],-dp[i-1][j-1]);
    		//+dp[i][j-1]-dp[i-1][j-1];
    		if(s[i-1]==t[j-1])_(dp[i][j],1+dp[i-1][j-1]);
    	}
    }
    cout << (dp[n][m]+1)%mod;
    }

Measured memory_bytes: 31616
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    ll sum = 0;
    FOR(i, 1, N) {
        if(i%3!=0 && i%5!=0) {
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3592
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    for c in &s {
        let po = *c as u8 - 'A' as u8;
        let c = ((po + n as u8) % 26 + 'A' as u8) as char;
        print!("{}", c);
    }
    println!();
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second                            
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define vi              vector<int>
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 


 
void c_p_c() {
  ios_base::sync_with_stdio(0); 
  cin.tie(0); 
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
// int gcd (int a, int b) {
//   if (b == 0) return a;
//   else return gcd (b, a % b);
// }
// int gcd(int a, int b, int& x, int& y) {
//   if (b == 0) {
//     x = 1;
//     y = 0;
//     return a;
//   }
//   int x1, y1;
//   int d = gcd(b, a % b, x1, y1);
//   x = y1;
//   y = x1 - y1 * (a / b);
//   return d;
// }
// int lcm (int a, int b)  {
//   return a / gcd(a, b) * b;
// }
// int fact(int n){
//   if(n==0) return 1 ;
//   else return n*fact(n-1); 
// }
void solve() {
  int n;
  cin >> n;
  int k = n % 10;
  if (k == 3) cout << "bon";
  else if (k == 0 or k == 1 or k == 6 or k == 8) cout << "pon";
  else cout << "hon";
}  
int32_t main() {
 //c_p_c();
 //w(x) 
 solve();
 return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args){
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        
        StringBuilder sb = new StringBuilder(str);
        
        if(str.endsWith("s")){
            sb.append("es");
        }else{
            sb.append("s");
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 26988
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N , M ;
    cin >> N >> M;
    int count = N ;
    vector<int> a(N,0);

    for(int i = 0; i < N; i++ ){
        cin >>a[i];
        M -= a[i];
    }
    
    sort(a.begin(),a.end());
    count = count + (M / a[0] );

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                ios_base::sync_with_stdio(false);
                cin.tie(NULL);
                lli t,n,i,j,b,a,k,q,m;
                string s;
                cin>>s;
                lli f=0;
                n=s.length();
                rep(i,n/2){
                    if(s[i]!=s[n-i-1]){
                        f=1;
                        break;
                    }
                }
                string ss="";
                rep(i,(lli((n-1)/2))){
                    ss+=s[i];
                }
                lli nn=ss.length();
                rep(i,nn/2){
                    if(ss[i]!=ss[nn-1-i]){
                        f=1;
                        break;
                    }
                }
                ss="";
                repp(i,((n+3)/2)-1,n)ss+=s[i];
                nn=ss.length();
                rep(i,nn/2){
                    if(ss[i]!=ss[nn-1-i]){
                        f=1;
                         break;
                    }
                }
if(f==0){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}



            }



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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	char ca, cb, cc, cd; cin >> ca >> cb >> cc >> cd;
	int a, b, c, d;
	a = ca - '0', b = cb - '0', c = cc - '0', d = cd - '0';
	rep(i, 0, 2) rep(j, 0, 2) rep(k, 0, 2) {
		int v = a + (1 - 2 * i) * b + (1 - 2 * j) * c + (1 - 2 * k) * d;
		if (v == 7) {
			cout << a << (i ? '-' : '+') << b << (j ? '-' : '+') << c << (k ? '-' : '+') << d << '=' << 7 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int llo;
#define a first
#define  b second
#define endl "\n"
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n,m;
	cin>>n>>m;
	llo it[n];
	for(llo i=0;i<n;i++){
		cin>>it[i];
	}

	vector<pair<llo,llo>> ran;
	llo su=0;
	for(llo i=0;i<n-1;i++){
		if(it[i]<=it[i+1]){
			su+=it[i+1]-it[i];
			ran.pb({it[i],-i});		

			ran.pb({it[i+1],i+1});
		}		
		else{
			su+=it[i+1]+m-it[i];
			ran.pb({it[i],-i});		
			ran.pb({it[i+1]+m,i+1});
		}
	}
	sort(ran.begin(),ran.end());
	llo ind=0;

	llo ans[2*m];
	llo co=0;
	for(llo i=0;i<2*m;i++){
		ans[i]=su;
	}
	llo su2=0;
	llo mi=su;
	for(llo i=1;i<2*m+1;i++){
		llo su3=0;
		llo co3=0;
		while(ind<ran.size()){
			if(ran[ind].a==i){
				if(ran[ind].b<=0){
					co3+=1;
					su3+=i;
				}
				else{
					co-=1;
					su2-=it[ran[ind].b-1];
				}
				ind+=1;
			}
			else{
				break;
			}
		}
		ans[(i-1)%m]-=i*co-su2;

		mi=min(mi,ans[(i-1)%m]);
		su2+=su3;
		co+=co3;
	}
	cout<<mi<<endl;


















	return 0;
}

Measured memory_bytes: 7152
def solve():
    import sys
    file_input = sys.stdin
    while True:
        N, Q = map(int, file_input.readline().split())
        if N == 0:
            break
        parent = [None, None]
        parent += [int(file_input.readline()) for _ in range(N - 1)]
        unmarked = [True] * (N + 1)
        unmarked[1] = False
        ans = 0
        for _ in range(Q):
            line = file_input.readline()
            v = int(line[2:])
            if line[0] == 'M':
                unmarked[v] = False
            else:
                while unmarked[v]:
                    v = parent[v]
                ans += v
        print(ans)

solve()


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

#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int n;
    cin >> n;
    set<ll> A;
    FOR(i, 0, n) {
        int x;
        cin >> x;
        if (A.count(x)) {
            A.erase(x);
        } else {
            A.insert(x);
        }
    }
    cout << A.size() << "\n";
    return 0;
}   


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define w while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define ll long long
using namespace std;
int main()
 {
       int n;
       cin>>n;
       int a[n];
       int dp[n+1];
       loop(i,0,n){
         ci a[i];
         dp[i]=0;
       }
      dp[n]=0;
      dp[0]=0;
      dp[1]=abs(a[1]-a[0]);
      loop(i,2,n){
        dp[i]= min( dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]) );
      }
      cout<<dp[n-1];
   }


Measured memory_bytes: 1024
n,m = gets.split.map(&:to_i)
imo = [0]*(n+2);
m.times{
  l,r = gets.split.map(&:to_i)
  imo[l]+=1
  imo[r+1]-=1
}
ans = 0
n.times{|i|
  imo[i+1]+=imo[i]
  ans += 1 if imo[i+1]==m
}

p ans


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

int main(){
 int r, D;
 long long x[11];
 cin >> r >> D >> x[0];
 for (int i = 1; i <= 10; i++){
     x[i] = x[i-1] * r - D;
     cout << x[i] << endl;
 }   
 return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===



bool dp[85][85][60000];



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

	constexpr int bias = 30000;

	int H, W; cin >> H >> W;
	vector<Vi> A(H, Vi(W)), B(H, Vi(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) {
			cin >> B[i][j];
		}
	}

	memset(dp, 0, sizeof(dp));

	int d = A[0][0] - B[0][0];
	dp[1][1][bias + d] = true;
	dp[1][1][bias - d] = true;
	
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			d = A[i - 1][j - 1] - B[i - 1][j - 1];
			for (int k = 0; k < 60000; ++k) {
				dp[i][j][k] |= dp[i - 1][j][k - d] | dp[i][j - 1][k - d]
					| dp[i - 1][j][k + d] | dp[i][j - 1][k + d];
			}
		}
	}

	int ans = I_INF;

	for (int i = 0; i < 60000; ++i) {
		if (dp[H][W][i]) {
			ans = min(ans, abs(i - bias));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 423680
# -*- coding: utf-8 -*-
input_line = input().split(' ')
N, D = int(input_line[0]), int(input_line[1])
count = 0
for i in range(N):
    tmp = [int(n) for n in input().split(' ')]
    if tmp[0] ** 2 + tmp[1] ** 2 <= D ** 2:
        count += 1
print(count)

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

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0)
{
  if (fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e3 + 2;
int a[maxn];

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n >= 30)
    cout << "Yes\n";
  else
    cout << "No\n";
  

  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	
  	cin>>s;
  	int n=s.size(),count=0;
  	if(n%2==0){
    	for(int i=0;i<n;i=i+2){
        	if(s[i]=='h'&&s[i+1]=='i'){
            	count++;
            }
          	else{
            	break;
            }
        
        }
      	if(count==n/2){
        	cout<<"Yes"<<endl;
        }
      	else{
        	cout<<"No"<<endl;
        }
    }
  	else{
    	cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
k = gets.chomp.to_i

def check_seven_multi(k)
  left = 0
  cnt = 0

  k.times do 
    cnt += 1
    left = (left * 10 + 7) % k
    if left == 0
      break
    end
  end

  puts cnt
end


if k.even? || k % 5 == 0
  puts -1
else 
  check_seven_multi(k)
end


Measured memory_bytes: 14340
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
  int n,k;
  long long sum=0;
  cin >> n >> k;
  vector<long long> h(n);
  for(int i=0; i<n; i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  for(int i=0; i<n-k; i++){
    sum+=h.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // input
    int n, m;
    cin >> n >> m;
    int x[100000];
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }

    // xの値の差を取る
    sort(x, x + m);
    int dif[100000];
    for (int i = 0; i < m - 1; i++) {
        dif[i] = x[i + 1] - x[i];
    }

    // 差の小さいものから足す
    sort(dif, dif + m - 1);
    int sum = 0;
    for (int i = 0; i < m - n; i++) {
        sum += dif[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int n,m,k,i,j,t;
	int a[1001];
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(k=1;k<=m;k++){
		for(i=0;i<n-1;i++){
			if(a[i]%k>a[i+1]%k){
				t=a[i];
				a[i]=a[i+1];
				a[i+1]=t;
			}
		}
	}
	for(i=0;i<n;i++)printf("%d\n",a[i]);
	return 0;
}


Measured memory_bytes: 2048
d, n = map(int, input().split())
if d == 0:
	if n != 100:
		print (n)
	else:
		print (n+1)
elif d == 1:
	if n != 100:
		print (n * 100)
	else:
		print (n*100 + 100)
else:
	if n != 100:
		print (n * 10000)
	else:
		print (n*10000 + 10000)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;


map<string, int> aa;
set<string> dic;

int main(){
	string a;

	while (cin >> a){
		dic.insert(a);
		++aa[a];
	}

	int m = 0;
	string ms;

	int m2 = 0;
	string ms2;


	for (auto x : dic){
		if (m < x.length()){
			m = x.length();
			ms = x;
		}
	}

	for (auto x : aa){
		if (m2 < x.second){
			ms2 = x.first;
			m2 = x.second;
		}
	}

	cout << ms2 << " " << ms << endl;

	return 0;
}

Measured memory_bytes: 1196
/*
  Code By RyeCatcher
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>
#include <utility>
#define ri register int
#define ll long long
#define ull unsigned long long
#define pb push_back
#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define SIZE 23333
using std::min;
using std::max;
using std::pair;
using std::queue;
using std::priority_queue;
using std::vector;
inline char gc(){
    static char buf[SIZE],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;
    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;
}
const int maxn=1000005;
const int inf=0x7fffffff;
ll n,m;
ll o,oo;
char s[maxn],t[maxn];
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
	ll p;
	read(n),read(m);
	scanf("%s",s+1);scanf("%s",t+1);
	p=gcd(n,m);
	oo=n*m;
	o=1ll*oo/p;//lcm
	ll la,lb,gg,gp,ga,gb;
	for(ll k=o;k<=oo;k+=o){
		la=k/n;
		lb=k/m;
		gg=gcd(la,lb);
		//printf("%lld %lld %lld\n",la,lb,gg);
		ga=gb=1,gg=la*lb/gg;
		la=gg/la,lb=gg/lb;
		//printf("%lld %lld %lld\n",la,lb,gg);
		bool flag=1;
		while(ga<=n&&gb<=m){
			if(s[ga]==t[gb])ga+=la,gb+=lb;
			else {
				flag=0;
				break;
			}
		}
		if(flag==1){printf("%lld\n",k);exit(0);}
	}
	puts("-1");
	return 0;
}	


Measured memory_bytes: 384
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long
#define mo 1000000007

int d[310][310][310];
vector<pair<int,int> > a[310];
int nn[10];

int main()
{
  int i,j,k,n,m,n1,ll,rr,x,b1,ii,jj,kk,l;
  int ans;
  scanf("%d%d",&n,&m);
  for (i=0;i<=n;i++)
    a[i].clear();
  for (i=0;i<m;i++)
  {
    scanf("%d%d%d",&ll,&rr,&x);
    a[rr].push_back(make_pair(ll,x));
  }
  memset(d,0,sizeof(d));
  ans=0;
  d[0][0][0]=1;
  for (i=0;i<=n;i++)
    for (j=0;j<=n;j++)
      for (k=0;k<=n;k++)
        if (d[i][j][k]>0)
        {
          nn[0]=max(i,max(j,k));
          nn[2]=min(i,min(j,k));
          nn[1]=i+j+k-nn[0]-nn[2];
          n1=nn[0];
          b1=1;
          for (l=0;l<a[n1].size();l++)
          {
            if (a[n1][l].second==3)
            {
              if (a[n1][l].first>nn[2]) b1=0;
            }
            else if (a[n1][l].second==2)
            {
              if (a[n1][l].first>nn[1]) b1=0;
              if (a[n1][l].first<=nn[2]) b1=0;
            }
            else
            {
              if (a[n1][l].first<=nn[1]) b1=0;
            }
            if (b1==0) break;
          }
          if (b1==0) continue;
          //cout<<i<<" "<<j<<" "<<k<<" "<<d[i][j][k]<<" "<<n1<<endl;
          if (n1==n)
          {
            ans+=d[i][j][k];
            if (ans>=mo) ans-=mo;
            continue;
          }
          ii=n1+1;
          jj=j;
          kk=k;
          d[ii][jj][kk]+=d[i][j][k];
          if (d[ii][jj][kk]>=mo) d[ii][jj][kk]-=mo;
          ii=i;
          jj=n1+1;
          kk=k;
          d[ii][jj][kk]+=d[i][j][k];
          if (d[ii][jj][kk]>=mo) d[ii][jj][kk]-=mo;
          ii=i;
          jj=j;
          kk=n1+1;
          d[ii][jj][kk]+=d[i][j][k];
          if (d[ii][jj][kk]>=mo) d[ii][jj][kk]-=mo;
        }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 116608
#include<stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
int a[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int ans=1;
	int temp=0,pre=-1;
	for(int i=0;i<n;i++){
		if(a[i]>pre)temp++,ans=max(ans,temp),pre=a[i];
		if(a[i]<pre)temp=1,pre=a[i];
	}
	temp=0,pre=2e9;
	for(int i=0;i<n;i++){
		if(a[i]<pre)temp++,ans=max(ans,temp),pre=a[i];
		if(a[i]>pre)temp=1,pre=a[i];
	}
	printf("%d\n",ans);
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789
#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
/*
template <typename... Args>
void dbg(Args... args) {
    ((cout << args << " "), ...);
    cout << "\n";
}
*/
//--------------------------------------------------//
int h, w;
char grid[310][310];
vector<pii> coin1[610];
vector<pii> coin2[610];
ll cnt1, cnt2;

int main() {
    use_cio();
    cin >> h >> w;
    rep(i, h) cin >> grid[i];
    rep(i, h) rep(j, w) {
        if (grid[i][j] == '#') {
            coin1[i + j].push_back({i, j});
            coin2[i - j + 300].push_back({i, j});
        }
    }
    rep(i, 610) sort(all(coin1[i])), sort(all(coin2[i]));
    rep(i, 610) {
        int sz = coin1[i].size();
        rep(j, sz) {
            repp(k, j + 1, sz) {
                int d = abs(coin1[i][j].first - coin1[i][k].first);
                if (i + 2 * d < 610)
                    cnt1 += upper_bound(all(coin1[i + 2 * d]), pii(coin1[i][j].first + 2 * d, (int)1e9)) - lower_bound(all(coin1[i + 2 * d]), pii(coin1[i][j].first + d, (int)-1e9));
                if (i - 2 * d >= 0)
                    cnt1 += upper_bound(all(coin1[i - 2 * d]), pii(coin1[i][j].first, (int)1e9)) - lower_bound(all(coin1[i - 2 * d]), pii(coin1[i][j].first - d, (int)-1e9));
            }
        }
    }
    rep(i, 610) {
        int sz = coin2[i].size();
        rep(j, sz) {
            repp(k, j + 1, sz) {
                int d = abs(coin2[i][j].first - coin2[i][k].first);
                if (i + 2 * d < 610)
                    cnt1 += upper_bound(all(coin2[i + 2 * d]), pii(coin2[i][j].first + 2 * d, (int)1e9)) - lower_bound(all(coin2[i + 2 * d]), pii(coin2[i][j].first + d, (int)-1e9));
                if (i - 2 * d >= 0)
                    cnt1 += upper_bound(all(coin2[i - 2 * d]), pii(coin2[i][j].first, (int)1e9)) - lower_bound(all(coin2[i - 2 * d]), pii(coin2[i][j].first - d, (int)-1e9));
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            if (grid[i][j] == '#') {
                for (int k = j + 2; k < w; k += 2) {
                    if (grid[i][k] == '#') {
                        if (i + (k - j) / 2 < h && grid[i + (k - j) / 2][(k + j) / 2] == '#') cnt2++;
                        if (i - (k - j) / 2 >= 0 && grid[i - (k - j) / 2][(k + j) / 2] == '#') cnt2++;
                    }
                }
            }
        }
    }
    rep(i, w) {
        rep(j, h) {
            if (grid[j][i] == '#') {
                for (int k = j + 2; k < h; k += 2) {
                    if (grid[k][i] == '#') {
                        if (i + (k - j) / 2 < w && grid[(k + j) / 2][i + (k - j) / 2] == '#') cnt2++;
                        if (i - (k - j) / 2 >= 0 && grid[(k + j) / 2][i - (k - j) / 2] == '#') cnt2++;
                    }
                }
            }
        }
    }
    cout << cnt1 - cnt2 << endl;
}


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

using ll = long long;
const int mod = 1e9 + 7;

int cnt[11][10];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    for (int i = 0; i <= 9; i++)
        cnt[1][i] = 1;
    for (int i = 2; i <= 10; i++) {
        for (int j = 0; j <= 9; j++) {
            if (j > 0)
                cnt[i][j] += cnt[i - 1][j - 1];
            if (j + 1 <= 9)
                cnt[i][j] += cnt[i - 1][j + 1];
            cnt[i][j] += cnt[i - 1][j];
        }
    }
    int d = 1;
    int sum = 0;
    while (1) {
        int now = 0;
        for (int i = 1; i <= 9; i++)
            now += cnt[d][i];
        if (sum + now >= K)
            break;
        sum += now;
        d++;
    }
    K -= sum;
    int prev = -1;
    for (int i = d; i >= 1; i--) {
        int sum = 0;
        int j;
        for (j = 0; j <= 9; j++) {
            if (i == d && j == 0)
                continue;
            if (prev != -1 && abs(j - prev) > 1)
                continue;
            if (sum + cnt[i][j] >= K)
                break;
            sum += cnt[i][j];
        }
        K -= sum;
        cout << j;
        prev = j;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for(int i=a; i<=b; i++){
    if(i%k==0){
      cout << "OK" << endl; return 0;
    }
  }

  cout << "NG" << endl;
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ab, bc, ca;
  ab = abs(a-b), bc = abs(b-c), ca = abs(c-a);
  cout << ab+bc+ca-max(max(ab, bc), ca) << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned int ui;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector<vector<T>>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector<vector<T>>>(a,vector<vector<T>>(b,vector<T>(c,t))){}};
// #include "../l/mod.h"

class D {
public:
	int N;
	vector<vector<int>> E;
	unordered_map<pii, double> C;
	vector<pair<int, double>> W;

	double count(int u, int v) {
		auto it = C.find({u,v});
		if (it != C.end()) return it->y;

		double ans = 0.0;
		if (W[u].x != -2) {
			ans = W[u].y;
			if (W[u].x != -1) ans += count(W[u].x, u);
			if (v != -1) ans -= count(v, u);
		} else {
			for (int w: E[u]) if (v!=w) ans += count(w,u);
			W[u] = {v, ans};
		}

		int cnt = E[u].size() - (v != -1);
		if (cnt > 0) ans /= cnt;
		++ans;
		return C[{u,v}] = ans;
	}

	void solve(istream& cin, ostream& cout) {
		cin >> N; E.clear(); E.resize(N); W.clear(); W.resize(N);
		for (int i = 0; i < N; ++i) {
			W[i] = {-2, 0.0};
		}

		C.clear();
		for (int i = 0; i < N-1; ++i) {
			int u,v; cin >> u >> v; --u; --v;
			E[u].push_back(v);
			E[v].push_back(u);
		}

		cout << fixed << setprecision(10);

		for (int j = 0; j < N; ++j) {
			cout << count(j, -1)-1 << '\n';
		}

	}
};


int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 44276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

bool judge(string s){
    int n = s.size();
    bool flag = true;
    rep(i,0,n){
        if(s[i] != s[n-1-i]) flag = false;
    }
    return flag;
}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = false;
    if(judge(s)){
        string sub1 = s.substr(0, (n-1)/2);
        string sub2 = s.substr((n-1)/2+1, (n-1)/2);
        if(judge(sub1) && judge(sub2)){
            flag = true;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

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

class Program
{
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        Stack<long> stack = new Stack<long>();
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == "+")
            {
                long b = stack.Pop();
                long a = stack.Pop();
                stack.Push(a + b);
            }
            else if (s[i] == "-")
            {
                long b = stack.Pop();
                long a = stack.Pop();
                stack.Push(a - b);
            }
            else if (s[i] == "*")
            {
                long b = stack.Pop();
                long a = stack.Pop();
                stack.Push(a * b);
            }
            else
            {
                stack.Push(long.Parse(s[i]));
            }
        }
        Console.WriteLine(stack.Pop());
    }
}


Measured memory_bytes: 20424
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int No = 0;
    int[] buka = new int[N+1];
    while(sc.hasNext()){
        buka[sc.nextInt()]++;
    }
    for(int i = 1;i <= N;i++){
        System.out.println(buka[i]);
    }
  }
}

Measured memory_bytes: 51720
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <map>

using namespace std;

int main() {
  
  for(int a, L; cin >> a >> L, (a|L);) {
    map<int, int> mp;
    for(int i=0; ; i++) {
      if(mp.count(a)) {
	cout << mp[a] << ' ' << a << ' ' << i-mp[a] << endl;
	break;
      }
      
      mp[a] = i;
      stringstream ss; ss << a; string s = ss.str(); int N = s.size();
      vector<int> vec;
      for(int i=0; i<L; i++) {
	if(i < N) vec.push_back(s[i]-'0');
	else vec.push_back(0);
      }
      
      sort(vec.begin(), vec.end());
      N = vec.size();
      int small = 0;
      for(int i=0; i<N; i++) {
	small *= 10;
	small += vec[i];
      }
      int big = 0;
      for(int i=N-1; i>=0; i--) {
	big *= 10;
	big += vec[i];
      }
      a = big - small;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1240