akhauriyash/Code-Regression huggingface dataset:
def gcd( x, y )
	if 1 < y && y < x
		return gcd( y, x%y )
	else
		if 1 == y
			return 1
		else 
			return x
		end
	end	
end

a, b = gets.split( " " ).map { |val| val.to_i }
if a < b
	a, b = b, a
end
puts( gcd( a, b ) )

Measured memory_bytes: 6096
import java.io.File;
import java.util.Scanner;

public class Main {
	public static int gcd(int x, int y) {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	}
}

Measured memory_bytes: 17356
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  char S[4];
  cin >> S;

  int count = 0;

  rep(i, 4) {
    if (S[i] == '+')
      count++;
    else
      count--;
  }

  cout << count << endl;

  return 0;
}

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

int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)
      break;
    int x[n];
    for(int i=0;i<n;i++){
      cin >> x[i];
    }

    //sort
    int t;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        if(x[i]<x[j]){
          t = x[i];
          x[i] = x[j];
          x[j] = t;
        }
      }
    }

    //calc
    int sum=0;
    for(int i=1;i<n-1;i++){
      sum+=x[i];
    }
    cout << sum/(n-2) << "\n";
  }
  return 0;
}

Measured memory_bytes: 3100
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    while(true) {
        string[] input = readln.chomp.split(".");
        if (input == ["#"]) break;
        if (input.length == 3) {
            seirekiToMaya(input).reduce!((a,b)=>a~"."~b).writeln;
        } else {
            mayaToSeireki(input).reduce!((a,b)=>a~"."~b).writeln;
        }
    }
}
string[] seirekiToMaya(string[] seireki) {
    int Y = seireki[0].to!int;
    int M = seireki[1].to!int;
    int D = seireki[2].to!int;
    long temp = 0;
    if (Y>2012) {
        temp = func(12, 2012)-21;
        foreach(y; 2013..Y) {
            temp += isUruu(y) ? 366:365;
        }
        foreach(m; 1..M) {
            temp += func(m, Y);
        }
        temp += D;
    } else {
        temp = D-21;
    }
    temp %= 13*20*20*18*20;
    long ki, w, t, ka, b;
    ki = temp;
    w = ki/20;
    ki %= 20;
    t = w/18;
    w %= 18;
    ka = t/20;
    t %= 20;
    b = ka/20;
    ka %= 20;
    return [b, ka, t, w, ki].to!(string[]);
}
string[] mayaToSeireki(string[] maya) {
    int b = maya[0].to!int;
    int ka = maya[1].to!int;
    int t = maya[2].to!int;
    int w = maya[3].to!int;
    int ki = maya[4].to!int;
    long temp = b;
    temp = temp*20+ka;
    temp = temp*20+t;
    temp = temp*18+w;
    temp = temp*20+ki;

    int y, m, d;
    if (temp>10) {
        temp-=11;
        y = 2013;
        m = 1;
        d = 1;
        while (temp>= (isUruu(y) ? 366:365)) {
            temp -= isUruu(y) ? 366:365;
            y += 1;
        }
        while (temp>= func(m, y)) {
            temp -= func(m, y);
            m += 1;
        }
        d += temp.to!int;
    } else {
        y = 2012;
        m = 12;
        d = 21+temp.to!int;
    }
    return [y, m, d].to!(string[]);
}
int func(int m, int y) {
    switch(m) {
        case 2: {
            if (isUruu(y)) {
                return 29;
            } else {
                return 28;
            }
        } break;
        case 4: case 6: case 9: case 11: {
            return 30;
        } break;
        default: {
            return 31;
        }
    }
}
bool isUruu(int y) {
    return y%4==0 && (y%100!=0 || y%400==0);
}

