akhauriyash/Code-Regression huggingface dataset:
//
//  agc029b.cpp
//
//
//  Created by Yoshida Satoshi on 2018/12/15.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#define MAX 200010

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    map<ll,int> mp;
    map<ll,int> mpp;
    set<ll> st;
    
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        auto itr=mp.find(a);
        if(itr==mp.end())
        {
            mp[a]=1;
            mpp[a]=0;
            st.insert(-a);
        }
        else
        {
            itr->second++;
        }
    }
    
    ll ans=0;
    for(auto itr=st.begin();itr!=st.end();itr++)
    {
        int x=-*itr;
        for(ll k=1;k<2000000010&&mp[x]>0;k=k<<1)
        {
            ll y=k-x;
            auto z=mp.find(y);
            if(z!=mp.end()&&mp[y]>0)
            {
                if(y==x)
                {
                    int p=mp[x]/2;
                    ans+=p;
                    mp[x]-=2*p;
                }
                else
                {
                    int p=min(mp[y],mp[x]);
                    ans+=p;
                    mp[y]-=p;
                    mp[x]-=p;
                }
            }
        }
    }
    
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 36608
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxlen=200000;

int n,k,mod=1e9+7,ans=0ll;
int jc[5*maxlen+5];

int quick_power(int a,int b)
{
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod;
	}
	return res;
}

int ny(int n)
{
	return quick_power(n,mod-2)%mod;
}

int C(int n,int k)
{
	if (k<=0||n==k)  return 1;
	if (2*k>n)  k=n-k;
	
	return ((jc[n]*ny(jc[n-k])%mod)*ny(jc[k]))%mod;
}

inline void get_all_jc()
{
	jc[0]=1;
	for (int i=1;i<=5*maxlen;i++)  jc[i]=(jc[i-1]*i)%mod;
}

signed main()
{
	cin>>n>>k;
	get_all_jc();
	
	if (k>n)  return cout<<C(2*n-1ll,n)<<endl,0;
	else
	{
		ans=C(2*n-1ll,n);
		for (int i=1;i<=n-k-1;i++)  ans=((ans-C(n,i)*C(n-1,i-1))%mod+mod)%mod;
		return cout<<ans<<endl,0;
	}
}

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

int main() {
  double a,b,x;
  cin>>a>>b>>x;
  double volume=2*a*a*b-2*x;
  double vol=volume/(a*a*a);
  double ans=atan(vol);
  double uni=180.0/M_PI;
  if(a*a*b/2.0<x){
    ans*=uni;
    cout<<setprecision(10)<<ans<<endl;
  }
  else{
    double nibu=a*b*b;
    double akari=2.0*x;
    double answer=atan(nibu/akari);
    answer*=uni;
    cout<<setprecision(10)<<answer<<endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if((A+B)%2==0) {
			System.out.println((A+B)/2);
		}else {
			System.out.println("IMPOSSIBLE");
		}
		
		sc.close();	
	}
 
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());



int main(){
    llong s;
    cin >> s;
    if( s < 10){
        cout << s << endl;
        return 0;
    }
    int keta=0;
    llong tmp=1;
    while(1){
        tmp*=10;
        keta+=1;
        if( s < tmp) break;
    }
    llong ans=0;
    int bit=1;
    while(1){
        int ind=-1;
        REP(i,keta){
            if( bit & 1 <<i){
                if(ind == -1){
                    ans += s/int( pow( 10, keta-i-1));
                    ind = i;
                }
                else{
                    int x=s/ int( pow( 10, keta-i-1));
                    ans += x % int( pow(10, i-ind));
                    ind = i;
                } 
            }
        }
        ans += s% int( pow(10,keta-ind-1));
        bit +=1;
        if( bit >= int( pow(2,keta -1))) break;
    }
    cout << ans +s<< endl;
}

Measured memory_bytes: 512
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <ull, int> P;
char s[MAX][MAX];
int count[MAX][MAX], H, W;

