akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = 0;
        int a = 0;
        int r = 0;
        int c = 0;
        int h = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            switch (s.substring(0, 1)) {
                case "M":
                    m++;
                    break;
                case "A":
                    a++;
                    break;
                case "R":
                    r++;
                    break;
                case "C":
                    c++;
                    break;
                case "H":
                    h++;
                    break;
            }
        }

        long ans = 0;

        for (int i = 7; i <= 28; i++) {
            if (Integer.bitCount(i) == 3) {
                long count = 1;
                int value = Integer.lowestOneBit(i);
                int left = i;
                for (int j = 0; j < 3; j++) {
                    switch (value) {
                        case 1:
                            count *= h;
                            break;
                        case 2:
                            count *= c;
                            break;
                        case 4:
                            count *= r;
                            break;
                        case 8:
                            count *= a;
                            break;
                        case 16:
                            count *= m;
                            break;
                    }
                    left -= value;
                    value = Integer.lowestOneBit(left);
                }
                ans += count;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 44600
#include<bits/stdc++.h>
using namespace std;
const int mod  = 1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    char arr[n][m];
    int dp[n][m];
    for(int i=0;i<n;i++){
        for(int j = 0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int i=1;i<m;i++){
        if(arr[0][i]=='#')break;
        dp[0][i] = 1;
    }
    for(int i=1;i<n;i++){
        if(arr[i][0]=='#')break;
        dp[i][0] = 1;
    }
    for(int i =1;i<n;i++){
        for(int j = 1;j<m;j++){
            if(arr[i][j] != '#'){
                dp[i][j] = (dp[i][j-1]%mod + dp[i-1][j]%mod)%mod;
            }
        }
    }

    cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(B/A > C) cout << C;
    else cout << B/A << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int N;
  cin >> N;
  set<int> S;
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    if(S.count(a)) S.erase(a);
    else S.insert(a);
  }
  cout << S.size() << endl;
  return 0;
}


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

int N;
long long a[55];

int main() {
	scanf("%d",&N);
	for (int i = 1; i <= N; i++)
		scanf("%lld",a+i);
	a[0] = 0;
	long long k = 0, tmp;
	bool flag;
	do {
		flag = false;
		for (int i = 1; i <= N; i++)
			if (tmp = (a[i] - a[0]) / N) {
				flag = true;
				a[i] -= tmp * (N+1);
				a[0] -= tmp;
				k += tmp;
			}
	} while (flag);
	printf("%lld\n",k); 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int num[3];
int min(int x,int y)
{
    return (x>y?y:x);
}
int main()
{
    num[0]=num[1]=num[2];
    char s[100100];
    scanf("%s",s);
    for(int i=0;s[i];i++)
    {
        num[(s[i]-'a')]++;
    }
    int minn=min(num[0],min(num[1],num[2]));
    num[0]-=minn;
    num[1]-=minn;
    num[2]-=minn;
    if(num[0]>1||num[1]>1||num[2]>1)
    {
        printf("NO\n");
    }
    else
    {
        printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
int main()
{
    string s;
    cin>>s;
    s.pb('$');
    int n=s.size(),ans=-1,c=0;
    if(s[0]=='R')
    {
        c++;
    }
    for(int i=1;i<n;i++)
    {
        if(s[i]==s[i-1] and s[i]=='R')
        {
            c++;
        }
        else if(s[i]!=s[i-1] and s[i]=='R')
        {
            c++;

        }
        else
        {
            ans=max(ans,c);
            c=0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    string s;cin>>s;
    rep(i,s.size()-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut itr = is.split_whitespace();
    let a = itr.next().unwrap().parse::<i64>().unwrap();
    let b = itr.next().unwrap().chars().fold(0, |pre, i| {
        if i.is_digit(10) {
            pre * 10 + i.to_digit(10).unwrap() as i64
        } else {
            pre
        }
    });

    println!("{}", a * b / 100);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int p[2 * (int)1e5];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int n, cnt = 0, least = 2 * (int)1e5 + 1;
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        if (p[i] < least)
        {
            ++cnt;
            least = p[i];
        }
        
    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 4436
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <utility>
#include <cmath>
#include <stdlib.h> 
#include <stdio.h>
#include <iterator>
#include <chrono>
#include <iomanip>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <deque>
#include <stack>
#include <queue>
#include <fstream>
#include <limits>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <sstream>
#include <random>
#include <cassert>

using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
int INF = 1e9 + 7;

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

	int d, t, s;
	cin >> d >> t >> s;
	cout << (d <= t * s ? "Yes" : "No");
}
	




/*
C:\Users\User\Desktop\comp_programming\final_straw_after_this_im_switching_to_vs_code\final_straw_after_this_im_switching_to_vs_code.cpp
*/

Measured memory_bytes: 3632
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	double A, B, C, D; cin >> A >> B >> C >> D;
	ll x = ceil(C / B);
	ll y = ceil(A / D);
	if (y < x) cout << "No" << endl;
	else cout << "Yes" << endl;
}
	

Measured memory_bytes: 11028
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int N = input[0];
		int D = input[1];
		int range = 1 + 2 * D;

		Console.WriteLine((N + range - 1) / range);
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
    int n;
    cin>>n;
    int x;
    int ans=1;
    int kai=0;
    cin>>x;
    int a[n];
    rep(i,n){
        cin>>a[i];
        kai+=a[i];
        if(kai<=x){
            ans++;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vs = vector<string>;
using vcc = vector<vector<char>>;
using vll = vector<vector<long long>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
int main() {
    ll n, m;
    cin >> n >> m;
    vll data(n, vector<ll>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> data[i][j];
        }
    }
    pair<int, int> p;
    pair<int, int> q;
    ll count = 0;
    vll dataa(n, vector<ll>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            dataa[i][j] = data[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i == n - 1 && j == m - 1) {
            }
            else {
                if (dataa[i][j] % 2 == 1) {
                    if (i == n - 1) {
                        dataa[i][j+1]++;
                        count++;
                    }
                    else {
                        dataa[i + 1][j]++;
                        count++;
                    }
                }
            }
        }
    }
    cout << count << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (data[i][j] % 2 == 1) {
                p.first = i + 1;
                p.second = j + 1;
                if (i != n - 1) {
                    data[i + 1][j]++;
                    q.first = i + 2;
                    q.second = j + 1;
                }
                else {
                    if (j != m - 1) {
                        data[i][j + 1]++;
                        q.first = i + 1;
                        q.second = j + 2;
                    }
                    else {
                    }
                }
                if (i == n - 1 && j == m - 1) {
                }
                else cout << p.first << " " << p.second << " " << q.first << " " << q.second << endl;
            }
        }
    }
}

Measured memory_bytes: 7472
#include <cstdio>
#include <vector>
#include <cstring>

void update(int &l, int r)
{
    if (l < r) l = r;
}

int main()    
{
    int N, P;
    scanf("%d %d", &N, &P);
    std::vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &X[i], &Y[i]);        
    }
    
    std::vector<std::vector<int>> p(N, std::vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {                        
            int np = 0, pp = 0;
            for (int k = i; k <= j; k++) {
                int mot = std::max(0, X[k] - pp);
                np += pp = std::max(0, Y[k] - mot);                
            }            
            p[i][j] = np;
        }
    }
    
    int dp[838][252][2];
    memset(dp, -1, sizeof(dp));
    dp[0][0][1] = P;    
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k < 2; k++) {
                if (dp[i][j][k] == -1) continue;

                update(dp[i + 1][j][1], dp[i][j][k]);
                
                if (k == 0) continue;
                for (int l = 0; l < N - i; l++) {                    
                    int np = dp[i][j][k] - p[i][i + l];
                    if (np >= 0) {
                        update(dp[i + l + 1][j + l + 1][0], np);
                    }
                }
            }
        }
    }

    int res = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < 2; j++) {
            if (dp[N][i][j] >= 0) {
                update(res, i);
            }
        }
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 4496
A,B=map(int,input().split())

