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

int main()
{
  int a, b, c, x;
  int ans = 0;
  cin >> a >> b >> c >> x;

  for (int k = 0; k <= a; k++) {
    for (int l = 0; l <= b; l++) {
      int t;
      t = x - (500 * k + 100 * l);
      if (t < 0) continue;
      if (c >= (t / 50)) ans++;
    }
  }

  cout << ans << endl;
}

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

 int sum=0;

 vector<int> data(N);
 for (int i =0; i<N; i++){
     cin >> data.at(i);
if(data.at(i)>=K){
    sum++;
}
 }
cout<<sum<<endl;
 }

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
#define Maxn 200010
char S[Maxn];
int main(){
	scanf("%s",S+1);
	n=strlen(S+1);
	int cnt=0,last=0;
	int i,at;
	for(i=1;i<=n;i=at+1){
		if(!last){
			cnt++;
			at=i;
			last=1;
		}else{
			if(last==1){
				if(S[i]==S[i-1]){
					if(i==n)break;
					at=i+1;
					cnt++;
					last=2;
				}else{
					at=i;
					cnt++;
					last=1;
				}
			}else if(last==2){
			    cnt++;
			    at=i;
			    last=1;
			} 
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	long long dp[100000];
	memset(dp, 0, sizeof(dp));
	for(int i = 1; i <= 100; i++) {
		for(int j = 1; j <= 100; j++) {
			for(int k = 1; k <= 100; k++) {
				if(i*i+j*j+k*k+i*j+j*k+k*i > n) continue;
				dp[i*i+j*j+k*k+i*j+j*k+k*i]++;
			}
		}
	}
	for(int i = 1; i <= n; i++) {
		printf("%lld\n", dp[i]);
	}
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a * b % 2 == 0) {
    cout << "Even" << endl;
  }
  if ( a * b % 2 == 1) {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 200005
LL dp[105][105][505];
int mod=1e9+7;
int main(){
    int n,x;
    scanf("%d %d",&n,&x);
    int l[105];
    for(int i = 1;i<=n;i++)
        scanf("%d",&l[i]);
    sort(l+1,l+n+1);
    reverse(l+1,l+n+1);
    MEM(dp);
    dp[0][0][0]=1;
    for(int i = 1;i<=n;i++){
        for(int j=1;j<=i;j++){
            for(int k=l[i];k<=x;k++){
                dp[i][j][k]+=dp[i-1][j-1][k-l[i]];
                dp[i][j][k]%=mod;
            }
            LL sum=0;
            for(int k =0;k<=x;k++){
                dp[i][j][k]+=sum*2*j;
                dp[i][j][k]%=mod;
                dp[i][j][k]+=dp[i-1][j][k]*(k-(l[i]-1)*j);
                dp[i][j][k]%=mod;
                sum+=dp[i-1][j][k];
                sum%=mod;
                if(k>=l[i]-1){
                    sum-=dp[i-1][j][k-l[i]+1];
                    sum=(sum+mod)%mod;
                }
            }
            sum=0;
            LL sum2=0;
            if(l[i]!=1)
            for(int k = 0;k<=x;k++){
                sum+=dp[i-1][j+1][k];
                sum2+=dp[i-1][j+1][k]*(l[i]-1)%mod;
                sum%=mod;
                sum2%=mod;
                dp[i][j][k]+=sum2*2*j*(j+1)/2;
                dp[i][j][k]%=mod;
                sum2=((sum2-sum)%mod+mod)%mod;
                if(k>=l[i]-2){
                    sum-=dp[i-1][j+1][k-l[i]+2];
                    sum=(sum+mod)%mod;
                }
            }
            //for(int k = 0;k<=x;k++){
             //   printf("%d %d %d %lld\n",i,j,k,dp[i][j][k]);
           // }
        }
    }
    LL ans=0;
    LL tmp=1;
    for(int i=1;i<=n;i++){
        tmp=tmp*i%mod;
        ans+=dp[n][i][x]*tmp;
        ans%=mod;
    }
    printf("%lld\n",ans);
}
/*

23847657 
23458792534

102334155
111111111 
111111111
*/

Measured memory_bytes: 43904
import java.util.Scanner;
 
class Main {
  
    public static final String LIGHT = "light";
    public static final String FLY = "fly";
    public static final String BANTAM = "bantam";
    public static final String FETHER = "feather";
    public static final String WELTER = "welter";
    public static final String MIDDLE = "middle";
    public static final String HEAVY = "heavy";
  
    public static void main(String[] args) {
  
        Scanner scanner = null;
        try {
            scanner = new Scanner(System.in);
            while (scanner.hasNextDouble()) {
                double weight = scanner.nextDouble();
  
                System.out.println(getClassName(weight));
            }
  
        } finally {
            scanner.close();
        }
    }
  
    private static String getClassName(double num) {
        StringBuilder sb = new StringBuilder();
  
        if (num <= 48.00 || (57.00 < num && num <= 64.00)
                || (69.00 < num && num <= 75.00)
                || (81.00 < num && num <= 91.00)) {
            sb.append(LIGHT);
            sb.append(" ");
        }
        if (num <= 51.00) {
            sb.append(FLY);
        } else if (num <= 54.00) {
            sb.append(BANTAM);
        } else if (num <= 57.00) {
            sb.append(FETHER);
        } else if (num <= 60.00) {
            // Light
        } else if (num <= 69.00) {
            sb.append(WELTER);
        } else if (num <= 81.00) {
            sb.append(MIDDLE);
        } else {
            sb.append(HEAVY);
        }
  
        return sb.toString().trim();
  
    }
  
}

Measured memory_bytes: 27976
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))[::-1]
    if N % 2 == 1:
        print(sum(A[:N//2]) + sum(A[1:N//2+1]))
    else:
        print(sum(A[:N//2-1]) + sum(A[1:N//2]) + A[N//2-1])


if __name__ == '__main__':
    main()


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

int main() {
    int k;
    string s;
    cin >> s >> k;
    REP(i,s.size()){
        int d = 'z' - s[i] + 1;
        if(s[i] == 'a')continue;
        if(d <= k){  // aに変えられるなら変える
            s[i] = 'a'; 
            k -= d;
        }
    }
    if(k > 0){
        k %= 26;
        s.back() += k;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll x, y, a, b, c;cin >> x >> y >> a >> b >> c;
	priority_queue<ll, vector<ll>, greater<>> pq_a;
	priority_queue<ll, vector<ll>, greater<>> pq_b;

	REP(i, a){
		ll now;cin >> now;
		pq_a.push(now);
	}
	REP(i, b){
		ll now;cin >> now;
		pq_b.push(now);
	}

	while(pq_a.size() > x)pq_a.pop();
	while(pq_b.size() > y)pq_b.pop();

	REP(i, c){
		ll now;cin >> now;
		if(pq_a.top() >= now && pq_b.top() >= now)continue;
		if(pq_a.top() > pq_b.top()){
			pq_b.pop();
			pq_b.push(now);
		}
		else{
			pq_a.pop();
			pq_a.push(now);
		}
	}

	ll ans = 0;
	while(!pq_a.empty()){ans += pq_a.top();pq_a.pop();}
	while(!pq_b.empty()){ans += pq_b.top();pq_b.pop();}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2548
init = input().split(' ')
init = [int(i) for i in init]
n,m= init[0],init[1]

ab = []

try:
	while True:
		inp1 = input().split(' ')
		inp1 = [int(i) for i in inp1]
		ab.append([inp1[0],inp1[1]])
except:
	pass

ab.sort()
total = sum([ab[j][0]*ab[j][1] for j in range(n)])
deltarget = sum([ab[j][1] for j in range(n)]) - m

while deltarget > 0:
	if deltarget - ab[len(ab)-1][1] > 0:
		total -= ab[len(ab)-1][0]*ab[len(ab)-1][1]
		deltarget -= ab[len(ab)-1][1]
		ab.pop(len(ab)-1)
	else:
		total -= ab[len(ab)-1][0]*deltarget
		break

print(total)

Measured memory_bytes: 23896
#include<stdio.h>

int main(){

    int n;
    scanf("%d",&n);
    int a[n+1],b[n],a0[n+1];
    for(int i=0;i<n+1;i++){
        scanf("%d",&a[i]);
        a0[i]=a[i];
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }

    for(int i=n;i>0;i--){
        if(a[i]>=b[i-1]){
            a[i]-=b[i-1];
            b[i-1]=0;
        }else{
            b[i-1]-=a[i];
            a[i]=0;
        }

        if(a[i-1]>=b[i-1]){
            a[i-1]-=b[i-1];
            b[i-1]=0;
        }else{
            b[i-1]-=a[i-1];
            a[i-1]=0;
        }
    }

    long count=0;
    for(int i=0;i<n+1;i++){
        count+=a0[i]-a[i];
    }
    printf("%ld\n",count);
    
    
    return 0;
}

Measured memory_bytes: 1280
from heapq import heappush, heappop

mod = 10 ** 9 + 7

N, *E = map(int, open(0).read().split())
E = sorted((e, 1 if i < N else -1) for i, e in enumerate(E))

res = 1
cnt = 0
for _, delta in E:
    if cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)

Measured memory_bytes: 26588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <map>

using namespace std;

int main (void)
{
  int n;
  cin >> n;
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    m[s]++;
  }

  cout << m.size() << endl;
  return 0;
}

Measured memory_bytes: 18720
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = in.nextInt();
            }

            int cnt = 0;
            for (int i = 0; i < ar.length; i++) {
                if (ar[i] == i + 1 && i == ar.length - 1) {
                    int swap = ar[i];
                    ar[i] = ar[i - 1];
                    ar[i - 1] = swap;
                    cnt++;
                }
                if (ar[i] == i + 1) {
                    int swap = ar[i];
                    ar[i] = ar[i + 1];
                    ar[i + 1] = swap;
                    cnt++;
                }
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 51344
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l1=[]
  l2=[]

  for i in range(len(l)):
    if i%2==0:
      l1.append(l[i])
    else:
      l2.append(l[i])

  l1.sort()
  l2.sort()

  a=[]
  b=[]

  p=l1[0]
  c=1
  mx=1
  for x in l1[1:]:
    if x==p:
      c+=1
    else:
      a.append([p,c])
      c=1
      p=x
  a.append([p,c])

  p=l2[0]
  c=1
  mx=1
  for x in l2[1:]:
    if x==p:
      c+=1
    else:
      b.append([p,c])
      c=1
      p=x
  b.append([p,c])

  a=sorted(a,key=lambda x:x[1],reverse=True)
  b=sorted(b,key=lambda x:x[1],reverse=True)

  if a[0][0]==b[0][0]:
    if len(a)==1 and len(b)==1:
      return n//2
    # if a[0][1]<b[0][1]:
    #   return n-a[1][1]-b[0][1]
    # return n-a[0][1]-b[1][1]
    else:
      return min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1])
  return n-a[0][1]-b[0][1]

print(main())


Measured memory_bytes: 21780
import collections

n = int(input())
ss = []

for i in range(n):
    s = input()
    s = sorted(s)
    po = ""
    for i in range(len(s)):
        po += s[i]
    ss.append(po)
    
ss = sorted(ss)


ans = 0
c = collections.Counter(ss)
#print( c.most_common() )
go = c.most_common()
for i in range(len(go)):
    k = go[i][1]
    ans += int((k-1)*k/2)
print(ans)

Measured memory_bytes: 24508
import Control.Applicative ((<$>))


computeFee :: Integral a => a -> a -> a
computeFee a b
    | a >= 13 = b
    | a >= 6 = div b 2
    | otherwise = 0


main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Int]
    print $ computeFee a b


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
string str="aaaaaaaaaa";
int n;
void dfs(int i,int j)
{
	if(i>=n)
	{
		for(int k=0;k<n;k++)
			putchar(str[k]);
		putchar(10);
		return;
	}
	str[i]='a'-1;
	for(int k=0;k<=j;k++)
	{
		str[i]++;
		dfs(i+1,max(k,j-1)+1);	
	}
}
int main()
{
	scanf("%d",&n);
	dfs(0,0);
	return 0;
}

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

int main(){
    long long N,A,B;
    cin >> N >> A >> B;
    long long a;
    long long n;
    long long b;
    n = N/(A+B);
    a = N %(A+B);
    if(a>=A) b = A;
    else b = a;

    long long sum = n*A + b;
    cout  << sum << endl;

}

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

//var 
int K,A,B;
bool ok = 0;

int main(){
	cin >> K >> A >> B;
	for(int i = A; i<=B; i++)ok |= (i%K==0);
	cout << (ok?"OK":"NG") << endl;
}

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

template <typename M>
struct SegmentTree {
    using T = typename M::T;

    int size;
    vector<T> node;

    SegmentTree(int n) : SegmentTree(vector<T>(n, M::id)) {}
    SegmentTree(const vector<T>& v) {
        size = 1;
        while (size < v.size()) size <<= 1;
        node.resize(2 * size, M::id);
        for (int i = 0; i < v.size(); i++) node[i + size] = v[i];
        for (int i = size - 1; i > 0; i--) node[i] = M::op(node[2 * i], node[2 * i + 1]);
    }

    T operator[](int k) const {
        return node[k + size];
    }

    void update(int k, const T& x) {
        k += size;
        node[k] = x;
        while (k >>= 1) node[k] = M::op(node[2 * k], node[2 * k + 1]);
    }

    T query(int l, int r) {
        T vl = M::id, vr = M::id;
        for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
            if (l & 1) vl = M::op(vl, node[l++]);
            if (r & 1) vr = M::op(node[--r], vr);
        }
        return M::op(vl, vr);
    }

    int find_first(int l, const function<bool(T)>& cond) {
        T vl = M::id;
        int r = 2 * size;
        for (l += size; l < r; l >>= 1, r >>= 1) {
            if (l & 1) {
                T nxt = M::op(vl, node[l]);
                if (cond(nxt)) {
                    while (l < size) {
                        nxt = M::op(vl, node[2 * l]);
                        if (cond(nxt)) l = 2 * l;
                        else vl = nxt, l = 2 * l + 1;
                    }
                    return l - size;
                }
                vl = nxt;
                l++;
            }
        }
        return -1;
    }

    int find_last(int r, const function<bool(T)>& cond) {
        T vr = M::id;
        int l = size;
        for (r += size; l < r; l >>= 1, r >>= 1) {
            if (r & 1) {
                r--;
                T nxt = M::op(node[r], vr);
                if (cond(nxt)) {
                    while (r < size) {
                        nxt = M::op(node[2 * r + 1], vr);
                        if (cond(nxt)) r = 2 * r + 1;
                        else vr = nxt, r = 2 * r;
                    }
                    return r - size;
                }
                vr = nxt;
            }
        }
        return -1;
    }
};

struct Monoid {
    using T = int;
    static inline T id = 0;
    static T op(T a, T b) {
        return max(a, b);
    }
};

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

    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    SegmentTree<Monoid> st(A);
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1) {
            int X, V;
            cin >> X >> V;
            st.update(X - 1, V);
        } else if (T == 2) {
            int L, R;
            cin >> L >> R;
            cout << st.query(L - 1, R) << "\n";
        } else {
            int X, V;
            cin >> X >> V;
            int j = st.find_first(X - 1, [&](int v) { return v >= V; });
            cout << (j == -1 ? N + 1 : j + 1) << "\n";
        }
    }
}

Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int k, a, b;
	cin >> k >> a >> b;
	if (k <= a) {
		cout << 1 << endl;
		return 0;
	}
	if (a <= b) {
		cout << -1 << endl;
		return 0;
	}
	k -= a;
	int div = a - b;
	if (k % div) {
		cout << ((k / div) + 1) * 2 + 1 << endl;
	}
	else {
		cout << 2 * (k / div) + 1 << endl;
	}
	return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}


