akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long N, long long i) {
  cout << N - i + 1 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long i;
  std::cin >> i;
  solve(N, i);
  return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // abs()
#include <string.h>         // memset()
#include <stdbool.h>

#define MAX_N 15
#define MAX_S (1 << MAX_N)

const double INF = 1e10;

int n;
int s[MAX_N], l[MAX_N], v[MAX_N];
double dp[MAX_N][MAX_S];
int w[MAX_N][MAX_S];
short prev[MAX_N][MAX_S][2];
int ord[MAX_N];

int
main(int argc, char **argv)
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d%d", &s[i], &l[i], &v[i]);

	memset(prev, -1, sizeof(prev));
	int S = 1;
	for (int i = 0; i < n; i++, S <<= 1)
		w[i][S] = v[i];

	int e = 1 << n;
	for (int k = 0; k < e; ++k)
	{
		S = 1;
		for (int i = 0; i < n; ++i, S <<= 1)
		{
			if (k & S)
				continue;

			int t = k | S;
			for (int j = 0; j < n; ++j)
			{
				if (i == j || w[j][k] == 0)
					continue;

				int d = abs(l[i] - l[j]);
				double x = dp[j][k] + (d * (70 + 20.0 * w[j][k])) / 2000.0;
				if (dp[i][t] == 0 || x < dp[i][t])
				{
					dp[i][t] = x;
					w[i][t] = w[j][k] + v[i];
					prev[i][t][0] = j;
					prev[i][t][1] = k;
				}
			}
		}
	}

	double min = INF;
	int u = 0;
	for (int i = 0; i < n; ++i)
	{
		double y = dp[i][e - 1];
		if (y == 0)
			continue;

		if (y < min)
		{
			min = y;
			u = i;
		}
	}

	ord[0] = u;
	int v = e - 1;
	for (int k = 1; k < n; ++k)
	{
		ord[k] = prev[u][v][0];
		v = prev[u][v][1];
		u = ord[k];
	}

	for (int i = n - 1; i >= 0; --i)
		printf("%d%c", s[ord[i]], (i != 0) ? ' ' : '\n');

	return 0;
}

Measured memory_bytes: 8660
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            var filePath = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                $"{Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location)}.in");
            Console.SetIn(new StreamReader(filePath));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            int answer;
            for (int i = 0; ; i++)
            {
                var payment = i * 1000;
                if (payment >= N)
                {
                    answer = payment - N;
                    break;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 17484
def check(B, C):
    A = list(map(int, input().split()))
    s = 0
    for i, a in enumerate(A):
        s += a * B[i]
    s += C
    if s > 0:
        return True
    else:
        return False


def resolve():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))

    ans = 0
    for _ in range(N):
        if check(B, C):
            ans += 1
    print(ans)
resolve()

Measured memory_bytes: 62272
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#define llint long long

using namespace std;

llint n;

int main(void)
{
	cin >> n;
	if(n == 0) cout << 1 << endl;
	else if(n == 1) cout << 2 << endl;
	else if(n == 2) cout << 1 << endl;
	else cout << 0 << endl;
	
	return 0;
}


Measured memory_bytes: 3104
using System;
using System.Linq;