Measured memory_bytes: 2648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int s,w; cin>>s>>w;
	if (s<=w) cout<<"unsafe";
	else cout<<"safe"<<endl;
	return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        String T=sc.next();
        int N=S.length();
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(S.charAt((i+j)%N)==T.charAt(j%N)){
                }else{
                    break;
                }
                if(j==N-1){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {

    int N;
    cin >> N;

    std::vector<ll> A(N); 
    ll n;
    
    //cout << N <<endl;
    map<ll,int> used;
    int index=0;
    
    for(int i = 0; i < N ; i++){
        cin >> n;
        A[i]=n;
        used[n]++;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    
    int upper;
    upper=int(log2(A[0]))+2;
    int residual;
    ll target;
    int kosuu=0;
    for(int i=0; i<A.size();i++){
        if (used[A[i]]>0){
            
            target=pow(2,int(log2(A[i]))+1);
            
            //cout << target<<endl;
            if (used[target-A[i]]>0){
                //cout << target-A[i] << " "<< used[target-A[i]] <<endl;
                if(target-A[i]==A[i]){
                    if(used[target-A[i]]>=2){
                        kosuu++;
                    used[A[i]]-=2;
                    }
                    
                }else{
                    kosuu++;
                    used[target-A[i]]--;
                    used[A[i]]--;
                }
            }
        }         
    }
    printf("%d\n",kosuu);
    return 0;
}


Measured memory_bytes: 26752
// tested on node version 0.10.36
var fs = require("fs");
function is_right_abc(a, b, c) {
    return a*a + b*b === c*c;
}
function is_right(a, b, c) {
    return is_right_abc(a, b, c) || is_right_abc(b, c, a) || is_right_abc(c, a, b);
}

var input = fs.readFileSync('/dev/stdin').toString();
var lines = input.split("\n");
var count = parseInt(lines.shift());
for(var i = 0; i < count; i++) {
    var parts = lines[i].split(" ");
    var a = parseInt(parts.shift());
    var b = parseInt(parts.shift());
    var c = parseInt(parts.shift());
    if(!isNaN(a + b + c)) {
        console.log(is_right(a, b, c) ? "YES" : "NO");
    }
}

Measured memory_bytes: 17208
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine()

    out.println(
      s.foldLeft[List[Char]](Nil) {
        case (acc, c) => c match {
          case 'B' if acc != Nil =>
            acc.tail
          case 'B' =>
            acc
          case c => c :: acc
        }
      }.reverse.mkString("")
    )

    out.flush()
  }
}


Measured memory_bytes: 27344
import math
a,b,C = [int(i) for i in input().split()]

S = (1 / 2) * a * b * math.sin(C/180 * math.pi)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C/180*math.pi))
L = a + b + c
h = 2 * S / a

print(S)
print(L)
print(h)



Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define cyes cout << "YES" << endl
#define cno cout << "NO" << endl
#define f(i, a, n) for(int i = a; i < n; i++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mod 1000000007
int gcd(int a, int b) { if (!b) return a; return gcd(b, a % b); }  
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
using namespace std;

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  int a[5];

  for(int i=0;i<5;i++)
  {
    cin >> a[i];
  }
  int ans;
  for(int i=0;i<5;i++)
  {
    if(a[i] == 0)
      ans =i;
  }

  cout << ans + 1;

  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func find(ds []int) int {
	n := len(ds)
	if n%2 != 0 {
		return 0
	}
	p := n / 2
	sort.Ints(ds)

	return ds[p] - ds[p-1]
}

func main() {
	n := nextInt()
	ds := nextInts(n)
	r := find(ds)
	fmt.Println(r)
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> s(n),t(m);
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    for (int i = 0;i < n;++i) cin >> s[i];
    for (int i = 0;i < m;++i) cin >> t[i];
    for (int i = 0;i < n+1;++i) dp[i][0] = 1;
    for (int i = 0;i < m+1;++i) dp[0][i] = 1;
    for (int i = 0;i < n;++i) {
        for (int j = 0;j < m;++j) {
            (dp[i+1][j+1] += dp[i][j+1]+dp[i+1][j]) %= mod;
            if (s[i] != t[j]) (dp[i+1][j+1] -= dp[i][j]) %= mod;
        }
    }
    cout << (dp[n][m]+mod)%mod << endl;
    // for (int i = 0;i < n+1;++i) p_ary(dp[i],0,m+1,j);
    return 0;
}

