akhauriyash/Code-Regression huggingface dataset:
//15:23
#include <stdio.h>
#include <string.h>
#include <algorithm>

typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abs(ll a){return(a<0)?-a:a;}

ll gcd(ll a, ll b){
        if(b > a){
                ll tmp = b;
                b = a;
                a = tmp;
        }
        if(b == 0) return a;
        else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
        ll gcdi = gcd(a,b);
        return a/gcdi*(b);
}

#define MOD (1000000000+7)
int main(){
        int N,M;
        scanf("%d %d",&N,&M);
        if(abs(N-M) >= 2){
                puts("0"); return 0;
        }
        ll patN = 1;
        ll patM = 1;
        for(int i = 1; i <= N; i++){
                patN *= i;
                patN %= MOD;
        }
        for(int i = 1; i <= M; i++){
                patM *= i;
                patM %= MOD;
        }
        if(N == M){
                printf("%lld\n",((2*patM*patN)%MOD));
        }else{
                printf("%lld\n",((patM*patN)%MOD));
        }

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,c=0;
    cin>>N;
   long long int a[N];
    for(int i=0;i<N;i++){
    cin>>a[i];
    }
    for(int i=0;i<N;i++){
        if(a[i]%2==1){
            c++;
        }
    }
    if(c%2==1){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
  return 0;  
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;

ll dp[45][405][405]; 
 
int main(void) {
  int i,j,k;
  int n,ma,mb;
  cin>>n>>ma>>mb;
  rep(i,45)rep(j,405)rep(k,405)
    dp[i][j][k]=INF;
  dp[0][0][0]=0;
 
  rep(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    rep(j,405)rep(k,405)
      if(dp[i][j][k]<INF){
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        if(j+a<405 && k+b<405)
          dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c);
     }
  }
 
  ll ans=INF;
  for(i=1;i*max(ma,mb)<405;i++)
    ans=min(ans,dp[n][i*ma][i*mb]);
  if(ans<INF)
    cout<<ans<<endl;
  else
    cout<<-1<<endl;
}

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

int main()
{
	int w[10], k[10];

	for (int i = 0; i < 10; i++)
		cin >> w[i];

	for (int i = 0; i < 10; i++)
		cin >> k[i];

	sort(w, w + 10);
	sort(k, k + 10);

	cout << w[7] + w[8] + w[9] << " " << k[7] + k[8] + k[9] << endl;

	return 0;
}


Measured memory_bytes: 3124
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

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



int main(){
	int64 A;
	double dB;
	cin >> A >> dB;
	int B = dB*64+dB*32+dB*4;
	int64 ans = A*B/100;
	printf("%lld\n",ans);
}


Measured memory_bytes: 3776
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int dp[(1<<18)][20], c[(1<<18)][20];

int n, a[N],b[N];

int main () {
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}

	for(int mask = 0; mask < (1<<n); mask++){
		for(int i = 0; i < n; i++){
			dp[mask][i] = mod;
		}
	}

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

	for(int mask = 0; mask < (1<<n); mask++){
		int res = 0;
		for(int j = n - 1; j >= 0; j--){
			c[mask][j] = res;
			if(mask & (1<<j)) res++;
		}
	}

	for(int mask = 1; mask < (1<<n); mask++){
		int bp = __builtin_popcount(mask);
		int np,k,x,y;
		for(int i = 0; i < n; i++) if(mask & (1<<i)){
			for(int j = 0; j < n; j++) if(!(mask & (1<<j))){
				if(abs(i - bp - 1) & 1){
					x = b[i];
				}
				else x = a[i];
				if(abs(j - bp) & 1){
					y = b[j];
				}
				else y = a[j];
				if(y >= x){
					int np = c[mask][j] + j;
				    dp[mask | (1<<j)][j] = min(dp[mask | (1<<j)][j], dp[mask][i] + abs(np - bp));
				}
			}
		}
	}
	int ans = mod;
	for(int i = 0; i < n; i++){
		ans = min(ans, dp[(1<<n) - 1][i]);
	}
	if(ans == mod) cout << -1;
	else cout << ans;
 
return 0;
}