namespace _0011
{
    class Program
    {
        private static void Main(string[] args)
        {
            const int maxNumberOfLines = 30;
            var numberOfVerticalLines = maxNumberOfLines + 1;
            var numberOfHorizontalLines = maxNumberOfLines + 1;
            while (maxNumberOfLines < numberOfVerticalLines)
            {
                var numberOfLines = Console.ReadLine();
                if (numberOfLines == null) continue;
                numberOfVerticalLines = int.Parse(numberOfLines);
            }
            while (maxNumberOfLines < numberOfHorizontalLines)
            {
                var numberOfLines = Console.ReadLine();
                if (numberOfLines == null) continue;
                numberOfHorizontalLines = int.Parse(numberOfLines);
            }

            var verticalLineNumbers = new int[numberOfVerticalLines];
            for (var i = 0; i < numberOfVerticalLines; i++)
            {
                verticalLineNumbers[i] = i + 1;
            }

            for (var i = 0; i < numberOfHorizontalLines; i++)
            {
                var horizontalLine = Console.ReadLine();
                if (horizontalLine == null) continue;
                var horizontalLineNumbers = horizontalLine.Split(',');
                var firstIndex = int.Parse(horizontalLineNumbers.First()) - 1;
                var lastIndex = int.Parse(horizontalLineNumbers.Last()) - 1;
                var temp = verticalLineNumbers[firstIndex];
                verticalLineNumbers[firstIndex] = verticalLineNumbers[lastIndex];
                verticalLineNumbers[lastIndex] = temp;
            }

            for (var i = 0; i < numberOfVerticalLines; i++)
            {
                Console.WriteLine(verticalLineNumbers[i]);
            }
        }
    }
}

Measured memory_bytes: 5788
n=int(input());div=[];ans=[]
for i in range(1,int(n**0.5)+2):
  if n%i == 0:
    div.append(i)
    div.append(n//i)

for i in div:
  if i == 1:
    continue
  m = n
  while m%i == 0:
    m//=i
  if m%i == 1:
    ans.append(i)
    
n -= 1
for i in range(1,int(n**0.5)+2):
  if n%i == 0:
    ans.append(i)
    ans.append(n//i)

print(len(set(ans))-1)

Measured memory_bytes: 3188
#include<stdio.h>

int t[110][110];
int main(){
  int a;
  scanf("%d",&a);
  for(int i=0;i<a;i++){
    int p,k;
    scanf("%d%d",&p,&k);
    while(k--){
      int s;
      scanf("%d",&s);
      t[p][s]=1;
    }
  }
  for(int i=1;i<=a;i++)for(int j=1;j<=a;j++)printf("%d%c",t[i][j],j==a?10:32);
}
						   



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

using namespace std;

int main() {

    long long x;
    cin >> x;

    long long cur = 7 % x;
    int ans = 1;

    while(cur != 0 and ans < 1e8) {
        cur = (cur * 10 + 7) % x;
        ans++;
    }

    if(ans == 1e8) cout << "-1\n";
    else cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3588
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();
        int c = sc.nextInt();

        System.out.println( a + b + c - Math.max(a,Math.max(b,c)) );
    }
}


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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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

template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a%b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    long long n;
    cin>>n;

    long long res=pow(n,3);
    cout<<res<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }


    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, Q;
        public long MOD = 1000000007;

        public void Run()
        {
            string S = Console.ReadLine();

            int ret = 0;
            int r = 0;
            for (int i = 0; i < S.Length; i++)
            {
                var c = S[i];
                if (c == 'A' || c == 'G' || c == 'C' || c == 'T')
                {
                    r++;
                }
                else
                {
                    r = 0;
                }

                ret = Math.Max(r, ret);

            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13140
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
main(){
	int N,i,h,m,d,r,R;
	for(;scanf("%d",&N),N;printf("%d\n",m)){
		vector<pair<int,int> >v;
		for(i=0;i<N*2;i++){
			scanf("%d:%d:%d",&h,&m,&d);
			v.push_back(make_pair(h*3600+m*60+d,i%2?-1:1));
		}
		sort(v.begin(),v.end());
		for(h=m=i=0;i<N*2;i++){
			h+=v[i].second;
			if(m<h)m=h;
		}
	}
}

Measured memory_bytes: 1284
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8){
    cout << "Yay!" << endl;
    return 0;
  }
  cout << ":(" << endl;
  return 0;
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S 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; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

string word = "abcdefghij";

void create(int n, int types, string str){
    if (str.length() == n)
        cout << str << endl;
    else{
        REP(i, types+1){
            create(n, max(types, i+1), str+word[i]);
        }
    }
}

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

    create(n, 1, "a");
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


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

	ll a,b,c,n, h, ret = 0;
	string s;
	cin >> a >> b;
	vi v;
	cout << (a - 1) * (b - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;


public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
	String[] a=sc.nextLine().split(" ");
	int H=Integer.parseInt(a[0]);
	int A=Integer.parseInt(a[1]);
	int res=H/A;
if(H%A>0)res++;
	System.out.println(res);
	
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
             return Double.parseDouble(next());
         }



        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } 
    }
}


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