template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;

    string s;
    cin >> s;

    int cnt_for = 0;
    int cnt_dom = 0;

    rep(i, n){
        if(cnt_for+cnt_dom < a+b){
            if(s[i] == 'a'){
                ++cnt_dom;
                Yes();
            }
            else if(s[i] == 'b' && cnt_for < b){
                ++cnt_for;
                Yes();
            }
            else{
                No();
            }
        }
        else{
            No();
        }
    }


    return 0;



}


Measured memory_bytes: 848
#include <iostream>
int main(){
	std::string m[3], w;
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		w = "NA";
		char c;
		for(int i=0;i<3;i++){
			c = m[i][0];
			if(2*c - m[i][1] - m[i][2] == 0 && c - '+')w = c;
			c = m[0][i];
			if(2*c - m[1][i] - m[2][i] == 0 && c - '+')w = c;
		}
		c = m[0][0];
		if(2*c - m[1][1] - m[2][2] == 0 && c - '+')w = c;
		c = m[0][2];
		if(2*c - m[1][1] - m[2][0] == 0 && c - '+')w = c;
		
		std::cout << w << '\n';
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    ll k;cin>>k;
    //just be vigilant about first and second
    ll pos=0;
    for(ll i=0;i<int(s.size());++i){
        if(s[i]!='1'){
            pos=i;break;
        }
    }
    if(k>=pos+1){
        cout<<s[pos];
    }
    else{
        cout<<1;
    }

    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
const char endk = '\n';
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll mod = 1e9 + 7;
    //const ll mod = 998244353;

    ll I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;

	ll ans = 0;
	for (ll i = 0; ; i++) {
		if (I < i || J < i || L < i) break;
		ll subans = O + i * 3;
		subans += (I - i) / 2 * 2;
		subans += (J - i) / 2 * 2;
		subans += (L - i) / 2 * 2;
		ans = max(ans, subans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

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

    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
        H = H - A[i];
    }

    if( H > 0) cout << "No" << endl;
    if( H <= 0) cout << "Yes" << endl;

}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int x, y;
    cin >> x >> y;

    int f = 300000;
    int s = 200000;
    int t = 100000;

    int ans = 0;

    if (x == 1) ans += f;
    else if (x == 2) ans += s;
    else if (x == 3) ans += t;

    if (y == 1) ans += f;
    else if (y == 2) ans += s;
    else if (y == 3) ans += t;

    if (x == 1 && y == 1) ans += 400000;

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int b,f,r,V,n,i,runonce=1;
  int box[4][3][10]={0,0,0};
  int prevb,prevf,prevr,prevV;
  prevV = 0;
  scanf("%d",&n);
for(i=1;i<=n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&V);
    box[b-1][f-1][r-1]+=V;
   
}
  for(b=1;b<4;b++){
    for(f=1;f<=3;f++){
      for(r=1;r<=10;r++){
	 
	if(r<=9){
	  
	  if(box[b-1][f-1][r-1]==0){
	    printf(" 0");
	  }
	  else{
	    printf(" %d",box[b-1][f-1][r-1]);
	  }
	}
	if(r==10){
          if(box[b-1][f-1][r-1]==0){
	    printf(" 0\n");
	  }

	  else{
	    printf(" %d\n",box[b-1][f-1][r-1]);
	  }
	 
	}}
	if(f==3){
	  printf("####################\n");
	}
      }}
  if(b=4){
for(f=1;f<=3;f++){
      for(r=1;r<=10;r++){
	if(r<=9){
	  if(box[b-1][f-1][r-1]==0){
	    printf(" 0");
	  }
	  else{
	    printf(" %d",box[b-1][f-1][r-1]);
	  }
	}
	if(r==10){
          if(box[b-1][f-1][r-1]==0){
	    printf(" 0\n");
	  }

	  else{
	    printf(" %d\n",box[b-1][f-1][r-1]);
	  }
	}
      }
 }}
  return 0;
}

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