Measured memory_bytes: 41472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = CinTAr();
            var i = (a[1] + a[2]) - a[0];
           if(i <= 0) { i = 0; }
            Cout(i);
            Cin();
        }



        static readonly int MOD1E9 = 10000007;
        static bool isInt(double d) { return (int)d == d; }
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void Cout(object s) { WriteLine(s); }
        static int[] yakusuu(int n)
        {
            if (n == 1) { return new int[] { 1 }; }
            HashSet<int> res = new HashSet<int>();
            for (int i = 1; i < Math.Ceiling(n / 2.0); i++)
            {
                if (n % i == 0)
                {
                    res.Add(i);
                    res.Add(n / i);
                }
            }
            return res.ToArray();
        }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }

        public static long nCr(int n, int r)
        {
            // naive: return Factorial(n) / (Factorial(r) * Factorial(n - r));
            return nPr(n, r) / Factorial(r);
        }

        public static long nPr(int n, int r)
        {
            // naive: return Factorial(n) / Factorial(n - r);
            return FactorialDivision(n, n - r);
        }

        private static long FactorialDivision(int topFactorial, int divisorFactorial)
        {
            long result = 1;
            for (int i = topFactorial; i > divisorFactorial; i--)
                result *= i;
            return result;
        }

        private static long Factorial(int i)
        {
            if (i <= 1)
                return 1;
            return i * Factorial(i - 1);
        }
    }
}


Measured memory_bytes: 13268
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/xxxyyyy/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/xxxyyyy/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String s = sc.next();
			for(int i = 0; i < s.length(); i++){
				if ( s.charAt(i) == '@') {
					i++;
					int n = s.charAt(i) - '0';
					i++;
					while(n-->0) System.out.print(s.charAt(i));
				} else
					System.out.print(s.charAt(i));
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int antena[5];
    int k;
    for (int i = 0; i < 5; i++) cin >> antena[i];
    cin >> k;
    bool flag = false;
    for (int i = 0; i < 5 - 1; i++){
        for (int j = i+1; j < 5; j++){
            int dist = antena[j] - antena[i];
            if (dist > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N,M,C ;
  cin >> N >> M >> C ;
  int B[30] ;
  cinf(M,B) ;
  int A[30] [30] ;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++)
      cin >> A[i][j] ;
  }
  int ans=0;
  rep(i,N){
    int sum=0 ;
    rep(j,M){
      sum += A[i][j]*B[j] ;
    }
    if(sum > -C)
      ans++ ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP1_10_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                double sum = 0;
                double sub = 0;
                double num = double.Parse(Console.ReadLine());
                if (num == 0) break;

                string[] str = Console.ReadLine().Split(' ');
                for (int i=0; i<num; i++)
                {
                    sum += double.Parse(str[i]);
                }

                double ave = sum / num;

                for (int j=0; j<num; j++)
                {
                    sub += Math.Pow((double.Parse(str[j]) - ave), 2);
                }
                double alpha = Math.Sqrt(sub / num);

                Console.WriteLine("{0:f8}", alpha);
            }
        }
    }
}

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

using namespace std;

int main(void) {
  int A, B;
  cin >> A >> B;
  
  for (int i = 1;i <= 13000;i++) {
    if ((int)(i * 0.08) == A && (int)(i * 0.10) == B) {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(20);
    int n,x,y;
    cin>>n>>x>>y;
    vector<int> v(n);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            v[min(j-i,abs(x-i)+abs(y-j)+1)]++;
        }
    }
    for(int i=1;i<n;i++)cout<<v[i]<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

int main(){
	int n,k;
	cin>>n>>k;
	
	int hoge=(n-1)*(n-2)/2;
	if(k>hoge){
		cout<<-1<<endl;
		return 0;
	}
	
	int m=n-1+hoge-k;
	cout<<m<<endl;
	
	for(int i=2;i<=n;++i) cout<<1<<' '<<i<<endl;
	
	int cnt=0;
	int u=2;
	while(cnt<hoge-k){
		for(int v=u+1;v<=n;++v){
			cout<<u<<' '<<v<<endl;
			if(++cnt>=hoge-k) return 0;
		}
		u++;
	}
}

Measured memory_bytes: 3596
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
typedef long long int lli;

using namespace std;

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

    int cnt=0,cnt2=0;

    for(int i=0;i<3;i++){   
        if(N[i]=='R'){
            cnt++;
        }
    }

    if(cnt>1){
        for(int i=1;i<4;i++){   
        if(N[i-1]=='R' && N[i]=='R'){
            cnt2++;
        }
        }
        cnt2++;
    }
    if(cnt==1 || cnt==0){
    cout << cnt << endl;
    }else{
    cout << cnt2 << endl;
        
    }
}

