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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = 0;
    bool result = true;
    if (s.size() % 2 != 0)
    {
        result = false;
    }
    for (auto &c : s)
    {
        if (n == 0)
        {
            if (c != 'h')
            {
                result = false;
            }
            n = 1;
        }
        else
        {
            if (c != 'i')
            {
                result = false;
            }
            n = 0;
        }
    }

    if (result)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int L = a + b;
  int R = c + d;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
  	
     
}

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

std::vector<int> z_algorithm(const std::string& S) {
	const int N = S.size();
	std::vector<int> Z(N, -1);
	Z[0] = N;
	int matched_length = 0;
	for (int i = 1; i < N; i++) {
		int j = i + matched_length;
		while (j < N && S[j - i] == S[j]) j++;
		Z[i] = matched_length = j - i;
		if (Z[i] == 0) continue;
		for (j = i + 1; j < i + Z[i] && Z[j - i] < i + Z[i] - j; j++) Z[j] = Z[j - i];
		matched_length = i + Z[i] - j;
		i = j - 1;
	}
	return Z;
}

int main() {
	int N;
	std::string S;
	std::cin >> N >> S;

	int ans = 0;
	for (int i = 0; i < N; i++) {
		std::vector<int> Z = z_algorithm(S.substr(i));
		for (int j = 0; j < N - i; j++) ans = std::max(ans, std::min(j, Z[j]));
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
using namespace std;
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
int main()
{
    long long h, n, a[1001], b[1001], f[10001];
    memset(f, 127, sizeof(f));
    f[0] = 0;
    scanf("%lld%lld", &h, &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a[i], &b[i]);
    }
    for (int j = 0; j <= h; j++)
    {
        for (int i = 0; i < n; i++)
        {
            f[j] = min(f[j], f[max(0, j - a[i])] + b[i]);
        }
    }
    printf("%lld", f[h]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
int main() {
	cin >> n;
	vector<vector<int>> f(n, vector<int>(12));
	rep(i, n) {
		rep(j, 10) {
			cin >> f[i][j];
		}
	}
	vector<vector<int>> p(n, vector<int>(12));
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}
	ll res = inf;
	for (int bit = 1; bit < (1 << 10); bit++) {
		vector<ll> ff(n);
		rep(i, 11) {
			if (bit & (1 << i)) {
				rep(j, n) {
					if (f[j][i] == 1) {
						ff[j]++;
					}
				}
			}
		}
		ll ptr = 0;
		rep(j, n) {
			ptr += p[j][ff[j]];
		}
		chmax(res, ptr);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

typedef struct {
	int s, t, c;
}pro_t;

bool cmp(const pro_t& a, const pro_t& b) {
	return a.s < b.s ;
}
int main() {
	int N, C; cin >> N >> C;
	vector<pro_t> pro(N);
	vector<vector<int>> ch(31, vector<int>(TE + 2));

	for (int i = 0; i < N; i++) {
		 cin >> pro[i].s >> pro[i].t >> pro[i].c;	
	}
	
	//if (cmp(pro[0], pro[1])) cout << "ff" << endl;
	sort(pro.begin(), pro.end(),cmp);
	//cout << "sorted" << endl;
	
	for (int i = 0; i < N; i++) {
		int s = pro[i].s, t = pro[i].t, c = pro[i].c;
		if (ch[c][s + 1] == -1)ch[c][s + 1]++;
		else ch[c][s]++;
		if (ch[c][t] == 1)ch[c][t]--;
		else  ch[c][t + 1]--;
	}
	/*
	for (int i = 1; i <= 15; i++)printf("%2d ", i);
	cout << endl;
	for (int i = 1; i <= 4; i++) {
		//cout << "i=" << i << " ";
		for (int j = 1; j <= 15; j++) {
			//cout << ch[i][j] << " ";
			printf("%2d ", ch[i][j]);
		}
		cout << endl;
	}
	*/
	int ans = 1;
	vector<int> im(31);
	for (int i = 1; i <= 2e5; i++) {
		int temp = 0;
		for (int j = 1; j <= 30; j++) {
			im[j] += ch[j][i];
			temp += im[j];
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 29604
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>();

    let mut maxlen = 0;
    for i in 0..n - 2 {
        for j in i + 1 + maxlen..n {
            if n - j < j - i || n - j < maxlen {
                break;
            }
            let sub = &s[i..j];
            if sub.len() > maxlen {
                let rest = &s[j..];
                if rest.contains(&sub) {
                    maxlen = sub.len();
                } else {
                    break;
                }
            }
        }
    }
    println!("{}", maxlen);
}


Measured memory_bytes: 4352
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	ll a,b,x;
	cin>>a>>b>>x;
	ll aa=(a>0?(a-1)/x+1:0);
	ll bb=b/x+1;

	cout<<bb-aa<<endl;

	
	return 0;
}





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

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    long long count = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            for (int k = j + 1; k < n; k++)
                if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k] &&
                    a[i] + a[j] > a[k] && a[j] + a[k] > a[i] &&
                    a[i] + a[k] > a[j])
                    ++count;
    std::cout << count;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {
        
        
        //   0
        // 1[2]3 4 
        //   5
        public static int[] dice = new int[6];

        public static void left() {
            int[] dice2 = new int[6];
            dice2[0] = dice[3];
            dice2[1] = dice[0];
            dice2[2] = dice[2];
            dice2[3] = dice[5];
            dice2[4] = dice[4];
            dice2[5] = dice[1];
            dice = dice2;
        }
        public static void right() {
            int[] dice2 = new int[6];
            dice2[0] = dice[1];
            dice2[1] = dice[5];
            dice2[2] = dice[2];
            dice2[3] = dice[0];
            dice2[4] = dice[4];
            dice2[5] = dice[3];
            dice = dice2;
        }

        public static void south() {
            int[] dice2 = new int[6];
            dice2[0] = dice[4];
            dice2[1] = dice[1];
            dice2[2] = dice[0];
            dice2[3] = dice[3];
            dice2[4] = dice[5];
            dice2[5] = dice[2];
            dice = dice2;
        }

        public static void north() {
            int[] dice2 = new int[6];
            dice2[0] = dice[2];
            dice2[1] = dice[1];
            dice2[2] = dice[5];
            dice2[3] = dice[3];
            dice2[4] = dice[0];
            dice2[5] = dice[4];
            dice = dice2;
        }
        public static void east() {
            int[] dice2 = new int[6];
            dice2[0] = dice[0];
            dice2[1] = dice[4];
            dice2[2] = dice[1];
            dice2[3] = dice[2];
            dice2[4] = dice[3];
            dice2[5] = dice[5];
            dice = dice2;
        }
        public static void west() {
            int[] dice2 = new int[6];
            dice2[0] = dice[0];
            dice2[1] = dice[2];
            dice2[2] = dice[3];
            dice2[3] = dice[4];
            dice2[4] = dice[1];
            dice2[5] = dice[5];
            dice = dice2;
        }


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                
                dice[0]=5;dice[1]=4;dice[2]=1;dice[3]=3;dice[4]=6;dice[5]=2;
                int sum = 1;
                for (int i = 0; i < n; i++) {
                    string str = Console.ReadLine();
                    if(str.Equals("North")){north();}
                    if(str.Equals("East")){east();}
                    if (str.Equals("West")) { west(); }
                    if (str.Equals("South")) { south(); }
                    if (str.Equals("Right")) { right(); }
                    if (str.Equals("Left")) { left(); }
                    //Console.WriteLine(dice[2]);
                    sum += dice[2];
                }
               
                Console.WriteLine(sum);


            }
        }

        
    }



    
}

