akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

struct Node{
    int key;
    Node *p, *l, *r;
};

Node *root, *NIL;

void Insert(int key){
    Node *x, *y, *z;

    z = new Node;
    z->key = key;
    z->l = NIL;
    z->r = NIL;

    x = root;
    y = NIL;

    while(x!=NIL){
        y = x;
        if(x->key>z->key){
            x = x->l;
        }
        else{
            x = x->r;
        }
    }

    if(y==NIL) {root = z;}
    else if(y->key>z->key) {y->l = z;}
    else if(y->key<=z->key) {y->r = z;}
}

void Find(Node *nk, int key){
    int flag = 0;
    while(nk!=NIL){
        if(nk->key==key){
            flag = 1;
            break;
        }
        else if(nk->key > key){
            //cout << nk->key << ">" << key << endl;
            nk = nk->l;
        }
        else{
            //cout << nk->key << "<" << key << endl;
            nk = nk->r;
        }
    }
    if(flag==1){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
}

void PreOrder(Node *nk){
    if(nk==NIL) return;
    //cout << nk->key << " ";
    cout << " " << nk->key;
    PreOrder(nk->l);
    PreOrder(nk->r);
}

void InOrder(Node *nk){
    if(nk==NIL) return;
    InOrder(nk->l);
    //cout << nk->key << " ";
    cout << " " << nk->key;
    InOrder(nk->r);
}

int main(){
    int n, num;
    string cmd;
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> cmd;
        if(cmd[0]=='i'){
            cin >> num;
            Insert(num);
        }
        else if(cmd[0]=='f'){
            cin >> num;
            Find(root, num);
        }
        else{
            InOrder(root);
            cout << endl;
            PreOrder(root);
            cout << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 21912
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    int n,k,ans;
    cin>>n>>k;
    ans=ceil(log(n)/log(k));
    if(!ans)ans=1;
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,i;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  cout<<a[n/2]-a[n/2-1];
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n,m;cin>>n>>m;
  vector<pair<ll, ll> > vpp(n);
  for(ll i=0;i<n;i++){ll a,b;cin>>a>>b;vpp[i]={a,b};};
  sort(vpp.begin(), vpp.end());
  ll ans=0;
  for(ll i=0;i<n;i++){
    auto a = vpp[i].first, b = vpp[i].second;
    ans += a * min(m, b);
    m -= min(m, b);
    if(m<=0)break;
  }
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 4696
#include<bits/stdc++.h>
using namespace std;
	int n, m, a, b, arr[100001], cur = 1;
	vector<int> adj[100001];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	vector<pair<int, int> > vec;
	cin >> n;
	fill(arr + 1, arr + n + 1, -1);
	for(int i=1; i<n; i++){
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cin >> m;
	for(int i=0; i<m; i++){
		cin >> a >> b;
		arr[a] = b;
		vec.push_back(make_pair(b, a));
	}
	sort(vec.begin(), vec.end());
	deque<int> deq;
	deq.push_back(vec[0].second);
	while(!deq.empty()){
		a = deq.front();
		deq.pop_front();
		while(cur < m && vec[cur].first == arr[a]) deq.push_front(vec[cur++].second);
		while(cur < m && vec[cur].first == arr[a] + 1) deq.push_back(vec[cur++].second);
		for(int i=0; i<adj[a].size(); i++){
			if(arr[adj[a][i]] != -1 && arr[adj[a][i]] != arr[a] + 1 && arr[adj[a][i]] != arr[a] - 1){
				cout << "No";
				return 0;
			}
			if(arr[adj[a][i]] != -1) continue;
			arr[adj[a][i]] = arr[a] + 1;
			deq.push_back(adj[a][i]);
		}
	}
	cout << "Yes\n";
	for(int i=1; i<=n; i++) cout << arr[i] << '\n';
}


Measured memory_bytes: 7928
n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
if k+1<=n:
  max=k+1
else:
  max=n
  
for i in range(1,max):
  dp[i]=abs(h[0]-h[i])
#print(dp)

"""
k番目から最後まで順番に見ていく
i-kからiまでのコストを計算し, それまでのコストの総和と
その時のコストの合計が最小のものをdp[i]に代入
"""
for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  #print("i={}".format(i))
  #print(li)
  dp[i]=min(li)
  #print(dp)
  
print(dp[-1])


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

int main(){
    char S[20];
    cin >> S;
    if(S[5]=='0'){
        int x = S[6] - '0';
        if(x>4){
            cout << "TBD" << endl;
        }else{
            cout << "Heisei" << endl;
        }
    }else{
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];

	auto A = readMatrix!char(H, W);
	auto dx = [1, 0, -1, 0], dy = [0, 1, 0, -1];

	ulong cnt;
	debug writeln;
	alias Pair = Tuple!(int, "y", int, "x");
	Pair[] stack1, stack2;

	foreach(y; 0..H) foreach(x; 0..W) {
		if(A[y][x] == '#') stack1 ~= Pair(y, x);
	}

	while(stack1 != [] || stack2 != []) {
		if(stack1 != []) cnt++;
		while(stack1 != []) {
			Pair p = stack1.front;
			stack1.popFront;

			foreach(k; 0..4) {
				auto ry = p.y + dy[k], rx = p.x + dx[k];

				if(0 <= ry && ry < H && 0 <= rx && rx < W && A[ry][rx] == '.') {
					A[ry][rx] = '#';
					stack2 ~= Pair(ry, rx);
				}
			}
		}
		if(stack2 != []) cnt++;
		while(stack2 != []) {
			Pair p = stack2.front;
			stack2.popFront;

			foreach(k; 0..4) {
				auto ry = p.y + dy[k], rx = p.x + dx[k];

				if(0 <= ry && ry < H && 0 <= rx && rx < W && A[ry][rx] == '.') {
					A[ry][rx] = '#';
					stack1 ~= Pair(ry, rx);
				}
			}
		}
	}
	(cnt - 1).writeln;
}


T[] deepcopy(T)(T[] a) {
	import std.traits : isArray;
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}
// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 13504
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0,ans=0, x = 0, y = 0, z = 0,n=0,m=0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001],sec[100001],pointx[100001],pointy[100001];
long long int iremono2[100001],check[100001];
std::vector<long long int>kinds{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input,input2;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
int main()
{
	cin >> input;
	for (int bit = 0; bit < (1 << ((int)input.size() - 1));bit++) {
		long long num = input[0] - '0';
		long long sum = 0;
		for (int i = 0; i < (int)input.size() - 1; i++) {
			if (bit&(1 << i)) {
				sum += num;
				num = 0;
			}
			num = num * 10 + input[i + 1] - '0';
		}
		sum += num;
		ans += sum;
	
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
def main():
    N,x = map(int,input().split())
    num = x
    a_s = list(map(int,input().split()))
    a_s.sort()
    cnt = 0
    for i,a in enumerate(a_s):
        if num >= a:
            num -= a
            cnt += 1

    if cnt == N and num > 0:
        cnt -= 1
    print(cnt)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;



int main()
{
  int a,b; //かっている数//最大100

  cin >> a >> b;



  bool isans=true;
  if (a%2==0 || b%2==0)isans=false;

  cout << (isans ? "Yes":"No");
  return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    REP(i, h) REP(j, w) cin >> s[i][j];
    bool flag = true;
    REP(i, h) REP(j, w) {
        int l = max(j - 1, 0);
        int r = min(j + 1, w - 1);
        int u = max(i - 1, 0);
        int d = min(i + 1, h - 1);
        if(s[i][j] == '#' && s[u][j] == '.' && s[d][j] == '.' &&
           s[i][l] == '.' && s[i][r] == '.')
            flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  string s;
  
  cin >> s;
  
  if(s=="hi"){
    cout << "Yes" << endl;
  }else
  if(s=="hihi"){
    cout << "Yes" << endl;
  }else
  if(s=="hihihi"){
    cout << "Yes" << endl;
  }else
  if(s=="hihihihi"){
    cout << "Yes" << endl;
  }else
  if(s=="hihihihihi"){
    cout << "Yes" << endl;
  }else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false);


    ll n,i,j,k,t;
    cin>>i>>j>>k;

    if((i*100+j*10+k)%4==0)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int a=0;
    int b=0;
    int c=0;
    int d=0;

    cin >> a >> b >> c >> d;

    if(a*b>=c*d)cout << a*b << endl;
    else if(a*b<=c*d)cout << c*d << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

double r;
double PI = 3.141592653589;
double s;
double l;

int main(void){
	
	scanf("%lf",&r);
	s = r * r * PI;
	l = 2 * r * PI;
	printf("%.7lf %.7lf\n",s,l);
	return 0;
}

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

int main(){

  int x;
  cin>>x;
  int h = x / 3600;
  int m = (x / 60) % 60;
  int s = x % 60;
  cout<<h<<":"<<m<<":"<<s<<endl;

  return 0;
}



Measured memory_bytes: 3088
n = gets.to_i
max = 0
array = []

(1..n).each do |number|
  cnt = 0
  while true
    if number % 2 == 0
      number /= 2
      cnt += 1
    else
      break
    end
  end
  array.push(cnt)
end

p 2** array.max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, i;
	cin >> n;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	sort(arr, arr + n);
	bool poss = true;
	fo(i, 1, n) {
		if(arr[i] == arr[i - 1])
		poss = false;
	}
	cout << (poss ? "YES" : "NO");
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static long dp[][]=new long[100001][3];
  public static long go(long a[][],int i,int ch){
    if(i>=a.length)
    {
      return 0;
    }
    if(dp[i][ch]!=-1)
    return dp[i][ch];
    long max=0;
    if(ch==0){
    dp[i][0]=a[i][0]+Math.max(go(a,i+1,1),go(a,i+1,2));
    max=Math.max(dp[i][0],max);
    }
    if(ch==1){
    dp[i][1]=a[i][1]+Math.max(go(a,i+1,0),go(a,i+1,2));
    max=Math.max(dp[i][1],max);
    }
    if(ch==2){
    dp[i][2]=a[i][2]+Math.max(go(a,i+1,0),go(a,i+1,1));
    max=Math.max(dp[i][2],max);
    }
    return max;
  }
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in); 
    int n=sc.nextInt();
    long a[][]=new long[n][3];
    for(int i=0;i<n;i++){
    a[i][0]=sc.nextLong();
    a[i][1]=sc.nextLong();
    a[i][2]=sc.nextLong();
    dp[i][0]=-1;
    dp[i][1]=-1;
    dp[i][2]=-1;
    }
    dp[n][0]=-1;
    dp[n][1]=-1;
    dp[n][2]=-1;
    long ans=Math.max(go(a,0,0),Math.max(go(a,0,1),
      go(a,0,2)));
    System.out.print(ans);
  }
}

Measured memory_bytes: 74396
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }

        int[][] dp = new int[N + 1][W + 1];
        for (int i = 1; i < N + 1; i++) {
            for (int j = 0; j < W + 1; j++) {
                if (j >= w[i - 1]) {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 31084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int a, b;
    char op[128];
    while (1) {
        a = iin();
        stin(op);
        b = iin();
        if (strcmp(op, "?") == 0) {
            break;
        } else if (strcmp(op, "+") == 0) {
            iout(a + b);
        } else if (strcmp(op, "-") == 0) {
            iout(a - b);
        } else if (strcmp(op, "*") == 0) {
            iout(a * b);
        } else if (strcmp(op, "/") == 0) {
            iout(a / b);
        }
    }
    return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>

int main() {
    int a, b, lex, max;
    scanf("%d %d", &a, &b);
    if(a < b) {
        lex = a;
        max = b;
    } else {
        lex = b;
        max = a;
    }
    
    for(int i = 0; i < max; i++)
        printf("%d", lex);

    return 0;
}

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

int main(){
  int N; cin>>N;
  string S; cin>>S;
  map<pair<string,string>, ll> mp1,mp2;
  rep(i,(1<<N)){
    string A="",B="",C="",D="";
    rep(j,N){
      if((i>>j)&1){
        A+=S[j];
        C+=S[N+j];
      }else{
        B+=S[j];
        D+=S[N+j];
      }
    }
    reverse(B.begin(),B.end());
    reverse(D.begin(),D.end());
    mp1[make_pair(A,B)]++;
    mp2[make_pair(D,C)]++;
  }
  ll ans=0;
  for(auto m:mp1){
    ans+=m.second*mp2[m.first];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 103424
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <cmath>
using namespace std;
#pragma warning (disale: 4996)
int p[100009], n, cnt;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a > 100000)cnt++; else p[a]++;
	}
	for (int i = 0; i < 100009; i++) {
		if (p[i] >= i)cnt += p[i] - i; else cnt += p[i];
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int main()
{
    int w,h,c;
    cin >> w>> h >>c;
    int g =gcd(w,h);
    cout << (w/g)*(h/g)*c << endl;
        return 0;
}



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

const int MOD=1e9+7;

char str[2][60];
int n;
int dp[2][3][3];

int main() {
    scanf("%d%s%s",&n,str[0]+1,str[1]+1);
    for(int i=0;i<3;i++)for(int j=0;j<3;j++) if((str[0][1]==str[1][1]&&i==j) || (str[0][1]!=str[1][1]&&i!=j)) dp[0][i][j]=1;
    
    int cur=1,pr=0;
    for(int i=2;i<=n;i++) {
        for(int j=0;j<3;j++)for(int k=0;k<3;k++) {
            dp[cur][j][k]=0;
            if((str[0][i]==str[1][i] && j!=k) || (str[0][i]!=str[1][i] && j==k)) continue;
            
            for(int a=0;a<3;a++)for(int b=0;b<3;b++) {
                if((str[0][i]==str[0][i-1] && j!=a) || (str[0][i]!=str[0][i-1] && j==a)) continue;
                if((str[1][i]==str[1][i-1] && k!=b) || (str[1][i]!=str[1][i-1] && k==b)) continue;
                dp[cur][j][k] = (dp[cur][j][k] + dp[pr][a][b])%MOD;
            }
        }
        swap(cur,pr);
    }

    int ans=0;
    for(int i=0;i<3;i++)for(int j=0;j<3;j++) ans = (ans + dp[pr][i][j])%MOD;
    printf("%d\n",ans);
    
    return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 55, M = 3e3, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    char v[] = {'a', 'e', 'i', 'o', 'u'};
    char c; cin >> c;
    for(int i = 0;i < 5;i++)    if(v[i] == c)   return cout << "vowel", 0;
    cout << "consonant";
}


Measured memory_bytes: 256
N, K = map(int, input().split())  # 複数数値入力
li = list()
for n in range(N):
    li.append(int(input()))

li.sort()

ans = float("inf")
for i in range(N - K + 1):
    if ans > li[i + K - 1] - li[i]:
        ans = li[i + K - 1] - li[i]
print(ans)


Measured memory_bytes: 7384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n) cout<<fixed<<setprecision(n);
#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define find(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  string a, b, c; cin >> a >> b >> c;
  outl("A" + string(1, b[0]) + "C")
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
#define ld long double
 
using namespace std;
 
const int N = 5e5 + 123;
const ll mod = 1e9 + 7;

struct Blocks{
	int s, w;
	ll v;
	Blocks(int ww=0, int ss=0, ll vv=0){
		v = vv, s = ss, w = ww;
	}
}a[N];

int n;
ll dp[1010][20100];
int was[N];

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for(int i = 1;i <= n;i++){
		int s, w;
		ll v;
		cin >> w >> s >> v;
		a[i] = Blocks(w, s, v);
		//cerr << a[i].v << " " << v << "\n";
	}

	sort(a + 1, a + n + 1, [](Blocks x, Blocks y){
		return x.s + x.w < y.s + y.w;	
	});

	ll res = 0;
	was[0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 20000;j >= 0;j--){
			dp[i][j] = dp[i - 1][j];
		}
		for(int j = 20000;j >= a[i].w;j--){		
			int x = j - a[i].w;
			if(was[x] == 1 && x <= a[i].s){
				dp[i][j] = max(dp[i][j], dp[i - 1][x] + a[i].v);
		//		cerr << a[i].v << "\n";
				was[j] = 1;
			}
			res = max(res, dp[i][j]);
		}
	}
	cout << res;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int info[4][3][10] = {0};
    
    int b, f, r, v;
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        info[b-1][f-1][r-1] += v;
    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++){
                cout << " " << info[i][j][k];
            }
            cout << endl;
        }
        if (i < 3) {
            cout << "####################" << endl;
        }
    }
    
    return 0;
}


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