Measured memory_bytes: 3632
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]

items = [1]
Nd6 = 0
while True:
    if N // (6**(Nd6 + 1)) > 0:
        Nd6 += 1
        items.append(6 ** Nd6)
    else: break

Nd9 = 0
while True:
    if N // (9 ** (Nd9 + 1)) > 0:
        Nd9 += 1
        items.append(9 ** Nd9)
    else: break

items.sort()

dp = [0 for _ in range(N + 1)]
def solve():
    for i in range(N):
        for itm in items:
            if i + itm < N + 1:
                if dp[i + itm] == 0:
                    dp[i + itm] =dp[i] + 1
                else:
                    dp[i + itm] = min(dp[i + itm], dp[i] + 1)

    return dp[N]
  

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 4468
import sys
readline=sys.stdin.readline

# それぞれの数がいくつあるかを管理

from collections import defaultdict
dic = defaultdict(int)

N = int(readline())
A = list(map(int,readline().split()))
ans = 0
for i in range(len(A)):
  dic[A[i]] += 1
  ans += A[i]

Q = int(readline())

for i in range(Q):
  b,c = map(int,readline().split())
  # bがdic[b]個分減り、cがdic[b]個分増える
  ans += c * dic[b] - b * dic[b]
  print(ans)
  dic[c] += dic[b]
  dic[b] = 0


Measured memory_bytes: 24100
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ill long long int
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  ill a, b;
  cin >> a >> b;
  if(a == b){
    cout << "Draw\n";
    return 0;
  }
  if(a == 1){
    cout << "Alice\n";
    return 0;
  }
  if(b == 1){
    cout << "Bob\n";
    return 0;
  }
  if(a > b){
    cout << "Alice\n";
    return 0;
  }
  cout << "Bob\n";
  return 0;
}

Measured memory_bytes: 3516
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0 for i in range(2501)] for j in range(k+2)] for k in range(n+1)]
#dp[i][j][k]:=i枚目まで見てj枚選んで和がkとなるようなカードの取り方の数
dp[0][0][0]=1
for i in range(n):
    see=x[i]
    for j in range(i+2):
        for k in range(2501):
            dp[i+1][j][k]+=dp[i][j][k]
            if see>k or j==0:continue
            dp[i+1][j][k]+=dp[i][j-1][k-see]
ans=0
for i in range(1,n+1):
    ans+=dp[-1][i][i*a]
print(ans)

Measured memory_bytes: 71516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++)
    cin>>d[i];
  int a=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) {
      a+=d[i]*d[j]; 
    } 
  } 
 int b=0;
  for(int i=0;i<n;i++){
    b+=pow(d[i],2);
  }
  cout<<(a-b)/2<< endl; 
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()