Measured memory_bytes: 5752
/*input
91
*/

#include <bits/stdc++.h>
using namespace std;

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 200003

long  divisors(long x) {
    long limit = x;
    long numberOfDivisors = 0;

    if (x == 1) return 1;

    for (long i = 1; i < limit; ++i) {
        if (x % i == 0) {
            limit = x / i;
            if (limit != i) {
                numberOfDivisors++;
            }
            numberOfDivisors++;
        }
        if(numberOfDivisors>=4)
        {
            break;
        }
    }

    return numberOfDivisors;
}
 bool isPrime(long n)
{
   
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (long i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
#define max_a 100001
bool visit[max_a]={false};
vector<long> a[max_a];
long sum=0;
long cost[max_a];
void dfs(long node)
{
    visit[node]=true;
    
    for(int i=0;i<(int)a[node].size();i++)
    {
        if(visit[a[node][i]]==false)
        {
            sum+=cost[a[node][i]];
            dfs(a[node][i]);
            
        }
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int flag=0;
    for(int i=0;i<(int)s.length();i++)
    {
        if(s[i]=='9')
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}




Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
def main():
    A,B,C,D = map(int,input().split())
    while True:
        C-=B
        if C <= 0:
            print('Yes')
            break
        A-=D
        if A <= 0:
            print('No')
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
// Author : Chi
// created :
//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb          push_back
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         1000000007
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define pdp(d,i)    fixed<<setprecision(i)<<d
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//namespaces
using    namespace __gnu_pbds;
using    namespace std;
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
long double dp[301][301][301];
long double rec(int x,int y,int z,int n){
    if(x < 0 || y < 0 || z < 0)
        return 0;
    if(x==0 && y==0 && z==0)
        return 0;
    if(dp[x][y][z] >= -0.9)
        return dp[x][y][z];
    return (dp[x][y][z] = (long double)(n + x * rec(x-1,y,z,n) + y * rec(x+1,y-1,z,n) + z*rec(x,y+1,z-1,n))/(long double)(x+y+z));
}
void solve(){
    int n;
    cin>>n;
    memset(dp,-1.0,sizeof dp);
    int ct[4];
    memset(ct,0,sizeof ct);
    r1n(kk,n){
        int t;
        cin>>t;
        ct[t]++;
    }
    cout<<pdp(rec(ct[1],ct[2],ct[3],n),10);
}

// Driver Code
int main(){
    TEST1
    return 0;
}


Measured memory_bytes: 426496
#include <stdio.h>
int main(void){
    int a,b,c,d;
    d = 0;
    int i;
    //a 
    //b 正規運賃
    scanf("%d %d %d",&a,&b,&c);
    d = a * c - b;
    printf("%d\n",d);
    for(i = 0; i < 9 ; i++){
         d = a * d - b;
        printf("%d\n",d);
    }    
}


Measured memory_bytes: 128
//b.c B-K-th Common Divisor
#include<stdio.h>

int min(int a,int b){
    if(a>b){
        return b;
    }
    return a;
}

int main(void){
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);

    int num = 0,i=min(a,b),ans;
    while(1){
        if(a%i==0 && b%i==0){
            num++;
            ans = i;
        }
        if(num == k){
            break;
        }
        i--;
    }

    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int main()
{
    int n,r;
    cin>>n;
    if(n%1000!=0)
    {
       r=(n/1000)+1;
       r=r*1000;
       cout<<r-n;
    }
    else
    {
        cout<<"0";
    }
}


Measured memory_bytes: 3552
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <math.h>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;

char a[8][8];

int solve (int H, int W, int K) {
   int res = 0;
   for (int hMask = 0; hMask < (1 << H); hMask++) {
      for (int wMask = 0; wMask < (1 << W); wMask++) {
         int count = 0;
         for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
               if (a[i][j] == '#'
                  && !(hMask & (1 << i))
                  && !(wMask & (1 << j))) {
                  count++;
               }
            }
         }
         if (count == K) {
            res++;
         }
      }
   }
   return res;
}

int main() {

   int H, W, K;
   scanf("%d %d %d", &H, &W, &K);

   for (int i = 0; i < H; i++) {
      scanf("%s", a[i]);
   }

   int ans = solve(H, W, K);
   printf("%d\n", ans);

   return 0;
}

Measured memory_bytes: 1732
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/aising2020/tasks/aising2020_a
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll l,r,d;
    cin >> l >> r >> d;
    ll ans = 0;
    for(int i = l;i<=r;i++){
        if(i%d==0) ans++;
    }
    cout << ans;

	return 0;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	tmp = 0
	for i, val in enumerate(A):
		if i == 0:
			tmp += 2*val
			continue
		if i % 2 == 1:
			tmp -= 2*val
		else:
			tmp += 2*val
	
	x = tmp / 2
	
	ans = []
	ans.append(int(x))
	for i, val in enumerate(A):
		tmp = (val - (ans[i]/2)) * 2
		ans.append(int(tmp))
	
	ans = ans[:-1]
	ans = [str(s) for s in ans]
	print(" ".join(ans))
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 28908
//============================================================================
// Name        : BinarySearch.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

void BubbleSort(vector<int>&);
int BinarySearch(const vector<int>&, const vector<int>&);
void WriteVector(const vector<int>&);

void WriteVector(const vector<int>& v){
	for(int i=0; i<v.size(); i++){
		cout << v.at(i) << "\n";
	}
}

void BubbleSort(vector<int>& v){
	bool changed = true;
	while(changed){
		changed = false;
	    for(int i=v.size()-1; 1<=i; i--){
		    if(v.at(i) < v.at(i-1)){
			    int tmp = v.at(i-1);
			    v.at(i-1) = v.at(i);
			    v.at(i) = tmp;
			    changed = true;
		    }
	    }
	}
	cout << "sorted" << "\n";
	WriteVector(v);
}

int BinarySearch(const vector<int>& unsorted_s, const vector<int>& sorted_t){

	int n_common = 0;

	for(int i=0; i<unsorted_s.size(); i++){
		int begin = 0;
		int end = sorted_t.size();
		//cout << "searching: " << unsorted_s.at(i) << "\n";
		while(begin < end){
		    int mid = (begin + end) / 2;

		    if(sorted_t.at(mid) == unsorted_s.at(i)){
		    	n_common = n_common + 1;
		    	//cout << "found: " << unsorted_s.at(i) << "\n";
		    	break;
		    }else if(sorted_t.at(mid) < unsorted_s.at(i)){
		    	//cout << "case1:  begin: " << begin << ", mid: " << mid << ", end: "
		    	//	 << end << ", unsorted_s.at(i): " << unsorted_s.at(i) << "\n";
		    	begin = mid+1;
		    }else{ //sorted_t.at(mid) > unsorted_s.at(i)
		    	//cout << "case2:  begin: " << begin << ", mid: " << mid << ", end: "
		    	//	 << end << ", unsorted_s.at(i): " << unsorted_s.at(i) << "\n";
		    	end = mid;
		    }
		}
	}
	return n_common;
}

int main() {
	int n, input;
	vector<int> s;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> input;
		s.push_back(input);
	}

	int m;
	vector<int> t;
	cin >> m;
	for(int i=0; i<m; i++){
		cin >> input;
		t.push_back(input);
	}

	//BubbleSort(t);

	int n_common = 0;
	n_common = BinarySearch(t, s);

	cout << n_common << "\n";

	return 0;
}



Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	char c1,c2,c3;
	char t1,t2,t3;

	cin>>c1>>c2>>c3;
	cin>>t1>>t2>>t3;

	int t=0;
	if(c1==t1)t++;
	if(c2==t2)t++;
	if(c3==t3)t++;
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int dp[50];
int fib(int n){
  if(n==0||n==1) return dp[n]=1;
  if(dp[n] != -1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}
int main(){
  int n,i;
  for(i=0;i<50;i++) dp[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  ll x;
  cin>>x;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) b[i]=a[i];
  repeat(i,1,n) {
    if(b[i-1]+b[i]>x) {
      if(b[i-1]+b[i]-x<=b[i]) {
        b[i] -= b[i-1]+b[i]-x;
      } else {
        b[i] =0;
        b[i-1]=x;
      }
    }
  }
  ll ans=0;
  rep(i,n) {
    ans+=a[i]-b[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#define LL long long


using namespace std;

int main() {
	LL n, count1 = 0, count2 = 0;
	cin >> n;
	vector<LL> v(n), ans(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	//1
	for (size_t i = 0; i < n; i++)
	{
		if ( i == 0)
		{
			if (v[0] == 0)
			{
				count1++;
				ans[i] = 1;
			}
			else
			{
				ans[i] = v[i];
			}
		}
		else
		{

			if ( ans[i-1] < 0 && ans[i - 1] + v[i] > 0 || ans[i - 1] > 0 && ans[i - 1] + v[i] < 0)
			{
				ans[i] = ans[i - 1] + v[i];
			}
			else if (ans[i - 1] + v[i] == 0)
			{
				if (ans[i - 1] < 0)
				{
					count1++;
					ans[i] = 1;
				}
				else
				{
					count1++;
					ans[i] = -1;
				}
			}
			else
			{
				count1 += abs(ans[i - 1] + v[i]) + 1;
				if (ans[i - 1] + v[i] < 0)
				{
					ans[i] = 1;
				}
				else if (ans[i - 1] + v[i] > 0)
				{
					ans[i] = -1;
				}
			}
		}
	}
	//2
	for (size_t i = 0; i < n; i++)
	{
		if (i == 0)
		{
			if (v[0] == 0)
			{
				count2++;
				ans[i] = -1;
			}
			else
			{
				count2 = abs(v[0]) + 1;
				if (v[0] < 0)
				{
					ans[0] = 1;
				}
				else
				{
					ans[0] = -1;
				}
			}
		}
		else
		{

			if (ans[i - 1] < 0 && ans[i - 1] + v[i] > 0 || ans[i - 1] > 0 && ans[i - 1] + v[i] < 0)
			{
				ans[i] = ans[i - 1] + v[i];
			}
			else if (ans[i - 1] + v[i] == 0)
			{
				if (ans[i - 1] < 0)
				{
					count2++;
					ans[i] = 1;
				}
				else
				{
					count2++;
					ans[i] = -1;
				}
			}
			else
			{
				count2 += abs(ans[i - 1] + v[i]) + 1;
				if (ans[i - 1] + v[i] < 0)
				{
					ans[i] = 1;
				}
				else if (ans[i - 1] + v[i] > 0)
				{
					ans[i] = -1;
				}
			}
		}
	}



	cout << min(count1,count2) << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

int main()
{
    std::uint32_t K, A, B;
    std::cin >> K >> A >> B;

    if(A % K == 0 || B % K == 0)
    {
        std::cout << "OK" << std::endl;
        return 0;
    }

    const auto AK = A / K;
    const auto BK = B / K;

    if(AK == BK)
    {
        std::cout << "NG" << std::endl;
        return 0;
    }
    else
    {
        std::cout << "OK" << std::endl;
        return 0;
    }
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main(){
 int x,y; cin >> x >> y;
 if ((x+y)%3!=0)cout << 0 << endl;
 else{
   int n=(x+y)/3;x-=n;y-=n;
   if(x<0 || y<0){
       cout << 0 << endl;
       return 0;
   }

  //cout << a << ' ' << b << ' ' <<  c << endl;
  //ll e=modinv(a,M),f=modinv(b,M);

  combination c(x+y);
  mint ans=c(x+y,x);
  cout  << ans.x << endl;
 }


}

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

int main (){
	int a,b;
	cin >> a >> b;
	if(a < b){
		cout << "a < b"<<endl;
	}else if(a > b){
		cout <<"a > b"<<endl;
	}else if(a == b){
		cout << "a == b"<<endl;
	}

	fflush(stdin);
	getchar();
return 0;
}

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn dfs(a: &Vec<isize>, n: usize, l: usize, r: usize, dp: &mut Vec<Vec<Option<isize>>>) -> isize {
    if let Some(val) = dp[l][r] {
        return val;
    } else if l == r {
        let val = if n % 2 == 0 { -a[l] } else { a[l] };
        dp[l][r] = Some(val);
        return val;
    }
    let rem = r - l + 1;
    let val = if rem % 2 == n % 2 {
        max!(
            a[l] + dfs(a, n, l + 1, r, dp),
            a[r] + dfs(a, n, l, r - 1, dp)
        )
    } else {
        min!(
            -a[l] + dfs(a, n, l + 1, r, dp),
            -a[r] + dfs(a, n, l, r - 1, dp)
        )
    };
    dp[l][r] = Some(val);
    val
}

fn solve() {
    let n = get!(usize);
    let a = get!([isize]);

    let mut dp = vec![vec![None; n]; n];
    let res = dfs(&a, n, 0, n - 1, &mut dp);
    println!("{}", res);
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

bool is_prime(int v) {
	if (v == 1) return false;

	for (int i = 2; i * i <= v; ++i) {
		if (v % i == 0) return false;
	}
	return true;
}

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

	vi v[5];
	for (int i = 2; i <= 55555; ++i) {
		if (is_prime(i)) {
			v[i % 5].push_back(i);
		}
	}

	rep(i, n) {
		if (i) printf(" ");
		printf("%d", v[1][i]);
	}
	printf("\n");
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int len = S.length();
		int[] ans = new int[len];
		int evepool = 0; // 偶数
		int oddpool = 0; // 奇数
		int lastR = 0;
		int firstL = 0;
		for(int i=0;i<len;i++){
			String tmp = S.substring(i,i+1);
			if("R".equals(tmp)){
				lastR = i;
				if(i%2==0){evepool++;}
				else{oddpool++;}
			}else{
				if(i-lastR==1){
					firstL=i;
					if(i%2==0){
						ans[i]+=evepool+1;
						ans[lastR]+=oddpool;
						evepool=0;
						oddpool=0;
					}else{
						ans[i]+=oddpool+1;
						ans[lastR]+=evepool;
						evepool=0;
						oddpool=0;
					}
				}else{
					if((i-firstL)%2==0){
					  ans[firstL]++;
					}else{
					  ans[lastR]++;
					}
				}
			}
		}
		for(int i=0;i<len;i++){
			if(i > 0)System.out.print(" ");
			System.out.print(ans[i]);	
		}
	}
}

Measured memory_bytes: 45796
#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
using namespace std;

int main()
{
	int n,m;
	list<int> a;
    cin>>n;
	for(int i=0;i<n;i++){
		int h,m;
		cin>>h>>m;
		a.push_back(h*100+m);
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int h,m;
		cin>>h>>m;
		a.push_back(h*100+m);
	}
	a.sort();
	a.unique();
	while(!a.empty()){
		int tmp=a.front();
		a.pop_front();
		printf(a.empty()?"%d:%02d\n":"%d:%02d ",tmp/100,tmp%100);
	}
    return 0;
}

Measured memory_bytes: 1192
from sys import stdin

def deal(x):
    if abs(x) < 1e-6: return 0
    else: return x

def solve(a, b, c, d, e, f):
    x = 0
    y = 0
    if b == 0:
        x = c / a
        y = (f - d * x) / e
    else:
        x = (b * f - e * c) / (b * d - e * a)
        y = (c - a * x) / b
    
    p = [deal(x), deal(y)]
    return p

for s in stdin:
    s = s[:-1]
    s = map(float, s.split())
    p = solve(s[0], s[1], s[2], s[3], s[4], s[5])
    print ("%.3f "%p[0] + "%.3f"%p[1])

Measured memory_bytes: 6260
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
x, y = 0, 0
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            x += 1
        if (i < j) and (a[i] > a[j]):
            y += 1

output = ((x * k * (k - 1) // 2) + (y * k)) % 1000000007
print(output)

Measured memory_bytes: 14420
# -*- coding: utf-8 -*-

N, A, B = map(int, input().split())

ans = 0
# 1～Nのループ
for i in range(1, N+1):

    sum1 = 0
    num = i
    # 各桁の値を合計していく
    for j in range(len(str(i))):
        sum1 += num % 10
        num = int(num / 10)
    # 条件に合っていれば答えに足す
    if sum1 >= A and sum1 <= B:
        ans += i

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    char tmp;
    string S;
    cin >> S;
    if(S[0]==S[2])
	puts("Yes");
    else
	puts("No");
    
    
    // ans = max(A*B, C*D);
    
    // cout <<ans<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
main(){
  int n;
  std::cin>>n;
  std::vector<int> a(n);
  for(auto& ai:a)std::cin>>ai;
  
  int64_t allxor = 0;
  for(auto ai:a)allxor ^= ai;
  
  for(auto ai:a)std::cout<< (allxor^ai) <<std::endl;
}


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



Measured memory_bytes: 3096
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  size_t size = str.length();
  int k=0;
  long long int n=0;
  long long int m=0;
  for(long long int i=0;i<size;i++){
    string substr=str.substr(k,1);
    if(substr == "0"){
      n=n+1;
    }else{
      m=m+1;
    }
    k=k+1;
  }
  if(n>=m){
    cout << m*2 << endl;
  }else{
    cout << n*2 << endl;
  }
  return 0;
}
  


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

const string t="CODEFESTIVAL2016";

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

	int ans=0;
	rep(i,16) ans+=s[i]!=t[i];
	cout << ans << endl;
	return 0;
}

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

const int mod = 1e9 + 7;
const int maxn = 1e3;
string g[maxn];
int dp[maxn + 1][maxn + 1] = {0};
int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++)
    cin >> g[i];
  dp[1][1] = 1;
  for (int i = 1; i <= h; i++)
    for (int j = 1 + (i == 1); j <= w; j++)
      if (g[i - 1][j - 1] == '.') {
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
      }
  cout << dp[h][w] << '\n';
}

Measured memory_bytes: 5248
MOD = 10 ** 9 + 7  # MODは変数に入れてしまったほうが打ち間違えなくていいです

N = int(input())
A = list(map(int, input().split()))

S = sum(A) % MOD
ans = 0

# A_Nも含まれてしまいますが、そのときはs=0なので問題ありません
for x in A:
    S -= x  # 自分と自分自身を掛けないように、先に引く必要があります
    S %= MOD  # MODはいちいち取っておくといいです
    ans += S * x
    ans %= MOD

ans %= MOD  # この行は完全に不要ですが、最後だけMODを取り忘れてWAになるミスは非常によくあるので、必要以上に取っておくと安心できます
print(ans)

Measured memory_bytes: 104920
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int mod=1e9+7;
const int N=1000005;
int c[105],n,ans=1;
char s[N];

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	rep(i,1,n)
		c[s[i]-'a']++;
	rep(i,0,25)
		ans=(ll)ans*(c[i]+1)%mod;
	ans=(ans+mod-1)%mod;
	cout<<ans<<endl;

	return 0;
}

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

int main() {
    int N,T;
    cin>>N>>T;
    const int n=N;
    int c[n], t[n];
    int answer = 1001;
    for(int i=0; i<n; i++){
        cin>>c[i]>>t[i];
    }
    for (int i=0; i<N; i++) {
        if(t[i]<=T and c[i]<answer)
            answer =c[i];
    }
    if(answer < 1001)
       cout<<answer;
    else
        cout<<"TLE";
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  int ans;
  if (a==b) {
   ans=a+b;
  }
  else if(a>b) {
    ans=a+a-1;
  }
  else if(a<b) {
    ans=b+b-1;
  }
  
   cout << ans << endl;
}


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

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC";
    else cout<<"ABC";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3588
require 'pp'

def calc(p1, p2)
  x = p1[0]-p2[0]
  y = p1[1]-p2[1]
  Math.sqrt(x*x+y*y)
end

def permutation(a, x, xx)
  if a.size == 0
    return xx << x
  end

  a.each.with_index do |c, i|
    b = a.dup
    b.delete_at(i)
    permutation(b, x + [c], xx)
  end
end

def factr(n)
  (1..n).reduce(&:*)
end

def main(a, n)
  f = factr(n)

  xx = []
  permutation(a, [], xx)

  total = 0
  xx.each do |x|
    sum = 0
    x.each_cons(2) do |a, b|
      sum += calc(a, b)
    end
    total += sum / f
  end

  puts total
end

n = gets.chop.to_i
a = []
n.times { a << gets.chomp.split.map(&:to_i) }
main(a, n)

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	vector<int> input(100'001, 0);
	long long int sum = 0;

	rep(i, n){
		int a;
		cin >> a;

		input[a]++;
		sum += a;
	}

	int q;
	cin >> q;

	vector<long long int> ans;

	rep(i, q){
		int b, c;
		cin >> b >> c;

		int place = input[b];
		input[b] = 0;

		input[c] += place;

		sum += place * (c - b);

		ans.push_back(sum);
	}

	rep(i, ans.size()){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4640
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

typedef long long ll;
#define MAX_N 100001
using namespace std;
int main(){
    int n;
    ll a[MAX_N];
    ll b[MAX_N];
    cin >> n;
    for(int i=0;i<n+1;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }

    ll ans=0;
    ll rest=a[0];
    for(int i=0;i<n;i++){
        if(rest>b[i]){
            ans+=b[i];
            rest=a[i+1];
        }else{
            if(b[i]-rest<a[i+1]){
                ans+=b[i];
                rest=a[i+1]-(b[i]-rest);
            }else{
                ans+=a[i+1]+rest;
                rest=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int n=(int)s.size();
vector<int>ones(n+1);
for(int i=0;i<n;i++){
    if(s[i]=='1')ones[i+1]=1;
}
for(int i=1;i<=n;i++){
    ones[i]+=ones[i-1];
}
cout<<min(ones[n],n-ones[n])*2;
    return 0 ;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}
 
vector <pll> lines;
int n;
ll c, h[N], dp[N];
int pos = 0;
 
ld cross(pll a, pll b) {
	return (b.S - a.S + 0.0) / (a.F - b.F + 0.0);
}
 
void add(pll new_line) {
	while (sz(lines) > 1) {
		int last = sz(lines) - 1;
		if (cross(lines[last], lines[last - 1]) < cross(new_line, lines[last - 1]))
			break;
		lines.pop_back();
	}
	pos = min(pos, sz(lines) - 1);
	lines.pb(new_line);
}
 
ll get_min(ll x) {
	while (pos != sz(lines) - 1 && cross(lines[pos], lines[pos + 1]) < x + 0.0)
		pos++;
	return lines[pos].F * x + lines[pos].S;
}
 
int main() {
	data();
	scanf("%d %lld", &n, &c);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", &h[i]);
   	add({-2 * h[1], h[1] * h[1] + dp[1]});
   	for (int i = 2; i <= n; ++i) {
   		dp[i] = get_min(h[i]) + h[i] * h[i] + c;		
   		add({-2 * h[i], dp[i] + h[i] * h[i]});
   	}
   	printf("%lld", dp[n]);
}
 
/*
	AMIR LOH	
*/

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  cin >> a >> b;
  if(a*b%2==0)pr("Even");
  else pr("Odd");
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

signed main() {

  int n;

  string s1;

  set<string> S;

  cin >> n;

  rep(i,n) {

    cin >> s1;

    S.insert(s1);

  }

  cout << S.size() << endl;

}



Measured memory_bytes: 19220
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    a[i]-=(i + 1)
a.sort()
mid1 = a[int(len(a) / 2) - 1]
mid2 = a[int(len(a) / 2)]
res1 = res2 = 0
for i in range(n):
    res1+=abs(a[i] - mid1)
    res2+=abs(a[i] - mid2)
print(min(res1,res2))

Measured memory_bytes: 26184
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
      Scanner scan = new Scanner(System.in);
      long N = scan.nextLong();
      long D = scan.nextLong();

      int ans = 0;
      for(int i = 0;i < N;i++){
        long x = scan.nextLong();
        long y = scan.nextLong();
        if((x * x + y * y) <= D * D){
            ans++;
        }
      }
        System.out.println(ans);
    }
}

Measured memory_bytes: 59708