Measured memory_bytes: 31616
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#define maxn 1010
#define INF 1<<30
using namespace std;
int h,w,k,x,y,x1,y1;
char A[maxn][maxn],s[maxn];
int dot[maxn][maxn],mindis;
bool v[maxn][maxn];
struct node {
	int e,f,step;
};
struct cmp {
	bool operator() (node a,node b) {
		return a.step>b.step;
	}
};
priority_queue<node,vector<node>,cmp> q;
void bfs(int a,int b,int c) {
	node a1,b1;
	a1.e=a; a1.f=b;
	a1.step=c;
	q.push(a1);
	while (!q.empty()) {
		a1=q.top();
		q.pop();
		if (a1.e<1||a1.f<1||a1.e>h||a1.f>w||a1.step>k)
			continue;
		if (A[a1.e][a1.f]=='#'||dot[a1.e][a1.f]!=-1)
			continue;
		dot[a1.e][a1.f]=a1.step;
		v[a1.e][a1.f]=1;
		b1.step=a1.step+1;
		b1.e=a1.e-1; b1.f=a1.f;
		if (!v[b1.e][b1.f])
			q.push(b1);
		b1.e=a1.e+1; b1.f=a1.f;
		if (!v[b1.e][b1.f])
			q.push(b1);
		b1.e=a1.e; b1.f=a1.f-1;
		if (!v[b1.e][b1.f])
			q.push(b1);
		b1.e=a1.e; b1.f=a1.f+1;
		if (!v[b1.e][b1.f])
			q.push(b1);
		
	}
}
int dis(int a,int b) {
	return min(a-1,min(b-1,min(h-a,w-b)));
}
int chu(int a) {
	if (a%k==0)
		return a/k;
	return a/k+1;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d %d %d",&h,&w,&k);
	for (int i=1;i<=h;i++) {
		scanf("%s",s);
		for (int j=1;j<=w;j++) {
			A[i][j]=s[j-1];
			if (A[i][j]=='S') {
				x=i;
				y=j;
				A[i][j]='.';
			}
		}
	}
	if (dis(x,y)==0)
		printf("0\n");
	else {
		memset(dot,-1,sizeof(dot));
		bfs(x,y,0);
		mindis=INF;
		for (int i=1;i<=h;i++) {
			for (int j=1;j<=w;j++) {
				if (dot[i][j]==-1)
					continue;
				if (mindis>dis(i,j)) {
					mindis=dis(i,j);
					x1=i; y1=j;
				}
			}
		}
		printf("%d\n",1+chu(dis(x1,y1)));
	}
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,num,verysum=1;
	cin>>n>>num;
	if(n>=40)
	{
		cout<<1;
		return 0;
	}
	if(n==1){
		cout<<num;
		return 0;
	}
	for(int i=2;pow(i,n)<=num;i++)
	{
		while(num%(long long)(pow(i,n))==0)
			verysum*=i,
			num/=(pow(i,n));
	}
	cout<<verysum;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
#include <map>
#include <math.h>
#include <vector>

#define INF 100000000

using namespace std;
int main(){
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if(b - a == c - b){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
}


Measured memory_bytes: 128
/*
  donttttttt use vector 
  run n = 1 and n = MAXN before submit
  try to AC within one submission
*/
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
     
typedef long long lo;
 
template<typename tp> inline void read(tp &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}

const lo mo = 1e9 + 7;
char str[333333]; int n;

int main(void) {
	scanf("%s", str + 1);
	n = strlen(str + 1);
	lo dpNULL, dp0, dp1, dp11, dp10, dp01, dp00, dp100;
	dpNULL = 1; dp0 = dp1 = dp11 = dp10 = dp01 = dp00 = dp100 = 0;
	
	rep (i, n) {
		lo nNULL, n0, n1, n11, n10, n01, n00, n100;
		nNULL = n0 = n1 = n11 = n10 = n01 = n00 = n100 = 0;
		
		if (str[i] != '1') {
			n0 += dpNULL;
			n0 += dp01;
			n0 += dp00;
			n00 += dp0;
			n10 += dp1;
			n11 += dp11;
			n100 += dp10;
			n10 += dp100;
		}

		if (str[i] != '0') {
			n1 += dpNULL;
			n1 += dp01;
			n1 += dp10;
			n11 += dp1;
			n11 += dp11;
			n10 += dp100;
			n01 += dp0;
			n0 += dp00;
		}			

		dpNULL = nNULL % mo;
		dp0 = n0 % mo;
		dp1 = n1 % mo;
		dp11 = n11 % mo;
		dp10 = n10 % mo;
		dp01 = n01 % mo;
		dp00 = n00 % mo;
		dp100 = n100 % mo;
	}
	cout << (dp1 + dp11 + dp10) % mo << "\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    REP(i, N) {
        ll x = 0;
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            x++;
        }
        A[i] = x;
    }

    cout << accumulate(ALL(A), 0) << LF;

    return 0;
}


Measured memory_bytes: 384
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vp,vpp1;
vector<pair<ll,ll> >vdp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    fast;
    cin>>n>>k;
    if(k==1 or n==0) cout<<0<<endl;
    else{
    ll x=abs(n-k);
    ll y=x%k;
    ll i=k-y;
    cout<<min(x,i);
    }
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		M += v[i];
	}
	bitset<4002001>bs;
	bs[0] = true;
	for (int i = 0; i < N; i++) {
		bs |= bs << v[i];
	}
	for (int i = (M+1) / 2; i <= M; i++) {
		if (bs[i]) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 1005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    int a, b;
    cin >>a >> b;
    if(a+b >= 10) puts("error");
    else cout << a+b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c,m;
cin>>a>>b>>c;
if(a>b)m=b,b=a,a=m;
if(b>c)m=c,c=b,b=m;
if(a>b)m=b,b=a,a=m;
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;}