int main(){
	long n;
	cin>>n;
	vector<long>v;
	vector<long>u;
	map<long,long>vmap;
	map<long,long>umap;
	long tmp;
	for(long i=0;i<n;++i){
		cin>>tmp;
		if(i%2==0){
			v.push_back(tmp);
			vmap[tmp]++;
		}
		else{
			u.push_back(tmp);
			umap[tmp]++;
		}
	}
	sort(v.begin(),v.end());
	sort(u.begin(),u.end());
	long maxu=0,maxv=0;
	for(long i=1;i<=v[n/2-1];++i){
		if(vmap[maxv]<=vmap[i])maxv=i;
	}
	for(long i=1;i<=u[n/2-1];++i){
		if(umap[maxu]<=umap[i])maxu=i;
	}
	long ans;
	if(maxv!=maxu){
		ans=n-umap[maxu]-vmap[maxv];
	}
	else{
		long maxv1=maxv;
		maxv=0;
		for(long i=1;i<=v[n/2-1];++i){
			if(vmap[maxv]<=vmap[i] && i!=maxu)maxv=i;
		}
		ans=n-umap[maxu]-vmap[maxv];
		maxu=0;
		for(long i=1;i<=u[n/2-1];++i){
			if(umap[maxu]<=umap[i] && i!=maxv1)maxu=i;
		}
		if(ans>n-umap[maxu]-vmap[maxv1]){
			ans=n-umap[maxu]-vmap[maxv1];
		}
	}
	cout<<ans<<endl;
}


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