void idou(){
    queue <P> Q;
    rep(i, H){
        rep(j, W) count[i][j] = -1;
    }
    Q.push(P(0, 0));
    count[0][0] = 0;
    P v;
    while (!Q.empty()){
        v = Q.front();
        Q.pop();
        if (v.first + 1 < H && s[v.first + 1][v.second] == '.' && count[v.first + 1][v.second] == -1) {
            Q.push(P(v.first + 1, v.second));
            count[v.first + 1][v.second] = count[v.first][v.second] + 1;
        }
        if (v.first - 1 >= 0 && s[v.first - 1][v.second] == '.' && count[v.first - 1][v.second] == -1) {
            Q.push(P(v.first - 1, v.second));
            count[v.first - 1][v.second] = count[v.first][v.second] + 1;
        }
        if (v.second + 1 < W && s[v.first][v.second + 1] == '.' && count[v.first][v.second + 1] == -1) {
            Q.push(P(v.first, v.second + 1));
            count[v.first][v.second + 1] = count[v.first][v.second] + 1;
        }
        if (v.second - 1 >= 0 && s[v.first][v.second - 1] == '.' && count[v.first][v.second - 1] == -1) {
            Q.push(P(v.first, v.second - 1));
            count[v.first][v.second - 1] = count[v.first][v.second] + 1;
        }
    }
}
int count_white(){
    int count = 0;
    rep(i, H){
        rep(j, W){
            if (s[i][j] == '.') count++;
        }
    }
    return count;
}