int main() {
  int N,cnt=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    while(a%2==0){cnt++;a/=2;}
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    int a,b;
    vector<int> A,B;
    cin >> N;
    REP(i,N-1){
        cin >> a >> b;
        a--;b--;
        A.push_back(a);
        B.push_back(b);
    }
    vector<int> G[214514];
    REP(i,N-1){
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    
    int d[214514]={};
    bool visited[214514]={};
    d[0]=1;
    queue<int> Q;
    Q.push(0);
    while(!Q.empty()){
        int q=Q.front();
        Q.pop();
        if(visited[q])continue;
        visited[q]=true;
        REP(i,G[q].size()){
            Q.push(G[q][i]);
            d[G[q][i]]=3-d[q];
        }
    }
    
    //REP(i,N){cout << d[i] << " ";}cout << endl;
    
    vector<int> V[3];
    REP(i,N){
        V[d[i]].push_back(i);
    }
    
    if(V[1].size()>V[2].size()){
        V[0]=V[1];
        V[1]=V[2];
        V[2]=V[0];
        V[0].clear();
    }
    
    if(V[1].size()<=N/3){
        V[0]=V[1];
        V[1].clear();
        while(V[0].size()<N/3){
            V[0].push_back(V[2][V[2].size()-1]);
            V[2].pop_back();
        }
        while(V[1].size()<(N+2)/3){
            V[1].push_back(V[2][V[2].size()-1]);
            V[2].pop_back();
        }
    }else{
        while(V[1].size()>(N+2)/3){
            V[0].push_back(V[1][V[1].size()-1]);
            V[1].pop_back();
        }
        while(V[2].size()>(N+1)/3){
            V[0].push_back(V[2][V[2].size()-1]);
            V[2].pop_back();
        }
        
    }
    
    /*REP(j,3){
        REP(i,V[j].size()){
            cout << V[j][i]+1 << " ";
        }cout << endl;
    }*/
    
    vector<int> Ans;
    REP(i,N){Ans.push_back(0);}
    REP(j,3){
        REP(i,V[j].size()){
            Ans[V[j][i]]=j;
        }
    }
    
    int x[3]={};x[0]=1;
    REP(i,N){
        int k=Ans[i];
        Ans[i]+=x[k]*3;
        x[k]++;
    }
    
    REP(i,N){
        cout << Ans[i];
        if(i!=N-1)cout << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 26592
import bisect

n=int(input())
l=list(map(int,input().split()))
l.sort()

res = 0
for i in range(n):
    for j in range(i+1,n):
        #最初にa+b以上になるインデックスを二分探索で求める
        k = bisect.bisect_left(l, l[i]+l[j])
        res += max(k-(j+1),0)
print(res)

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

int main(){
    int n, p;
    cin >> n >> p;
    int A[n], ec = 0;   //even_counter
    for(int i = 0; i < n; i++){
        cin >> A[i];
        if(A[i] % 2);
        else ec++;
    }
    long long ans = 0; 
    if(ec == n){
        if(p);
        else ans = pow(2, n);
    }else{
        ans = pow(2, n - 1);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n==0 and x==0: break
    else:
        res = 0
        for i in range(1, n+1):
            for j in range(i+1, n+1):
                for k in range(j+1, n+1):
                    if i+j+k==x: res+=1
        print(res)


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int x=Int32.Parse(Console.ReadLine());
            if (x < 1200) Console.WriteLine("ABC");
            if (x >= 1200) Console.WriteLine("ARC");
        }
    }
}


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

int main(){
    ll x;
    cin>>x;
    ll ans=x/11;
    ans*=2;
    if(x%11>0 && x%11<7)ans+=1;
    else if(x%11>=7)ans+=2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
count = [0 for _ in range(10**5 + 100)]

for _ in range(N):
    a, b = map(int, input().split())
    count[a] += b

now = 0
ans = 0
for i, c in enumerate(count):
    now += c
    if now >= K:
        ans = i
        break

print(ans)

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
int a, b;
cin >> a >> b;
int x, y;
x = max(a, b);
y = min(a, b);
REP(i, x) cout << y;
cout << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int a[5],b=0;
        bool use[3]={0};
        for(int i=0;i<5;++i){
            cin>>a[i];if(!a[i])return 0;
            switch(a[i]){
                case 1:use[0]=1;break;
                case 2:use[1]=1;break;
                case 3:use[2]=1;break;
            }
        }
        for(int i=0;i<3;++i){
            b+=use[i];
        }
        if(b!=2){
            for(int i=0;i<5;++i){
                cout<<3<<endl;
            }
        }else{
            for(int i=0;i<5;++i){
                if(use[0]&use[1]){
                    if(a[i]!=2)cout<<1<<endl;
                    else cout<<2<<endl;
                }
                if(use[1]&use[2]){
                    if(a[i]!=3)cout<<1<<endl;
                    else cout<<2<<endl;
                }
                if(use[0]&use[2]){
                    if(a[i]!=1)cout<<1<<endl;
                    else cout<<2<<endl;
                }
            }
        }
    }
}

Measured memory_bytes: 1160
S=input()
PUT_1 = S[0:3]
PUT_2 = S[1:4]
PUT_1_ANS = (PUT_1[0]==PUT_1[1]) and (PUT_1[0]==PUT_1[2])
PUT_2_ANS = (PUT_2[0]==PUT_2[1]) and (PUT_2[0]==PUT_2[2])
ANS = PUT_1_ANS or PUT_2_ANS
if ANS:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
arr = gets.split.map(&:to_i)
arr.sort!

count = 0
count += arr[2] - arr[1]
 
if (arr[2] - arr[0] - count) % 2 == 0
  count += (arr[1] - arr[0]) / 2
else
  count += ((arr[1] - arr[0]) / 2) + 2
end
 
puts count

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int a, b, cnt(0);
	while (cin >> a >> b, a || b) {
		bool f(false);
		if(cnt++)cout << endl;
		for (int i = a; i <= b; i++) {
			if ((i % 4 == 0) && ((!(i % 100 == 0)) || (i % 400 == 0))) {
				cout << i << endl;
				f = true;
			}
		}
		if (f == false)cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL a,b,c,d,i,j,k,m,n,t;
string s[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)cin>>s[i];
	sort(s+1,s+n+1);
	for(i=0;i++<n;)
	{
		if(s[i]!=s[i-1])t++;
	}
	cout<<t;
}

Measured memory_bytes: 9908
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,x;
    lli i,j,k;
    double ave;
    vector<lli> v,w;
    cin>>n;
    rep(i,0,n){
        cin>>x;
        v.push_back(x);
    }
    w=v;
    sort(v.begin(),v.end());
    ave=(v[n/2]+v[n/2-1])/2.0;
    rep(i,0,n){
        if(ave>=w[i]){
            cout<<v[n/2]<<endl;
        }
        else{
            cout<<v[n/2-1]<<endl;
        }
    }
}

