akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  vector<string> b(h*2);
  for (int i = 0; i < h*2; i++) {
    b[i] = a[i/2];
  }
  for (int i = 0; i < h*2; i++) {
    cout << b[i] << endl;
  }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        // 主処理
        long result = lcm(a, b);

        // 出力
        System.out.println(result);
        sc.close();
    }

    public static long lcm(int a, int b) {
        int temp;
        long c = a;
        c *= b;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return c / b;
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;

int main() {
    cin >> n;
    vector<ll> v(n);
    rep(i, n) { cin >> v[i]; }
    sort(all(v));
    ll ans = 1;
    rep(i, n) {
        if (v[i] == 0) {
            cout << 0 << endl;
            return 0;
        } else if (log10l(v[i]) + log10l(ans) > 18. || v[i] * ans > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
        ans *= v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4056
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a > 8 || b > 8){
            System.out.println(":(");
        }else{
            System.out.println("Yay!");
        }
        
    }
}


Measured memory_bytes: 23380
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
            int M = in.nextInt();
            int [] arr=  new int[N];
            int max = 0;
            for(int i=0;i<M;i++){
                max+=in.nextInt();
            }
            out.println(N-max>=0?N-max:-1);
            out.flush();
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

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


int main(){
    int n;
    vector<int> a;

    cin>>n;

    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        a.push_back(b);
    }

    bool eq = true;

    for(int i=1;i<n;i++){
        if(a[0] != a[i]) eq = false;
    }

    if(eq){
        cout<<a[0]<<" "<<a[0]<<"\n";
        return 0;
    }


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

    int com_n = a[n-1];
    int com_r = 0;
    int m = 999999999;

    for(int i=0;i<n;i++){
        if(m > abs(com_n - a[i]*2)) com_r = a[i];
        m = min(m,com_n - a[i]*2);
    }
    
    cout<<com_n<<" "<<com_r<<"\n";
    
}

Measured memory_bytes: 1020
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int n;
  cin >> n;
  set<int> a;
  while (n--) { // O(n log n)
    int s;
    cin >> s;
    a.insert(s);
  }
  int q;
  cin >> q;
  int c = 0;
  while (q--) { // O(q log n)
    int t;
    cin >> t;
    c += a.count(t);
  }
  cout << c << endl;
}

Measured memory_bytes: 3144
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<stdio.h>
using namespace std;
const int MAX = 100;
int main() {
	int W, N;
	int t[MAX];

	cin >> W >> N;
	for (int i = 0; i < W; i++) {
		t[i] = i;
	}
	for (int i = 0; i < N; i++) {
		int a, b;
		scanf("%d,%d", &a, &b); a--; b--;
		swap(t[a], t[b]);
	}
	for (int i = 0; i < W; i++) {
		printf("%d\n", t[i] + 1);
	}
	return 0;
}

Measured memory_bytes: 3140
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskC solver = new TaskC();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskC {    
    final int ring = (int) 1e9 + 7;
    int n;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      n = in.nextInt();
      int[] divisors = new int[n + 1];
      for (int i = 1; i <= n; ++i) {
        int x = i;
        for (int j = 2; j <= n; ++j) {
          while (x % j == 0) {
            ++divisors[j];
            x /= j;
          }
        }
      }
      long ans = 1;
      for (int i = 2; i <= n; ++i) {
          ans = mul(ans, divisors[i] + 1);
      }
      out.println(ans);
    }
    
    boolean isprime(int x) {
      for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) {
          return false;
        }
      }
      return true;
    }
    
    long mul(long a, long b) {
      return a * b % ring;
    }
    
    int i(long x) {
      return (int) x;
    }
    
    <T> void heapsort(T[] a, int s, int e) {
      Queue<T> queue = new PriorityQueue<>();
      for (int i = s; i <= e; ++i)
        queue.add(a[i]);
      for (int i = s; i <= e; ++i)
        a[i] = queue.poll();
    }    
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

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

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

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 8784
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#include <cstring>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return 0;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}






///target expert

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    vector <pll> v(n); vector <ll> ans(n), ans2(n);
    REP(i,0,n){cin>>v[i].F>>v[i].S; ans[i]=v[i].F+v[i].S; ans2[i]=v[i].F-v[i].S;}
    sort(ans2.B,ans2.E);
    sort(ans.B, ans.E);
    cout<<max(ans[n-1]-ans[0],ans2[n-1]-ans2[0]);
}



Measured memory_bytes: 9492
#include "stdio.h"
#include "limits.h"
#include <iostream>
#include <algorithm>
using namespace std;