Measured memory_bytes: 3040
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    char W[10];
    char T[100];
    int count=0;

    scanf("%s",W);

    while(1){
        scanf("%s",T);

        if(strcmp(T,"END_OF_TEXT")==0){
            break;
        }

        for(int i=0;T[i]!='\0';i++){
            T[i]=tolower(T[i]);
        }

        if(strcmp(T,W)==0){
            count++;
        }
        
    }
    printf("%d\n",count);
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, m, a[211];

int main() {
	megaRandom();
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i ++)
		scanf("%d", &a[i]);
	sort(a + 1, a + m + 1);
	if(n == 1) {
		printf("1\n1\n1");
		return 0;	
	}
	if(m == 1) {
		printf("%d\n2\n%d 1", a[1], a[1] - 1);
		return 0;
	}
	if(m == 2) {
		printf("%d %d\n", a[1], a[2]);
		if(a[2] == 1) 
			printf("1\n%d", n); 
		else
			printf("2\n%d %d", a[1] + 1, a[2] - 1);
		return 0;
	}
	vector<int> v;
	for(int i = 1; i <= m; i ++) 
		if(a[i] & 1) 
			v.pb(i);
	if(sz(v)) {
		if(!(a[1] & 1))swap(a[v.back()], a[1]);
		if(!(a[m] & 1))swap(a[v.back()], a[m]);
		v.pp();
	}
	if(sz(v)) {
		if(!(a[1] & 1))swap(a[v.back()], a[1]);
		if(!(a[m] & 1))swap(a[v.back()], a[m]);
		v.pp();
	}
	if(sz(v)) {
		puts("Impossible");
		return 0;
	}
	//if(a[2] % 2 && a[1] % 2 && a[m] % 2)
		//assert(0);
	for(int i = 1; i <= m; i ++)
		printf("%d ", a[i]);
	printf("\n");
	if(a[m] == 1) {
		a[1] ++;
		printf("%d\n", m - 1);
		for(int i = 1; i < m; i ++)
			printf("%d ", a[i]);
		return 0;
	}

	a[1] ++, a[m] --;	
	printf("%d\n", m);
	for(int i = 1; i <= m; i ++)
		printf("%d ", a[i]);		
	return 0;  
}


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


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

   
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Read();
        long count = 1;
        if (s == 1||s==2)
            Console.WriteLine(4);
        else
        {
            while (s != 4)
            {
                count++;
                if (s % 2 == 0)
                    s = s / 2;
                else
                    s = 3 * s + 1;
            }
            Console.WriteLine(count + 3);
        }

        Console.Out.Flush();
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
  int n, i, x;
 
  scanf("%d",&n);
 
  for(i = 1;i <= n;i++){ 
      if(i % 3 == 0){
      printf(" %d",i);
      }else{
          for(x = i;x;x /= 10){
          if(x % 10 == 3){
              printf(" %d",i);break;
              }
          }
      }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n,q;
  cin>>n;
  ll count[100005]={0};
  ll a[n];
  long long int sum=0;
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
    count[a[i]]++;
    
  }
  ll c,d;
  cin>>q;
  while(q--)
  {
    cin>>c>>d;
    sum=sum-count[c]*c+count[c]*d;
    //count[c]=0;
    count[d]+=count[c];
    count[c]=0;
    cout<<sum<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 5160
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007
const int N = 501031;

long long Q,H,S,D,need,ans;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>Q>>H>>S>>D;
	cin>>need;
	int one=min(Q*4,min(H*2,S));
	int two=D;
	ans=need/2*two+one*(need%2);
	ans=min(ans,one*need);
	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


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

typedef long long ll;
typedef long double ld;

int main()
{

  ll N,K;
  cin >> N >> K;

  N = N - (N/K)*K;

  while(1){
    if(N > abs(N-K)){
      N = abs(N-K);
    }else{
      break;
    }
  }

  cout << N <<endl;
  

  return 0;
}


Measured memory_bytes: 256
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;

int n, k;
map<int, bool>mp;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>k;
		if(mp[k])
		{
			cout<<"NO"<<endl;
			return 0;
		}
		mp[k] = true;
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int m, k;
    cin >> m >> k;
    
    if ((1 << m) <= k) {
        cout << -1 << endl;
        return 0;
    }
    
    vector<int> ans;
    if (m == 0) {
        ans = {0, 0};
    }
    else if (m == 1) {
        if (k == 0) {
            ans = {0, 0, 1, 1};
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    else {
        for (int i = 0; i < (1 << m); i++) {
            if (i != k)
                ans.push_back(i);
        }
        ans.push_back(k);
        for (int i = (1 << m) - 1; i >= 0; i--) {
            if (i != k)
                ans.push_back(i);
        }
        ans.push_back(k);
    }
    
    for (int p : ans)
        cout << p << " ";
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	int h,w,i,j;
//	dp[1000][1000],a[1000][1000];
	cin>>h>>w;
	int dp[h][w];
	char a[h][w];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++) cin>>a[i][j];
	}
	dp[0][0]=1;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
		if(i || j)
		dp[i][j]=0;
//		if(a[i][j]=='#') continue;
		if(i && a[i-1][j]=='.') dp[i][j]=dp[i-1][j];
		if(j&& a[i][j-1]=='.') dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
//		cout<<dp[i][j]<<" ";
		}
	}
	cout<<dp[h-1][w-1];
	return 0;

}

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

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

    int64_t ans = 0;
    string march = "MARCH";
    for (int64_t i = 0; i + 2 < 5; i++) {
        for (int64_t j = i + 1; j + 1 < 5; j++) {
            for (int64_t k = j + 1; k < 5; k++) {
                ans += m[march[i]] * m[march[j]] * m[march[k]];
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int a;
      //string s;
      //cin >> a >> b >> c;
      cin >> a;
      //if((a+b)%2==1)cout << 1 + (a+b)/2 << endl;
      //else cout << (a+b)/2 << endl;
      cout << a/3 << endl;
      return 0;
    }

Measured memory_bytes: 256
class Baseball
  attr_accessor :point, :first, :second, :third, :out_count
  def initialize
    @point = 0
    @out_count = 0
    @first = false
    @second = false
    @third = false
  end

  def hit
    @first, @second, @third, @point = [true, @first, @second, @third ? @point+1 : @point]
  end

  def homerun
    @point += 1
    @point += 1 if @first
    @point += 1 if @second
    @point += 1 if @third
    @first, @second, @third = [false, false, false]
  end

  def out
    @out_count += 1
  end

  def exit?
    @out_count >= 3
  end
end

def main
  round = Integer(gets)
  round.times do
    game = Baseball.new
    while true
      if game.exit?
        puts game.point
        break
      end

      case gets.chomp
      when "HIT"
        game.hit
      when "OUT"
        game.out
      when "HOMERUN"
        game.homerun
      end
    end
  end
end

main

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

typedef long long ll;
typedef long double ld;

int comp1[1000005];
int comp2[1000005];
int sz[1000005];

int cnt;

map <pair <int, int>, int> mp;
vector <int> graf[1000005];

void dfs1(int v){
    comp1[v] = cnt;
    for(auto c : graf[v]){
        if(!comp1[c]) dfs1(c);
    }
}

void dfs2(int v){
    comp2[v] = cnt;
    for(auto c : graf[v]){
        if(!comp2[c]) dfs2(c);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, k, l;
    cin >> n >> k >> l;
    for(int i=1; i<=k; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    for(int i=1; i<=n; i++){
        if(!comp1[i]){
            ++cnt;
            dfs1(i);
        }
    }
    for(int i=1; i<=n; i++){
        graf[i].clear();
    }
    for(int i=1; i<=l; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    cnt = 0;
    for(int i=1; i<=n; i++){
        if(!comp2[i]){
            ++cnt;
            dfs2(i);
        }
    }
    for(int i=1; i<=n; i++){
        mp[{comp1[i], comp2[i]}]++;
    }
    for(int i=1; i<=n; i++){
        cout << mp[{comp1[i], comp2[i]}] << " ";
    }
    return 0;
}


Measured memory_bytes: 44800
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N;
	cin>>N;
	
	cout<<N*N<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int l,r,s;
} report_t;

int count(const int arr[],int l,int r) {
	int ret=0;
	int i;
	for(i=l-1;i<r;i++)ret+=arr[i];
	return ret;
}

int main(void) {
	int n,x,m;
	report_t reports[10];
	int i,search_max;
	int answer[6]={0,0,0,0,0,0};
	int answer_sum=-1;
	if(scanf("%d%d%d",&n,&x,&m)!=3)return 1;
	for(i=0;i<m;i++) {
		if(scanf("%d%d%d",&reports[i].l,&reports[i].r,&reports[i].s)!=3) {
			return 1;
		}
	}
	for(i=0,search_max=1;i<n;i++)search_max*=(x+1);
	for(i=0;i<search_max;i++) {
		int j,cur;
		int cur_lion[6];
		int ok=1,cur_score;
		for(j=0,cur=i;j<n;j++) {
			cur_lion[j]=cur%(x+1);
			cur/=(x+1);
		}
		for(j=0;j<m;j++) {
			ok=ok && (count(cur_lion,reports[j].l,reports[j].r)==reports[j].s);
		}
		if(ok) {
			cur_score=count(cur_lion,1,n);
			if(cur_score>answer_sum) {
				answer_sum=cur_score;
				for(j=0;j<n;j++)answer[j]=cur_lion[j];
			}
		}
	}
	if(answer_sum<0) {
		puts("-1");
	} else {
		for(printf("%d",answer[0]),i=1;i<n;i++)printf(" %d",answer[i]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 604
n=int(input())
a=list(map(int,input().split()))
mini=float('inf')
sum1=0
sum2=sum(a)
for i in range(n):
    sum1=sum1+a[i]
    sum2=sum2-a[i]
    mini=min(mini,abs(sum1-sum2))
print(mini)

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

struct material
{
    int price;
    vector<string> need;
};

int min_price(map<string, material>& mmap, string s)
{
    if (!mmap[s].need.empty()){
        int sum = 0;
        for (string name : mmap[s].need){
            sum += min_price(mmap, name);
        }
        mmap[s].price = min(mmap[s].price, sum);
        mmap[s].need.clear();
    }

    return mmap[s].price;
}

void solve(int n)
{
    int m;
    map<string, material> mmap;

    for (int i = 0; i < n; i++){
        string s;
        int p;

        cin >> s >> p;
        mmap[s] = { p, vector<string>() };
    }

    cin >> m;
    for (int i = 0; i < m; i++){
        string o;
        int k;
        int sum = 0;

        cin >> o >> k;
        while (k-- > 0){
            string q;

            cin >> q;
            mmap[o].need.push_back(q);
        }
    }
    for (auto i = mmap.begin(); i != mmap.end(); i++){
        i->second.price = min_price(mmap, i->first);
    }

    string s;
    cin >> s;
    printf("%d\n", mmap[s].price);
}

int main()
{
    int n;

    while (cin >> n, n){
        solve(n);
    }

    return 0;
}

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

int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int t, x; scanf("%d %d", &t, &x);
    printf("%.10lf\n", (double)t / (double)x);
    
    return 0;
}


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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;


bool compare(vector<double> a,vector<double> b) {
    if(a[2]==b[2]) {
        return (a[1]<b[1]);
    }
    return (a[2]>b[2]);

}

bool compare2(vector<double> a, vector<double> b) {

    return (a[1]<b[1]);
}

int main()
{

    int h,n;
    cin>>h>>n;
    vector<vector<int>> a(n,vector<int>(3));
    vector<vector<int>> b(n,vector<int>(3));
    rep(i,0,n) {
        cin>>a[i][0];
        cin>>a[i][1];
    }

    vi dp(h+1,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++) {

        for(int j=1;j<=h;j++) {

            //cout<<"i "<<i<<" a[i] "<<a[i][0]<<" b[i] "<<a[i][1]<<endl;
            if(j-a[i][0]>=0)
            {
                dp[j] = min(dp[j],dp[j-a[i][0]]+a[i][1]);
            } else {
                dp[j] = min(dp[j],a[i][1]);

            }

        }
    }

    cout<<dp[h]<<endl;
    return 0; 
}



Measured memory_bytes: 384
n,m=map(int,input().split())
ka=[[int(i) for i in input().split()] for j in range(n)]
num=[0 for i in range(m+1)]
count=0
for i in range(n):
    for j in range(1,ka[i][0]+1):
        num[ka[i][j]]+=1

for i in range(1,len(num)):
    if n==num[i]:
        count+=1

print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

vi solve(const vi &a, int k){
  int n = a.size();
  vector<vi> max_dp(n+1, vi(k+1,-INF)), min_dp(n+1, vi(k+1,+INF));
  max_dp[0][0] = min_dp[0][0] = 0;

  rep(i,n){
    rep(j,k+1){
      int x = (j&1) ? -1 : 1;
      if(max_dp[i][j] != -INF) {
        chmax( max_dp[i+1][j], max_dp[i][j] + a[i]*x);
        chmin( min_dp[i+1][j], max_dp[i][j] + a[i]*x);
        if(j!=k){
          chmax( max_dp[i+1][j+1], max_dp[i][j] + a[i]*x*-1);
          chmin( min_dp[i+1][j+1], max_dp[i][j] + a[i]*x*-1);
        }
      }

      if(min_dp[i][j] != +INF){
        chmax( max_dp[i+1][j], min_dp[i][j] + a[i]*x);
        chmin( min_dp[i+1][j], min_dp[i][j] + a[i]*x);
        if(j!=k){
          chmax( max_dp[i+1][j+1], min_dp[i][j] + a[i]*x*-1);
          chmin( min_dp[i+1][j+1], min_dp[i][j] + a[i]*x*-1);
        }
      }
    }
  }

  vi res(k+1,0);
  rep(i,k+1){
    int max_v = max_dp[n][i] == -INF ? 0 : abs(max_dp[n][i]);
    int min_v = min_dp[n][i] == +INF ? 0 : abs(min_dp[n][i]);
    res[i] = max( max_v, min_v );
  }
  rep(i,k) chmax(res[i+1], res[i]);
  return res;
}

int main(){
  string s; int k;
  cin >> s >> k;

  vi ud, lr;
  rep(i,s.size()){
    if(s[i] == 'U') ud.eb(-1);
    if(s[i] == 'D') ud.eb(+1);
    if(s[i] == 'L') lr.eb(-1);
    if(s[i] == 'R') lr.eb(+1);
  }

  vi ud_k = solve(ud, k), lr_k = solve(lr, k);
  int ans = 0;
  rep(i,k+1){
    chmax(ans, ud_k[i] + lr_k[k-i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 18948
A, B, K = gets.split.map(&:to_i)

array = []

for i in A..B do
    if i > A + (K-1) then
        break
    end
    array.push(i)
end

B.downto(A) do |i|
    if i < B - (K-1) then
        break
    end
    array.push(i)
end

puts array.uniq.sort

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

int check(string a, string b, int index){
	int blength = b.length();
	int alength = a.length();
	for(int i = 0; i < alength; i++){
		if(a[i] != b[index++])
			return 0;
		if(index == blength)
			index = 0;
	}
	return 1;
}

int main(){
	string a, b;
	cin >> a >> b;
	bool boolean = false;
	int alength = a.length();
	for(int i = 0; i < alength; i++){
		if(check(a, b, i)){
			boolean = true;
			break;
		}
	}
	if(boolean)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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

struct	S	{
	int	L;
	int	R;
};

int	CAL_B(int L, int R, vector<vector<int>> &A, vector<vector<int>> &B) {
	if (B.at(L).at(R) !=-1) return B.at(L).at(R);
	int S=0;
	for (int i=L+1; i<=R; i++) S += A.at(L).at(i);
	S += CAL_B(L+1, R, A, B);
	B.at(L).at(R)=S;
	return S;
};

int	CAL(int L, int R, vector<vector<int>> &A, vector<vector<int>> &B) {
	if (L==R) return A.at(L).at(R);
	int S=0;
	for (int i=L; i<=R; i++) S += A.at(i).at(i);
	S += CAL_B(L, R, A, B);
	return S;
};

int	main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<S> ST(M);
	vector<S> P(Q);
	for (int i=0; i<M; i++) {
		cin >> ST.at(i).L >> ST.at(i).R;
	}
	for (int i=0; i<Q; i++) {
		cin >> P.at(i).L >> P.at(i).R;
	}
	// Start Processing
	vector<vector<int>> A(N+1, vector<int> (N+1, 0));
	for (int i=0; i<M; i++) {
		A.at(ST.at(i).L).at(ST.at(i).R)++;
	}
	vector<vector<int>> B(N+1, vector<int> (N+1, -1));
	for (int i=1; i<=N; i++) B.at(i).at(i)=0;
	for (int i=0; i<Q; i++) {
		cout <<CAL(P.at(i).L, P.at(i).R, A, B) <<endl;
	}
	return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

using P = pair<int, int>;

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

    int n;
    cin >> n;

    vector<double> x(n);
    vector<string> u(n);
    rep (i, n)
        cin >> x[i] >> u[i];

    double btc_to_jpy = 380000.0;
    rep (i, n)
        if (u[i] == "BTC") x[i] *= btc_to_jpy;

    print(sum_(x));

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//exhaustive search
public class Main {
	public static boolean solve(int[] data, int t, int rest) {
		
		//termination conditions
		if(rest == 0) {
			return true;
		}
		
		//otherwise, come to last
		if(t == data.length -1) {
			if(data[t] == rest) return true;
			return false;
		}
		
		return solve(data, t+1, rest) || solve(data, t+1, rest-data[t]);
	}
	
	
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int [] A = new int[n];
		for(int i = 0; i < n; i++) {
			A[i] = cin.nextInt();
		}
		
		n = cin.nextInt();
		for(int j = 0; j < n; j++) {
			if(solve(A, 0, cin.nextInt())) {
				System.out.println("yes");
			}else {
				System.out.println("no");
			}
		}
		
		
		cin.close();
		
	}
	
}

Measured memory_bytes: 26800
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n;
string s;
int wh[200010],bl[200010];
signed main(){
    cin >> n;
    cin >> s;

    REP(i,n){
        bl[i+1] = bl[i] + (s[i] == '#');
    }
    REPN(i,n){
        wh[i] = wh[i+1] + (s[i] == '.');
    }
    int ret = 1145141919LL;
    REP(i,n+1){
        ret = min(ret, bl[i] + wh[i]);
        cerr << bl[i] << " " << wh[i] << endl;
    }
    
    cout << ret << endl;
}

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

const int N = 5005, mod = 1000000007;

void reduce(int &x) { x += x >> 31 & mod; }
int dp[N][N], n, l; std::string s;

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> s, l = s.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * 2u) % mod;
			reduce(dp[i + 1][std::max(j - 1, 0)] += dp[i][j] - mod);
		}
	}
	int ans = dp[n][l]; while (l--) ans = ans * (mod + 1LL >> 1) % mod;
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 96384
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   int a, b;
   cin >> a >> b;
   cout << a*b << " " << (a+b)*2 << endl;
   return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll N;
ll after;
constexpr ll D[] = {1LL, 10LL, 100LL, 1000LL, 10000LL, 100000LL, 1000000LL, 10000000LL, 100000000LL, 1000000000LL};
inline ll get(const ll v, const ll d)
{
    return v / D[d] % 10;
}
ll dfs(const ll d, const ll dial)
{
    if (d == N) {
        return after == dial ? 0 : 11;
    } else {
        const ll plus = (get(after, d) - get(dial, d) + 10) % 10;
        if (plus == 0) {
            return dfs(d + 1, dial);
        } else {
            ll ans = 11;
            for (ll i = 0; i + d < N; i++) {
                ll next = dial;
                for (ll j = d; j <= d + i; j++) {
                    const ll from = get(dial, j);
                    if (from + plus < 10) {
                        next += D[j] * plus;
                    } else {
                        next -= D[j] * (10 - plus);
                    }
                }
                ans = min(ans, 1 + dfs(d + 1, next));
            }
            return ans;
        }
    }
}

int main()
{
    while (true) {
        cin >> N;
        if (N == 0) {
            break;
        }
        ll before;
        cin >> before >> after;
        cout << dfs(0, before) << endl;
    }
    return 0;
}



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

#define INFTY 100000002

int innerCompare(vector<int> a, vector<int> b) {
	if (a[1] <= b[1]) {
		if (a[1] == b[1]) {
			return 0;
		}
		else {
			return -1;
		}
	}
	else {
		return 1;
	}
}
void merge(vector< vector<int> > &A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector< vector<int> > L(n1 + 1, {0, 0});
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	vector< vector<int> > R(n2 + 1, {0, 0});
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1][0] = INFTY;
	R[n2][0] = INFTY;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		int com = INFTY;
		if (R[j][0] != INFTY && L[i][0] != INFTY) com = innerCompare(L[i], R[j]);
		if (R[j][0] == INFTY || (L[i][0] != INFTY && com <= 0)) {
			A[k] = L[i];
			i = i + 1;
		}
		else {
			A[k] = R[j];
			j = j + 1;
		}
		//		cout << com << ": " << L[i] << endl;
	}

	//	for(int i = 0;i<data.length(); i++) cout << i << ": " << tree[i] << endl;

}

void mergeSort(vector< vector<int> > &A, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}
int main(){
	int N;
	cin >> N;
	vector< vector<int> > schedule(N, {0, 0});
	for (int i = 0; i < N; i++) {
		int s, t;
		cin >> s >> t;
		schedule[i][0] = s;
		schedule[i][1] = t;
	}

	mergeSort(schedule, 0, N);

	int res = 0;

	int time = 1;
	int cur = 0;
	while (true) {
		if (res != 0) {
			bool isfound = false;
			for(int i = cur+1; i < N; i++){
				if (schedule[i][0] >= time) {
					cur = i;
					isfound = true;
					break;
				}
			}
			if (!isfound) break;
		}
		time = schedule[cur][1] + 1;
		res++;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 13888
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int n= s.nextInt();
		int x =s.nextInt();
		Integer[] l=new Integer[n];
		for(int i=0;i<n;i++) {
			l[i]=s.nextInt();
		}
		System.out.println(Main.calc(x,l));
	}

	public static int calc(int x,Integer[] l) {

		long sum=0;
		int count=0;
		if(0<=x) {
			count++;
		}
		for(int i=0;i<l.length;i++) {
			sum+=l[i];
			if(sum<=x) {
				count++;
			}else {
				break;
			}

		}
		return count;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long

using namespace std;

bool sorter(pair<int, int> a, pair<int, int>b)
{
    return a.first>b.first;
}

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

    int a, b;
    cin>>a>>b;
    b += a*3;
    cout<<b/2;



}



Measured memory_bytes: 256