akhauriyash/Code-Regression huggingface dataset:
buildings = []
4.times do
    building = []
    3.times do
        floor = []
        10.times do
            floor.push(0)
        end
        building.push(floor)
    end
    buildings.push(building)
end

n = gets.to_i
n.times do
    b,f,r,v=gets.chomp.split(" ").map(&:to_i)
    buildings[b-1][f-1][r-1] += v
end

buildings.each_with_index do |building, i|
    puts "####################" if i != 0
    building.each do |floor|
        puts " " + floor.join(" ")
    end
end



Measured memory_bytes: 8884
#include<bits/stdc++.h>
using namespace std;
int n;
int find_p(int x) {
	int tmp=x;
	while(tmp>=10) tmp/=10;
	return tmp;
}
int ans=0,c[20][20];
int main()
{
	memset(c,0,sizeof(c));
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		int j=find_p(i),k=i%10;
		c[j][k]++;
	}
	for(int i=0;i<=9;++i)
		for(int j=0;j<=9;++j)
			ans+=c[i][j]*c[j][i];
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

int table[101];

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= 100; ++i) {
        for (int n = i; n > 0 && n % 2 == 0; n /= 2) {
            ++table[i];
        }
    }
    int ans = 0;
    int tmp = -1;
    for (int i = 1; i <= N; ++i) {
        if (table[i] > tmp) {
            tmp = table[i];
            ans = i;
        }
    }
    cout << ans << endl;
}


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

#define MOD 998244353

long long quick_powll(long long x, long long n){
    if(n == 0)
    return 1;
    if(n % 2 == 0)
    return quick_powll(x * x % MOD, n / 2);
    else
    return x * quick_powll(x, n - 1) % MOD;
}