int main(){
   int x,a,b;
   cin>>x>>a>>b;
   if(abs(x-a)<abs(x-b)) cout<<"A"<<endl;
   else cout<<"B"<<endl;
}

Measured memory_bytes: 3628
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
int IM = 1e16;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) {for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PTN(int n = 1, int a = 0, int b = 0, int c = 0) { if (n--)cout << a << " "; if (n--)cout << b << " "; if (n--)cout << c << " "; cout << endl; }
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <-------------------------------------------------------------------------------------------------------------------------------------------------------------------------> Ignore This--> memset substr pop_back  insert tuple first second push_back string continue make_pair break deque stack queue sort reverse accumulate  count lower_bound upper_bound next_permutation copy_n __builtin_popcount make_tuple
// <========================================================================================================================================================================

signed  main() {
    SPD_emergency
    
    int i, j, k, x, y, u;
    //int t; cin >> t; while (t--)
    {
        string s,t;
        cin >> s >> t;
        int x = s.size();
        string l = t.substr(0,x);
        if(l==s){
            PT("Yes");
        }
        else
            PT("No");


    }
    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        int N = NextInt(), K = NextInt();
        long[] A = LineLong().OrderBy(v => v).ToArray();

        //f(X) の加算なのでmaxXの総和 - minXの総和でも問題ないです

        FacInv FI = new FacInv();
        FI.Make(N + 10);

        long ans = 0;
        for (int i = 0; i <= N - K; i++)
        {
            ans -= (A[i] * FI.nCr(N - i - 1, K - 1)) % MOD;
            ans %= MOD;
        }

        //Array.Reverse(A);
        for (int i = N - 1; i >= K - 1; i--)
        {
            ans += (A[i] * FI.nCr(i, K - 1)) % MOD;
            ans %= MOD;
        }

        Console.WriteLine((ans + MOD) % MOD);
    }
}