using namespace std;

int main(){
    int X, Y;
    cin >> X >> Y;

    for(int i=0; i<=X; i++){
        // i: turtle
        int j = X - i;

        if((2*i + 4*j)==Y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

int main(){
  int A , B ;
  cin >> A >> B ;
  for(int i=1;i<=1009;i++){
    if(i*8/100==A&&i/10==B){
      cout << i << endl;
      break ;
      return 0 ;
    }
  
    if(i==1009) cout << -1 << endl;
  }
  }
    
    
    


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin >>a>>b>>c;
if(a+b==c ||a+c==b||b+c==a) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int N, i, j, pr, b, n, no[10]={1,5,3,3,3,3,3,4,3,4};
	string s;
	vector<string> c(10);
	c[0] = "a";
	c[1] = ".,!? ";
	c[2] = "abc";
	c[3] = "def";
	c[4] = "ghi";
	c[5] = "jkl";
	c[6] = "mno";
	c[7] = "pqrs";
	c[8] = "tuv";
	c[9] = "wxyz";
	
	cin >> N;
	for(i=0;i<N;i++){
		cin >> s;
		pr = 0;
		n = 0;
		//cout << s.size();
		for(j=0;j<s.size();j++){
			b = s[j] - '0';
			//cout << b;
			if(pr == b){
				n++;
			}
			else if(b==0){
				//cout << pr << n%no[pr] << endl;
				cout << c[pr][n%no[pr]];
			}
			else {
				n=0;
			}
			pr = b;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
import math

def is_prime(m):
    if m == 2 or m == 3:
        return True
    for i in range(2, int(math.sqrt(m))+2):
        if m%i == 0:
            return False
    return True

n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if is_prime(x):
        count += 1
print(count)


Measured memory_bytes: 5680
#include <iostream>

using namespace std;

int main()
{
    string one,two;
    int c=0;
    cin >> one >> two;
    for(int i=0;i<one.length();i++){
        if(one[i]!=two[i]){
            c++;
        }
    }
    cout << c;


    return 0;
}


Measured memory_bytes: 3872
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var goodp = -1; var gooddef = 999999d;
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var p = int.Parse(line[0]);
                var h = int.Parse(line[1]) / 100d;
                var w = int.Parse(line[2]);
                var def = Math.Abs(w / (h * h) - 22d);
                if (def < gooddef) { goodp = p; gooddef = def; }
            }
            Console.WriteLine(goodp);
        }
    }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int x;
    cin>>x;
    int syo=x/100;
    int amari=x%100;
    if(syo*5>=amari)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll check(ll v)
{
	// cout << v << "\n";
	if(v == 0)
		return 0;
	ll s = 0;
	while(v>0)
	{
		ll n = v;
		ll cnt = 0;
		while(n>0)
		{
			if(n%2)
				cnt++;
			n = n/2;
		}
		v = v%cnt;
		s++;
	}
	return s;
}

string str;
vector<ll> adj;

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

	ll n,x,pd,pm,d,m,i;

	cin >> n;
	cin >> str;
	reverse(all(str));

	x = 0;
	for(i=0;i<n;++i)
	{
		if(str[i] == '1')
			x++;
	}

	if(x == 0)
	{
		for(i=1;i<=n;++i)
			cout << 1 << "\n";
		return 0;
	}

	pd = pm = 1;
	d = 0;
	m = 0;
	for(i=0;i<n;++i)
	{
		if(str[i] == '1')
		{
			if(x > 1)
				d = (d+pd%(x-1))%(x-1);
			m = (m+pm%(x+1))%(x+1);
		}
		if(x > 1)
			pd = (pd*2)%(x-1);
		pm = (pm*2)%(x+1);
	}

	// cout << x << " " << d << " " << m << "\n";

	pd = pm = 1;
	for(i=0;i<n;++i)
	{
		if(str[i] == '0')
			adj.pb(1+check((m+pm%(x+1))%(x+1)));
		else
		{
			if(x == 1)
				adj.pb(0);
			else
				adj.pb(1+check((d-pd%(x-1)+(x-1))%(x-1)));
		}
		if(x > 1)
			pd = (pd*2)%(x-1);
		pm = (pm*2)%(x+1);
	}

	reverse(all(adj));
	for(auto v:adj) 
		cout << v << "\n";
}

Measured memory_bytes: 5540
N, M = map(int,input().split())
mat = [[ 0 for _ in range(N)] for _ in range(M)]
for i in range(M):
    A = list(map(int, input().split()))
    for j in range(A[0]):
        mat[i][A[j+1]-1] = 1
P = list(map(int,input().split()))

def calc(X):
    for i in range(M):
        tmp = 0
        for j in range(N):
            tmp += mat[i][j] * X[j]
        if tmp % 2 != P[i]:
            return 0
    return 1

ans = 0
for i in range(2 ** N):
    X = [(i >> s) % 2 for s in range(N)]
    ans += calc(X)
print(ans)


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

typedef signed long long ll;
typedef long double ld;

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

#define DEBUG

int main()
{
	int a, b;
	cin >> a >> b;
	if(a >= 13) cout << b << endl;
	else if(a >= 6) cout << b/2 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/01 15:13:18 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	n, m;
	cin >> n >> m;
	priority_queue<int>	Q;
	rep(i, n)
	{
		int x;
		cin >> x;
		Q.push(x);
	}
	rep(i, m)
	{
		int x;
		x = Q.top();
		x /= 2;
		Q.pop();
		Q.push(x);
	}
	int	sum;
	sum = 0;
	rep(i, n)
	{
		sum += Q.top();
		Q.pop();
	}
	cout << sum << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

int main()
{

    string m,n;
    cin>>m>>n;
    int i,k=0,j;

    for(i=0; i<m.size(); i++)
    {
        //  cout<<m<<endl;
        if(m==n)
        {
            cout<<"Yes"<<endl;
            k=1;
            break;
        }
        else
        {
            for(j=m.size()-1; j>=1; j--)
            {
                swap(m[j],m[j-1]);
            }
        }
    }
    if(k==0)
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3460
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
ll dx[4] = {1, -1, 0, 0};
ll dy[4] = {0, 0, 1, -1};
priority_queue<pair<ll, pair<ll, ll>>> pq;
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll h, w, k, x1, x2, y1, y2, i, j;
    cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    ll dist[h + 1][w + 1], b[h + 1][w + 1];
    queue<pair<ll, ll>> q;
    for(i = 0; i <= h; i++) {
    	for(j = 0; j <= w; j++) {
    		dist[i][j] = 1e18;
    		b[i][j] = 0;
    	}
    }
    dist[x1][y1] = 0;
    b[x1][y1] = 1;
    string s[h];
    for(i = 0; i < h; i++) {
    	cin>>s[i];
    }
    q.push(mp(x1, y1));
    while(!q.empty()) {
    	pair<ll, ll> temp = q.front();
    	q.pop();
    	for(i = 0; i < 4; i++) {
    		for(j = 1; j <= k; j++) {
    			ll new_x = temp.ff + dx[i] * j;
    			ll new_y = temp.ss + dy[i] * j;
    			if(new_x < 0 || new_y < 0 || new_x >= h || new_y >= w || s[new_x][new_y] == '@' || dist[new_x][new_y] < dist[temp.ff][temp.ss] + 1) {
    				break;
    			}
    			if(b[new_x][new_y]) {
    				continue;
    			}
    			b[new_x][new_y] = 1;
    			dist[new_x][new_y] = dist[temp.ff][temp.ss] + 1;
    			// cout<<new_x<<" "<<new_y<<" "<<temp.ff<<" "<<temp.ss<<" "<<dist[new_x][new_y]<<"\n";
    			q.push(mp(new_x, new_y));
    		}
    	}
    }
    // for(i = 0; i < h; i++) {
    // 	for(j = 0; j < w; j++) {
    // 		cout<<dist[i][j]<<" ";
    // 	} cout<<"\n";
    // }
    // cout<<dist[]
    if(b[x2][y2]) {
    	cout<<dist[x2][y2]<<"\n";
    } else {
    	cout<<"-1\n";
    }
}

Measured memory_bytes: 35524
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int k, n; cin >> n >> k;
    int h[n]; for (int i = 0; i < n; i++) cin >> h[i];
    sort(h, h+n);
    int ans = 1<<30;
    for (int i = 0; i + k - 1< n; i++) ans = min(ans, h[i+k-1] - h[i]);
    cout << ans << endl;
}


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

const int N = 1e5;

int n,m;
vector<int> li[N+5];
set<int> dup;
int cnt[N+5];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int x; 
		scanf("%d",&x);
		int lol = x%m;
		li[lol].push_back(x);
		if(dup.find(x) == dup.end()){
			dup.insert(x);
		} else {
			dup.erase(x);
			cnt[lol]++;
		}
	}
	int ans = li[0].size()/2;
	for(int i=1;;i++){
		int butuh = m-i;
		if(butuh < i) break;
		if(butuh == i){
			ans+=li[i].size()/2;
			continue;
		}
		ans += min(li[i].size(),li[butuh].size());
		if(li[i].size() > li[butuh].size()){
			int tmp = li[i].size() - li[butuh].size();
			ans+=min(cnt[i],tmp/2);
		} else {
			int tmp = li[butuh].size() - li[i].size();
			ans+=min(cnt[butuh],tmp/2);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int n, m;
    cin >> n;
    //++
    vector<string> blue(n);
    for (int i = 0; i < n; i++)
    {
        cin >> blue[i];
    }
    cin >> m;
    //--
    vector<string> red(m);
    for (int i = 0; i < m; i++)
    {
        cin >> red[i];
    }
    
    //blueなら++
    map<string, int> mp;
    for (int i = 0; i < n; i++)
    {
        mp[blue[i]]++;
    }
    //redなら--
    for (int i = 0; i < m; i++)
    {
        mp[red[i]]--;
    }
    
    
    int maxv = -1;
    string ans;
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        maxv = max(maxv, it->second);
    }
    
    if (maxv < 0)
        cout << 0 << endl;
    else
        cout << maxv << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,m,a,b,c,d[15][15],dp[(1<<15)][15];
int main(void){
    cin>>n>>m;
    for(int i=0;i<15;i++){
        for(int j=0;j<15;j++){
            d[i][j]=-1;
        }
    }
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        d[a][b]=c;
    }
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<15;j++){
            dp[i][j]=1e9;
        }
    }
    
    dp[0][0]=0;
    for(int i=0;i<(1<<n);i++){
        for(int k=0;k<n;k++){
            for(int j=0;j<n;j++){
                if(((i>>j)&1)==1)continue;
                if(d[k][j]!=-1){
                    dp[i|(1<<j)][j]=min(dp[i|(1<<j)][j],dp[i][k]+d[k][j]);
                }
            }
        }
    }
    if(dp[(1<<n)-1][0]==1e9)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1][0]<<endl;
}



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