int mati[3000];
int matis[3000];
int miti[100000][2];
int miti2[3000][3000];
int matiw[3000];

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

	{
		scanf("%d %d %d",&n,&m,&k);
	}
	
	{
		for(int i = 0; i < 3000; i++)
		{
			for(int ii = 0; ii < 3000; ii++)
			{
				miti2[i][ii] = -1;
			}
		}
	}

	{
		for(int i = 0; i < m; i++)
		{
			int w1,w2,w3;
			scanf("%d %d %d",&w1,&w2,&w3);
			miti[i][0] = w1 - 1;
			miti[i][1] = w2 - 1;
			miti2[w1 - 1][w2 - 1] = w3;
			miti2[w2 - 1][w1 - 1] = w3;
		}
	}

	{
		for(int i = 0; i < n; i++)
		{
			mati[i] = INT_MAX;
			matis[i] = 0;
		}
	}

	{
		int w;
		for(int i = 0; i < k; i++)
		{
			scanf("%d",&w);
			mati[w - 1] = 0;
		}
	}

	{
		for(int i = 0; i < n; i++)
		{
			for(int ii = 0; ii < n; ii++)
			{
				if(matis[ii] == 0)
				{
					matiw[ii] = mati[ii];
				}
				else
				{
					matiw[ii] = INT_MAX;
				}
			}
			sort(matiw,matiw + n);
			for(int ii = 0; ii < n; ii++)
			{
				if(mati[ii] == matiw[0] && matis[ii] == 0)
				{
					for(int iii = 0; iii < n; iii++)
					{
						if(miti2[ii][iii] != -1)
						{
							if(mati[iii] > mati[ii] + miti2[ii][iii])
							{
								mati[iii] = mati[ii] + miti2[ii][iii];
							}
						}
					}
					matis[ii] = 1;
					break;
				}
			}
		}
	}

	int l = 0;

	{
		int w,w1,w2;
		for(int i = 0; i < m; i++)
		{
			w1 = miti[i][0];
			w2 = miti[i][1];
			if(mati[w1] == mati[w2] + miti2[w1][w2])
			{
				w = mati[w1];
			}
			else if(mati[w2] == mati[w1] + miti2[w1][w2])
			{
				w = mati[w2];
			}
			else
			{
				w = (mati[w1] + mati[w2] + miti2[w1][w2] - 1) / 2 + 1;
			}
			if(l < w)
			{
				l = w;
			}
		}
	}

	printf("%d\n",l);

	return 0;
}

Measured memory_bytes: 37176
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

template<typename T> struct BIT{
	vector<T> dat;
	ll sz;
	//all 1-indexed
	BIT(ll sz) : sz(sz){
		dat.assign(++sz, 0);
	}

	T sum(ll k){
		T ret = 0;
		for(++k; k > 0; k -= k & -k) ret += dat[k];
		return (ret);
	}

	void add(ll k, T x){
		for(++k; k < dat.size(); k += k & -k) dat[k] += x;
	}
	
	ll get(T k){
		if(k <= 0) return 0; 
		ll ret = 0;
		int n = 1; while(n < sz) n *= 2;
		for(int i=n/2; i>0; i/=2){
			if(ret+i < sz && dat[ret+i] < k){
				k -= dat[ret+i];
				ret += i;
			}
		}
		return ret;
	}
};

int main(){
	ll n,k; cin >> n >> k;
	vl a(n); rep(i,n) cin >> a[i];
	ll ok = 1e9, ng = 0;
	while(ok-ng > 1){
		ll mid = (ok + ng) / 2;
		ll cnt = 0;
		rep(i,n){
			cnt += (a[i] - 1) / mid;
		}
		if(cnt > k) ng = mid;
		else ok = mid;
	}
	cout << ok << "\n";
}


Measured memory_bytes: 4764
h,w=map(int,input().split())
b=[["#"]*(w+2)]
a=0
for i in range(h):
  c=["#"]
  for j in input():
    a+=j=="#"
    c.append(j)
  b.append(c+["#"])
b+=[["#"]*(w+2)]
b[h][w]=0
Q=[(1,1)]
x=0
y=-1
while Q:
	x+=1
	p=[]
	for i,j in Q:
		for dx,dy in [(1,0),(-1,0),(0,1),(0,-1)]:
			if b[i+dx][j+dy]==".":
				p+=[(i+dx,j+dy)]
				b[i+dx][j+dy]="#"
			elif b[i+dx][j+dy]==0:
				y=x
	if y>0:break
	Q=p
if y>0:print((h*w)-a-y-1)
else:print(-1)

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