public class FacInv
{
    private long[] fac;
    private long[] inv;

    public void Make(long N)
    {
        fac = new long[N + 10];
        inv = new long[N + 10];
        fac[0] = fac[1] = 1;
        inv[0] = inv[1] = 1;
        for (long i = 1; i <= N; i++)
        {
            fac[i] = (fac[i - 1] * i) % MOD;
            inv[i] = RepPow(fac[i], MOD - 2);
        }
    }
    public long nCr(long n, long r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        long res = fac[n];
        res = (res * inv[n - r]) % MOD;
        res = (res * inv[r]) % MOD;
        return res;
    }
    long RepPow(long x, long p, long m = 1000000007)
    {
        long res = 1;
        while (p > 0)
        {
            if ((p & 1) == 1) res = (res * x) % m;
            x = (x * x) % m;
            p >>= 1;
        }
        return res % m;
    }
}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 33244
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

int main()
{
 hs;

 ll a,b;
 cin>>a>>b;
 ll cnt=0;
 ll rem=1;
 while(rem<b)
 {
  cnt++;
  rem+=a-1;

 }
 cout<<cnt<<endl;


 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(y % 2 == 0 && y >= 2 * x && 4 * x >= y)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


}



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

long long r, g, b, n;

long long solve();

int main() {
  cin >> r >> g >> b >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(long long i = 0; i <= n; ++i)
    for(long long j = 0; j <= n; ++j) {
      long long now = n - i * r - j * g;
      if(now >= 0 && now % b == 0) ++ans;
    }
  return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i,a,amax=1,amin=1000000000;
  cin>>n;
  for (i = 0; i < n; i++) {
    cin>>a;
    if(a==max(a,amax))amax=a;
    if(a==min(a,amin))amin=a;
  }
  cout<<amax-amin<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys


alph="abcdefghijklmnopqrstuvwxyz"
allis=list(alph)
S=input()
if(S=="zyxwvutsrqponmlkjihgfedcba"):
    print(-1)
    sys.exit()

"""
if(S=="abcdefghijklmnopqrstuvwxyz"):
    print("b")
    sys.exit()
"""
for i in alph:
    if(i not in S):
        print(S+i)
        sys.exit()
        
"""
outp=""
for i in range(len(S)):
    if(S[i]==alph[i]):
        outp+=S[i]
    else:
        outp=outp[:-1]
        outp=outp+alph[i]
        break
"""
l=-1
for i in range(len(S)-1)[::-1]:
    if(ord(S[i])<ord(S[i+1])):
        l=i
        break
        
x=sorted(S[i+1:])
for i in x:
    if(i>S[l]):
        print(S[:l]+i)
        sys.exit()
print("b")


Measured memory_bytes: 3064
import numpy as np

a = input().split()
H = int(a[0])
W = int(a[1])
K = int(a[2])
  
b = []
for i in range(H):
  line = input()
  row = []
  for j in range(W):
    if line[j] == ".":
      row.append(0)    
    elif line[j] == "#":
      row.append(1)
  b.append(row)
b = np.array(b)

r = np.zeros(H)
c = np.zeros(W)

def plus1(x):
  x[0] += 1
  for i in range(len(x)):
    if i < len(x)-1:
      if x[i] == 2:
        x[i] = 0
        x[i+1] += 1
      

count = 0
while r[-1] < 2:
  while c[-1] < 2:
    #print(r, c)
    if K == np.dot(r,(np.dot(b,c))):
      count += 1
    plus1(c)
  c = np.zeros_like(c)
  plus1(r)
    
print(count)

Measured memory_bytes: 27296
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int a, b;
    cin >> a >> b;
    a--, b--;
    cout << b / a + (bool)(b % a) << "\n";
}