int32_t main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int yen=1000;
    int stock=0;
    for(int i=0;i<n-1;i++){
       stock=0;
        if(a[i]<a[i+1]){
            stock=yen/a[i];
        }
        yen+=(a[i+1]-a[i])*stock;
    }
    cout<<yen<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

using Graph = vector<vector<pair<int, int>>>;
int ts[101010];
int timestamp = 0;

void dfs(Graph &G, vector<int> &visit, vector<int> &ord, int now){
    visit[now] = 1;
    repe(i, G[now]){
        if(!visit[i.first]){
            dfs(G, visit, ord, i.first);
        }
    }
    ord.push_back(now);
    ts[now] = timestamp++;
}


int main(){
    int n, m;
    cin >> n >> m;
    Graph G(n);
    vector<int> used(m, 0), rem(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    if(m%2){
        cout << -1 << endl;
        return 0;
    }
    rep(i, n) rem[i] = G[i].size();

    vector<int> visit(n, 0), ord;
    dfs(G, visit, ord, 0);
    // repe(i, ord){
    //     cout << i+1 << endl;
    // }

    vector<pair<int, int>> ans;
    repe(i, ord){
        while(rem[i] >= 2){
            deque<pair<int, int>> select;
            repe(j, G[i]){
                if(used[j.second]) continue;
                if(ts[j.first] < ts[i]) select.push_front(j);
                else select.push_back(j);
            }
            // repe(j, select){
            //     cout << i << " " << j.first << " / ";
            // }
            // cout << endl;
            if(select.size() < 2){
                cout << -1 << endl;
                return 0;
            }
            int tmp = 0;
            repe(j, select){
                used[j.second] = 1;
                ans.emplace_back(i, j.first);
                rem[i]--;
                rem[j.first]--;
                if(++tmp >= 2) break;
            }
        }
    }
    repe(i, ans){
        cout << i.first+1 << " " << i.second+1 << endl;
    }

}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	string q,S,w; cin>>q>>S>>w;
	cout<<"A"<<S[0]<<"C";
}

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