def solve2(h, w):
    if h % 2 == 0 or w % 2 == 0:
        return [h*w // 2]
    elif h < w:
        return [h * (w//2), h * (w//2 + 1)]
    else:
        return [w * (h//2), w * (h//2 + 1)]

def solve1(h, w):
    ans = []
    ans.append(max([(h//3) * w] + solve2(h - h//3, w)) - min([(h//3) * w] + solve2(h - h//3, w)))
    ans.append(max([(h//3 + 1) * w] + solve2(h - h//3 - 1, w)) - min([(h//3 + 1) * w] + solve2(h - h//3 - 1, w)))
    return min(ans)

print(min([solve1(h, w), solve1(w, h)]))

Measured memory_bytes: 61976
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N;
  cin>>N;
  int A[N];
  REP(i,N){
    cin>>A[N-1-i];
  }
  
  vector<int> L(N+1,MOD);
  L[0]=-1;
  
  REP(i,N){
    if(A[i]<L[0]){
      L[0]=A[i];
      continue;
    }
    auto it=upper_bound(ALL(L),A[i]);
    int index=it-L.begin();
    
    if(L[index-1]==A[i]) L[index]=A[i];
    else L[index--]=A[i];
  }
  
  RREP(i,N){
    if(L[i]==MOD){
      co(i-1);
      return 0;
    }
  }
  co(N);
  return 0;
}

Measured memory_bytes: 4032
#include <stdio.h>
int a,b,c;
int main(){
  scanf("%d %d %d",&a,&b,&c);
  if(a!=b&a!=c)
  {printf("%d",a);}
  if(b!=a&b!=c)
  {printf("%d",b);}
  
  if(c!=b&c!=a)
  {printf("%d",c);}


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint t0, t1; std::cin >> t0 >> t1;
  lint a0, a1; std::cin >> a0 >> a1;
  lint b0, b1; std::cin >> b0 >> b1;
  lint A = a0*t0 + a1*t1;
  lint B = b0*t0 + b1*t1;
  if (A == B) {
    std::cout << "infinity" << std::endl;
    return 0;
  }
  if (A > B) {
    std::swap(a0,b0);
    std::swap(a1,b1);
    std::swap(A,B);
  }
  lint A_ = a0*t0;
  lint B_ = b0*t0;
  if (A_ < B_) {
    std::cout << 0 << std::endl;
    return 0;
  }
  lint D = B - A;
  lint D_ = A_ - B_;
  lint ans = 2 * (D_ / D) + 1 - (D_ % D == 0);
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        int n = int.Parse(inp[0]);

        List<string> keihin = new List<string>();
        for(int i = 0;i < n;i++) {
            var inps = Console.ReadLine();
            keihin.Add(inps);
        }

        keihin = keihin.Distinct().ToList();

        Console.WriteLine(keihin.Count);
    }
}

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

int gcd(int a,int b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}

int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int result=v[0];
    for(int i=0;i<n;i++)
    {
        result=gcd(result,v[i]);
    }
    cout<<result<<endl;
}

Measured memory_bytes: 3720
import numpy as np
N, K, S = map(int, input().split())
X = [S for _ in range(K)]
if S == 10**9:
    Y = [S - 1 for _ in range(N - K)]
else:
    Y = [S + 1 for _ in range(N - K)]
print(' '.join(map(str, X+Y)))


Measured memory_bytes: 24412
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    s = f.read_str()
    t = f.read_str()

    ans = 0
    for i in xrange(len(s)):
        if s[i] == t[i]:
            ans += 1

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 4636
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func main() {
	var X int
	fmt.Scanf("%d\n", &X)
	N := 100
	cnt := 0
	for N < X {
		N = N + N/100
		cnt++
	}
	fmt.Println(cnt)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 1816
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a<0 && b<0){
        cout<<(b-a)*c<<endl;
    }else if(a<0 && b>0){
        cout<<-a*c+d+b*e<<endl;
    }else if(a>0 && b>0){
        cout<<(b-a)*e<<endl;
    }
    
}


/*
abcdea

/root
a.txt
bunp.html
/desktop
r.txt
fsharp.cs
dp.cpp
/users
bison.txt

root r.txt
users r.txt
users a.txt

desktop/r.txt
../r.txt
../../a.txt
*/



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main()
{
 //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  ios_base:: sync_with_stdio(0);
    cin.tie(0);
    int a=0,b,c,n,i,j,k=0,l=0;
    string abc;
   cin>>a;
   cin>>abc;
   b=abc.size();
   for(i=0;i<b-1;i++){
    if(abc[i]!=abc[i+1]) l++;
   }
  cout<<l+1;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc174/tasks/abc174_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }

    // 二分探索（okは取り得る値の最大値にする）
    int ng = 0, ok = 1e9;
    // 全ての丸太を長さtarget以下にする
    auto fn = [&](int target) {
        int cnt = 0;
        REP(i, N) {
            // 例えば長さ7を7以下にするなら切らなくていい。
            // 7未満にするなら1回切るように数える。
            cnt += DIV(A[i], target) - 1;
            if (cnt > K) {
                break;
            }
        }
        return cnt <= K;
    };
    // めぐる式二分探索よりもコーナーケースに強い実装
    // https://qiita.com/hamko/items/794a92c456164dcc04ad
    while (ok - ng > 1) {
        int mid = (ng + ok) / 2;
        (fn(mid) ? ok : ng) = mid;
    }
    // okが初期値から変わらなければ、fn(mid)は常にfalse
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main() {
  int n;
  cin >> n;
  vector<int64_t> h(n);
  for (int i = 0; i < n; i++) cin>>h.at(i);
  
  int count = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i==n-1) {
      ans=max(ans,count);
    }
    else {
      if(h.at(i)>=h.at(i+1)){count++;}
      else{ans=max(ans,count); count = 0;}
    }
  }
  cout << ans << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> st(m);
    for(int i = 0; i < m; i++){
        cin >> p.at(i) >> st.at(i);
    }
    int wacount = 0;
    int account = 0;
    vector<int> flag(n+1, 0);
    vector<int> wa(n+1, 0);
    for(int i = 0; i < m; i++){
        if(flag.at(p.at(i)) == 0 && st.at(i) == "WA"){
            wa.at(p.at(i)) = wa.at(p.at(i)) + 1;
        } else if(flag.at(p.at(i)) == 0 && st.at(i) == "AC"){
            account++;
            flag.at(p.at(i)) = 1;
        }
    }
    for(int i = 1; i < n+1; i++){
        if(flag.at(i) == 1){
            wacount = wacount + wa.at(i);
        }
    }
    cout << account;
    cout << " ";
    cout << wacount;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    ll a,b,c,x,y; cin>>a>>b>>c>>x>>y;
    ll ans=INF;
    for(ll ab=0; ab<=max(x,y)*2; ab++){
        ll sum=0;
        sum+=ab*c;
        sum+= max((y-ab/2),0LL) *b;
        sum+= max((x-ab/2),0LL) *a;
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i< (n); i++)
typedef long long ll;
using namespace std;
const int INF = 1001001001;

int c[10][1005];

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    int ans = INF;
    rep(i,h) cin >> s[i];
    rep(div, 1<<(h-1))
    {
        int g=0;
        vector<int> id(h);
        rep(i,h)
        {
            id[i] = g;
            if(div>>i & 1) g++;
        }
        g++;
        rep(i,g)rep(j,w) c[i][j] = 0;
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j] - '0');
        bool ok = true;
        rep(i,g)rep(j,w) if(c[i][j] > k) ok = false;
        if(!ok) continue;

        int num = g-1;
        vector<int> now(g);
        auto add = [&](int j)
        {
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if(now[i] > k) return false;
            return true;
        };

        rep(j,w)
        {
            if(!add(j))
            {
                num++;
                now = vector<int>(g);
                add(j);
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}



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

int main(){

	int N;
	cin >> N;
	char S[110];
	for(int i = 0; i < N; i++)
	{
		cin >> S[i];
		if(S[i] == 'Y'){
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	
	return 0;
	
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)

int main(){
    int n,m;
    cin >> n >> m;
    if(n >= m){
        cout << 0;
        return 0;
    }
    vector<int> x(m);
    priority_queue<int,vector<int>,greater<int>> que;
    rep(i,m){
        cin >> x[i];
    }

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

    rep(i,m-1){
        que.push(x[i+1]-x[i]);
    }
    int sum = 0;
    rep(i,m-n){
        sum+=que.top();
        que.pop();
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 1276
s = list(input())
for i in range(26):
    x = chr(i + ord('a'))
    cnt = 0
    m = (0,-1)
    for j,t in enumerate(s):
        cnt -= 1
        if t == x:cnt += 2
        if m[0] < cnt and m[1]+1 != j:
            print(m[1]+2,j+1)
            exit(0)
        elif m[0] > cnt:
            m = (cnt,j)
print(-1,-1)


Measured memory_bytes: 49520
#include<stdio.h>
int main(void){

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

    if(n==2){
        scanf("%d%d",&a,&b);
        printf("%d\n",a+b);
    }else{
        if(n==1){
            printf("Hello World\n");
        }
    }
    return 0;
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

void solve(long long N, long long M){
    ll res = N*(N-1)/2 + M*(M-1)/2;
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<int,int>> vp;
#define pb push_back
#define ll long long int 

void solve()
{
	int a,b,c,r,t=0;
	cin>>a>>b>>c;
	 r=b;
	 t=c;
	 while(r<a)
	 {
	 	t+=c;
	 	r+=b;
	 }
	 cout<<t;
	
}
int main()
{ 
    

   solve();
    
	return 0;
}



Measured memory_bytes: 3620
'''
すぬけ君は 1 〜 N の整数が等確率で出る N 面サイコロと表と裏が等確率で出るコインを持っています。
すぬけ君は、このサイコロとコインを使って今から次のようなゲームをします。
まず、サイコロを 1 回振り、出た目を現在の得点とする。
得点が 1 以上 K−1 以下である限り、すぬけ君はコインを振り続ける。
表が出たら得点は 2 倍になり、裏が出たら得点は 0 になる。
得点が 0 になった、もしくは K 以上になった時点でゲームが終了する。

このとき、得点が K 以上である場合すぬけ君の勝ち、 0 である場合すぬけ君の負けである。

N と K が与えられるので、このゲームですぬけ君が勝つ確率を求めてください。

'''
import math

def main():
	'''
	メイン関数
	'''
	# N面サイコロ, 判定K
	N, K = map(int, input().split())

	# while
	sum  = 0
	for i in range(1,N+1):
		
		x = 0
		while(i*2**x < K) :
			x = x + 1

		sum = sum + (1/N ) * (1/2) ** x  

	print(sum)



if __name__ == '__main__':
	main()


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

int main(void){

	int rectangle=0, lozenge=0;

	while (true){
		int a,b,c;
		char e;
		cin>>a>>e>>b>>e>>c;
		if (cin.eof()) break;
		if (a==b) lozenge++;
		if (a*a+b*b==c*c) rectangle++;
	}
	cout<<rectangle<<endl;
	cout<<lozenge<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
ll dp[maxn];
int w[maxn],v[maxn];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,V;
    scanf("%d%d",&n,&V);
    for(int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=V;j>=w[i];j--)
        {
            dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    printf("%lld\n",dp[V]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



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

int main() {

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




	int n, k;
	int min = 0;
	cin >> n >> k;

	int arr[n];

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

	sort(arr, arr + n);
	for (int j = 0; j < k; j++) {
		min = min + arr[j];
	}

	cout << min;

}

Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>

#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

using namespace std;


// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

bool solve(const vector<int>& A, const int idx, const int tgt) {
    const int n = A.size();
    if (tgt == 0) return true; // in this line, idx can be equal to or greater than n
    if (idx >= n) return false;

    // next step
    bool zero = solve(A, idx + 1, tgt);
    bool one  = solve(A, idx + 1, tgt - A[idx]);
    return zero || one;
}

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

    int n; cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    int q; cin >> q;
    vector<int> M(q);
    rep(i, q) cin >> M[i];

    rep(i, q) {
        const int target = M[i];
        std::cout << (solve(A, 0, target) ? "yes" : "no") << endl;
    }

    return 0;
}



Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N, i;

    public static void main(String[] args) {
        FastScanner fc = new FastScanner(System.in);
        N = fc.nextInt();
        i = fc.nextInt();
        System.out.println(solve());
    }

    static int solve() {
        return N - i + 1;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

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

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

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 23124
class PriorityQueue
    def initialize(arr)
        @size = arr.size
        @array = arr
        @array.unshift(nil)
        h = (@size / 2) | 0
        h.downto(1) do |i|
            maxHeapify(i)
        end
    end
    def getArray
        return @array[1..@size]
    end
    def maxHeapify(i)
        left = 2 * i
        right = 2 * i + 1
        largest = 0
        if left <= @size && @array[left] > @array[i]
            largest = left
        else
            largest = i
        end
        if right <= @size && @array[right] > @array[largest]
            largest = right
        end
        if largest != i
            @array[i], @array[largest] = @array[largest], @array[i]
            maxHeapify(largest)
        end
    end
    def pop
        return -(1<<40) if @size < 1
        maxv = @array[1]
        @array[1] = @array[@size]
        @size -= 1
        maxHeapify(1)
        maxv
    end
    def push(e)
        @size += 1
        i = @size
        @array[i] = -(1<<40)
        return if e < @array[i]
        @array[i] = e
        while i > 1 && @array[i/2] < @array[i]
            @array[i], @array[i/2] = @array[i/2], @array[i]
            i = i / 2
        end
    end
end
 
n, m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map{|n| n.to_i * (-1)}
pq = PriorityQueue.new(a)
arr = []
m.times do
    arr << gets.chomp.split(" ").map(&:to_i)
end
arr = arr.sort_by(&:last).reverse

arr.each do |i|
    b, c = i
    b.times do
        smallest = pq.pop
        if -smallest >= c then
            pq.push(smallest)
            break
        end
        pq.push(-c)
    end
end
 
a = pq.getArray
puts a.map{|n| n*(-1)}.inject(:+)

Measured memory_bytes: 20368
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
 
int main(){
  string n;
  cin >> n;
  if(n == "ABC"){
      cout << "ARC" << endl;
  }else{
      cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())), dtype='int')
dp = np.ones(N, dtype='int') * 1000000000
dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[max(i-K,0):i] + abs(h[max(i-K,0):i] - h[i]))

print(dp[N - 1])


Measured memory_bytes: 22760
N = int(input())

def dfs(s, mx):
  global N
  if len(s) == N:
    print(s)
  else:
    for i in range(ord(mx) - ord('a') + 1):
      dfs(s + chr(ord('a') + i), chr(ord(mx) + 1) if chr(ord('a') + i) == mx else mx)

dfs('', 'a')

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

int main(){
	int count;
	int aSum, bSum;
	int aCard, bCard;

	while(cin >> count, count){
		aSum = bSum = 0;

		for(int i=0; i < count; i++){
			cin >> aCard >> bCard;
			if(aCard > bCard) aSum += aCard + bCard;
			else if(aCard < bCard) bSum += aCard + bCard;
			else aSum += aCard, bSum += bCard;
		}
		cout << aSum << " " << bSum << endl;
	}
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var n, o, e int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		if i%2 == 1 {
			o++
			continue
		}
		e++
	}
	fmt.Println(float64(o) / float64(n))
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main()
{
	char str[1024];
	int i,j;
	int len;
	int flag=0;
	
	memset(str,'\0',sizeof(str));
	
	while(fgets(str,sizeof(str),stdin)!=NULL){
		flag=0;
		len=strlen(str);
		
		while(1){
			for(i=0;i<len;i++){
				if(str[i]=='t'&&str[i+1]=='h'){
					if(str[i+2]=='e'){
						flag=1;
						break;
					}
					else if(str[i+2]=='i'&&str[i+3]=='s'){
						flag=1;
						break;
					}
					else if(str[i+2]=='a'&&str[i+3]=='t'){
						flag=1;
						break;
					}
				}
			}
			if(flag==0){
				for(i=0;i<len;i++){
					if(str[i]>='a'&&str[i]<='z'){
						if(str[i]=='z'){
							str[i]='a';
						}
						else{
							str[i]++;
						}
					}
				}
			}
			else if(flag=1){
				printf("%s",str);
				break;
			}
		}
		memset(str,'\0',sizeof(str));
	}
	return 0;
}

Measured memory_bytes: 0
from subprocess import*
call(('pypy3','-c',"""
I=lambda:list(map(int,input().split()))
n,Ma,Mb=I()
m=[[0,0,0]]+[I()for _ in range(n)]
dp=[[[10**18]*(10*n+1)for _ in range(10*n+1)]for _ in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
    for j in range(10*n+1):
        if j-m[i][0]<0:
            dp[i][j]=dp[i-1][j]
            continue
        for k in range(10*n+1):
            if k-m[i][1]<0:
                dp[i][j][k]=dp[i-1][j][k]
            else:
                dp[i][j][k]=min(dp[i-1][j-m[i][0]][k-m[i][1]]+m[i][2],dp[i-1][j][k])
ans=10**18
for i in range(1,10*n+1):
    j=Mb*i/Ma
    if j==int(j) and j<10*n+2:
        ans=min(ans,dp[-1][i][int(j)])
print(-(ans==10**18)or ans)
"""))

Measured memory_bytes: 99272