Measured memory_bytes: 256
function Main(input) {

    const tmp = input.split(' ');

    const a = parseInt(tmp[0], 10);
    const b = parseInt(tmp[1], 10);

    const sum = a * b;
    if ((sum % 2) === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int h[101][101];

int main() {

    int N;
    cin >> N;

    for (int x = 0; x <= 100; x++) for (int y = 0; y <= 100; y++) {
        h[y][x] = -1;
    }

    for (int i = 0; i < N; i++) {
        int cx, cy, ch;
        cin >> cx  >> cy >> ch;

        for (int x = 0; x <= 100; x++) for (int y = 0; y <= 100; y++) {

            int _h = max(0, abs(cx - x) + abs(cy - y) + ch);
            if (ch > 0) {
                if (h[y][x] == -1) h[y][x] = _h;
                else {
                    if (h[y][x] != _h) h[y][x] = -2;
                }
            } else {
                if (h[y][x] > _h) h[y][x] = -2;
            }

        }
    }

    int ax, ay = 0;
    for (int x = 0; x <= 100; x++) for (int y = 0; y <= 100; y++) {
        if (h[y][x] > 0) {
            ax = x;
            ay = y;
        }
    }

    cout << ax << " " << ay << " " << h[ay][ax] << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }
    println!("{}", cmp::min(a, b) + cmp::min(c, d))
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

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;
}

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

   int sum = 0;
   for(int i = 1; i <= N; i++){
      sum += L + i - 1;
   }

   int diff_min = INF;
   int ans;
   for(int i = 1; i <= N; i++){
      int sum_tmp = 0;
      for(int j = 1; j <= N; j++){
         if(i != j){
            sum_tmp += L + j -1;
         }
      }
      int diff_sum = abs(sum_tmp - sum);
      if(diff_sum < diff_min){
         diff_min = diff_sum;
         ans = sum_tmp;
      }
   }

   cout << ans << endl;



   return 0;
}