uint xor128(){
	static uint x=123456789,y=362436069,z=521288629,w=88675123;
	uint t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct node{
	node*l,*r;
	uint pri;
	int cnt,val,Min;
};
node pool[400000];
int p;

inline int cnt(node*t){return t?t->cnt:0;}
inline int Min(node*t){return t?t->Min:INF;}

inline node*update(node*t){
	t->cnt=cnt(t->l)+cnt(t->r)+1;
	t->Min=min({t->val,Min(t->l),Min(t->r)});
	return t;
}
inline node*merge(node*l,node*r){
	if(!l)return r;
	if(!r)return l;
	if(l->pri>r->pri){
		l->r=merge(l->r,r);
		return update(l);
	}
	else{
		r->l=merge(l,r->l);
		return update(r);
	}
}
inline pair<node*,node*>split(node*t,int k){
	if(!t)return make_pair((node*)NULL,(node*)NULL);
	if(k<=cnt(t->l)){
		auto p=split(t->l,k);
		t->l=p.second;
		return make_pair(p.first,update(t));
	}
	else{
		auto p=split(t->r,k-cnt(t->l)-1);
		t->r=p.first;
		return make_pair(update(t),p.second);
	}
}

int main(){
	int n,q;scanf("%d%d",&n,&q);
	node*root=NULL;
	rep(i,n){
		int a;scanf("%d",&a);
		node*t=&pool[p++];
		*t={NULL,NULL,xor128(),1,a,a};
		root=merge(root,t);
	}
	rep(i,q){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		if(x==0){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y-1);
			auto c=split(b.second,1);
			root=merge(merge(merge(a.first,c.first),b.first),c.second);
		}
		else if(x==1){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y);
			printf("%d\n",Min(b.first));
			root=merge(merge(a.first,b.first),b.second);
		}
		else{
			auto a=split(root,y);
			auto b=split(a.second,1);
			b.first->val=b.first->Min=z;
			root=merge(merge(a.first,b.first),b.second);
		}
	}
}