int mery[8] = { 4,1,4,1,2,1,2,1 };
void kaiten() {
	int a = mery[0];
	for (int b = 0; b < 7; b++)mery[b] = mery[b + 1];
	mery[7] = a;
}
int k() {
	int b = 0;
	for (int a : mery) {
		b = b * 10 + a;
	}
	return b;
}
signed main() {
	int a[8];
	while (cin >> a[0]) {
		for (int b = 1; b < 8; b++)cin >> a[b];
		int MIN = INT_MAX;
		int o = 0;
		for (int c = 0; c < 8; c++) {
			kaiten();
			int e = 0;
			for (int d = 0; d < 8; d++) {
				if (a[d] > mery[d])e += a[d] - mery[d];
			}
			if (e < MIN) {
				MIN = e;
				o = k();
			}
			if (e == MIN) {
				o = min(o, k());
			}
		}
		string p = to_string(o);
		for (int q = 0; q < 8; q++) {
			if (q)cout << " ";
			cout << p[q];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
	{
		cout<<k;
		return 0;
	}
	else if(k<=a+b)
	{
		cout<<a;
		return 0;
	}
	else
	{
		cout<<a-(k-(a+b));
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 3532
import string
s=input()
n=len(s)
ans=100
l=string.ascii_lowercase
for c in l:
    cnt=0
    ts=s[:]
    while True:
        if len(set(ts))==1:
            break
        cnt+=1
        for i in range(n-cnt):
            if ts[i]!=c:
                ts=ts[:i]+ts[i+1]+ts[i+1:]
        ts=ts[:-1]
    ans=min(ans,cnt)
print(ans)

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

namespace P0005_GCDandLCM
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> lines = new List<string>();
            string readLine;

            do
            {
                readLine = Console.ReadLine();
                if (readLine != null)
                {
                    lines.Add(readLine);
                }
            }
            while (readLine != null);


            foreach (string line in lines)
            {
                List<string> abStrs = line.Split(' ').ToList<string>();
                List<int> ab = new List<int>();

                foreach (string abStr in abStrs)
                {
                    ab.Add(int.Parse(abStr));
                }

                ab.Sort();
                ab.Reverse();

                int gcd = GCD(ab[0], ab[1]);

                Console.WriteLine("{0} {1}", gcd, (ab[0] / gcd) * ab[1]);
            }

        }

        private static int GCD(int a, int b) 
        {
            if(b == 0)
            {
                return a;
            }
            else
            {
                int temp = a;
                a = b;
                b = temp % b;

                return GCD(a, b); 
            }
        }
    }
}

Measured memory_bytes: 6040
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
puts A.inject(1){|res,i| res*i/(res.gcd(i))}


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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>


typedef long long int ll;

using namespace std;

int main()
{
	ll n, k; cin >> n >> k;
	vector<int> A(n+1);
	for(int i = 1; i <=n; ++i) cin >> A[i];
	vector<int> visited(n+1, 0);

	int pos = 1;
	int totalEdges = 0;
	while(visited[pos] == 0)
	{
		visited[pos] = 1;
		int nextPos  = A[pos];
		pos = nextPos;
		++totalEdges;
		if(totalEdges == k)
		{
			cout << pos ;
			return 0;
		}
	}

	for(int i = 1; i <= n; ++i) visited[i] = 0;

	int cyclePos = pos;
	int cycleEdges = 0;

	while(visited[pos] == 0)
	{
		visited[pos] = 1;
		int nextPos = A[pos];
		pos = nextPos;
		++cycleEdges;
	}

	ll remain = k - (totalEdges - cycleEdges);
	remain %= cycleEdges;

	pos = cyclePos;
	while(remain)
	{
		--remain;
		pos = A[pos];
	}

	cout << pos;

	return 0;
}

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

const int Nmax=200010;

int main() {
	int a,b,n=10;
  	cin >> a >> b;
	if(10<=b && b<=99) n = 100;
	if(b == 100) n = 1000;
	
	if(pow((int)sqrt(n*a+b),2) == n*a+b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <iostream>

using namespace std;
#define MAX_NUM 1001
#define MOD (1000000000 + 7)
static uint32_t nums[MAX_NUM];

void prime_factorize(uint32_t n)
{
  uint32_t i = 2;
  for (; i * i <= n; i++) {
    while (n % i == 0) {
      nums[i]++;
      n /= i;
      nums[i] %= MOD;
    }
  }

  nums[n]++;
}

int32_t main()
{
  uint32_t N;
  cin >> N;

  for (uint32_t n = 2; n <= N; n++) {
    prime_factorize(n);
  }

  uint64_t count = 1;
  for (uint32_t n = 2; n <= N; n++) {
    count *= (nums[n] + 1);
    count %= MOD;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
cnt = 0
num_lst = [3, 5, 7]
stack = deque([3, 5, 7])
while len(stack) > 0:
    now_num = stack.popleft()
    if now_num > n:
        break
    if len(set(str(now_num))) == 3:
        cnt += 1
    for x in num_lst:
        next_num = str(now_num) + str(x)
        next_num = int(next_num)
        stack.append(next_num)

print(cnt)

Measured memory_bytes: 5664
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int gethash(vector<int>&v) {
	int ha = 0;
	for (int i = 0; i < v.size(); ++i) {
		ha *= 3;
		ha += v[i]+1;
	}
	return ha;
}
map<int, bool>memo;
bool solve(vector<int>v, int fst) {
	int t = gethash(v)*2 + fst;
	if (memo.find(t)== memo.end()) {
		
		bool win = false;
		bool canput = false;
		for (int i = 0; i < 13; ++i) {
			if (v[i] == fst) {
				if ((i&&v[i - 1] == -1)||(i!=12&&v[i+1]==-1)) {
					v[i] = -1;
					if (count(v.begin(), v.end(), fst) == 0) {
						win = true;
						canput = true;

					}else if (!solve(v, !fst)) {
						win = true;
						canput = true;
					}
					else {
						canput = true;
					}
					v[i] = fst;
				}
			}
		}
		if (!canput) {
			memo[t]=!solve(v, !fst);
		}
		else {
			memo[t] = win;
		}
	}
	return memo[t];
}
int main() {
	int N; cin >> N;
	while (N--) {
		vector<int>field(13,0);
		field[6] = -1;
		for (int i = 0; i < 6; ++i) {
			int a; cin >> a;
			field[a - 1] = 1;
		}
		bool ok = solve(field, true);
		if (ok)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3232
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const ll MOD = 1000*1000*1000+7;
ll add(ll a, ll b) { return (a+b)%MOD; }
ll mul(ll a, ll b) { return (a*b)%MOD; }

ll inv(ll a, ll p) {
  return ( a == 1 ? 1 : (1 - p*inv(p%a, a)) / a + p );
}

int main() {
  ll H, W, A, B;
  while (cin >> H >> W >> A >> B) {
    vector<ll> fact(300000);
    fact[0] = 1LL;
    for (int i : range(1, 300000)) fact[i] = mul(fact[i - 1], i);

    auto ways = [&](ll n, ll m) {
      return mul(mul(fact[n + m], inv(fact[n], MOD)), inv(fact[m], MOD));
    };

    ll res = 0;
    for (int i = 0; i < H - A; ++i) {
      res = add(res, mul(ways(B - 1, i), ways(H - 1 - i, W - B - 1)));
    }
    cout << res << endl;
  }
}



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

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    if(n == d) s += '#';
    if(c == d){
        cout << "No" << endl;
        return 0;
    }
    bool can = true;
    bool can2 = false;
    for(int i = a; i < c; i++){
        if(s[i-1] == '#' && s[i] == '#') can = false;
    }
    for(int i = b; i < d; i++){
        if(s[i-1] == '#' && s[i] == '#') can = false;
    }
    for(int i = b; i <= d; i++){
        if(s[i-2] == '.' && s[i-1] == '.' && s[i] == '.') can2 = true;
    }
    if(c < d) cout << (can? "Yes" : "No") << endl;
    else cout << (can & can2 ? "Yes" : "No") << endl; 
    return 0;
}

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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n, m, p;
int b[10][10][60];

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

bool ok(int x, int y, int z) {
    return 0 <= x and x < n and 0 <= y and y < n and 0 <= z and z < 60;
}

int check(int x, int y, int z, int col, int DX, int DY, int DZ) {
    int ret = 0;
    if (DX == -1) {
        rep(aa, 3) rep(bb, 3) rep(cc, 3) {
            if (aa == bb and bb == cc and aa == 1) continue;
            int nx = x+dx[aa], ny = y+dy[bb], nz = z+dz[cc];
            int nx2 = x+dx[(aa+2)%4], ny2 = y+dy[(bb+2)%4], nz2 = z+dz[(cc+2)%4];
            int tmp = 1;
            if (ok(nx, ny, nz) and b[nx][ny][nz] == col) {
                tmp += check(nx, ny, nz, col, aa, bb, cc) + 1;
            }
            if (ok(nx2, ny2, nz2) and b[nx2][ny2][nz2] == col) {
                tmp += check(nx2, ny2, nz2, col, (aa+2)%4, (bb+2)%4, (cc+2)%4) + 1;
            }
            ret = max(ret, tmp);
        }
    }
    else {
        int nx = x+dx[DX], ny = y+dy[DY], nz = z+dz[DZ];
        if (!ok(nx, ny, nz)) return 0;
        else if (b[nx][ny][nz] == col) {
            return check(nx, ny, nz, col, DX, DY, DZ) + 1;
        }
    }
    return ret;
}

int main() {
    while (cin >> n >> m >> p and (n or m or p)) {
        rep(x, 10) rep(y, 10) rep(z, 60) b[x][y][z] = -1;
        bool end = false;
        rep(i, p) {
            int x, y;
            cin >> x >> y;
            x--;
            y--;
            for (int z=0; z<10; ++z) {
                if (b[x][y][z] == -1) {
                    b[x][y][z] = i%2;
                    int flag = check(x, y, z, i%2, -1, -1, -1);
                    if (!end and flag >= m) {
                        cout << (i%2 ? "White" : "Black") << ' ' << i+1 << endl;
                        end = true;
                    }
                    break;
                }
            }
        }
        if (!end) {
            cout << "Draw" << endl;
        }
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
ll sum (ll n) {
    return n*(n+1)/2;
}

int main() {
    int n;
    cin >> n;
    ll ans=0;
 
    ans = sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15;

    cout << ans << endl;
 
}

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

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long
const int N=1e5+10;
const int MOD=1e9+7;

int32_t main()
{
boost;
string s;
cin>>s;
  for(int i=0;i<s.length()-1;++i)
  {
    if(s[i]==s[i+1])
	{
      cout<<i+1<<" "<<i+2;
      return 0;
    }
  }

  for(int i=0;i<s.length()-2;++i)
  {
    if(s[i]==s[i+2])
	{
      cout<<i+1<<" "<<i+3;
      return 0;
    }
  }
cout<<-1<<" "<<-1;
return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
string s[8];
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};
main()
{
	for(int i=0;i<8;i++)cin>>s[i];
	int f=1;
	while(f)
	{
		f=0;
		int mcnt=0,mini=-1,minj=-1;
		for(int i=0;i<8;i++)for(int j=0;j<8;j++)
		{
			if(s[i][j]!='.')continue;
			int cnt=0;
			for(int r=0;r<8;r++)
			{
				int nowcnt=0;
				int x=i+dx[r],y=j+dy[r];
				while(x>=0&&x<8&&y>=0&&y<8&&s[x][y]=='x')
					nowcnt++,x+=dx[r],y+=dy[r];
				if(x>=0&&y>=0&&x<8&&y<8&&s[x][y]=='o')cnt+=nowcnt;
			}
			if(mcnt<cnt)
			{
				mcnt=cnt;
				mini=i,minj=j;
			}
		}
		if(mcnt)
		{
			int i=mini,j=minj;f++;
			s[i][j]='o';
			for(int r=0;r<8;r++)
			{
				int x=i+dx[r],y=j+dy[r];
				while(x>=0&&x<8&&y>=0&&y<8&&s[x][y]=='x')
					x+=dx[r],y+=dy[r];
				if(x>=0&&y>=0&&x<8&&y<8&&s[x][y]=='o')
				{
					x=i+dx[r],y=j+dy[r];
					while(x>=0&&x<8&&y>=0&&y<8&&s[x][y]=='x')
						s[x][y]='o',x+=dx[r],y+=dy[r];
				}
			}
		}
		mcnt=0,mini=-1,minj=-1;
		for(int i=8;i--;)for(int j=8;j--;)
		{
			if(s[i][j]!='.')continue;
			int cnt=0;
			for(int r=0;r<8;r++)
			{
				int nowcnt=0;
				int x=i+dx[r],y=j+dy[r];
				while(x>=0&&x<8&&y>=0&&y<8&&s[x][y]=='o')
					nowcnt++,x+=dx[r],y+=dy[r];
				if(x>=0&&y>=0&&x<8&&y<8&&s[x][y]=='x')cnt+=nowcnt;
			}
			if(mcnt<cnt)
			{
				mcnt=cnt;
				mini=i,minj=j;
			}
		}
		if(mcnt)
		{
			int i=mini,j=minj;f++;
			s[i][j]='x';
			for(int r=0;r<8;r++)
			{
				int x=i+dx[r],y=j+dy[r];
				while(x>=0&&x<8&&y>=0&&y<8&&s[x][y]=='o')
					x+=dx[r],y+=dy[r];
				if(x>=0&&y>=0&&x<8&&y<8&&s[x][y]=='x')
				{
					x=i+dx[r],y=j+dy[r];
					while(x>=0&&x<8&&y>=0&&y<8&&s[x][y]=='o')
						s[x][y]='x',x+=dx[r],y+=dy[r];
				}
			}
		}
	}
	for(int i=0;i<8;i++)cout<<s[i]<<endl;
}



Measured memory_bytes: 3216
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++){
		if(a*i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>

int fb_num[45];

int fb(int n){
  if(n==1 || n==0)return fb_num[n]=1;
  if(fb_num[n]>0)return fb_num[n];
  return fb_num[n]=fb(n-1)+fb(n-2);
}
int main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",fb(n));

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int getcost(int a,int b);
int h[100008];
int main(){
  int N;
  cin>>N;
  int dp[N+1];//1 indexed
 
  for (int in=1;in<=N;in++){
    cin>>h[in];
  }
  dp[1] = 0;
  dp[2] =abs(h[2]-h[1]);
  // dp[n] =min(dp[n-1]+h[n]-h[n-1],dp[n-2]+h[n]-h[n-2])
  if(N == 2) {cout<<dp[2]<<endl;return 0;}
  for(int n=3;n<=N;n++){
    dp[n] = min(dp[n-1]+getcost(n,n-1),dp[n-2]+getcost(n,n-2));
    
  }
  cout<<dp[N]<<endl;
  return 0;
}

int getcost(int a,int b){
  if(h[a]>h[b])
  return (h[a]-h[b]);
  else return h[b]-h[a];
}



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

int main()
{

   int n;
   cin>>n;
    double a[n+1];
    a[0]=0.0;
    for(int i=1;i<=n;i++)
      cin>>a[i];

    double dp[n+1][n+1];

    memset(dp,0,sizeof dp);
    dp[0][0]=1.0;
    if(n==1)
        cout<<a[1]<<"\n";
    else
    {
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j==0)
                dp[i][j]=(1-a[i])*dp[i-1][0];
            else
              dp[i][j]=dp[i-1][j-1]*a[i]+dp[i-1][j]*(1-a[i]);
        }
    }
    double sum=0;
    for(int i=(n/2)+1;i<=n;i++)
       sum+=dp[n][i];
    cout<<setprecision(10)<<sum<<"\n";
    }
   return 0;

}


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

using namespace std;

int main (){
	// freopen("input.txt", "r", stdin); // redirects standard input
	// freopen("output.txt", "w", stdout); // redirects standard output
	int n,a,b;
	cin >> n >> a >> b;
	int diff = abs( a - b );
	if( diff & 1 ){
		cout << "Borys" ;
	}
	else{
		cout << "Alice" ;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]

on_off_patterns = []
for i in range(2 ** N):
    on_off = [0] * N
    for j in range(N):
        if ((i >> j) & 1):
            on_off[N-1-j] = 1
    on_off_patterns.append(on_off)
    
bulbs = []
for i in range(M):
    bulb_data = [int(i) for i in input().split()]
    k = bulb_data[0]
    switches = bulb_data[1:]
    bulbs.append([n -1 for n in switches])
    
p = [int(i) for i in input().split()]

cnt = 0
for pattern in on_off_patterns:
    bulb_on_off = [0] * M
    for b in range(len(bulbs)):
        value = 0
        for s in range(len(bulbs[b])):
            value += pattern[bulbs[b][s]]
            
        if value % 2 == p[b]:
            bulb_on_off[b] = 1
        else :
            bulb_on_off[b] = 0
    if sum(bulb_on_off) == M:
        cnt += 1
print(cnt)
            

Measured memory_bytes: 3188
import java.util.*;

public class Main
{
	public static void main (String[] args) 
	{
		
 		Scanner sc= new Scanner(System.in);
 		String s1= sc.next();
 		String s2 = sc.next();
 		int dp[][]=new int[s1.length()+1][s2.length()+1];
 		int maxv = Integer.MIN_VALUE;
 		for(int i=0;i<=s1.length();i++){
 		    for(int j=0;j<=s2.length();j++){
 		        if(i==0||j==0){
 		            dp[i][j]=0;
 		        }
 		        else {
 		            if(s1.charAt(i-1)==s2.charAt(j-1)){
 		                dp[i][j]= dp[i-1][j-1]+1;
 		            }
 		            else {
 		                dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
 		                
 		            }
 		        }
 		    }
 		}
//  		for(int i=0;i<arr_str.length;i++){
//  		    System.out.print(arr_str[i]+" ");
//  		}
//  		System.out.println();
//  		//System.out.println(dp[s1.length()][s2.length()]);
//  		for(int i=0;i<=s1.length();i++){
//  		    for(int j=0;j<=s2.length();j++){
//  		        System.out.print(dp[i][j]+" ");
//  		    }
//  		    System.out.println("");
//  		}
        int i = s1.length();
        int j =s2.length();
        String f = "";
        int minVal = dp[s1.length()][s2.length()];
        while(i>=1 && j>=1){
            
            if (s1.charAt(i-1)==s2.charAt(j-1)){
                f = s1.charAt(i-1)+""+f;
                
                i=i-1;
                j=j-1;
                
            }
            else if (dp[i][j-1]==dp[i][j]){
               // f = s1.charAt(i)+""+f;
               j=j-1;
                
            }
            else {
                i=i-1;
            }
            }
        
 		//System.out.println(dp[s1.length()][s2.length()]);
 		System.out.println(f);
	

	    
		
	}
}

Measured memory_bytes: 84940
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,cnt=0;
    cin >> n;
    ll p[n];
    rep(i,n) cin >> p[i];
    for(int i=1;i<=n-2;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")


int N, X, ans = 1;
int temp[100] = {1,};
int temp2[100] = {1,};

int solve(int x, int le){//cout<<x<<" "<<le<<endl;
	if(le == 0)return x;//cout<<"a"<<endl;
	if(x == 1)return 0;
	if(x == temp2[le]) return temp[le];//cout<<"b"<<endl;
	if(x*2 < temp2[le]) return solve(x-1,le-1);//cout<<"c"<<endl;
	if(x*2 == temp2[le]+1) return temp[le-1]+1;//cout<<"d"<<endl;
	return solve(x-temp2[le-1]-2,le-1)+temp[le-1]+1;
}
signed main(){
	cout<<fixed<<setprecision(7);
	

	
	cin>>N>>X;
	
	for(int i = 1; i <= N; i++){
		temp[i] = temp[i-1]*2+1;
		temp2[i] = temp2[i-1]*2+3;
	}
	cout<<solve(X,N)<<endl;
	
	
	return 0;
}

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

int main()
{
  int N;
  int v[21], c[21];
  int p[21];
  int res=0;
  cin >> N;

  rep(i,N) {
    cin >> v[i];
  }
  rep(i,N) {
    cin >> c[i];
  }
  rep(i,N){
    p[i] = v[i] - c[i];
  }

  rep(i,N){
    if(p[i]>0) res += p[i];
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
import itertools
A=[list(map(int,input().split())) for i in range(3)]
A=list(itertools.chain.from_iterable(A))
N=int(input())
for _ in range(N):
    b=int(input())
    try:
        A[A.index(b)]="X"
    except:
        continue
answer="No"
for bingo in [[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6],[0,3,6],[1,4,7],[2,5,8]]:
    if A[bingo[0]]=="X" and A[bingo[1]]=="X" and A[bingo[2]]=="X":
        answer="Yes"
print(answer)

Measured memory_bytes: 3064
// Aaradhya Beri
//#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K<=A) cout<<K<<endl;
  else if(K<=A+B) cout<<A<<endl;
  else cout<<(2*A)+B-K<<endl;
    return 0;
}

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

ll x;

ll f(ll R) {    // [0, R]
    if (R == -1) {
        return 0;
    } else {
        return R / x + 1;
    }
}

int main() {
    ll a, b;
    cin >> a >> b >> x;
    cout << f(b) - f(a - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    s = list(map(int, input().split()))

    def solve(i, mm):
        if mm == 0:
            return True
        if i >= n:
            return False
        if sum(t[i::]) < mm:
            return False
        res = solve(i + 1, mm) or solve(i + 1, mm - t[i])
        return res

    for r in s:
        print('yes' if solve(0, r) else 'no')



Measured memory_bytes: 5624
n = int(input())
#a, b, c, d = list(map(int, input().split()))
# Ch, Cw = list(map(int, input().split()))
# Dh, Dw = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(4)]
# k = int(input())
# a = list(map(int, input().split("/")))
# r = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# data = [list(map(int, input().split())) for i in range(n)]
# month = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]


def permutations(n, r):
    return math.factorial(n) // math.factorial(n - r)


def calc_eight(n):
    ans = 1
    mod = 10**9 + 7
    for i in range(n):
        ans *= 8
        ans %= mod
    return ans


def calc_ten(n):
    ans = 1
    mod = 10**9 + 7
    for i in range(n):
        ans *= 10
        ans %= mod
    return ans


def calc_nine(n):
    ans = 1
    mod = 10**9 + 7
    for i in range(n):
        ans *= 9
        ans %= mod
    return ans


if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    mod = 10**9 + 7
    _all = calc_ten(n)
    _all %= mod
    other = calc_eight(n)
    other %= mod
    nine = calc_nine(n)
    nine %= mod
    # print(_all)
    # print(other)
    # print(nine)
    # print(nine*2-other)
    # print(ans)
    ans = _all-(nine*2-other)
    ans %= mod
    print(ans)


Measured memory_bytes: 9104
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = 1

if X >= Y:
    ans = 1
elif X < Y:
    z = list(range(X+1, Y+1))

for i in z:
    if max(x) < i and i <= min(y):
        ans = 0
        
if ans == 0:
     print('No War')
        
else:
    print('War')

Measured memory_bytes: 3064
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let p: Vec<usize> = sc.vec(n);

    let mut cur_min = 1 << 50;
    let mut ans = 0;
    for i in 0..n {
        cur_min = cmp::min(cur_min, p[i]);
        if cur_min == p[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
#include <iostream>

using namespace std;
/** Problem0149 : Eye Test **/
int main()
{
	int table[2][4] = {{0}};
	double l, r;
	
	while (cin >> l >> r) {
		if (l >= 1.1)
			table[0][0]++;
		else if (l >= 0.6)
			table[0][1]++;
		else if (l >= 0.2)
			table[0][2]++;
		else
			table[0][3]++;
		
		if (r >= 1.1)
			table[1][0]++;
		else if (r >= 0.6)
			table[1][1]++;
		else if (r >= 0.2)
			table[1][2]++;
		else
			table[1][3]++;
	}
	
	for (int i=0; i<4; i++)
		cout << table[0][i] << " " << table[1][i] << endl;
	
	return 0;
}

Measured memory_bytes: 1224
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define pii pair<int,int>
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first

int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c;
    T=1;
    while(T --> 0)
    {
        cin>>n;
        int A[n];
        unordered_map<int,int> mp;
        for(i=0;i<n;i++)
        {
            cin>>A[i];
            mp[A[i]]++;
        }
        for(i=0;i<n;i++)
        cout<<mp[i+1]<<'\n';
        
    }
    return 0;
}

Measured memory_bytes: 13060
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		ULL N; cin >> N;
		ULL ans = 0;
		for (ULL i = 1; i* i < N; i++) {
			if ((N - i) % i == 0)
				if ((N - i) / i > i) ans += (N - i) / i;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

const int N = 10;

char s[N + 5]; 

int main() {

    std::cin >> s; 
    int n = strlen(s); 

    int flag = 1; 

    for (int i = 0; i < n; i ++) {
        if ((i % 2 == 0 && s[i] == 'h') || (i % 2 == 1 && s[i] == 'i')) ;
        else flag = 0;  
    }

    if (n % 2 == 1) std::cout << "No" << std::endl; 
    else std::cout << (flag ? "Yes" : "No") << std::endl;

    return 0; 
}

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

int main() {
  int N, l, r, x, i;
  cin >> N;
  x = 0;
  for (i = 0; i < N; i++) {
    cin >> l >> r;
    x += r-l+1;
    }
    cout << x << endl;
  }

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

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

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

struct Key {
    int price, code;
    Key(int price = INT_MAX, int code = 0) : price(price), code(code) {}
    Key operator+(const Key& key) { return Key(price + key.price, code | key.code); }
};

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

    int n, m;
    cin >> n >> m;

    vector<Key> keys(m);
    rep(i, 0, m) {
        int b;
        cin >> keys[i].price >> b;
        rep(j, 0, b) {
            int c;
            cin >> c;
            keys[i].code |= (1 << (c - 1));
        }
    }

    // O(m * n)
    vector<Key> min_keys(n);
    rep(i, 0, n) {
        rep(j, 0, m) {
            if ((keys[j].code & (1 << i)) && min_keys[i].price > keys[j].price) {
                min_keys[i] = keys[j];
            }
        }
    }

    // 開けない宝箱がある場合．
    rep(i, 0, n) {
        if (min_keys[i].price == INT_MAX) {
            cout << -1 << endl;
            return 0;
        }
    }

    // O(2^n * n * m)
    vector<Key> dp(1 << n);
    dp[0].price = 0;

    rep(bit, 1, 1 << n) {
        // 何個の宝箱を開くか．
        int n_open = __builtin_popcount(bit);

        // 1個のみ開く場合，最小コストの鍵を使う．
        if (n_open == 1) {
            dp[bit] = min_keys[(int)log2(bit)];
            continue;
        }

        rep(i, 0, m) {
            // 1回前の状態．
            int prev_bit = bit & (~keys[i].code);

            // この鍵が関係ないときはスキップする．
            if (bit == prev_bit) { continue; }

            if (dp[bit].price == INT_MAX || dp[bit].price > dp[prev_bit].price + keys[i].price) {
                dp[bit] = dp[prev_bit] + keys[i];
            }
        }
    }

    cout << dp.back().price << endl;
    return 0;
}

Measured memory_bytes: 256