Measured memory_bytes: 256
N = int(input())
T = [];X = [];Y = []
for _ in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
if N == 1:
    print('Yes' if T[0] == sum(X+Y) else 'No')
    exit()
for i in range(N):
    if i == 0: continue
    d = abs(X[i] + Y[i] - X[i-1] - Y[i-1])
    t = T[i] - T[i-1]
    if (t + d) % 2 or t < d:
        print('No')
        exit()
else:
    print('Yes')

Measured memory_bytes: 17596
#coding:UTF-8
def Check(P,k,w):
    i=0
    for j in range(k):
        s=0
        while s+w[i]<=P:
            s+=w[i]
            i+=1
            if i==n:
                return n
    return i

def Allocation(n,k,w):
    left=0
    right=100000000000000
    while right-left > 1:
        mid=int((left+right)/2)
        v=Check(mid,k,w)
        if v>=n:
            right=mid
        else:
            left=mid
    print(right)
  
if __name__=="__main__":
    a=input()
    n=int(a.split(" ")[0])
    k=int(a.split(" ")[1])
    w=[]
    for i in range(n):
        w.append(int(input()))
    Allocation(n,k,w)

Measured memory_bytes: 11628
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string S;
    cin >> S;

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

    char ans = 'a';
    rep(i, S.size()){
        if(S[i] == ans){
            ans++;
        }else if(S[i] > ans){
            break;
        }
    }

    if(ans > 'z'){
        cout << "None" << endl;
    }else{
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001




int main() {
    ll N; cin >> N;
    cout << N * (N-1) / 2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int a, b, count=0;

	cin >> a >> b;
	vector<int> c(a);

	for (int i = 0;i < a;i++)
	{
		cin >> c[i];
	}

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

	for (int i = 0;i < b;i++)
	{
		count += c[i];
	}
	cout << count << endl;
}

Measured memory_bytes: 3624
S = input()
year = int(S[0:4])
mon = int(S[5:7])
day = int(S[8:])
#print(year,mon,day)
if year <= 2019 and 1 <= mon <= 4 and 1 <= day <= 30:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanRunes()
	t := scanRunes()

	ss := s
	n := (len(t) + len(s) - 1) / len(s)
	for i := 0; i < n; i++ {
		ss = append(ss, s...)
	}

	zarr := Zalgorithm(string(t) + "#" + string(ss))
	zarr = zarr[len(t)+1:][:len(s)]

	for i := 0; i < len(s); i++ {
		zarr[i] = zarr[i]/len(t)
		if zarr[i] != 0 {
			zarr[i] = 1
		}
	}

	cnt := 0
	done := make([]int, len(s))
	memo := make([]int, len(s))
	var dfs func(to int) int
	dfs = func(to int) int {
		if cnt == done[to] {
			return -1
		}

		if zarr[to] == 0 {
			return 0
		}

		done[to] = cnt
		if memo[to] == 0 {
			memo[to] = dfs((to+len(t))%len(s))
			if memo[to] != -1 {
				memo[to]++
			}
		}
		return memo[to]
	}

	ans := 0
	for i := 0; i < len(s); i++ {
		if zarr[i] == 0 {
			continue
		}
		cnt++
		t := dfs(i)
		if t == -1 {
			fmt.Fprintln(wr, -1)
			return
		}
		ans = max(ans, t)
	}

	fmt.Fprintln(wr, ans)

}