Measured memory_bytes: 9476
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int r = Integer.valueOf(input[0]);
        int c = Integer.valueOf(input[1]);

        int[][] matrix = new int[r+1][c+1];
        
        //input data
        for(int i = 0; i < r; i++){
            String[] line = br.readLine().split(" " , c);
            for(int j = 0; j < c; j++){
                matrix[i][j] = Integer.parseInt(line[j]);
            }
        }

        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
                matrix[i][c] += matrix[i][j];
            }
        }

        for(int i = 0; i < c+1; i++){
            for(int j = 0; j < r; j++){
                matrix[r][i] += matrix[j][i];
            }
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i <= r; i++){
            for(int j = 0; j <= c; j++){
                sb.append(matrix[i][j]);
                if(j != c) sb.append(" ");
            }
            if(i != r)sb.append("\n");
        }
        System.out.println(sb);

    }
}



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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    double L;
    cin >> L;
    cout << fixed << setprecision(6);
    cout << L * L * L / 27.0 << endl;
}

Measured memory_bytes: 256
N = int(input())
minus = 0
for _ in range(N):
    number = int(input())
    if number != 2 and number % 2 == 0:
        minus += 1
        continue
    i = 3
    while i * i <= number:
        if number % i == 0:
            minus += 1
            break
        i += 2