int main()
{
    int n;
    cin >> n;
    vector<int> d(n, 0);
    vector<int> dd(n);
    int maxd = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> dd[i];
        d[dd[i]]++;
        maxd = max(maxd, dd[i]);
    }

    long long ans = 0;
    if(d[0] == 1 && dd[0] == 0)
    {
        int i = 0;
        for (i = maxd; i >= 0; i--)
        {
            if(d[i] == 0)break;
        }
        if(i == -1)
        {
            ans = 1;
            for (int i = 1; i <= maxd; i++)
            {
                ans *= quick_powll(d[i - 1], d[i]);
                ans %= MOD;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    sort(ALL(a));
    ll x=*(lower_bound(ALL(a),a[n-1]/2)-1);
    ll y=*(lower_bound(ALL(a),a[n-1]/2));
    if (y==a[0] or a[n-1]-y>x){
        cout << a[n-1] << " " << y << endl;
    }else{
        cout << a[n-1] << " " << x << endl;
    }
    return 0;
}


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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

void solve() {
  int N;
  int a, b;
  int ans = 0;
  int cnt = 0;
  cin >> N;
  rep(i, 0, N) {
    cin >> a >> b;
    if (a == b) {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }
  cout << ((ans >= 3) ? "Yes" : "No") << endl;
}

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

Measured memory_bytes: 3648
#import numpy as np
import sys
#from collections import deque
#import copy


def xnxn(n=0, flag="v"):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            if flag == "l":
                return temp
            else:
                return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


n = xnxn()
if n == 1:
    print(1)
    sys.exit()

a = xnxn()

a.sort()

a_max = max(a)

dp = [1] * (a_max+1)


if a[0] != a[1]:
    count = 1
else:
    count = 0
for k in range(1, a_max // a[0]+1):
    dp[a[0] * k] = 0

for i in range(1, n):
    if dp[a[i]] == 1:
        for k in range(1, a_max // a[i]+1):
            dp[a[i] * k] = 0
        if i+1 < n and a[i] == a[i+1]:
            continue
        count += 1

print(count)


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

int D[55][55];
char S[55][55];
queue<pair<int, int>> Q;

int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++) scanf("%s", S[i]);
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    Q.push(make_pair(0, 0));
    S[0][0] = '#';
    int score = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') score++;
        }
    }
    while (Q.size()) {
        pair<int, int> p = Q.front();
        Q.pop();
        for (int i = 0; i < 4; i++) {
            int y = p.first + dy[i];
            int x = p.second + dx[i];
            if (y >= 0 && y < H && x >= 0 && x < W && S[y][x] == '.') {
                D[y][x] = D[p.first][p.second] + 1;
                S[y][x] = '#';
                Q.push(make_pair(y, x));
            }
        }
    }
    if (D[H-1][W-1] == 0) score = -1;
    else score = score - D[H-1][W-1];
    printf("%d\n", score);
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool flag = true;
  REP(i,s.size()) {
    if(i % 2 == 0 && s[i] == 'L') flag = false;
    if(i % 2 == 1 && s[i] == 'R') flag = false;
    if(s[i] == 'U') continue;
    if(s[i] == 'D') continue;
    if(s[i] == 'R') continue;
    if(s[i] == 'L') continue;
    flag = false;
  }
  YesorNo(flag);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100005
int arr[N][3];
int vaction(int n)
{
    for(int i=1;i<n;i++)
    {
        arr[i][0]+=max(arr[i-1][1],arr[i-1][2]);
        arr[i][1]+=max(arr[i-1][0],arr[i-1][2]);
        arr[i][2]+=max(arr[i-1][0],arr[i-1][1]);
    }
    return max((max(arr[n-1][0],arr[n-1][1])),arr[n-1][2]);
}

int main() 
{
int n,a,b,c;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>a>>b>>c;
    arr[i][0]=a;
    arr[i][1]=b;
    arr[i][2]=c;
}
	cout<<vaction(n)<<"\n";
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int main(void)
{
    double x1, y1, x2, y2, x3, y3, xp, yp;
    double pa[2], pb[2], pc[2], ab[2], ac[2], bc[2];
    double z1, z2, z3;
    int i;

    while(fscanf(stdin,"%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF){

        //ベクトルの計算
        pa[0] = xp - x1;
        //printf("%lf\n", pa[1]);
        pa[1] = yp - y1;
        //printf("%lf\n", pa[2]);
        pb[0] = xp - x2;
        //printf("%lf\n", pb[1]);
        pb[1] = yp - y2;
        //printf("%lf\n", pb[2]);
        pc[0] = xp - x3;
        //printf("%lf\n", pc[1]);
        pc[1] = yp - y3;
        //printf("%lf\n", pc[2]);



        //外積の計算
        //ベクトルaとベクトルbの計算
        z1 = pa[0] * pb[1] - pa[1] * pb[0];
        //ベクトルaとベクトルbの計算
        z2 = pc[0] * pa[1] - pc[1] * pa[0];
        //ベクトルbとベクトルcの計算
        z3 = pb[0] * pc[1] - pb[1] * pc[0];

        //printf("%lf, %lf, %lf\n", z1, z2, z3);

        if (z1 > 0.0 && z2 > 0.0 && z3 > 0.0){
            printf("YES\n");
        }else if (z1 < 0.0 && z2 < 0.0 && z3 < 0.0){
            printf("YES\n");
        }else {
            printf("NO\n");
        }
    }

    return (0);
}


Measured memory_bytes: 1972
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt
import kotlin.math.tan

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (x, k, d) = readLongList()


    if (abs(x) / d >= k) {
        out.println(abs(x).toBigInteger() - k.toBigInteger() * d.toBigInteger())
    } else {
        val tmp = abs(x) / d
        val b = k - tmp

        val remain = abs(x) % d
        if (b % 2 == 0L) {
            out.println(remain)
        } else {
            out.println(abs(remain - d))
        }
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36728
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())
s1 = input()
s2 = input()
s3 = input()

ans = 0
for i in range(n):
  if s1[i] == s2[i] and s2[i] == s3[i]:
    pass
  elif s1[i] == s2[i] or s1[i] == s3[i] or s2[i] == s3[i]:
    ans += 1
  else:
    ans += 2
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  if(a<b)
    { if(b<c){
	printf("Yes\n");}
      else printf("No\n");}
    else
      printf("No\n");

  return 0;
}
  

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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n,0);
    rp(i,n-1){
        int a;
        cin >> a;
        ans.at(a-1)++;
    }
    for(auto an:ans){
        cout << an << endl;
    }
    return 0;
}