Measured memory_bytes: 5488
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
A = list(map(int, input().split())) + [-1]
ans = float("inf")
for a in A:
  L = []
  K = []
  for t in A:
    if t >= a:
      L.append(t)
    else:
      L.sort()
      for c in range(len(L)-k+1):
        K.append(L[c])
      L = []
  K.sort()
  if len(K) < q:
    continue
  else:
    y = K[q-1]
    ans = min(ans, y-a)
print(ans)

Measured memory_bytes: 9392
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())

using namespace std;
typedef long long  ll;

int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n , m;
    cin >> n >> m;
    vector<int> cnt(m + 1 , 0);
    for(int i = 0 ; i < n ; ++i){
        int k;
        cin >> k;

        for(int j = 0 ; j < k ; ++j){
            int x;
            cin >> x;
            cnt[x]++;
        }
    }


    int ans = 0;
    for(int i = 1 ; i <= m ; ++i){
        ans += cnt[i] == n;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
        t: String,
    }

    let ss: Vec<char> = s.as_str().chars().collect();
    let tt: Vec<char> = t.as_str().chars().collect();
    let mut count;
    let mut max = 0;

    for i in 0..(s.len() - t.len() + 1) {
        count = 0;

        for j in 0..t.len() {
            if ss[i + j] == tt[j] {
                count += 1;
            }
        }

        if count > max {
            max = count;
        }
    }

    println!("{}", t.len() - max);
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
int main()
{
	ll n, x, m;
	cin >> n >> x >> m;
	map<ll, int> mp;
	mp[x] = 1;

	vector<ll> a(2);
	a[1] = x;

	ll ans = x;
	for(ll i = 2; i <= n; i++){
		a.push_back(a[i-1]*a[i-1]);
		a[i] %= m;

		if(mp[a[i]]){
			ll start = mp[a[i]]; 
			ll score = 0;
			for(ll j = start; j < i; j++) score += a[j]; // 1周期のスコア
			ll rpsz = i - 1 - mp[a[i]] + 1;
			ll sz = n - i + 1;

			ans += sz / rpsz * score;
			ll nokori = sz % rpsz;
			while(nokori--){
				ans += a[start++];
			}
			break;
		}
		mp[a[i]] = i;
		ans += a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 6772
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	ll k,A,B;
	cin>>k>>A>>B;
	if(B <= A + 2)
	{
		printf("%lld\n",k + 1);
	}
	else
	{
		ll now = min(k,A - 1);
		ll ans = now + 1;
		k -= now;
		ans += (B - A) * (k / 2);
		ans += k % 2;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
ll dp[100001][3];
void solve()
{
	ll n;
	cin>>n;
	mem(dp,0);
	ll a,b,c;
	for(ll i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		if(i==0)
		{			
			dp[0][0]=a;
			dp[0][1]=b;
			dp[0][2]=c;
		}
		else
		{
			dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
			dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
			dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

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


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	string s, t;
	cin >> s >> t;
	
	int n = s.size(), m = t.size();
	
	int dp[n+1][m+1];
	memset(dp,0,sizeof dp);
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	//cout << dp[n][m] << endl;
	
	string ans = "";
	int l = n, r = m;
	while(l && r){
		if(s[l-1] == t[r-1]){
			ans += s[l-1];
			l--;	r--;
		}
		else if(dp[l][r] == dp[l-1][r]){
			l--;
		}
		else
			r--;
	}
	
	reverse(ans.begin(),ans.end());
	
	cout << ans << endl;

	return 0;
}



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

int main(){
    int n , k ;
    cin >> n >> k ;
    vector<int> P(n) ;
    rep(i,n) cin >> P[i] ;
    sort(P.begin(),P.end()) ;
    int ans = 0 ;
    rep(i,k){
        ans += P.at(i) ;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N],sum[N];
 
ll gao(int l,int r){
    return sum[r]-sum[l-1];
}
 
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    int n ;
    cin >>n;
    for(int i=1;i<=n;i++)   cin >> a[i];
    for(int i=1;i<=n;i++)   sum[i]=sum[i-1]+a[i];
    ll l=1,r=3;
    ll ans=1e18+8;
    for(int i=2;i<=n-2;i++){
         while(l+1<i&&abs(gao(1,l)-gao(l+1,i))>=abs(gao(1,l+1)-gao(l+2,i)))
            l++;
         while(r+1<n&&abs(gao(i+1,r)-gao(r+1,n))>=abs(gao(i+1,r+1)-gao(r+2,n)))
            r++;
         set<ll>st;
         st.insert(gao(1,l));
         st.insert(gao(l+1,i));
         st.insert(gao(i+1,r));
         st.insert(gao(r+1,n));
         ans=min(ans,abs(*st.begin()-*prev(st.end())));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a=0,b=0,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>n>>s;
    for (ll i=0; i<n; i++) {
        if (s[i]=='R') {
            a++;
        }
        else b++;
    }
    if (a>b) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}



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

using namespace std;
#define int long long
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim>
struct rge {
    c b, e;
};

sim> rge<c> range(c i, c j) { return rge<c>{i, j}; }

sim> auto dud(c *x) -> decltype(cerr << *x, 0);

sim> char dud(...);

struct debug {
#ifndef LOCAL

    ~debug() {
        cerr << endl;
    }

    eni(!=) cerr << boolalpha << i;
        ris;
    }

    eni(==) ris << range(begin(i), end(i));
    }

    sim, class b dor(pair<b, c> d) {
        ris << "(" << d.first << ", " << d.second << ")";
    }

    sim dor(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
    }

#else
    sim dor(const c &)
    {
        ris;
    }
#endif
};

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define int long long

void solve();

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}

const int mod = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    int x = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        ans = (ans % mod + (v[i] % mod * x % mod) % mod) % mod;
        x = (x % mod + v[i] % mod) % mod;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4764
if __name__=="__main__":
    sum = 0
    x,y = map(int,input().split())
    c = [list(map(int,input().split())) for n in range(10)]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if c[i][j]>c[i][k]+c[k][j]:
                    c[i][j] = c[i][k]+c[k][j]

    for i in range(x):
        a = list(map(int,input().split()))
        for j in a:
            if j!=-1:
                sum+=c[j][1]

    print(sum)




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

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

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

int n, m;
int par[200001];
int sz[200001];

int getPar(int a)
{
	if (par[a] == a) return a;
	return par[a] = getPar(par[a]);
}

void merge(int a, int b)
{
	a = getPar(a), b = getPar(b);
	if (a == b) return;
	par[a] = b;
	sz[b] += sz[a];
}

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

	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		par[i] = i;
		sz[i] = 1;
	}

	while (m--)
	{
		int a, b; cin >> a >> b;
		merge(a, b);
	}

	cout << *max_element(sz + 1, sz + n + 1);
}

Measured memory_bytes: 5212
import numpy as np
i8 = np.int64
i4 = np.int32


def calc(dp1, dp2, k):
    dp2[k:] += dp1[:dp1.shape[0]-k]
    dp2[:dp2.shape[0]-k] += dp1[k:]


def solve(z, dp):
    zero = dp.shape[2] // 2
    dp[0, 0, zero + z[0, 0]] = 1
    dp[0, 0, zero - z[0, 0]] = 1
    for x in range(1, z.shape[1]):
        calc(dp[0, x - 1], dp[0, x], z[0, x])
    for y in range(1, z.shape[0]):
        calc(dp[y - 1, 0], dp[y, 0], z[y, 0])
        for x in range(1, z.shape[1]):
            calc(dp[y, x - 1], dp[y, x], z[y, x])
            calc(dp[y - 1, x], dp[y, x], z[y, x])
            if (x + y) % 50 == 0:
                dp[y, x] = dp[y, x] > 0
    for i in range(zero, dp.shape[2]):
        if dp[dp.shape[0] - 1, dp.shape[1] - 1, i] > 0:
            return i - zero
    return -1


def main():
    stdin = open('/dev/stdin', 'rb')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    H, W = pin[:2]
    a = pin[2: 2 + H * W].reshape(H, W)
    b = pin[2 + H * W:].reshape(H, W)
    z = np.abs(a - b)
    dp = np.zeros((H, W, 80 * 80 *2 + 1), i8)
    ans = solve(z, dp)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 652580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, P;
  cin >> N >> P;
  
  rep(i, N) {
    int A;
    cin >> A;
    if(A % 2 == 1) {
      fin(1LL << (N-1));
      return 0;
    }
  }
  
  fin(!P ? (1LL << N) : 0);
  
  return 0;
  
  ll odd = 0;
  vll A(N);
  rep(i, N) {
    int Aa;
    cin >> Aa;
    A[i] = Aa;
  }
  
  vvll dp(N + 1, vll(2));
  dp[0][0] = 1;
  rep(i, N) {
    if(A[i] % 2 == 0) {
      //余り0
      dp[i+1][0] = dp[i][0] + dp[i][0];
      dp[i+1][1] = dp[i][1] + dp[i][1];
    } else {
      dp[i+1][0] = dp[i][0] + dp[i][1];
      dp[i+1][1] = dp[i][1] + dp[i][0];
    }
  }
  
  fin(dp[N][P]);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    int i;
    for(i=n;i>0;i--){
        if(i==64)
            break;
        if(i==32)
            break;
        if(i==16)
            break;
        if(i==8)
            break;
        if(i==4)
            break;
        if(i==2)
            break; 
        if(i==1)
            break;
    }
    printf("%d\n", i);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long[] a = new long[N];
	        long[] b = new long[N];
	        long[] c = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	        }
	        for (int i=0 ; i<N; i++) {
	            b[i] = Long.parseLong(sc.next());
	        }
	        for (int i=0 ; i<N; i++) {
	            c[i] = Long.parseLong(sc.next());
	        }
	        Arrays.parallelSort(a);
	        Arrays.parallelSort(b);
	        Arrays.parallelSort(c);
	        long[] d = new long[N];
	        long[] e = new long[N];
	        long[] f = new long[N];
	        for(int i=0;i<N;i++) {
	        	int low = -1;
	        	int hi = N;
	        	while(hi-low>1) {
	        		int mid = low+(hi-low)/2;
	        		if(a[i]>=b[mid]) low=mid;
	        		else hi=mid;	
	        	}
	        	d[i]=hi;
	        }
	        for(int i=0;i<N;i++) {
	        	int low = -1;
	        	int hi = N;
	        	while(hi-low>1) {
	        		int mid = low+(hi-low)/2;
	        		if(b[i]>=c[mid]) low=mid;
	        		else hi=mid;	
	        	}
	        	e[i]=N-hi;
	        }
	        f[N-1]=e[N-1];
	        for(int i=N-2;i>=0;i--) {
	        	f[i]=f[i+1]+e[i];
	        }
	        long ans=0;
	        for(int i=0;i<N;i++) {
	        	if(d[i]<N)ans=ans+f[(int) d[i]];
	        }
	    	System.out.println(ans);
	    	
	        		
	    }
	    

	}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

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

    vector<pair<ll, ll> > BA(N);
    REP(i,N){
        ll a, b;
        cin >> a >> b;
        BA[i] = make_pair(b, a);
    }

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

    ll time = 0;
    ll ans = true;
    REP(i,N){
        auto p = BA[i];
        ll b = p.first;
        ll a = p.second;

        time += a;
        if(b < time){
            ans = false;
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> // 

using namespace std;
using ll = long long;

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

    int h, n;
    cin >> h >> n;
    vector<int> dp(h + 1, 0x3f3f3f3f);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        for (int j = 0; j < h; ++j) {
            dp[min(j+x,h)] = min(dp[min(j+x,h)], dp[j] + y);
        }
    }

    cout << dp[h] << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.chomp
ans = 0

3.upto(n.size) do |i|
	[3, 5, 7].repeated_permutation(i) do |e|
		if e.uniq.size == 3
			ans += 1 if e.join("").to_i <= n.to_i
		end
	end
end

puts ans

Measured memory_bytes: 1916
#include<cstdio>
int a[105];

int abs(int u){ return u>0?u:-u; }

int main(){
    int n;
    scanf("%d",&n);
    int sum = 0;
    for(int i = 1; i <= n; i++){ 
        scanf("%d",&a[i]);
        sum += a[i];
    }
    int diff = abs(n*a[1]-sum), find = 0;
    for(int i = 2; i <= n; i++){
        if(abs(n*a[i]-sum)<diff){
            diff = abs(n*a[i]-sum), find = i-1;
        }
    }
    printf("%d\n",find);
    return 0;
}


Measured memory_bytes: 1700
#include <iostream>

int main(int argc,char* argv[]){
  bool peeple[1001];

  while(true){
    int pop,space;
    std::cin >> pop >> space;
    if(pop == 0 && space == 0){break;}

    for(int i = 1; i <= pop; i++){
      peeple[i] = false;
    }
    
    int cur_pop = pop;
    int cur_num = 1;
    while(cur_pop != 1){
      int count = 0;
      while(count < (space-1) || peeple[cur_num] == true){
	if(peeple[cur_num] == true){
	  if(cur_num == pop){
	    cur_num = 1;
	  }else{
	    cur_num++;
	  }
	  continue;
	}else{
	  if(cur_num == pop){
	    cur_num = 1;
	  }else{
	    cur_num++;
	  }
	  count++;
	}
      }
      
      peeple[cur_num] = true;
      cur_pop--;
      while(peeple[cur_num] == true){
	if(cur_num == pop){
	  cur_num = 1;
	}else{
	  cur_num++;
	}
      }
    }
    
    for(int i = 1; i <= pop;i++){
      if(peeple[i] == false){
	std::cout << i << std::endl;
	break;
      }
    }
  }

  return 0;
  
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys,collections
n,k = map(int,sys.stdin.readline().split())
w = list(map(int,sys.stdin.readlines()))
ng = sum(w)//k-1
ok = sum(w)
def isOK(p):
  j = 0
  for i in range(k):
    s = 0
    while j < n and s + w[j] <= p:
      s += w[j]
      j += 1
  return j == n
while ok - ng > 1:
  mid = (ok+ng)//2
  t = collections.Counter(w)
  if isOK(mid):
    ok = mid
  else:
    ng = mid
print(ok)


Measured memory_bytes: 16152
#include <iostream>
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N, A, B, C, D;
ll dp[1010][1010], perm[1010][1010], fact[1010];

ll mod_pow(int n, int k) {
    ll ret = 1, val = n, rest = k, s = 0;
    while(rest != 0) {
        if(s != 0) (val *= val) %= MOD;
        if(k >> s & 1) {
            rest -= (1 << s);
            (ret *= val) %= MOD;
        }
        s++;
    }
    return ret;
}

int main() {
    fact[0] = 1;
    for(int i=1; i<1010; i++) fact[i] = (i * fact[i-1]) % MOD;
    for(int i=0; i<1010; i++) {
        for(int j=0; j<=i; j++) {
            perm[i][j] = (fact[i] * mod_pow(fact[i-j], MOD-2)) % MOD;
        }
    }

    cin >> N >> A >> B >> C >> D;
    dp[A-1][0] = 1;
    for(int i=A; i<=B; i++) {
        for(int j=0; j<=N; j++) {
            (dp[i][j] += dp[i-1][j]) %= MOD;
            for(int k=C; j-k*i >= 0 && k <= D; k++) {
                // printf("(%d, %d, %d): perm[%d][%d] = %lld, fact[k] = %lld, (i!)^k = %lld\n", i, j, k, N-j+k*i, k*i, perm[N-j+k*i][k*i], fact[k], mod_pow(fact[i], k));
                ll val = (dp[i-1][j-k*i] * perm[N-j+k*i][k*i]) % MOD;
                (val *= mod_pow(fact[k], MOD-2)) %= MOD;
                (val *= mod_pow(mod_pow(fact[i], k), MOD-2)) %= MOD;
                (dp[i][j] += val) %= MOD;
            }
            // printf("dp[%d][%d] = %lld\n", i, j, dp[i][j]);
        }
    }
    cout << dp[B][N] << endl;
    return 0;
}

Measured memory_bytes: 15360