print(N - minus)


Measured memory_bytes: 5612
import java.util.Scanner;

public class Main {

    public static int q, i, n;
    public static int[] A;
    public static int[] m;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        A = new int[n];
        for (i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }
        q = sc.nextInt();
        m = new int[q];
        for (i = 0; i < q; i++) {
            m[i] = sc.nextInt();
        }
        for (i = 0; i < q; i++) {
            if (solve(0, m[i])) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
    }

    public static boolean solve(int i, int m) {
        if (m == 0) {
            return true;
        }
        if (i >= n) {
            return false;
        }

        boolean res = solve(i + 1, m) || solve(i + 1, m - A[i]);

        return res;
    }
}


Measured memory_bytes: 26772
#include <stdio.h>
 
int main(void)
{
  int min = 1000000001;
  int N;
  int a[201];
  int i, tmp;
  scanf("%d", &N);
  for ( i=0; i<N; i++ ) {
    tmp = 0;
    scanf("%d", &a[i]);
    while ( a[i] > 0 && a[i] % 2 == 0 ) {
      a[i] >>= 1;
      tmp++;
    }
    if ( min > tmp ) {
      min = tmp;
    }
  }
  printf("%d\n", min);
  return 0;
}

Measured memory_bytes: 128
def multiply_columns(column_a, column_b):
    total = 0
    
    for a, b in zip(column_a, column_b):
        total += (a * b)
    
    return total


n, m = [int(x) for x in input().split()]

matrix = []
column_matrix = []

for _ in range(n):
    nums = [int(y) for y in input().split()]
    matrix.append(nums)

single_column_vector = []
for _ in range(m):
    number = int(input())
    single_column_vector.append(number)
    

totals = []
total = 0

for column in matrix:
    total = multiply_columns(column, single_column_vector)
    totals.append(total)

for total in totals:
    print(total)



Measured memory_bytes: 6020