// Zalgorithm function
func Zalgorithm(s string) []int {
	n := len(s)
	res := make([]int, n)
	i, j := 1, 0
	for i < n {
		for i+j < n && s[j] == s[i+j] {
			j++
		}
		res[i] = j
		if j == 0 {
			i++
			continue
		}
		k := 1
		for i+k < n && k+res[k] < j {
			res[i+k] = res[k]
			k++
		}
		i += k
		j -= k
	}
	return res
}


Measured memory_bytes: 94080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
signed main(){
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    map<int,int>mp;
    int ans = 0;
    reverse(all(v));
    for(int i = 0; i < v.size(); ++i){
        auto itr = mp.upper_bound(v[i]);
        mp[v[i]]++;
        if(itr == mp.end())
            ++ans;
        else{
            mp[itr -> first]--;
            if(mp[itr -> first] == 0) mp.erase(itr);
        }
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 7168
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a>=k){
        cout << k << endl;
        return 0;
    }
    k -= a;
    if(b>k){
        cout << a << endl;
        return 0;
    }
    k -=b;
    cout << a-k << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

void solve(long long N, long long A, long long B){
	if(A>B or (N==1 and A!=B)){
		cout<<0<<endl;
		return;
	}
	long long M = (B*(N-1)+A), m = (A*(N-1)+B);
	dump(M);
	dump(m);
	cout<<M-m+1<<endl;
}

int main(){	
	long long N;
	long long A;
	long long B;
	scanf("%lld",&N);
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(N, A, B);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll x, y;
  std::cin >> x >> y;
  init();
  if((x+y)%3!=0||(max(x, y)>2*min(x, y))){
    std::cout << 0 << '\n';
    exit(0);
  }
  ll num = (x+y)/3;
  ll ooi = max(x, y) - min(x, y);
  ll a = num - ooi;
  if(a%2!=0){
    std::cout << 0 << '\n';
    exit(0);
  }
  a/=2;
  std::cout << comb(num, a) << '\n';
  return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n;
    cin >> n;
    map <string, int> mp;
    string preW;
    bool flag = true;
    rep (i, n) {
        string w;
        cin >> w;
        if (i != 0) flag &= (preW.back() == w.front());
        flag &= (mp[w] == 0);
        mp[w] = 1;

        preW = w;
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sort random_shuffle
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if (a<=8 && b<=8)
	   cout<<"Yay!"<<endl;
	else
	   cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256