Measured memory_bytes: 3996
#include<iostream>
using namespace std;
#include<map>
#include<unordered_map>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define int long long int
#define mod 1000000007
int power(int a,int b)
{
	int x=pow(a,b);
	return x;
}
int function2(int arr[],int initial,int final,int mat[][13],int value,int total,int n,int memo[][4101])
{
	if(initial>final)
	{
		if(value==total)
		   return 0;
		else
		   return 1000000000;
	}
	if(memo[initial][value]!=-1)
	    return memo[initial][value];
	else
	{
		int newval=value;
		int j;
		for(j=0;j<n;j++)
		{
			if(mat[initial][j]==1)
			{
				newval|=power(2,j);
			}
		}
		int x=arr[initial]+function2(arr,initial+1,final,mat,newval,total,n,memo);
		int y=function2(arr,initial+1,final,mat,value,total,n,memo);
		memo[initial][value]=min(x,y);
		return memo[initial][value];
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	set<int> st1;
	int i;
	for(i=2;i*i<=a;i++)
	{
		if(a%i==0)
		{
			st1.insert(i);
			while(a%i==0)
			{
				a/=i;
			}
		}
	}
	if(a!=1)
	{
		st1.insert(a);
	}
	st1.insert(1);
	set<int> st2;
	st2.insert(1);
	for(i=2;i*i<=b;i++)
	{
		if(b%i==0)
		{
			st2.insert(i);
			while(b%i==0)
			{
				b/=i;
			}
		}
	}
	if(b!=1)
	{
		st2.insert(b);
	}
	int answer=0;
	for(int x:st1)
	{
		auto it=st2.find(x);
		if(it!=st2.end())
		   answer++;
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <vector>
using namespace std;

typedef struct Node {
	int v;
	Node *l, *r;
	Node() {
		this->v = 0;
		this->l = NULL;
		this->r = NULL;
	}
} Node;

void InsertNode(Node*& root, const int& v)
{
	if(root == NULL) {
		root = new Node;
		root->v = v;
		return;
	}
	if(v <= root->v) {
		InsertNode(root->l, v);
	} else {
		InsertNode(root->r, v);
	}
}

void PreOrder(Node* root)
{
	if(root == NULL) {
		return;
	}
	printf(" %d",root->v);
	PreOrder(root->l);
	PreOrder(root->r);
}

void InOrder(Node* root)
{
	if(root == NULL) {
		return;
	}
	InOrder(root->l);
	printf(" %d",root->v);
	InOrder(root->r);
}

int main()
{
	int T; scanf("%d",&T);
	Node* root = NULL;
	while(T--) {
		char s[7]; scanf("%s",s);
		if(s[0] == 'i') {
			int x; scanf("%d",&x);
			InsertNode(root, x);
		} else {
			InOrder(root);
			putchar('\n');
			PreOrder(root);
			putchar('\n');
		}
	}
	return 0;
}



Measured memory_bytes: 18204
#include <iostream>
using namespace std;
  
int main() {
  long long n;
  long long ans=__LONG_LONG_MAX__;
  cin >> n;
 
  
  for(int x=1;x<=(n/2)+1;x++){
    long long A=x;
    long long B=n-x;
    long long sumA=0;
    long long sumB=0;
    while(A>0){
      long long temp=A%10;
      sumA+=temp;
      A=A/10;
    }
    while(B>0){
      long long temp=B%10;
      sumB+=temp;
      B=B/10;
    }
    ans=min(ans,(sumA+sumB));
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();
            System.out.println(Math.min(N * A, B));
        }
    }
}


Measured memory_bytes: 27068
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N;
    cin >> N;
    if(N % 2 == 0) cout << N / 2 << endl;
    else cout << (int)(N / 2) + 1 << endl;
}


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

using namespace std;

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define dump(x) cerr << #x << "=" << x << endl

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;

int main(void) {
    string s;
    cin >> s;
    sort(all(s));
    if (s=="abc") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  double x1,y1,x2,y2;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  printf("%.8f\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
}

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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<P>> dp(n + 1, vector<P>(2, {0, 0}));
  dp[0][0] = {0, 1000};
  dp[0][1] = {0, 1000};
  for (int i = 0; i < n; i++) {
    // 株を最大化
    ll s = dp[i][1].first;
    ll y = dp[i][1].second;
    s += y / a[i];
    y -= (y / a[i]) * a[i];
    if (s > dp[i][0].first) {
      dp[i + 1][0] = {s, y};
    } else if (s == dp[i][0].first && y > dp[i][0].second) {
      dp[i + 1][0] = {s, y};
    } else {
      dp[i + 1][0] = dp[i][0];
    }
    // 金を最大化
    s = dp[i][0].first;
    y = dp[i][0].second;
    y += s * a[i];
    s = 0;
    if (y > dp[i][1].second) {
      dp[i + 1][1] = {s, y};
    } else {
      dp[i + 1][1] = dp[i][1];
    }
  }
  cout << dp[n][1].second << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cmath>
#include<ctime>
#include<cstring>
#define yyj(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define llg long long
llg n,i,a,b,tot,cs;
using namespace std;
char s[100010*3];
int main()
{
	//yyj("b");
	cin>>n>>a>>b;
	scanf("%s",s+1);
	for (i=1;i<=n;i++)
	{
		if (s[i]=='c') printf("No\n");
		if (s[i]=='a')
		{
			if (tot<a+b)
			{
				tot++;
				printf("Yes\n");
			}
			else printf("No\n");
		}
		if (s[i]=='b')
		{
			cs++;
			if (tot<a+b && cs<=b)
			{
				tot++;
				printf("Yes\n");
			}
			else printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
int b[maxn];
struct Node
{
    int x,y;
}w[maxn];
int vis[maxn];
vector<int>s[maxn];
bool cmp(Node a,Node b)
{
    if(a.x==b.x)
        return a.y<b.y;
    return a.x>b.x;
}
int ans=0;
bool cnp(int a,int b)
{
    return a>b;
}
int k=0;
void dfs(int x)
{
       for(int i=0;i<s[x].size();i++)
       {
           if(vis[s[x][i]]==0)
           {
           vis[s[x][i]]=1;
                ans+=a[++k];
                b[s[x][i]]=a[k];
                dfs(s[x][i]);
           }

       }
}
int main()
{
     int n;
    scanf("%d",&n);
     int x,y;
     ll sum=0,maxs=0;
     for(int i=0;i<n-1;i++)
        {
            scanf("%d%d",&x,&y);
           s[x].push_back(y);
           s[y].push_back(x);
        }
        for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
            sort(a,a+n,cnp);
     for(int i=1;i<=n;i++)
     {
        w[i].x=s[i].size();
         w[i].y=i;
     }

      sort(w+1,w+n+1,cmp);
        b[w[1].y]=a[0];
        vis[w[1].y]=1;
       dfs(w[1].y);
       printf("%d\n",ans);
       for(int i=1;i<=n;i++)
        printf("%d%c",b[i],i==n? '\n':' ');


    return 0;
}


Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,k;
  cin >> n >> k;
  vector<pii> a(n);
  REP(i,n) cin >> a[i].first >> a[i].second;
  sort(ALL(a));
  int ans = 0;
  int ka = 0;
  for(int i=0;ka<k&&i<n;++i){
    ka += a[i].second;
    ans = a[i].first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
    int key;
    struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

struct Node *treeMinimum(struct Node *x){
    while(x->left != NIL)
        x=x->left;
    return x;
}

struct Node *find(struct Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key)
            u=u->left;
        else
            u=u->right;
    }
    return u;
}

struct Node *treeSuccessor(struct Node *x){
    if(x->right != NIL)
        return treeMinimum(x->right);
    struct Node *y=x->parent;
    while(y != NIL && x == y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

void treeDelete(struct Node *z){
    struct Node *y;
    struct Node *x;
    
    if(z->left == NIL || z->right == NIL)
        y=z;
    else
        y=treeSuccessor(z);
    if(y->left != NIL)
        x=y->left;
    else
         x=y->right;
    if(x != NIL)
        x->parent = y->parent;
    if(y->parent == NIL)
        root=x;
    else{
        if(y == y->parent->left)
            y->parent->left=x;
        else
            y->parent->right=x;
    }
    if(y != z)
        z->key=y->key;

    free(y);
}


void insert(int k){
    struct Node *y=NIL;
    struct Node *x=root;
    struct Node *z;

    z=(struct Node *)malloc(sizeof(struct Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x != NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }
        else
            x=x->right;
    }
    z->parent=y;
    if(y==NIL)
        root=z;
    else{
        if(z->key < y->key)
            y->left=z;
        else
            y->right=z;
    }
}

void inorder(struct Node *u){
    if(u==NIL)
        return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(struct Node *u){
    if(u==NIL)
        return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(void){
    int n,i,x;
    char line[7];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",line);
        if(!strcmp(line,"insert")){
            scanf("%d",&x);
            insert(x);
        }
        else if(!strcmp(line,"print")){
            inorder(root);
            puts("");
            preorder(root);
            puts("");
        }
        else{
            scanf("%d",&x);
            struct Node *temp=find(root,x);
            if(temp != NIL)
                puts("yes");
            else puts("no");
        }
    }
    return 0;
}

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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 112345;
const int MOD = 1e9 + 7;

int n, a;
set<int> s;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    s.insert(a);
  }
  if (s.size() == n) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int a,b;cin>>a>>b;
  if((a-b)&1)cout<<"IMPOSSIBLE"<<endl;
  else cout<<(a+b)/2<<endl;
}


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

vector < char > from = {'3', '5', '7'};

int64_t rec (string &n, vector < char > &a, int j, map < char, int > &saw) {
    for (int i = 0; i < j; ++i) {
        if (n[i] > a[i])
            break;
        else if (a[i] > n[i])
            return int64_t(0);
    }
    if (j == int(a.size()) && saw['3'] && saw['5'] && saw['7'])
        return int64_t(1);
    else if (j == int(a.size()))
        return int64_t(0);
    else {
        int64_t res = 0;
        if (j) {
            for (char c: from) {
                a[j] = c;
                ++saw[c];
                res += rec(n, a, j + 1, saw);
                --saw[c];
                a[j] = '0';
            }
        }
        else {
            for (int i = 0; i < int(n.size()) - 2; ++i) {
                for (char c: from) {
                    a[i] = c;
                    ++saw[c];
                    res += rec(n, a, i + 1, saw);
                    --saw[c];
                    a[i] = '0';
                }
            }
        }
        return res;
    }
}

signed main () {
    vector < int64_t > three(10);
    vector < int64_t > fact(10);
    three[0] = fact[0] = 1;
    for (int64_t i = 1; i < 10; ++i) {
        three[i] = three[i - 1] * 3;
        fact[i] = fact[i - 1] * i;
    }
    
    string n;
    cin >> n;
    vector < char > a(int(n.size()), '0');
    map < char, int > saw;
    cout << rec(n, a, 0, saw) << '\n';
}


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

using namespace std;

int main()
{
    long long x;
    cin >> x;

    long long sum = 100;
    int i = 0;
    while (sum < x) {
        sum *= 1.01;
        i++;
    }

    cout << i << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	double ans=0,a;
	for(int i=0;i<n;i++) {
		cin>>a;
		ans+=1/a;
	}
	ans=1/ans;
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;
		
		for (int i = a; i <= b; i++) {
			if (i % k == 0) {
				count++;
				break;
			}
		}
		if (count == 0) {
			System.out.println("NG");
		} else {
			System.out.println("OK");
		}
	}
}

Measured memory_bytes: 35740
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;

const ll MAX_N=131072;
vector<int> G[1000010];
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N, Q;
struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }
    // k 番目のノードについて遅延評価を行う
    void eval(int k, int l, int r) {
        // 遅延配列が空でない場合、自ノード及び子ノードへの
         // 値の伝播が起こる
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            // 最下段かどうかのチェックをしよう
            // 子ノードは親ノードの 1/2 の範囲であるため、
            // 伝播させるときは半分にする
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            // 伝播が終わったので、自ノードの遅延配列を空にする
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        // k 番目のノードに対して遅延評価を行う
        eval(k, l, r);
        // 範囲外なら何もしない
        if(b <= l || r <= a) return;
        // 完全に被覆しているならば、遅延配列に値を入れた後に評価
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        // そうでないならば、子ノードの値を再帰的に計算して、
        // 計算済みの値をもらってくる
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        // 関数が呼び出されたら評価！
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};
int main(){
  int N,Q;cin>>N>>Q;
  LazySegmentTree seg(vector<ll>(N,0));
  rep(i,Q){
    int query;cin>>query;
    if (query==0){
      int s,t,x;cin>>s>>t>>x;
      seg.add(s-1,t,x);
    }else{
      int s,t;cin>>s>>t;
      cout<<seg.getsum(s-1,t)<<endl;
    }
  }
}



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

const int INF = 1e8;

const int MAXN = 210;
int N;
char adj[MAXN][MAXN];

int dist[MAXN][MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> adj[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) dist[i][j] = 0;
			else if (adj[i][j] == '1') dist[i][j] = 1;
			else dist[i][j] = INF;
		}
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	for (int st = 0; st < N; st++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (adj[i][j] == '1' && dist[st][i] == dist[st][j]) {
					cout << -1 << '\n';
					exit(0);
				}
			}
		}
	}

	int diam = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			diam = max(diam, dist[i][j]);
		}
	}
	cout << diam + 1 << '\n';

	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int A[N], B[N], C[N];
  for (int i=0 ; i<N ; i++) scanf("%d", &A[i]);
  for (int i=0 ; i<N ; i++) scanf("%d", &B[i]);
  for (int i=0 ; i<N ; i++) scanf("%d", &C[i]);
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);
  long long res=0;
  for (int i=0 ; i<N ; i++) {
    int b = B[i];
    long long a = (long long)(lower_bound(A, A+N, b) - A);
    long long c = (long long)(upper_bound(C, C+N, b) - C);
    res += a*(N-c);
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 1408
n,k = map(int,input().split())
s = input()

cnt = 0
for i in range(len(s)):
	if s[i] == 'L':
		if i == 0:
			continue
		if s[i-1] == 'L' :
			cnt += 1
	else:
		if i == len(s) - 1:
			continue
		if s[i+1] == 'R' :
			cnt += 1

print(min(n-1,cnt + k*2))

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

using namespace std;

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

    int n;
    cin >> n;

    int d[3009];

    for (int i=0; i<n; i++) cin >> d[i];

    int ret = 0;

    for (int i=0; i<n; i++) ret += d[i] -1;

    cout << ret << '\n';

    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = []
for _ in range(N):
    temp = int(input())
    a.append(temp)

index = 0
current = 0
count = 0
for i in range(N):
    if current == 2:
        print(count)
        break
    current = a[index]
    index = current - 1
    count += 1
else:
    print(-1)


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

int main(){
  int64_t a;
  cin >> a;
  
  int i=0;
  int64_t b=100;
  while(i<4200){
    b += b/100;
    i++;
    if(b>=a)
      break;
  }
  cout << i << endl;
}


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

long long int sum(int a, int b){
    long long int sum=0;
    while(a > 0){
        sum += a % 10;
        a /= 10;
    }

    while(b > 0){
        sum += b % 10;
        b /= 10;
    }
    return sum;
}

int main(){
    int n, a=1, b;
    long long int menorsum=1000000000;
    cin >> n;
    b = n-1;
    
    while(b > 0){
        if(sum(a, b) < menorsum) menorsum = sum(a, b);
        a++;
        b--;
    }

    cout << menorsum << 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++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

struct RUP{
  int n;
  vector<int> dat,laz;
  const int def=INT_MAX;
  RUP(){}
  RUP(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
    laz.clear();
    laz.resize(2*n-1,-1);
  }
  inline void eval(int len,int k){
    if(laz[k]<0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=laz[k];
      laz[k*2+2]=laz[k];
    }
    dat[k]=laz[k];
    laz[k]=-1;
  }
  int update(int a,int b,int x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b) return laz[k]=x;
    eval(r-l,k);
    dat[k]=min(update(a,b,x,k*2+1,l,(l+r)/2),
	       update(a,b,x,k*2+2,(l+r)/2,r));
    return dat[k];
  }
  int query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
  void update(int a,int b,int x){
    update(a,b,x,0,0,n);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, Q; cin >> N >> Q;
    vector<T> XST;
    vector<int> vals;
    rep(i, N) {
        int S, T, X; cin >> S >> T >> X;
        XST.pb(make_tuple(X, S, T));
        vals.pb(S-X);
        vals.pb(T-1-X);
    }
    int D[Q];
    rep(i, Q) {
        cin >> D[i];
        vals.pb(D[i]);
    }
    
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    map<int, int> idx;
    rep(i, vals.size()) idx[vals[i]] = i;
    
    sort(XST.begin(), XST.end());
    reverse(XST.begin(), XST.end());
    RUP lst(vals.size());
    rep(i, N) {
        int X = get<0>(XST[i]);
        int S = get<1>(XST[i]);
        int T = get<2>(XST[i]);
        lst.update(idx[S-X], idx[T-X-1]+1, X);
    }
    
    rep(i, Q) {
        int res = lst.query(idx[D[i]], idx[D[i]]+1);
        if (res==INT_MAX) cout << -1 << endl;
        else cout << res << endl;
    }
}

Measured memory_bytes: 84888
package main

import (
	"fmt"
)

func main() {
	var p, q, r int
	fmt.Scan(&p, &q, &r)
	list := make([]int, 6)
	list[0] = p + q
	list[1] = r + q
	list[2] = p + r
	list[3] = q + r
	list[4] = q + p
	list[5] = q + p

	minimum := minmin(list)

	fmt.Println(minimum)

}

func minmin(list []int) int {
	min := list[0]

	for i := 1; i < len(list); i++ {
		if min > list[i] {
			min = list[i]
		}
	}
	return min
}


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

using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    int c=a;
    int d= b;
    cout<<c/d<<endl;
    cout<<c%d<<endl;
    printf("%.10f",a/b);
    
    return 0;
    
}


Measured memory_bytes: 3220
#include <iostream>
#include <set>

int main()
{
   int length;
   std::cin >> length;
   std::multiset<int> ms;
   int value;
   for (int i = 0; i < length; i++) {
      std::cin >> value;
      if (!i) {
         ms.insert(value);
         continue;
      }
      auto itr = ms.lower_bound(value);
      if (itr == ms.begin()) {
         ms.insert(value);
      } else {
         itr--;
         if (*itr != value) {
            ms.erase(itr);
         }
         ms.insert(value);
      }
   }
   std::cout << ms.size() << std::endl;
   return 0;
}


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

void bubbleSort( int* x )
{
    for( int i = 0; i < 4; i++ )
    {
        for( int j = i; j < 5; j++ )
        {
            if( x[i] > x[j] )
            {
                int temp = x[i];
                x[i] = x[j];
                x[j] = temp;
            }
        }
    }
}

int main()
{
    int a[5];

    for( int i = 0; i < 5; i++ )
        cin >> a[i];

    bubbleSort(a);

    for( int i = 4; i >= 0; i-- )
    {
        cout << a[i];
        if( i != 0 )
            cout << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3096
//064 C - Colorful Leaderboard 2017/06/10

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n ;
    vector<int> a(n);
    rep(i ,n) cin >> a[i];
    int ans = 0; int genius=0;
    bool color[8]={false};
    rep(i ,n){
        if(a[i]<=399 && !color[0]) {++ans; color[0]=true;} 
        else if(a[i]>=400 && a[i]<=799 && !color[1]) { ++ans; color[1]=true; }
        else if(a[i]>=800 && a[i]<=1199 && !color[2]) { ++ans; color[2]=true; }
        else if(a[i]>=1200 && a[i]<=1599 && !color[3]) { ++ans; color[3]=true; }
        else if(a[i]>=1600 && a[i]<=1999 && !color[4]) { ++ans; color[4]=true; }
        else if(a[i]>=2000 && a[i]<=2399 && !color[5]) { ++ans; color[5]=true; }
        else if(a[i]>=2400 && a[i]<=2799 && !color[6]) { ++ans; color[6]=true; }
        else if(a[i]>=2800 && a[i]<=3199 && !color[7]) { ++ans; color[7]=true; }
        else if(a[i]>=3200) ++genius;
    }
    int absent=0;
    rep(i,8) if(!color[i]) ++absent;
    cout << ( absent==8 ? 1 : ans ) << " " << ans+genius << endl;
}

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

int index(int numToFind, std::vector<int> vectorToFindIn) {int len = vectorToFindIn.size();for (int i = 0; i < len; i++){if (vectorToFindIn[i] == numToFind){return i;}}return -1;}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,score;
	cin>>n;
	int p[n];
	int q[n];
	for (int i=0;i<n;++i)
	{
		cin>>p[i];
		q[i]=p[i];
	}
	sort(q,q+n);
	score=0;
	for (int i=0;i<n;++i)
	{
		if (q[i]!=p[i])
		{
			++score;
		}
	}
	if (score<=2)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;
    
    string s,s1;
    cin>>n;
    cin>>s>>s1;
    for(i=0;i<n;i++)
    {
        cout<<s[i]<<s1[i];
    }
    cout<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int d[108][108];

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

	if(K>(N-1)*(N-2)/2){
		cout<<-1<<endl;
		return 0;
	}

	for (int i = 0; i < N; ++i){
		for (int j = i+1; j < N; ++j){
			d[i][j] = 1;
		}
	}
	int cnt = 0;
	for (int i = 1; i < N-1; ++i){
		for (int j = i+1; j < N; ++j){
			if(cnt >= K)i=N,j=N;
			d[i][j] = 0;
			cnt++;
		}
	}
	int M = 0;
	for (int i = 0; i < N; ++i){
		for (int j = i+1; j < N; ++j){
			if(d[i][j])M++;
		}
	}
	cout<<M<<endl;
	for (int i = 0; i < N; ++i){
		for (int j = i+1; j < N; ++j){
			if(d[i][j]){
				cout<<i+1<<" "<<j+1<<endl;
			}
		}
	}
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			cerr<<d[i][j]<<" ";
		}
		cerr<<endl;
	}
}


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

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

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

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

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// <---------------------- > //


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