def XOR(x):
    if x%4==1 or x%4==2:
        l="0"
    else:
        l="1"
    i=2
    while x>=(2**(i-1)):
        k=x%(2**i)
        if k<=2**(i-1)-1:
            l+="0"
        else:
            if k%2==0:
                l+="1"
            else:
                l+="0"
        i+=1    
    l=l[::-1]
    return(l)

b=XOR(B)
a=XOR(A-1).zfill(len(b))
ans=""

for j in range(len(b)):
    if b[j]==a[j]:
        ans+="0"
    else:
        ans+="1"

print(int(ans,2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-6
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 998244353;
long double PI = acosl(-1);
const ll infl = 1e18+100;
const int inf = 2e9+100;
const int nmax = 600+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

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

    ll I, O, J, L, fau;
    cin>>I>>O>>fau>>J>>L>>fau>>fau;

    int sam = I%2 + J%2 + L%2;
    ll ans = 0;
    if(sam>=2 and I>0 and J>0 and L>0)
        ans+=3, I--, J--, L--;

    ans += O + 2*(I/2) + 2*(L/2) + 2*(J/2);

    cout<<ans<<endl;
}
/*

*/


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	string t;
	cin >> t;

	for (int i = t.size() - 1; 0 <= i; i--)
	{
		if (t[i] == '?')
		{
			t[i] = 'D';
		}
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 3724
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

face = sys.stdin.readline().split()

right = [[None for front in range(6)] for top in range(6)]

# Top:1 Face:2 -> Right:3, Top:2 Face:6 -> Right:3 ...
right[0][1] = right[1][5] = right[5][4] = right[4][0] = 3 - 1
right[1][0] = right[5][1] = right[4][5] = right[0][4] = 4 - 1
right[0][2] = right[2][5] = right[5][3] = right[3][0] = 5 - 1
right[2][0] = right[5][2] = right[3][5] = right[0][3] = 2 - 1
right[3][1] = right[1][2] = right[2][4] = right[4][3] = 1 - 1
right[1][3] = right[2][1] = right[4][2] = right[3][4] = 6 - 1

# print(right)

q = int(sys.stdin.readline())
for i in range(q):
    top, front = sys.stdin.readline().split()
    r_index = right[face.index(top)][face.index(front)]
    print(face[r_index])



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 10000000;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main() {
  int n,s,a;
  cin>>n;
  for(int i=0;i<=n/4;i++){
    for(int j=0;j<=n/7;j++){
      if((i*4)+(j*7)==n){
        cout<<"Yes"<<endl;
        exit(0);
      }
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
   string S;
       cin >> S;
       map<char,int> mp;
           
       for(int i = 0; i < S.size();i++){
           mp[S[i]]++;
       }
       
       if(S.size()!=26){
    
           string s;
           for(char i = 'a'; i <= 'z';i++){
               if(mp[i]==0){
                   s = {i};
                   break;
               }
           }
           
           cout << S << s<< endl;
           
       }else{
           
           if(S == "zyxwvutsrqponmlkjihgfedcba"){
               cout << -1 <<endl;
               return 0;
           }
           
           
           string T = S;
           next_permutation(S.begin(), S.end());
           string ans = "";
           for(int i = 0; i < S.size();i++){
               ans += S.substr(i,1);
               if(S[i] > T[i])break;
           }
           cout << ans <<endl;
       }
}


Measured memory_bytes: 3608
S = input()
li = list(S)

prev = ''
count = 0

for i in range(len(li)):
    if 0 == i:
        prev = li[i]
    else:
        if '0' == prev and '0' == S[i]:
            count += 1
            li[i] = '1'
        elif '1' == prev and '1' == S[i]:
            count += 1
            li[i] = '0'
        prev = li[i]
print(count)


Measured memory_bytes: 3956
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT32_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

int main()
{
	ll N = 0;
	ll K = 0;
	ll a = 0;
	ll b = 0;
	ll ret = 0;
	map< ll, ll > dic;

	cin >> N >> K;

	Rep(i, N) {
		cin >> a >> b;
		dic[a] += b;
	}

	map< ll, ll >::iterator itr = dic.begin();
	ll index = 0;
	while(1)
	{
		index += itr->second;
		if (index >= K) {
			ret = itr->first;
			break;
		}

		// next key
		itr++;
	}

	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 6272
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        A[0] = sc.nextInt();
        A[1] = sc.nextInt();
        int max;
        int max2;
        if (A[0] > A[1]) {
            max = A[0];
            max2 = A[1];
        } else if (A[0] < A[1]) {
            max = A[1];
            max2 = A[0];
        } else {
            max = A[0];
            max2 = A[0];
        }
        for(int i=2; i<N; i++){
            A[i] = sc.nextInt();
            if (A[i] > max) {
                max = A[i];
            } else if (A[i] > max2) {
                max2 = A[i];
            }
        }

        for (int i=0; i<N; i++) {
            if(A[i] == max) {
                System.out.println(max2);
            } else {
                System.out.println(max);
            }
        }
    }
}

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

int main() {
  string n;
  cin >> n;
  if ( n.find("7") == string::npos){
     cout << "No" << endl;
}else{
    cout << "Yes" << endl;
}
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

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

	string s;
	cin >> s;
	vector<int>v[26];
	for (int i = 0; i < s.length(); i++)
	{
		v[s[i] - 97].push_back(i + 1);
	}
	int mx = 0, a = 1, b = s.length();
	for (int i = 0; i < 26; i++)
	{
		if (v[i].size() > 1)
		{
			if ( v[i][v[i].size() - 1] - v[i][0] > mx)
			{
				mx = v[i][v[i].size() - 1] - v[i][0] ;
				a = v[i][0];
				b = v[i][v[i].size() - 1];
			}
		}
	}
	// cout << mx << endl;
	if (mx == 0)
	{
		if ((s.length() - 2) % 2)
			cout << "First" << endl;
		else
			cout << "Second" << endl;
	}
	else
	{
		mx -= 2;
		if (a != 1)
			mx += a - 2;
		if (b != s.length())
			mx += s.length() - b - 1 ;
		if(a!=1&&b!=s.length())
			mx+=3;
		if (mx % 2)
			cout << "First" << endl;
		else
			cout << "Second" << endl;
	}
	//cout << mx << endl;


}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 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;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> a(N), b(N);
	REP(i, N) cin >> a[i];
	int64 res = 0;
	priority_queue<PLL, vector<PLL>> pq;
	REP(i, N) {
	    cin >> b[i];
	    pq.emplace(b[i], i);
	}

	while (pq.size()) {
	    int64 v, idx;
	    tie(v, idx) = pq.top(); pq.pop();
	    if (v <= a[idx]) {
            if (v < b[idx]) {
                res = -1;
                break;
            } else {
                continue;
            }
	    }
	    int64 mul = max({b[(idx-1+N)%N], b[(idx+1)%N], a[idx]});
	    int64 minus = b[(idx-1+N)%N] + b[(idx+1)%N];
	    mul = (v - mul + minus - 1) / minus;
        v -= minus * mul;
	    if (v <= 0) {
	        if (mul == 1) {
                res = -1;
                break;
            } else {
	            v += minus;
	            mul -= 1;
	        }
	    }
	    b[idx] = v;
	    pq.emplace(v, idx);
	    res += mul;
//	    REP(j, N) {
//	        cout << b[j] << " ";
//	    }
//	    cout << endl;
	}
	cout << res << endl;
}


Measured memory_bytes: 9584
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;
LL Q;
LL a,b;
int main()
{
	/*LL n=1000;
	LL last=-1;
	for (LL u=1;u*u<=n;u++)
	{
		if (last==n/u) printf("NO\n");
		last=n/u;
		printf("%lld %lld\n",u,n/u);
	}*/
	scanf("%lld",&Q);
	while (Q--)
	{
		scanf("%lld%lld",&a,&b);
		LL n=a*b-1;
		if (a>b) swap(a,b);
		LL o=0;
		LL l=1,r=sqrt(n)+5;
		while (l<=r)
		{
			LL mid=(l+r)/2;
			if (mid*mid<=n) {o=mid;l=mid+1;}
			else r=mid-1;
		}
		if (o==0)
		{
			printf("0\n");
			continue;
		}
		LL ans=2*o;//先看一下有多少对答案
		if (o==(n/o)) ans--;
		//printf("%lld %lld\n",o,ans);
		LL g=(n/o)-o;//中间有多少个空格
		LL t=a-1;//如果b要配，那么肯定是配这一个
		if (a<=o)//如果是比这个大的 
			ans--;
		if (t==0)//你什么b没有参与配对，没有影响
			printf("%lld\n",ans);
		else
		{ 
			LL tt=n/t;
			if (tt!=b)  printf("%lld\n",ans);
			else
			{
				//printf("YES");
				//那么现在的状态就是t*b 
				if (g!=0) printf("%lld\n",ans);
				else
				{
					if (t==o)//如果刚好是最后一个
						printf("%lld\n",ans-1);
					else
					{
						tt=t+1;
						LL h=n/tt;
						if (b-h>1) printf("%lld\n",ans);
						else printf("%lld\n",ans-1);
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S) + 1

A = [0] * N

c = 0
for i, si in enumerate(S):
    if si == '<':
        c += 1
    else:
        c = 0
    A[i+1] = c

c = 0
for i in range(len(S)-1, -1, -1):
    if S[i] == '>':
        c += 1
    else:
        c = 0
    A[i] = max(A[i], c)

# print(A)
print(sum(A))

Measured memory_bytes: 23336
#coding:utf-8
#1_5_B 2015.4.1
while True:
    length,width = map(int,input().split())
    if length == width == 0:
        break

    for i in range(length):
        for j in range(width):
            if j == width - 1:
                print('#')
            elif i == 0 or i == length - 1 or j == 0:
                print('#', end='')
            else:
                print('.', end='')
    print()

Measured memory_bytes: 6812
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
#define tabs(a, b) ((a<b) ? (b-a) : (a-b))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
void faster(){
   	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ull INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

int n;
vector<int> g[MAXN];

int dfs(int v){
	vector<int> q;
	q.clear();

	for(int to : g[v]){
		q.pb(dfs(to));
	}

	sort(all(q));
	reverse(all(q));

	int res = g[v].size();
	int y = 0;
	for(int x : q){
		res = max(res, x + y + 1);
		y++;
	}

	return res;
}

void solve(){
	cin >> n;

	for(int i = 2, u; i <= n; ++i){
		cin >> u;
		g[u].pb(i);
	}

	cout << dfs(1);
}

int main(){

	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

Measured memory_bytes: 19840
def abs(x):
    return -x if x < 0 else x


n = int(input())
spots = list(map(int, input().split()))

costs = [n1 - n2 for n1, n2 in zip(spots + [0], [0] + spots)]
costs_sum = sum([abs(cost) for cost in costs])

for i in range(n):
    if costs[i] * costs[i + 1] < 0:
        elim = min([abs(costs[i]), abs(costs[i + 1])])
        print(costs_sum - 2 * abs(elim))
    else:
        print(costs_sum)

Measured memory_bytes: 14284
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, M, X = map(int, input().split())
    cost = 10**10
    cost_choose = 0
    books = []
    for _ in range(N):
        books.append(list(map(int, input().split())))
    

    for choose in range(1<<N):
        val = 0
        skill = [0] * (M+1)
        for i in range(N):
            if choose & (1 << i) != 0:
                val += books[i][0]
                for j in range(1, M+1):
                    skill[j] += books[i][j]
        accomp = True
        for j in range(1, M+1):
            if skill[j] >= X:
                continue
            else:
                accomp = False
                break
        #print("choose={}, skill={}, cost={}".format(choose, skill, val))
        if accomp:
            cost = min(cost, val)
            cost_choose = choose

    if cost == 10**10: print(-1)  
    else: print(cost)
    #print(cost_choose)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68588
from itertools import accumulate

N, K = map(int, input().split())
*A, = map(int, input().split())
cumsum = [0] + list(accumulate(A))

def beauty(l, r): return cumsum[r+1] - cumsum[l]

beauties = [beauty(i, j) for i in range(N) for j in range(i, N)]
ans = ''
for i in reversed(range(len(format(max(beauties), 'b')))):
    temp = [b for b in beauties if b & (1 << i)]
    if len(temp) >= K:
        ans += '1'
        beauties = temp
    else:
        ans += '0'
print(int(ans, 2))

Measured memory_bytes: 23880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char op;
  int A,B,sum;
  cin>>A>>op>>B;
  
  if(op=='+'){
  sum=A+B;
  }
  if(op=='-'){
  sum=A-B;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    A.sort(reverse=True)
    ans=0
    ma=A[0]
    l=deque([A[0]])
    for a in A[1:]:
        ans+=l.popleft()
        l.append(a)
        l.append(a)
    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 98532
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let aa = util::gets::<i64>();

    let ans = (-100..101)
        .map(|x| aa.iter().map(|&a| (x - a).pow(2)).sum::<i64>())
        .min()
        .unwrap();

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


Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vi b(m);
    rep(i, m) cin >> b[i];
    vi c;
    int j = 0;
    rep(i, n) {
        while(j != m-1 and a[i] > b[j]) j++;
        if(a[i] == b[j]) c.emplace_back(a[i]);
    }
    rep(i, c.size()) cout << c[i] << '\n';
}


Measured memory_bytes: 4716
require 'pp'
require 'set'

n, x = gets.chomp!.split(" ").map(&:to_i)
l_n = gets.chomp!.split(" ").map(&:to_i)

d_n = [0]
count = 1
n.times do |i|
    d_n[i+1] = d_n[i] + l_n[i]
    if d_n[i+1] <= x
        count += 1
    else
        break
    end
end

puts count


Measured memory_bytes: 2300
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(), k = scanner.nextInt();
		Map<String,Integer> map = new HashMap<>();
		for(int i=0;i<n;i++){
			String a = scanner.next();
			if(!map.containsKey(a)){
				map.put(a, 1);
			}else{
				map.put(a, map.get(a) + 1);
			}
		}
		int count = 0;
		int size = map.size();
		map = map.entrySet().stream()
				.sorted(Entry.<String,Integer>comparingByValue())
				.collect(Collectors.toMap(Entry::getKey,Entry::getValue,(e1, e2)->e1,LinkedHashMap::new));
		for(String key : map.keySet()){
			if(size <= k){
				break;
			}
			count += map.get(key);
			size--;
		}
		System.out.println(count);
	}

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  string s;
  cin>>s;
  n=s.size();

  if(check(s)&&check(s.substr(0,(n-1)/2))&&check(s.substr(((n+3)/2)-1,n-(((n+3)/2)-1))))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
if N == 1:
    print(xyh[0][0],xyh[0][1],xyh[0][2])
    exit()

for cx in range(101):
    for cy in range(101):
        H = set()
        d = []
        for x,y,h in xyh:
            if h >= 1:
                H.add(abs(x-cx)+abs(y-cy)+h)
            else:
                d.append(abs(x-cx)+abs(y-cy))

        if len(H) == 1:
            if len(d) == 0 or list(H)[0] <= min(d):
                print(cx,cy,list(H)[0])
                exit()

Measured memory_bytes: 43756
import java.util.Scanner;

/**
 * Next Prime
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int X = sc.nextInt();

            for (int i = X;; i++) {
                if (isPrime(i)) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }

    static boolean isPrime(int n) {
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>

using namespace std;

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

	int min = INT_MAX;
	for (int i = 0; i <= (input.length()-3); ++i)
	{
		string sub = input.substr(i, 3);
		int num = atoi(sub.c_str());
		int diff = abs(753 - num);
		if (diff < min)
		{
			min = diff;
		}
	}
	cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
    is >> p.first >>p.second ;
    return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
    rep(i, v.size()) {
        is >> v[i];
    }
    return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
const int MAX = 100;

//aC b = aP b / b! = a! / (a-b)! / b!

int main(){

	int n,p;
    ll ans=0LL;
	ll cnta = 0LL;
	ll cntb = 0LL;
	cin >>n>>p;
	map<int, int> dis;
	int a;
	dis[0] = 0;
	dis[1] = 0;
	rep(i, n) { cin >> a;
		dis[a % 2]++;
	}
	//repi(itr, dis) { clog << itr->F << " " << itr->S << endl; }
	cnta = 1LL << (dis[0]);
	a    = dis[1];
	V COM(MAX, 1LL);
	COM[0] = 1LL;
	clog << a << endl;
	COM[1] = a;
	for (int i = 1; i < MAX;i++){
		COM[i] = COM[i - 1] * (a -i+1) / i;
		//clog << i << " " << COM[i] << endl;
	}
		if (p == 0) {
			for (int i = 0; i <= a; i += 2) {
				cntb += COM[i];
			}
		} else {
			for (int i = 1; i <= a; i += 2) {
				cntb += COM[i];
			}
		}
        if(cntb==0 and p==0){
		    cntb = 1LL;
	    }
//	clog << cnta << " " << cntb << endl;
	cout << cnta * cntb << endl;
}
// 17592186044416
// 17592183947264

Measured memory_bytes: 3624
s = input()
n = len(s)
ans = 0

for bit in range(1 << (n-1)):#n-1個+を入れる場所がある。
    f = s[0]

    for i in range(n-1):
        if bit & (1<<i):
            f += "+"  #フラグが立っているのなら＋を挿入
        f +=s[i+1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 9148
#include <cstdio>
#include <algorithm>
using namespace std;

int cnt_digits(long long n)
{
    int digits = 0;

    while (n > 0) {
        n /= 10;
        digits++;
    }

    return digits;
}

int main(void)
{
    long long n;
    scanf("%lld", &n);

    int ans = cnt_digits(n);

    for (long long a = 1; a * a <= n; a++) {
        if (n %a != 0)
            continue;
        const long long b = n / a;

        const int cur = max(cnt_digits(a), cnt_digits(b));

        if (ans > cur)
            ans = cur;
    }

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

vector< bool > prime_table(int n) {
    vector< bool > prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    vector<bool> pt = prime_table(55555);
    ll cnt=0;
    Vec a;
    REP(i,2,55556){
        if(i%5==1&&pt[i]){
            a.pb(i);
            cnt++;
        }
        if(cnt==n)break;
    }
    vout(a);
    return  0;
}


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

using namespace std;

#define int long long

const int mod=1000000007;

int32_t main()
{
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=k;i<=n+1;i++){
        int _min=(i*(i-1))/2;
        int _max= n*i - (i*(i-1))/2;
        ans+=_max-_min+1;
    }
    cout<<ans%mod<<endl;
}


Measured memory_bytes: 3672
#include<stdio.h>

int gcd(int,int);

int main(){

  int a,b,g;
  
  scanf("%d%d",&a,&b);

  g = gcd(a, b);

  printf("%d\n",g);

}

int gcd(int x, int y){

  int r;
  
  if(x < y){
    r = x;
    x = y;
    y = r;
  }
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  
  return x;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll=long long; 
int main(){
  ll N;
  cin>>N;
  vector<ll>tr(N);
  ll c=0;
  ll a=0;
  for(ll i=0;i<N;i++){
    cin>>tr.at(i);
    if(a<=tr.at(i)){
      a=tr.at(i);
    }
    else{
    c+=a-tr.at(i);
    }
  }
  
  cout<<c<<endl;
  
  
  
    
  
}


Measured memory_bytes: 4788