int main(){
    cin >> H >> W;
    rep(i, H){
        rep(j, W) cin >> s[i][j];
    }
    idou();
    if (count[H-1][W-1] == -1) {
        cout << -1 << endl;
    }
    else{
        int ans = count_white() - count[H-1][W-1] - 1;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;

    if(k <= a) {
        out(k+1);
        re0;
    }

    if(a+2 >= b) {
        out(k+1);
        re0;
    }

    ll cnt = a+1;  // いまの操作回数
    ll m = (k - cnt)/2;
    if(cnt%2 == k%2) {
        out(m*(b-a) + b);
    }
    else {
        out(m*(b-a) + b + 1);
    }

    re0;
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

//#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=85,NN=N*N*2ll;

int mat[N][N];
bool dp[N][N][NN];
int n,m;

inline void upd(int i,int j,int k)
{
    if(k+mat[i][j]<NN)
        dp[i][j][k+mat[i][j]]=1;
    dp[i][j][abs(k-mat[i][j])]=1;
}

void solve()
{
    mem(dp,0);

    cin>>n>>m;

    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
            cin>>mat[i][j];
    }

    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
        {
            int tmp;
            cin>>tmp;
            mat[i][j]=abs(mat[i][j]-tmp);
        }
    }

    dp[0][0][mat[0][0]]=1;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
        {
            for(int k=0;k<NN;++k)
            {
                if(!dp[i][j][k])
                    continue;

                upd(i+1,j,k);
                upd(i,j+1,k);
            }
        }
    }

    for(int i=0;;++i)
    {
        if(dp[n-1][m-1][i])
        {
            cout<<i;
            return;
        }
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 102272
import java.util.*;

class Main {
	
	static int north[] = {1,5,2,3,0,4};
	static int east[]  = {3,1,0,5,4,2};
	static int west[]  = {2,1,5,0,4,3};
	static int south[] = {4,0,2,3,5,1};
	static int left[]  = {0,3,1,4,2,5};
	static int right[] = {0,2,4,1,3,5};
	
	
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int n = in.nextInt();
			if(n==0) return ;
			int dice[] = {1,2,3,4,5,6};
			int ans = 1;
			for(int i=0; i<n; i++){
				String cmd = in.next();
				dice = change(dice, cmd);
				ans += dice[0];
			}
			System.out.println(ans);
		}
	}
	
	private static int[] change(int[] dice, String dir){
		int ans[] = new int[6];
		if(dir.equals("North")){
			for(int i=0; i<6; i++)
				ans[i] = dice[north[i]];
		}
		else if(dir.equals("East")){
			for(int i=0; i<6; i++)
				ans[i] = dice[east[i]];
		}
		if(dir.equals("West")){
			for(int i=0; i<6; i++)
				ans[i] = dice[west[i]];
		}
		if(dir.equals("South")){
			for(int i=0; i<6; i++)
				ans[i] = dice[south[i]];
		}
		if(dir.equals("Right")){
			for(int i=0; i<6; i++)
				ans[i] = dice[right[i]];
		}
		if(dir.equals("Left")){
			for(int i=0; i<6; i++)
				ans[i] = dice[left[i]];
		}
		return ans;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    cout << min(a, b) << " " << max(0ll, a + b - n) << "\n";

    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define F first
#define S second
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;

int mcrdx[]={1,0,-1,0};
int mcldx[]={-1,0,1,0};
int mcdy[]={0,1,0,-1};
char fL[51][51],fR[51][51];
int mcH,mcW;
bool mcok[51][51][51][51];
string mcdfs(pair<int,int> sr,pair<int,int> sl){
	stack<pair<pair<int,int>,pair<int,int>>> st;
	st.push({sr,sl});
	while(!st.empty()){
		pair<int,int> r=st.top().F,l=st.top().S;
		st.pop();
		if(fR[r.S][r.F]=='%'&&fL[l.S][l.F]=='%') {
			return "Yes";
		}else if(fR[r.S][r.F]=='%'||fL[l.S][l.F]=='%'){
			continue;
		}
		REP(i,0,4){
			pair<int,int> nr={r.F+mcrdx[i],r.S+mcdy[i]},nl={l.F+mcldx[i],l.S+mcdy[i]};
			if(!ck(nr.F,mcW)||!ck(nr.S,mcH)) nr=r;
			else if(fR[nr.S][nr.F]=='#')	nr=r;
			if(!ck(nl.F,mcW)||!ck(nl.S,mcH)) nl=l;
			else if(fL[nl.S][nl.F]=='#')	nl=l;

			//	cout<<nr.F<<" "<<nr.S<<" "<<nl.F<<" "<<nl.S<<" "<<endl;
			if(!mcok[nr.F][nr.S][nl.F][nl.S]){
				mcok[nr.F][nr.S][nl.F][nl.S]=true;
				st.push({nr,nl});
			}
		}
	}
	return "No";
}
int main(){

	while(cin>>mcW>>mcH,mcW){
		pair<int,int> Rin,Len;
		memset(mcok,false,sizeof(mcok));
		REP(i,0,mcH) {
			REP(j,0,mcW){
				cin>>fL[i][j];
				if(fL[i][j]=='L')	Len={j,i};
			}
			REP(j,0,mcW){
				cin>>fR[i][j];
				if(fR[i][j]=='R')	Rin={j,i};
			}
		}

		p(mcdfs(Rin,Len));

	}
	return 0;
}

Measured memory_bytes: 27544
l = list([0] * 26)
while True:
    try:
        s =input().lower()
    except EOFError:
        break
    for i in range(len(s)):
        t = ord(s[i]) - ord('a')
        if t>=0 and t<26:
            l[t] += 1
            
for i in range(26):
    print(f'{chr(i + 97)} : {l[i]}')


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

int main(){
  int N, Q;
  std::cin>>N>>Q;
  std::vector<int> l(Q, 0);
  std::vector<int> r(Q, 0);
  std::string str;
  std::cin>>str;

  for(int i = 0 ; i < Q ; i++ ){
    std::cin>>l[i]>>r[i];
  }

  std::vector<int> rem;
  bool checkA = false;
  int countA = 0;
  rem.push_back(0);
  for(int i = 0 ; i < N ; i++ ){
    if(str[i]=='A' && checkA == false) checkA = true;
    if(checkA == true && str[i+1] == 'C'){
      countA++;
      rem.push_back(countA);
      checkA = false;
    }else{
      checkA = false;
      rem.push_back(countA);
    }
  }
  for(int i = 0 ; i < Q ; i++ ){
    std::cout<<rem[r[i]-1]-rem[l[i]-1]<<std::endl;
  }
  return 0;
}


Measured memory_bytes: 2232
def calculate_median(lst):
    lst.sort()
    median_right = lst[int(len(lst)/2)]
    median_left = lst[int(len(lst)/2)-1]
    return median_right, median_left


N = int(input())
X = list(map(int, input().split()))
X_copy = X.copy()
median_right, median_left = calculate_median(X)
for i in range(N):
    if X_copy[i] >= median_right:
        print(median_left)
    elif X_copy[i] < median_right:
        print(median_right)

Measured memory_bytes: 25744
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  ll sum=0;
  ll mi=10000000,ma=-10000000;
  ll x;
  rep(i,n){
    cin>>x;
    sum+=x;
    mi=min(mi,x);
    ma=max(ma,x);
  }
  
  cout<<mi<<" "<<ma<<" "<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 3088
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
AA = inpl()

S = sum(AA)
L = 0

ans = INF
for a in AA:
    L += a
    R = S - L
    ans = min(ans,abs(L-R))

print(ans)


Measured memory_bytes: 27232
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	if (a == "H") {
		cout << b;
	}
	else {
		if (b == "H") {
			cout << "D";
		}
		else {
			cout << "H";
		}
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  int res = 0;
  for(int i = 1; i < n-1; i++){
    if(max(p[i-1],p[i]) == min(p[i], p[i+1]))res++;
    if(min(p[i-1],p[i]) == max(p[i], p[i+1]))res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

type node struct {
	parent, left, right int
}

var tree []node

func prewalk(u int) { // 先行順巡回
	fmt.Print(" ", u)
	if tree[u].left != -1 {
		prewalk(tree[u].left)
	}
	if tree[u].right != -1 {
		prewalk(tree[u].right)
	}
}
func inwalk(u int) { // 中間順巡回
	if tree[u].left != -1 {
		inwalk(tree[u].left)
	}
	fmt.Print(" ", u)
	if tree[u].right != -1 {
		inwalk(tree[u].right)
	}
}
func postwalk(u int) { // 後行順巡回
	if tree[u].left != -1 {
		postwalk(tree[u].left)
	}
	if tree[u].right != -1 {
		postwalk(tree[u].right)
	}
	fmt.Print(" ", u)
}

func main() {
	var N, root int
	fmt.Scan(&N)
	tree = make([]node, N)
	for i := range tree {
		tree[i].parent = -1
	}
	for i := 0; i < N; i++ {
		var id, left, right int
		fmt.Scan(&id, &left, &right)
		tree[id].left = left
		tree[id].right = right
		if left != -1 {
			tree[left].parent = id
		}
		if right != -1 {
			tree[right].parent = id
		}
	}
	for i := range tree {
		if tree[i].parent == -1 {
			root = i
		}
	}
	// fmt.Println("root", root, "tree", tree)
	fmt.Println("Preorder")
	prewalk(root)
	fmt.Println()
	fmt.Println("Inorder")
	inwalk(root)
	fmt.Println()
	fmt.Println("Postorder")
	postwalk(root)
	fmt.Println()
}



Measured memory_bytes: 1136
#include<iostream>
using namespace std;
int main()
{
    int n,ans=0,anss=0;
    string begin,end;
    cin>>n;
    cin>>begin>>end;
    anss=ans=begin.length()+end.length();
    for(int i=1; i<=n; i++)
    {
        string subb=begin.substr(begin.length()-i,i),sube=end.substr(0,i);
        if(subb==sube) anss=ans-i;
    }
    cout<<anss<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;     // 辺の行先
  int weight; // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  string ans;
  if (N == 0)
    ans += "0";
  else
  {
    while (N != 0) // Nは負の数もあり得るから条件はN != 0のとき
    {
      int rem = N % (-2);
      if (rem == -1)
        rem += 2;
      ans += (char)(rem + '0');
      cerr << ans << endl;
      N -= rem;
      N /= -2; // Nから余りを取り除いて-2で割る．
    }
    reverse(ans.begin(), ans.end());
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
#define drep(i,n) for(int i = n; i >= 0; i--)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

int chmax(int& a,int b){
	if(b > a){
		a=b;
	}
	return a;
}
int chmin(int& a,int b){
	if(b < a){
		a=b;
	}
	return a;
}

int dp[1010][1010];

int main(){
	string s,t;
	cin >> s >> t;
	int ss=s.size();int ts=t.size();
	rep(i,ss+1){
		rep(j,ts+1){
			dp[i][j]=inf;
		}
	}
	REP(i,0,ss+1)dp[i][0]=i;
	REP(i,0,ts+1)dp[0][i]=i;
	for(int i=1;i<=ss;i++){
		for(int j=1;j<=ts;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
			}else{
				dp[i][j]=min(dp[i-1][j-1]+1,min(dp[i-1][j]+1,dp[i][j-1]+1));
			}
		}
	}
	cout << dp[ss][ts] << endl;
	return 0;
}

Measured memory_bytes: 5132
N = int(input())
if N//10==0:
  print (N)
elif N//100==0:
  print (9)
elif N//1000==0:
  print (N-99+9)
elif N//10000==0:
  print (999-99+9)
elif N//100000==0:
  print (N-9999+999-99+9)
else:
  print (99999-9999+999-99+9)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=4e3+5;
int b[N][N];
char s[N][N];
int n,m,q,x1,y1,x2,y2,i,j,ans;
int main()
{
//	freopen("grid.in","r",stdin);
//	freopen("grid.out","w",stdout);
	scanf("%d%d%d",&n,&m,&q);
	rep(i,1,n) scanf("%s",s[i]+1);
	rep(i,1,n)
		rep(j,1,m)
		{
			if (s[i][j]!='1') continue;
			b[i*2-1][j*2-1]=1;
			if (i+1<=n && s[i+1][j]=='1') b[i*2][j*2-1]=-1;
			if (j+1<=m && s[i][j+1]=='1') b[i*2-1][j*2]=-1;
		}
	rep(i,1,n*2-1)
		rep(j,1,m*2-1)
			b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
	rep(i,1,q)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		x1=x1*2-1; y1=y1*2-1; x2=x2*2-1; y2=y2*2-1;
		ans=b[x2][y2]-b[x1-1][y2]-b[x2][y1-1]+b[x1-1][y1-1];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 73856
#include <stdio.h>
#include <ctype.h>
int main(){
	int g;
	char mozi;
	for(g=0; g<=1199;g++){
		scanf("%c", &mozi);
		
		if(isupper(mozi) != 0){
			mozi=tolower(mozi);
		}else{
			mozi=toupper(mozi);
		
		}
		printf("%c", mozi);
		if(mozi == '\n')break;
	}
//	for(g=0;g<1000;g++){
//
//	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = (1e18) +1;

int main() {
    ll N,M;
    cin >> N >>M;
    vector<ll> x(N),y(N),z(N);
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    ll ans = -INF;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k =0;k<2;k++){
                vector<ll> sum(N,0);
                for(int l=0;l<N;l++){
                    if(i){
                        sum[l] += x[l];
                    }else{
                        sum[l] -= x[l];
                    }
                    if(j){
                        sum[l] += y[l]; 
                    }else{
                        sum[l] -= y[l];
                    }
                    if(k){
                        sum[l] += z[l];
                    }else{
                        sum[l] -= z[l];
                    }
                }
                sort(sum.rbegin(),sum.rend());
                ll temp =0;
                for(int l=0;l<M;l++){
                    temp += sum[l];
                }
                ans = max(ans,temp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

string s;
int K;

int main() {
    cin >> s >> K;
    map<string, bool> sub;
    int len = min(K + 1, (int) s.length() + 1);
    for (int k = 1; k < len; k++) {
        for (int i = 0; i < s.length() - k + 1; i++) {
            sub[s.substr(i, k)] = true;
        }
    }
    int cnt = 1;
    for (auto itr  = sub.begin(); itr != sub.end(); itr++) {
        if (cnt == K) {
            cout << (*itr).first << endl;
            return 0;
        }
        cnt++;
    }
}

Measured memory_bytes: 1920
S = input()

if len(set(S)) == 1:
    print(0)

else:
    top = 0
    bottom = len(S) - 1
    count = 0
    while top < bottom:
        if S[top] == S[bottom]:
            top += 1
            bottom -= 1
        else:
            if S[top] == "x":
                top += 1
                count += 1
            elif S[bottom] == "x":
                bottom -= 1
                count += 1
            else:
                print(-1)
                break
    else:
        print(count)

Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> c(H);
    rep(i, H) cin >> c[i];
    // count '#'
    int cnt=0;
    rep(i, H) rep(j, W) if(c[i][j] == '#') cnt++;

    deque<vector<int>> q;
    q.push_back({0,0,1}); // x, y, dist
    c[0][0] = '#';
    int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
    int leng = -1;
    while (!q.empty()){
      bool ok=false;
        vector<int> tmp = q.front(); q.pop_front();
        int x = tmp[0], y = tmp[1], dist = tmp[2];
        rep(i, 4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx == W-1 && ny == H-1){
                leng = dist + 1;
              ok=true;
              break;
            }else if(0 <= nx && nx < W && 0 <= ny && ny < H && c[ny][nx] == '.'){
                q.push_back({nx, ny, dist+1});
                c[ny][nx] = '#';
            }
        }
      if(ok)break;
    }
    if(leng == -1) cout << -1 << endl;
    else cout << H*W-leng-cnt << endl;
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;

int main(void){
	uint32 N;
	vector<uint32> a;
	cin >> N;
	a.resize(N);
	REP(i, N) cin >> a[i];
	int32 cnt[32] = {};
	uint32 rest = 0;
	REP(i, N){
		rest ^= a[i];
		if(a[i] != 0)
			cnt[__builtin_ffs(a[i])]++;
	}
	int32 res = 0;
	while(rest){
		int32 bit = 32-__builtin_clz(rest);
		if(cnt[bit]){
			res++;
			rest ^= (1 << bit)-1;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << res << endl;
}

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

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 = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int H, W;
  ll ans;
  cin >> H >> W;
  if (W == 1 || H == 1) {
    ans = 1;
  } else {
    ans = ((H * W) % 2 == 0 ? (ll)H * W / 2 : (ll)H * W / 2 + 1);
  }
  cout << ans << endl;
}

signed main() {
  solve();

  return 0;
}


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

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

Measured memory_bytes: 256
import itertools,collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def main():
    n,a,b=map(int, input().split())
    v=[int(i) for i in input().split()]
    v.sort(reverse = True)
    tmp = v[0:a]
    dd = collections.defaultdict(int)

    for i in v:
        dd[i]+=1

    cnt = 0
  
    k = 0
    for i in tmp:
        k+=i
    s = min(tmp)
    avg = k/len(tmp)
    if(tmp[0]!=s):
        howmany = v.count(s)
        nantoori = tmp.count(s)
        #howmany個からnantoori個選ぶ方法
        res = howmany

        for i in range(nantoori-1):
            res *= (howmany-i+1)
        res2 = 1
        for i in range(nantoori):
            res2 *= (i+1)
        print(avg)
        print(combinations_count(howmany,nantoori))
    else:
        howmany = dd[s]
        res=0
        for i in range(a,min(b+1,howmany+1)):
            res += combinations_count(howmany, i)


        print(avg)
        print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9508
#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cin >> s;
    int num = 0;
    if(s[0] == '1') num++;
    if(s[1] == '1') num++;
    if(s[2] == '1') num++;

    std::cout << num << std::endl;
}

Measured memory_bytes: 256
'use strict';
function Main(stdin) {
  var line = stdin.split('\n');
  var result = (function(data) {
  	var tmp = [];
  	var index = 0;
		while (data[index] != '0') {
			tmp.push('Case ' + (index + 1) + ': ' + data[index++]);
		}
    return tmp.join('\n');
  }(
    line.map(Number)
  ));
  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10896
// ABC 088

// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  const N = input[0];
  var a = input[1].split(" "); //全てのカード

  // 降順
  a.sort(
    function(x,y) {
      return (parseInt(x,10) < parseInt(y,10) ? 1: -1);
    }
  )

  var alice_number = 0,
  bob_number = 0;

  a.forEach(function(value,index) {
    // Alice
    if(index % 2 == 0) {
      alice_number += parseInt(value,10);
    }
    // Bob
    else {
      bob_number += parseInt(value,10);
    }
  })

  console.log(alice_number-bob_number);

}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
	int N , l , r ;
    cin >> N;
    int sum = 0;
    for(int i = 0 ; i < N ; i++){
    	cin >> l >> r ;
        sum += r - l + 1;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define fr(a, b, c) for(int a = b, __ = c; a < __; a++)
#define dbg(x) cerr << ">>>>> " << x << endl;
#define _ << " , " <<

using namespace std;
typedef long long ll;

int ls[50];
int dp[211111], to[211111];
char go[211111];
int main(){
	ios::sync_with_stdio(0);
	string a;
	cin >> a;
	int n = a.size();
	fr(i, 0, 26){
		ls[i] = n+1;
	}
	dp[n] = 1;
	to[n] = n+1;
	go[n] = 'a';
	for(int i = n-1; i > -1; i--){
		dp[i] = n+200;
		ls[a[i] - 'a'] = i;
		// dp[i] = dp[ls[0]+1] + 1;
		// go[i] = 'a';
		// to[i] = ls[0]+1;
		fr(c, 0, 26){
			if(dp[ls[c]+1] + 1 < dp[i]){
				go[i] = 'a' + c;
				to[i] = ls[c]+1;
				dp[i] = dp[ls[c]+1] + 1;
			}
		}
	}
	int i = 0;
	while(i <= n){
		cout << go[i];
		i = to[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2324
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll solve(ll h,ll w){
    ll res = 1LL<<60;
    rep(i,h-1){
        ll ma = w*(i+1);
        ll tate = h-(i+1);
        ll yoko = w;
        ll mi;
        ll nokori;
        if(tate%2==0 or yoko%2==0){
            mi= tate*yoko/2;
        }else{
            mi = max(tate*(yoko/2),yoko*(tate/2));
        }
        nokori = tate*yoko-mi;
        res = min(res,max(nokori,ma)-min(ma,mi));
        //cout << ma << " " << mi << " " << nokori << endl;
    }
    return res;
}
int main(){
    ll h,w;
    cin >> h >> w;
    cout << min(solve(h,w),solve(w,h)) << endl;
}

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

// template {{{
/* vim: set foldmethod=marker: */

// constant
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
#define EPS 1e-14

// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

// input
template <class T> inline T in_(){ T x; cin >> x; return x; }

// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPit(type, i, obj) for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj) for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)

// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) obj.size()
#define sza(ary) (sizeof(ary) / sizeof(*ary))
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define cleAR(ary) memset((ary), 0, sizeof(ary))

// print util
#define print(x) cout << (x) << endl
#define printd(x, d) cout << fixed << setprecision(d) << (x) << endl
#define printv(v) REP(i, sz(v)) cout << v[i] << "\n "[i < sz(v) - 1]
#define printa(ary) REP(i, sza(ary)) cout << ary[i] << "\n "[i < sza(ary) - 1]
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl

//template }}}

signed main()
{
    int n = in_<int>();
    int k = in_<int>();
    set<int> hate;
    set<int> can_use;
    REP(i, k) hate.insert(in_<int>());
    REP(i, 10) if (not exist(hate, i)) can_use.insert(i);

    bool can_pay = false;
    while (1){
        string s = to_string(n);
        can_pay = true;
        for (auto& c : s){
            if (exist(hate, c - '0')){
                can_pay = false;
                break;
            }
        }
        if (can_pay) break;
        n++;
    }
    print(n);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int n,r;
    cin>>n>>r;
    if(n==0 && r==0) break;
    int a[51]={};
    for(int i=1;i<=n;i++){
      a[i]=n-i+1;
    }
    for(int i=0;i<r;i++){
      int p,c;
      cin>>p>>c;
      for(int j=1;j<=c;j++){
	for(int k=1;p+c-k>0;k++){
	  if(p+c-k>1)swap(a[p+c-k-1],a[p+c-k]);
	}
      }
    }
    cout<<a[1]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int train, taxi;
  train = N*A;
  taxi = B;
  if (train >= taxi){
    cout << taxi << endl;
  }
  else{
    cout << train << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int a = in.nextInt(), b = in.nextInt();
		if(a <= 0 && 0 <= b){
			System.out.println("Zero");
		}else{
			if(a < 0){
				int c = Math.min(b, 0);
				if(-(a - c) % 2 == 1){
					System.out.println("Positive");
				}else{
					System.out.println("Negative");
				}
			}else{
				System.out.println("Positive");
			}
		}
	}
}

Measured memory_bytes: 23508
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include<tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-7)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define R pair<pair<int, int>, pair<int, int>>
#define S(i,j,k,l) mkp(mkp(i,j),mkp(k,l))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(n,i) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define range(i,v) for(auto& (i) : v)
#define mkp make_pair
#define mem(x,k) memset(x,k,sizeof(x))
#define vec vector
#define pb emplace_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define getidx(b,i) lower_bound(all(b),(i))-b.begin()
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'a')
#define itoc(c) (char)(c+'a')
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
#define pppp(x,y,z,w) pb(S(x,y,z,w))
#define cyes cout<<"Yes\n"
#define cno cout<<"No\n"
#define endl "\n"
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
const vec<int>dx{ -1,1,0,0 }, dy{ 0,0,-1,1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
H readh() { H u; ll k = scanf("%lld %lld", &u.fs, &u.sc); return u; }
void printh(H t) { printf("%lld %lld\n", t.fs, t.sc); }
bool inarea(H t, int h, int w) { return 0 <= t.fs && t.fs < h && 0 <= t.sc && t.sc < w; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 1000005;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//--------------------------------------------------------------
signed main() {
	int n, r;
	cin >> n >> r;
	if (n >= 10) cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = tuple(map(int, input().split(" ")))

a_count = dict()
for a_i in a:
	if a_i not in a_count:
		a_count[a_i] = 0 
	a_count[a_i] += 1

sum_num = 0
for a_i in a_count:
	a_count_a_i = a_count[a_i]
	sum_num += a_count_a_i - a_i if a_i <= a_count_a_i else a_count_a_i
print(sum_num)

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

using namespace std;

int main(){
	long long int N, x;
	long long int count = 0;
	cin >> N >> x;
	vector<long long int> a(N);
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	if (N == 1){
		if (a[0]>x){
			count = a[0] - x;
		}
	}
	for (int i = 0; i < N-1; i++){
		int sum = a[i] + a[i + 1];
		if (sum<=x) continue;
		if (sum-x < a[i + 1]){
			a[i + 1] = a[i + 1] - (sum-x);
			count += sum - x;
			continue;
		}
		else{
			a[i] = x;
			a[i + 1] = 0;
			count += sum - x;
			continue;
		}
	}
	cout << count << endl;
	return 0;
}

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

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

  vector<vector<int>> s(M,vector<int>(0));
  for(int i=0; i<M; i++){
    int k; cin >> k; //スイッチの個数
    for(int j=0; j<k; j++){
      int sw; cin >> sw;
      s.at(i).push_back(sw);    
    }
  }
  
  vector<int> p(M);
  for(int i=0; i<M; i++)
    cin >> p.at(i);
  
  int count = 0;
  for(int bit=0; bit<(1<<N); bit++){
   //bit全探索
    bool check = true;
    for(int k=0; k<M; k++){

      int cnt = 0;
      
      for(int i=0; i<s.at(k).size(); i++){
      
        if( bit & ( 1<<s.at(k).at(i)-1 ) )
          cnt++;
      
      }
      
      if( cnt % 2 != p.at(k) )  
        check = false;
    
    }
    if(check)
      count++;
  
  }

  cout << count << endl;
  
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll H;

map<ll, ll> c;

ll f(ll h) {
	ll ret = 0;
	if (h == 1) return 1;
	if (c[h] != 0) return c[h];
	ret = f(h / 2) * 2 + 1;
	return ret;
}

int main() {

	cin >> H;

	cout << f(H) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

/**
 * ZAKIREN第5章
 *
 * @author K.Yamauchi
 *
 */
public class Main {

	/** 入力用 */
	private static Scanner scan = new Scanner(System.in);

	/** 出力用 */
	private static StringBuilder stringBuilder = new StringBuilder();

	/**
	 * メイン。
	 * @param args
	 */
	public static void main(String[] args) {

		// １行目（命令数）の読み込み
		int size = Integer.parseInt(scan.next());

		// 計算用連結リスト
		Deque<String> deque = new ArrayDeque<>();

		// 2行目以降（命令）の読み込み
		for (int i = 0; i < size; i++) {
			String command = scan.next();
			if (command.equals("insert")) {
				deque.push(scan.next());
			} else if (command.equals("delete")) {
				deque.remove(scan.next());
			} else if (command.equals("deleteFirst")) {
				deque.pollFirst();
			} else {
				deque.pollLast();
			}
		}

		// 読み込み終了
		scan.close();
		scan = null;

		// 結果出力
		for (int i = deque.size() - 1; i >= 0; i--) {
			stringBuilder.append(deque.pollFirst());

			if (i > 0) {
				stringBuilder.append(" ");
			}
		}

		System.out.println(stringBuilder.toString());

	}

}


Measured memory_bytes: 350648
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**9)

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

# @njit
def solve(n,m,l):
  edges = {i+1:[] for i in range(n)}
  for i in range(m):
    a,b = l[i]
    edges[a].append(b)
    edges[b].append(a)
  def dfs(start,end,rest):
    if rest == 0:
      return start == end
    else:
      return any(dfs(nextNode,end,rest-1) for nextNode in edges[start])

  return dfs(1,n,2)



def main():
  N,M = map(int,input().split())
  l = [tuple(map(int,input().split())) for _ in range(M)]
  print("POSSIBLE" if solve(N,M,l) else "IMPOSSIBLE")
  return

if __name__ == '__main__':
  main()


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

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn main() {
  input! {
    n: usize,
    _c: usize,
    p: [(usize, usize, usize); n],
  }
  let mut p = p;
  p.sort_by_key(|&(s, _, c)| (c, s));
  let mut p2 = vec![];
  p2.push(p[0]);
  for i in 1 .. n {
    let last = *p2.last().unwrap();
    if last.2 == p[i].2 && last.1 == p[i].0 {
      p2.pop();
      p2.push((last.0, p[i].1, last.2));
    } else {
      p2.push(p[i]);
    }
  }
  let mut event = vec![];
  for &(s, t, _) in &p2 {
    event.push((s, false));
    event.push((t, true));
  }
  event.sort();
  let mut ans = 0;
  let mut current = 0;
  for &(_, end) in &event {
    if end {
      current -= 1;
    } else {
      current += 1;
    }
    ans = cmp::max(ans, current);
  }

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


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

int n, m, q;
int a[50], b[50], c[50], d[50];
int A[10];

int ans = -1;
void dfs(int dep, int x) {
    if (dep == n) {
        int t = 0;
        rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) t += d[i];
        ans = max(ans, t);
        return;
    }

    for (int i = x; i <= m; i++) {
        A[dep] = i;
        dfs(dep + 1, i);
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    dfs(0, 1);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  int po=0,yo=0;
  REP(i,n){
    if(s[i]=='a'&&po+yo<a+b){
      puts("Yes");
      ++po;
    }else if(s[i]=='b'&&po+yo<a+b&&yo<b){
      puts("Yes");
      ++yo;
    }else{
      puts("No");
    }
  }
  return 0;
}


Measured memory_bytes: 896