void MAIN() {
	cin>>s>>s;
	string ans = "";ans+='A';ans+=s[0];ans+='C' ;
	cout<<ans;
	cin>>s;
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {

		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
using namespace std;
int main() {
    string str;
    int number[10000] = {0};
    while (cin>>str) {
        for (int i = 0; i < str.size(); i++) {
            if (str[i] >= 'a'&&str[i] <= 'z') {
                number[str[i] - 'a'] += 1;
            }
            else if (str[i] >= 'A'&&str[i] <= 'Z') {
                number[str[i] - 'A'] += 1;
            }
        }
    }
    for (int i = 0; i < 26; i++) {
        cout << (char)(i+'a') << " : " << number[i] << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
LL INF = 1e9;
double EPS=1.0e-9;


    string s;
int main()
{
    cin>>s;
    LL ans=0;
    REP(i,(1<<(s.size()-1)) )
    {
        LL sum=0,val=0;
        REP(j,s.size())
        {
            val=val*10+s[j]-'0';
            //if(j==0)continue;
            if((i&(1<<(j)))>0)
            {
                //cout<<val<<" ";
                sum+=val;
                val=0;
            }
        }
                //cout<<val<<" ";
        sum+=val;
        val=0;
        
        //cout<<sum<<endl;
        ans+=sum;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int a, b, w, x, y;
 
int main () {
cin >> w >> a >> b;
if(a>b+w){
    y=a-(b+w);
     cout << y << endl;
}else if (b>a+w){
    x=b-(a+w);
    cout << x << endl;
    }else{
    cout << 0 << endl;
    }
}



Measured memory_bytes: 3600
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#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 mod             1000000007
#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());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    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 main(){
    cpp();
    ll n, k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(ll i=0; i<k; i++){
        ll d;
        cin>>d;
        while(d--){
            ll x;
            cin>>x;
            v[x]=1;
        }
    }
    ll cnt = 0;
    for(ll i=1; i<=n; i++){
        if(v[i]==0){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

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

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	int a[26] = {};
	for(auto x : s)
		a[x-'a']++;

	bool check = true;
	for(int i = 0; i < 26; i++)
		if(a[i] == 0){
			check = false;
			cout << (char)(i+'a') << endl;
			break;
		}

	if(check)
		cout << "None"<< endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

typedef unsigned long long ui;

int main()
{
    ui nx[101];
    ui dp[101][21] = {{}};

    int n;
    cin >> n;
    for( int iii=0; iii<n; ++iii ) {
        cin >> nx[iii];
    }

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

    for( int i=1; i<n-1; ++i ) {
        for( int j=0; j<=20; ++j ) {
            if ( dp[i-1][j] > 0 ) {
                ui const p = j + nx[i];
                if ( p >= 0 && p <= 20 )
                    dp[i][p] += dp[i-1][j];

                ui const m = j - nx[i];
                if ( m >= 0 && m <= 20 )
                    dp[i][m] += dp[i-1][j];
            }
        }
    }

/*
    for( int j=0; j<=20; ++j ) {
        for( int i=0; i<n-1; ++i ) {
            cout << dp[i][j] << ", ";
        }
        cout << endl;
    }
/**/

    cout << dp[n-2][nx[n-1]] << endl;
}

Measured memory_bytes: 1188
import sys
from math import gcd
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    ans = int(input())
    for _ in range(n - 1):
        val = int(input())
        ans = ans * val // gcd(ans, val)
    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> p;
  if (n % 2 == 1) {
    for (int i = 0; i < n - 1; i++)
      p.push_back(make_pair(i, n - 1));
    n--;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (i + j == n - 1)
        continue;
      p.push_back(make_pair(i, j));
    }
  }
  cout << p.size() << endl;
  for (auto &v : p)
    cout << v.first + 1 << " " << v.second + 1 << endl;
  return 0;
}


Measured memory_bytes: 384
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
 
import java.util.*;
class Main {
     
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String tar = sc.next().toLowerCase();
        int count = 0;
        while(true) {
            String tmp = sc.next();
            if(tmp.equals("END_OF_TEXT")) break;
            if(tar.equals(tmp.toLowerCase())) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26384