akhauriyash/Code-Regression huggingface dataset:
/**
 *   Author:  Wasi Ur Rahman
 *   FROM RMSTU
**/
#include <bits/stdc++.h>
#define ll                     long long
#define boost                  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ticktock               cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n"
#define min3(a,b,c)            min(a,min(b,c))
#define min4(a,b,c,d)          min(d,min3(a,b,c))
#define max3(a,b,c)            max(a,max(b,c))
#define max4(a,b,c,d)          max(d,max3(a,b,c))
#define all(v)                 v.begin(),v.end()
#define revall(v)              v.rbegin(),v.rend()
#define pb                  	push_back
#define eb                     emplace_back
#define setbits(x)             __builtin_popcountll(x)
#define zrobits(x)             __builtin_ctzll(x)
#define si(x)               	scanf("%d", &x)
#define sii(x, y)           	scanf("%d %d", &x, &y)
#define siii(x, y, z)       	scanf("%d %d %d", &x, &y, &z)
#define siiii(p,x, y, z)    	scanf("%d %d %d %d",&p, &x, &y, &z)
#define sll(x, y)           	scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       	scanf("%lld %lld %lld", &x, &y, &z)
#define read                	freopen("input.txt","r",stdin)
#define write               	freopen("output.txt","w",stdout)
#define println()          		cout << endl
#define printi(x)           	printf("%d\n")
#define printii(x,y)        	printf("%d %d\n")
#define printiii(x,y,z)     	printf("%d %d %d\n")
#define printl(x)           	printf("%lld\n")
#define printll(x,y)        	printf("%lld %lld\n")
#define printlll(x,y,z)     	printf("%lld %lld %lld\n")
using namespace std;
/*************************************
*          A S S E M B L E         *
**************************************/
bool Prime(ll n){if(n <= 1)return false;for (ll i = 2; i<=sqrt(n); i++)if (n % i == 0)return false;return true;}
ll fact(ll n){ll res = 1;for(ll i = n;i>=1;i--)res *= i;return res;}
ll nCr(ll n,ll r){return (fact(n)/(fact(r)*fact(n-r)));}
ll nPr(ll n,ll r){return fact(n)/fact(n-r);}
ll modpow(ll a, ll n, ll mod){ll res=1;while(n>0){if(n&1) res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
const int mod= 1e9+7;
inline int add(int a,int b){if((a+=b)>=mod)a-=mod;return a;}
inline int dec(int a,int b){if((a-=b)<0)a+=mod;return a;}
inline int mult(int a,int b){long long t=1ll*a*b;if(t>=mod)t%=mod;return t;}
inline int power(int a,int b){int out=1;while(b){if(b&1)out=mult(out,a);a=mult(a,a);b>>=1;}return out;}
/*************************************
*  E N D    G A M E   S T A R T S  *
**************************************/
int main(){
    boost;
    ll n;
    cin >> n;
    ll i = 1;
    ll p = 1;
    ll ans = 0;
    for(ll i = 1;;i++){
        p = 1000*i;
        if(p >= n)
        {
            cout << abs(p-n) << endl;
            break;
        }
    }
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
const int N = 3066, MOD = 1e9 + 7;
int n, dp[N][N];
char s[N];
int main()
{
    cin >> n >> (s + 1);
    dp[1][1] = 1;
    for (int i = 2; i <= n; ++i) {
        if (s[i - 1] == '<') {
            int c = 0;
            for (int j = 1; j <= i; ++j) {
                dp[i][j] = c;
                c = (c + dp[i - 1][j]) % MOD;
            }
        } else {
            int c = 0;
            for (int j = i; j >= 1; --j) {
                c = (c + dp[i - 1][j]) % MOD;
                dp[i][j] = c;
            }
        }
    }
    cout << accumulate(dp[n] + 1, dp[n] + n + 1, 0ll) % MOD << endl;
}


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

int main()
{
    int A,B;
    cin>>A;
    cin>>B;
    if(A>=13)
        cout<<B<<endl;
    else if(A>=6 && A<=12)
        cout<<B/2<<endl;
    else if(A<=5)
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3556
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    T = iss()
    print('Yes' if len(T[len(S):]) == 1 and T[:len(S)] == S else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9436
n=int(input())
ls=[list(map(int,input().split())) for i in range(n)]
ls=sorted(ls,key=lambda x:sum(x),reverse=True)
taka=sum([ls[i][0] for i in range(0,len(ls),2)])
aoki=sum([ls[i][1] for i in range(1,len(ls),2)])

print(taka-aoki)


Measured memory_bytes: 32992
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll A[200010];
std::vector<ll> vs;
std::map<ll, ll> mp;
ll T = 0;

int main()
{
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> A[i], --A[i];

  ll p = 0;

  vs.emplace_back( 0 );

  ll cnt = 1;

  mp[0] = 0;

  rep( i, N+1 )
  {
    p = A[p];

    if( mp.count(p) )
    {
      T = mp[p];

      break;
    }

    mp[p] = cnt;

    ++cnt;

    vs.emplace_back( p );
  }

  ll ans;

  if( K < T )
    ans = vs[K];
  else
  {
    K -= T;

    ans = vs[T+K%(vs.size()-T)];
  }


  std::cout << ans+1 << std::endl;

  return 0;
}

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

int main()
{
    int N;
    vector<int> D;
    int ans = 1;
    cin >> N;
     for (int i = 0; i < N; ++i)
    {
        int d;
        cin >> d;
        D.push_back(d);
    }
    sort(D.rbegin(), D.rend());
    int tmp = D[0];
     for (int i = 0; i < N; ++i)
    {
        if(D[i] != tmp){
            ++ans;
            tmp = D[i];
        }
    }
    cout << ans << endl;
}

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

H, W = map(int, input().split())
S = ['.' * (W + 2)]
for i in range(H):
    s = '.' + input() + '.'
    S.append(s)
S.append('.' * (W + 2))

ans = []

for h in range(1, H + 1):
    t = ''
    cnt = 0
    for w in range(1, W + 1):
        if S[h - 1][w] == '#':
            cnt += 1
        if S[h + 1][w] == '#':
            cnt += 1
        if S[h][w - 1] == '#':
            cnt += 1
        if S[h][w + 1] == '#':
            cnt += 1
        if S[h - 1][w - 1] == '#':
            cnt += 1
        if S[h + 1][w + 1] == '#':
            cnt += 1
        if S[h + 1][w - 1] == '#':
            cnt += 1
        if S[h - 1][w + 1] == '#':
            cnt += 1

        if S[h][w] == '#':
            t += '#'
        else:
            t += str(cnt)
        cnt = 0
    ans.append(t)

for i in ans:
    print(i)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            int[,] h = new int[2, n];
            str = Console.ReadLine().Split();
            for (int i = 0; i < n; ++i)
            {
                h[0, i] = int.Parse(str[i]);
                h[1, i] = 1;    // good!
            }

            for (int i = 0; i < m; ++i)
            {
                str = Console.ReadLine().Split();
                int a = int.Parse(str[0]) - 1;
                int b = int.Parse(str[1]) - 1;
                if (h[0, a] <= h[0, b])
                {
                    h[1, a] = 0;    // not good!
                }
                if (h[0, a] >= h[0, b])
                {
                    h[1, b] = 0;    // not good!
                }
            }
            int sum = 0;
            for (int i = 0; i < n; ++i)
            {
                sum += h[1, i];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 52064
#include<stdio.h>
#define N 10000

int main(){
  int point1,point2,i,j,n,line1[N],line2[N];
  
  scanf("%d",&point1);
  for(i=0 ; i<point1 ; i++){
    scanf("%d",&line1[i]);
  }
  
  scanf("%d",&point2);

  for(i=0 ; i<point2 ; i++){
    scanf("%d",&line2[i]);
  }
  n=0;
  for(i=0 ; i<point2 ; i++){
    for(j=0 ; j<point1 ; j++){
      if(line1[j]==line2[i]){
	n++;
	break;
      }
    }
  }
  printf("%d\n",n);
  
  return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> A(n), D(n,1);
  A[0] = -1;
  D[0] = 0;
  for(int i = 1; i < n; ++i){
    cin >> A[i];
    --A[i];
    ++D[A[i]];
  }
  vector<int> C = D;
  priority_queue< pair<int,int> > pq;
  //queue< pair<int,int> > pq;
  for(int i = 1; i < n; ++i){
    if(D[i] == 1)
      pq.emplace(-D[i],i);
    --C[i];
  }
  while(!pq.empty()){
    int d = -pq.top().first, idx = pq.top().second;
    //int d = -pq.front().first, idx = pq.front().second;
    pq.pop();
    int p = A[idx];
    D[p] = max(D[p], C[p]+d);
    --C[p];
    if(p > 0 and !C[p]){
      pq.emplace(-D[p],p);
    }
  }
  //for(int i = 0; i < n; ++i) cout << D[i] << " ";cout << endl;
  cout << D[0]-1 << endl;
  return 0;
}


Measured memory_bytes: 2552
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
  //printf("\n");
  char str[1000];
  
  int N,T;
  fgets(str,1000,stdin);
  sscanf(str,"%d %d",&N,&T);

  int c, t;
  int mincost = 1001;
  for(int n=0;n<N;n++) {
    fgets(str,1000,stdin);
    sscanf(str,"%d %d",&c,&t);

    if( t<=T && c<mincost ) {
      mincost = c;
    }
  }
  if( mincost==1001 ) printf("TLE");
  else printf("%d",mincost);

  //printf("\n");
}


Measured memory_bytes: 256
import sys
for line in sys.stdin.readlines():
    line=map(int,line.strip().split(","))
    l,v1,v2=line[0:10],line[10],line[11]
    dist=(sum(l)+0.0)/(v1+v2+0.0)*v1
    for i in xrange(11):
        if sum(l[:i])>=dist:
            print i
            break

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

#define MAX_V 205
#define INF 1e9

long long int d[MAX_V][MAX_V]={0}; // d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF、ただしd[i][i]=0とする)
int V;       // 頂点数
int r[9];

void warshall_floyd() {
  for (int k = 1; k <= V; k++)
    for (int i = 1; i <= V; i++)
      for (int j = 1; j <= V; j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
    int n, m, R;

    cin >> n >> m >> R;
    for(int i=0;i<R;++i){
        cin >> r[i];
    }
    for(int i=0;i<MAX_V;++i){
        for(int j=0;j<MAX_V;++j){
            if(i!=j)d[i][j] = INF;
        }
    }
    for(int i=0;i<m;++i){
        int a,b,c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    V = n;
    warshall_floyd();
    long long int mini = LLONG_MAX;
    sort(r,r+R);
    do{
        long long int sum = 0;
        for(int i=0;i<R-1;++i){
            sum += d[r[i]][r[i+1]];
        }
        if(mini > sum)mini = sum;
    }while(next_permutation(r,r+R));

    cout << mini << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long N,W,w[103],v[103];
long long dp[100003][103][2];
long long f(long long bag,long long x,long long st)
{
    if(bag==0) return 0;
    if(bag<0) return -1987654321;
    if(x==-1) return 0;
    if(dp[bag][x][st]!=-1) return dp[bag][x][st];
    if(st) return dp[bag][x][st]=max(f(bag-w[x],x-1,true),f(bag-w[x],x-1,false))+v[x];
    else return dp[bag][x][st]=max(f(bag,x-1,true),f(bag,x-1,false));
}

int main()
{
    memset(dp,-1,sizeof(dp));
    scanf("%lld %lld",&N,&W);
    for(long long i=0;i<N;i++) scanf("%lld %lld",&w[i],&v[i]);
    printf("%lld",max(f(W,N-1,true),f(W,N-1,false)));
}


Measured memory_bytes: 161280
#include<cstdio>

using namespace std;

int main()
{
    long long n;
    while(~scanf("%lld",&n))
    {
        if(n==1)
             printf("2\n");
        else if(n&1)
            printf("%lld\n",2*n);
        else
            printf("%lld\n",n);
    }
    return 0;
}

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

int main() {
  int a;
  cin >> a;
  int b[100];
  for(int i =0;i <a ;i++)
    cin >> b[i];
     
  sort(b,b+a);
  
  
  cout << b[a-1]-b[0] <<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int C = in.i();
        int K = in.i();
        int[] T = in.ii(N);
        Arrays.sort(T);

        int t = 0;
        int p = 0;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (t < T[i] || p == C) {
                t = T[i] + K;
                p = 1;
                ans++;
            } else {
                p++;
            }
        }
        
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36652
using System;
 
namespace AtCoder
{
    class Program
    {
        static IO io = new IO();
 
        static void Main(string[] args)
        {
            //入力
            io.Read();
            int n = io.Int();
            io.ReadSplit();
            int[] a = io.Int(n);
 
            //計算
            long operations1 = EnumeratOperation(a, 1);
            long operations2 = EnumeratOperation(a, -1);
 
            //出力
            io.WriteLine(Math.Min(operations1, operations2).ToString());
        }
        static long EnumeratOperation(int[] a, int sign)
        {
            long sum = 0;
            long operations = 0;
            for (int i = 0; i < a.Length; ++i)
            {
                sum += a[i];
                if (sum == 0)
                {
                    operations += 1;
                    sum -= sign;
                }
                else if (sum * sign > 0)
                {
                    long newoperation = -sum - sign;
                    operations += Math.Abs(newoperation);
                    sum += (newoperation);
                }
                sign *= -1;
            }
            return operations;
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

Measured memory_bytes: 26972
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int calc(int a,int b,int n){
  if(n==0) return a+b;
  if(n==1) return a-b;
  return a*b;
}
char enzansi(int n){
  if(n==0) return '+';
  if(n==1) return '-';
  if(n==2) return '*';
}
string siki(string i,string j,int n){
  string enzan = "+";
  enzan = enzansi(n);
  string ret = "("+i+enzan+j+")";
  return ret;
}
string IntToString(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}

int main(void){
  int a[4];
  while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
    if(a[0]==0) break;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(i!=j){
          for(int k=0;k<3;k++){
            int e[3]; 
            e[0] = calc(a[i],a[j],k);
            for(int h=0,n=1;h<4;h++)if(h!=i&&h!=j)e[n++] = a[h];
            REP(l,3)REP(m,3)if(l!=m){
              for(int p=0; p<3; p++){
                int f[2];
                int g;
                f[0] = calc(e[l],e[m],p);
                REP(n,3)if(n!=l&&n!=m){
                  f[1]=e[n];
                  g = n;
                }
                REP(n,3){
                  if(calc(f[0],f[1],n)==10){
                    if(g==0){
                      string A = siki(IntToString(a[i]),IntToString(a[j]),k);
                      string B = siki(IntToString(e[l]),IntToString(e[m]),p);
                      cout<<siki(B,A,n)<<endl;
                    }else{
                      string A = siki(IntToString(a[i]),IntToString(a[j]),k);
                      string B;
                      if(l==0){
                        B = siki(A,IntToString(e[m]),p);
                      }else{
                        B = siki(IntToString(e[l]),A,p);
                      }
                      cout<<siki(B,IntToString(f[1]),n)<<endl;
                    } 
                    goto ENDDD;
                  }                }
              }
            }
          }
        }
      }
    }
    cout<<0<<endl;
ENDDD:;
  }     
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int i,j,N,A[100],key;
    scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(j=0;j<N-1;j++){
    printf("%d ",A[j]);
  }

  printf("%d\n",A[N-1]);

  for(i=1;i<N;i++){
    key=A[i];
    j=i-1;
    while(j>=0&&A[j]>key){
      A[j+1]=A[j];
      j--;
      A[j+1]=key;
    }
  for(j=0;j<N-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[N-1]);
  }

  return 0;
  }



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

int main() {
  int n,m; cin>>n>>m;
  ll k; cin>>k;
  // 机AとBの本を、上から読んでいったときの合計時間
  vector<ll> a(n+1,0);
  vector<ll> b(m+1,0);
  for(int i=1; i<=n; i++) {
    int t; cin>>t;
    a[i]=a[i-1]+t;
  }
  for(int i=1; i<=m; i++) {
    int t; cin>>t;
    b[i]=b[i-1]+t;
  }
  // Aの読む冊数を固定して考える
  // Bはm冊から減らしていけば良い
  int bMax=m;
  int ans=0;
  for(int i=0; i<=n; i++) {
    for(int j=bMax; j>=0; j--) {
      if(a[i]+b[j]>k) continue;
      else {
        bMax=j;
        ans=max(ans,i+j);
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6424
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    
    
    int n, m;
    cin >> n >> m;
    
    vector<P> v(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i].first >> v[i].second;
    }
    
    sort(v.begin(), v.end());
    int can = 1;
    int i = 0;
    priority_queue<P> q;
    ll ret = 0;
    while (can <= m)
    {
        while (v[i] < make_pair(can + 1, 0))
        {
            q.push(make_pair(v[i].second, v[i].first));
            i++;
        }
        if (q.size() > 0)
        {
            P use = q.top();
            q.pop();
            ret += use.first;
        }
        can++;
    }
    
    
    cout << ret << endl;
    
    
    return 0;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int dfs(vector<vector<int>> &edges, int now, int prev) {
    int grd = 0;
    for (int next : edges[now]) {
        if (next == prev) continue;
        grd ^= dfs(edges, next, now);
    }
    grd++;
    return grd;
}

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


    vector<vector<int>> edges(n);
    rep(i, n - 1) {
        int x, y;
        cin >> x >> y;

        x--;
        y--;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    int res = dfs(edges, 0, -1);
    res--;
    cout << (res == 0 ? "Bob" : "Alice") << endl;

}


Measured memory_bytes: 11904
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    cin >> s;
    string tmp, origin;
    origin.resize(s.size());
    copy(s.begin(), s.end(), origin.begin());
    int ans = INT_MAX;
    for(char a = 'a'; a <= 'z'; ++a){
        s.resize(origin.size());
        copy(origin.begin(), origin.end(), s.begin());
        int num;
        rep(i, 101){
            bool end = true;
            char f = s[0];
            repi(i, s){
                if(*i != f){
                    end = false;
                    break;
                }
            }
            if(end){
                num = i;
                break;
            }
            tmp.resize(s.size() - 1);
            rep(j, s.size() - 1){
                if(s[j] == a){
                    tmp[j] = s[j];
                }else{
                    tmp[j] = s[j + 1];
                }
            }
            s = tmp;
        }
        ans = min(num, ans);
    }
    cout << ans << endl;
    return 0;
}


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

int h,w,n;
int main(){
	cin >> h >> w >> n;
	int a = max(h,w);
	int b = min(h,w);
	int ans = 0;
	while(ans * a < n){
		ans += 1;
	}
	cout << ans << endl;
}

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

int main(){
  int S;
  cin >> S;
  vector<int> a;
  a.push_back(S);
  int i = 1;
  while(true){
    int next;
    if(a[i-1] % 2 == 0){
      next = a[i-1]/2;
    }else{
      next = a[i-1] * 3 + 1;
    }
    auto  itr = find(a.begin(),a.end(),next);
    if(distance(a.begin(),itr) == a.size()){
      a.push_back(next);
      i++;
    }else{
      cout << i + 1 <<endl;
      break;
    }
    
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

struct Point {
    double x, y;
};

void koch(int n, Point a, Point b) {
    if (n == 0) return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    cout << s.x << " " << s.y << endl;
    koch(n - 1, s, u);
    cout << u.x << " " << u.y << endl;
    koch(n - 1, u, t);
    cout << t.x << " " << t.y << endl;
    koch(n - 1, t, b);
}

int main() {
    Point a = {0, 0}, b = {100, 0};
    int n;
    cin >> n;
    cout << a.x << " " << a.y << endl;
    koch(n, a, b);
    cout << b.x << " " << b.y << endl;
}


Measured memory_bytes: 3292
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <tuple>

using namespace std;

class Solver{

};

int main() {
	vector<tuple<string, string>> colors{
		make_tuple("#000000","black"),
		make_tuple("#0000ff","blue"),
		make_tuple("#00ff00","lime"),
		make_tuple("#00ffff","aqua"),
		make_tuple("#ff0000","red"),
		make_tuple("#ff00ff","fuchsia"),
		make_tuple("#ffff00","yellow"),
		make_tuple("#ffffff","white"),
	};


	while (true) {
		string s;
		cin >> s;
		if (s[0] == '0')break;

		int num = -1;
		int dd = 1e9;
		int r = 0;
		int g = 0;
		int b = 0;
		if ('a' <= s[1] && s[1] <= 'f')r += 16 * (s[1] - 'a' + 10);
		else r += 16 * (s[1] - '0');
		if ('a' <= s[2] && s[2] <= 'f')r += (s[2] - 'a' + 10);
		else r += (s[2] - '0');
		if ('a' <= s[3] && s[3] <= 'f')g += 16 * (s[3] - 'a' + 10);
		else g += 16 * (s[3] - '0');
		if ('a' <= s[4] && s[4] <= 'f')g += (s[4] - 'a' + 10);
		else g += (s[4] - '0');
		if ('a' <= s[5] && s[5] <= 'f')b += 16 * (s[5] - 'a' + 10);
		else b += 16 * (s[5] - '0');
		if ('a' <= s[6] && s[6] <= 'f')b += (s[6] - 'a' + 10);
		else b += (s[6] - '0');

		for (int i = 0; i < 8; i++) {
			int rr = 0;
			int gg = 0;
			int bb = 0;
			if (get<0>(colors[i])[1] == 'f')rr = 255;
			if (get<0>(colors[i])[3] == 'f')gg = 255;
			if (get<0>(colors[i])[5] == 'f')bb = 255;

			int tmp_d = (rr - r) * (rr - r)
				+ (gg - g) * (gg - g) + (bb - b) * (bb - b);
			if (tmp_d < dd) {
				num = i;
				dd = tmp_d;
			}
		}

		cout << get<1>(colors[num]) << endl;
	}
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define pb push_back
#define s(a, x, y) sort(a.begin()+x, a.begin()+y);
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
ll x, n, a[102];
vector<int> u(102, 2);
int main() {
	u[0]=1;
	cin>>x>>n;
	for(int i=0; i<n; i++){
		cin>>a[i];
		u[fabs(x-a[i])]--;
	}
	for(int i=0; i<100; i++){
		if(u[i]>0){
			for(int j=0; j<n; j++){
				if(x-i==a[j]){
					cout<<x+i;
					return 0;
				}
			}
			cout<<x-i;
			return 0;
		}
	}
	return 0;
}

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

#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

const double PI = 3.14;


int main()
{
	uint64_t a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	bool kawaisou = false;

	if( a1 == a2 && a2 != a3 )	kawaisou = true;
	if( a1 == a3 && a2 != a3 )	kawaisou = true;
	if( a2 == a3 && a1 != a3 )	kawaisou = true;

	cout << ( kawaisou ? "Yes" : "No" ) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int main() {
  	ios::sync_with_stdio(false);
  	int a,b;
  	cin>>a>>b;
  	if(a>b)swap(a,b);
  	for(int i=1;i<=b;i++)cout<<a;
 	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> w(N);
    int from, to;
    for(int i = 0; i < M; i++) {
        cin >> from >> to;
        from--;
        to--;
        w.at(from).push_back(to);
        w.at(to).push_back(from);
    }
    vector<int> ans(N);
    queue<int> q;
    q.push(0);

    while(q.size()) {
        int room = q.front();
        q.pop();
        for(int to : w.at(room)) {
            if(ans.at(to) != 0) {
                continue;
            }
            ans.at(to) = room + 1;
            q.push(to);
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < N; i++) {
        cout << ans.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 10120
use std::io;


fn main() {
    let (a, mut b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    if a < 6 { b = 0; }
    if a <= 12 { b /= 2; }

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


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define y first
#define x second

using namespace std;
typedef unsigned long long ll;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int c = 1;
    fr(i, 1, n){
        if(s[i] != s[i - 1]) c++;
    }
    cout << c - 1 << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#define N 1000

int c[N + 1][N + 1];

int max(int x, int y)
{
	return (x > y) ? x : y;
}

int lcs(std::string X, std::string Y)
{
	int ret = 0;
	int m = X.length();
	int n = Y.length();
	X = " " + X;
	Y = " " + Y;
	for (int i = 0; i <= m; i++) c[i][0] = 0;
	for (int j = 1; j <= n; j++) c[0][j] = 0;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (X[i] == Y[j])
			{
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else
			{
				c[i][j] = max(c[i][j - 1], c[i - 1][j]);
			}
			ret = max(c[i][j], ret);
		}
	}

	return ret;
}

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

	for (int i = 0; i < n; i++)
	{
		std::string x, y;
		std::cin >> x;
		std::cin >> y;
		std::cout << lcs(x, y) << std::endl;
	}
}


Measured memory_bytes: 7152
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

 //int dp[1001][1001];
 /*
vector < int > tree(400005);

void buildtree (vector < int > v,int node,int start,int fin)
  {
      if(start==fin)
      {
          tree[node]=v[start];
          return;
      }
      int mid=(start+fin)/2;
      buildtree(v,2*node,start,mid);
      buildtree(v,2*node+1,mid+1,fin);
      tree[node]=tree[2*node]+tree[2*node+1];
  }

 int sum (int node,int tl,int tr,int l , int r)
   {
       if(l>r) return 0;
       if(l==tl and r==tr) return tree[node];
       int mid=(tl+tr)/2;
       return sum(2*node,tl,mid,l,min(r,mid))+sum(2*node+1,mid+1,tr,max(l,mid+1),r);
   }

  void update(int node,int tl , int tr,int pos,int val)
    {
        if(tl==tr) {tree[node]=val; return;}
        int mid=(tl+tr)/2;
        if(pos<=mid)
              update(2*node,tl,mid,pos,val);
        else
            update(2*node+1,mid+1,tr,pos,val);
        tree[node]=tree[2*node]+tree[2*node+1];

    }
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}
*/
   bool vis[100005];

void dfs(vector < vector < int > > &g ,int s)
{
    vis[s]=true;
    for(auto it : g[s])
        if(!vis[it]) dfs(g,it);
}
void solve()
{
    int i,j=0,r=200,p,q,k,d,y=0,h,flag=1,n,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l;
   cin>>n>>m>>q;
   vector  < int > v(n);
   rep(i,0,n) v[i]=m;
   rep(i,0,q)
    {
        cin>>y;
        y--;
        v[y]++;
    }
    rep(i,0,n)
    {
        if(v[i]>q) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
     solve();
}


Measured memory_bytes: 1024
while True:
    N, M = map(int, raw_input().split())
    if N == M == 0:
        break
    A = [int(raw_input()) for _ in xrange(N)]
    B = [int(raw_input()) for _ in xrange(M)]
    s = sum(A) - sum(B)
    A = set(A)
    B = set(B)
    if s % 2 != 0:
        print -1
        continue
    ans = []
    for a in A:
        if a - s / 2 in B:
            ans.append((a, a - s / 2))
    print ' '.join(map(str, min(ans, key=lambda x:x[0]+x[1]))) if len(ans) > 0 else -1
    

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

int main() {
  
  int r, g, b;
  cin >> r >> g >> b;
  
  r *= 100;
  g *= 10;
  
  int N = r + g + b;
  
  if ( N % 4 == 0 ) cout << "YES" << endl;
  if ( N % 4 != 0 ) cout << "NO" << endl;
  
}

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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r = 0;
	int c,s = 0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	double res = 0;
	int n = ri(), k = ri();
	for (int i = 1; i <= n; i++) {
		double cur = 1;
		for (int j = i; j < k; j *= 2) cur /= 2;
		res += cur;
	}
	printf("%.11f\n", res / n);
	
	return 0;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if (s==u) a--;
	else if (t==u) b--;
	cout<<a<<" "<<b<<"\n";
	return 0;
}


Measured memory_bytes: 256
import numpy as np
n,d = map(int,input().split())
x = []
for i in range(n):
    x.append(np.array(list(map(int, input().split()))))
    
count = 0
for i in range(n-1):
  for k in range(i+1,n):
    if (np.linalg.norm(x[i]-x[k]))%1 == 0:
      count += 1
      
print(count)

Measured memory_bytes: 12504
#include<stdio.h>


int selectionSort(int A[], int N){
	int i,j,t,sw=0,minj;
	for( i=0; i<N-1; i++){
		minj=i;
		for(j=i; j<N; j++){
			if(A[j]<A[minj])minj=j;
		}
		t=A[i];A[i]=A[minj];A[minj]=t;
		if(i!=minj)sw++;
	}
	return sw;
}

int main(){
	int A[100],N,i,sw;
	
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	sw=selectionSort(A,N);
	
	for(i=0;i<N;i++){
		if(i>0)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	
	return 0;
}
    

Measured memory_bytes: 604
n, yen = map(int, input().split())
yen //= 1000

for noguchi in range(n + 1):
    for higuchi in range(n + 1 - noguchi):
        yukichi = n - noguchi - higuchi
        if noguchi + higuchi * 5 + yukichi * 10 == yen:
            print(yukichi, higuchi, noguchi)
            exit(0)
print("-1 -1 -1")

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


int x, y;
int main() {
	scanf("%d%d", &x, &y);
	int g = __gcd(x, y);
	x /= g;
	y /= g;
	if (x % y == 0) {
		printf("-1\n");
	} else {
		if (y == 2) {
			printf("%lld\n", 3ll * x * g);
		} else {
			printf("%lld\n", 2ll * x * g);
		}
	}
	
	
	return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int f(int n)
{
    int c=0;
    for(int i=1;;i++)
    {
        for(int j=1;;j++)
        {
            for(int k=1;;k++)
            {
                if(i*i+j*j+k*k+i*j+j*k+k*i==n)
                {
                    c++;
                }
                else if(i*i+j*j+k*k+i*j+j*k+k*i>n)
                {
                    break;
                }
            }
            if(j*j>=n)
                break;
        }
        if(i*i>=n)
            break;
    }
    return c;
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;

    loop(i,1,n+1)
    {
        cout<<f(i)<< "\n";
    }


    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int n = s.size();
    int ans_1 = n, ans_2 = n;
    rep(i,n) {
        if (s[i] == '1') ans_1 = min(ans_1,max(i,n-1-i));
        if (s[i] == '0') ans_2 = min(ans_2,max(i,n-1-i));
    }
    cout << max(ans_1,ans_2) << endl;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


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

    int N, T, S;
    cin >> N >> T >> S;
    V<pair<int, int>> items(N);
    FOR(i, 0, N) {
        int A, B;
        cin >> A >> B;
        items[i] = make_pair(A, B);
    }

    VV<LL> dp(N + 10, V<LL>(3010, -INF));
    dp[0][0] = 0;

    FOR(i, 0, N) {
        int p = items[i].first;
        int t = items[i].second;

        FOR(j, 0, dp[0].size()) {
            // not use
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            // use
            if (j < S and j + t > S) {
                if (S + t < dp[0].size()) {
                    dp[i + 1][S + t] = max(dp[i + 1][S + t], dp[i][j] + p);
                }
            }
            else {
                if (j + t < dp[0].size()) {
                    dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + p);
                }
            }
        }
    }

    LL ans = 0;
    FOR(i, 0, T + 1) {
        ans = max(ans, dp[N][i]);
    }
    print(ans);

	return 0;
}


Measured memory_bytes: 73956
import heapq

N = int(input())
A = list(map(int, input().split()))
n1 = A[:N]
s1 = [sum(n1)]
heapq.heapify(n1)
for i in range(N):
    heapq.heappush(n1,A[N+i])
    p = heapq.heappop(n1)
    s1.append(s1[-1]-p+A[N+i])

s3 = [-(sum(A[-N:]))]
n3 = [-a for a in A[-N:]]
heapq.heapify(n3)
for i in range(N):
    heapq.heappush(n3,-A[-N-i-1])
    p = heapq.heappop(n3)
    s3.append(s3[-1]-p-A[-N-i-1])
M = -10**15
# print(s3)
for i,j in zip(s1,s3[::-1]):
    # print(i,j)
    M = max(M,i+j)

print(M)

Measured memory_bytes: 38292