akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var x = sc.nextInt();
        var a = sc.ArrayInt(N);
        a = a.OrderBy(i => i).ToArray();

        var ans = 0;
        for (int i = 0; i < N; i++) {
            if (x >= a[i]) {
                x -= a[i];
                if (i == N-1) {
                    if (x == 0) {
                        ans++;
                    }
                } else {
                    ans++;
                }
            }
        }
        WriteLine(ans);
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#include<stdio.h>
 
int main(){
    string S;
    cin >> S;
    int L=S.length();
    int num=0;
    for(int i=0;i<L-1;++i){
        if(S[i]!=S[i+1]){
            ++num;
        }
    }
    cout << num;
}

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

//#define int int64_t
#define REP(i, s, n) for (signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) begin(c), end(c)


#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	const int NM = 1e6;
	vector<int> seisi, dp(NM, 1 << 29), dp2(NM, 1 << 29);
	for (int i = 1; i * (i + 1) * (i + 2) / 6 < NM; i++) {
		int x = i * (i + 1) * (i + 2) / 6;
		seisi.push_back(x);
	}
	dp2[0] = dp[0] = 0;
	rep(i, NM) {
		for (auto x : seisi) {
			if (i - x < 0) break;
			dp[i] = min(dp[i], dp[i - x] + 1);
			if (x % 2) dp2[i] = min(dp2[i], dp2[i - x] + 1);
		}
	}

	int n;
	while (cin >> n && n) {
		cout << dp[n] << " " << dp2[n] << endl;
	}
}

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

int main(void){
    int a,b,c,day = 0,sum = 0;

    cin >> a >> b >> c;
    while(sum < c){
        day++;
        sum += a;
        if(day % 7 == 0){
            sum += b;
        }
    }

    cout << day << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
long long a[100005]={0};
long long b[100005]={0};
long long sum=0;
int main() {
    int n;
    cin >> n;
    for(int i=0;i<n+1;i++){
        cin >> b[i] ;
    }
    for(int i=0;i<n;i++){
        cin >> a[i] ;
    }
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){

            sum+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
        else{
            b[i]-=a[i];
            sum+=a[i];
            a[i]=0;
        }
        if(a[i]>=b[i+1]){
            sum+=b[i+1];
            a[i]-=b[i+1];
            b[i+1]=0;
        }
        else{
            b[i+1]-=a[i];
            sum+=a[i];
            a[i]=0;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
// 3:15~
#include <bits/stdc++.h>
using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Board{
	ull data[4];
	Board():data{}{}
	int get(int i,int j){
		return data[i]>>j*8&0xff;
	}
	void set(int i,int j,int x){
		(data[i]&=~(0xffull<<j*8))|=(ull)x<<j*8;
	}
};
bool operator==(const Board& a,const Board& b){
	rep(i,4) if(a.data[i]!=b.data[i]) return false;
	return true;
}
namespace std{
	template<>
	struct hash<Board>{
		size_t operator()(const Board& x)const{
			const char* p=(const char*)&x;
			size_t res=2166136261;
			rep(i,sizeof(x)) (res^=*p++)*=16777619;
			return res;
		}
	};
}

int solve()
{
	Board b0;
	rep(i,4) repi(j,1,8){
		int x; cin>>x;
		if(x%10==1) b0.set(x/10-1,0,x);
		else        b0.set(i,j,x);
	}
	Board bz;
	rep(i,4) rep(j,7) bz.set(i,j,(i+1)*10+j+1);
	
	queue<Board> q; q.push(b0);
	int res=0;
	for(;;res++){
		queue<Board> q2;
		unordered_set<Board> vis;
		while(q.size()){
			Board cur=q.front(); q.pop();
			if(cur==bz) return res;
			if(vis.count(cur)) continue;
			vis.insert(cur);
			
			vector<pii> f(48);
			rep(i,4) rep(j,8) if(cur.get(i,j)) f[cur.get(i,j)]=mp(i,j);
			
			rep(i,4) repi(j,1,8) if(cur.get(i,j)==0){
				int left=cur.get(i,j-1);
				if(left==0 || left%10==7) continue;
				Board next=cur;
				int x=left+1;
				next.set(f[x].first,f[x].second,0);
				next.set(i,j,x);
				q2.push(next);
			}
		}
		if(q2.empty())
			return -1;
		swap(q,q2);
	}
}

int main()
{
	int n; cin>>n;
	rep(_,n) cout<<solve()<<endl;
}

Measured memory_bytes: 1764
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b;
	cin >> a >> b;

	if (a + b >= 10)print("error");
	else print(a + b);






	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
S = tuple(map(int, input().split()))
ans = 0
for c in range(1, n-1):
  temp = 0
  T = set()
  for k in range(n):
    d = c*k
    if d+c >= n:
      break
    if d == n-1-d or d in T or n-1-d in T:
      break
    T.add(d)
    T.add(n-1-d)
    temp += S[d]+S[n-1-d]
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 23052
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), yen = sc.nextInt() / 1000;
        int count = 0;
        int minX = yen / 10;
        count += 10 * minX;
        int minY = (yen - count) / 5;
        count += minY * 5;
        int minZ = yen - count;
        int sum = minX + minY + minZ;

        if (sum == n) {
            System.out.println(minX + " " + minY + " " + minZ);
        } else if (sum > n) {
            System.out.println("-1 -1 -1");
        } else {
            int diff = n - sum;
            if (minX * 9 + minY * 4 >= diff) {
                while (diff >= 9 && minX > 0) {
                    minX--;
                    minZ += 10;
                    diff -= 9;
                }
                while (diff >= 4 && minY > 0) {
                    minY--;
                    minZ += 5;
                    diff -= 4;
                }
                while (diff > 0 && minX > 0) {
                    minX--;
                    minY += 2;
                    diff -= 1;
                }
                if (diff == 0 && minX >= 0 && minY >= 0 && minZ >= 0) {
                    System.out.println(minX + " " + minY + " " + minZ);
                } else {
                    System.out.println("-1 -1 -1");
                }
            } else {
                System.out.println("-1 -1 -1");
            }
        }
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int ans=1e9;
    for(int i=0;i<=n-m;i++){
        int c=0;
        for(int j=0;j<m;j++){
            if(i+j<n&&s[i+j]!=t[j]) c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
def examA():
    C = [S() for _ in range(2)]
    if C[0][0]==C[1][2] and C[0][1]==C[1][1] and C[0][2]==C[1][0]:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int a[30] = {INT_MAX};
    for(int j = 0; j <= 'z'-'a'; j++){
        a[j] = INT_MAX;
    }
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        int str[30]={0}, len = s.length();
        for(int j = 0; j < len; j++) str[s[j] - 'a']++;
        for(int j = 0; j <= 'z'-'a'; j++){
            a[j] = min(a[j], str[j]);
        }
    }
    for(int j = 0; j <= 'z'-'a'; j++){
        for(int i = 0; i < a[j]; i++) cout << (char)('a'+j);
    }
    cout << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;
  
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  
  for(int i = 1; i < n-1; i++){
    if( (p.at(i-1) - p.at(i)) * (p.at(i) - p.at(i+1)) > 0) 
       cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#define INF 1e+9
using namespace std;

typedef pair<int,int> P;

int main(){
	int n,p[100010] = {},d[100010];
	bool used[100010] = {};
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> p[i];
	}
	for(int i = 0;i < n + 6;i++) d[i] = INF;
	d[0] = 0;
	used[0] = true;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,0));
	while(!que.empty()){
		P pp = que.top();que.pop();
		int v = pp.second;
		if(v >= n) continue;
		if(d[v] < pp.first) continue;
		for(int i = 1;i <= 6;i++){
			if(d[v + i] > d[v] + 1){
				if(p[v + i]){
					int pos = v + i;
					bool f = false;
					while(p[pos]){
						pos += p[pos];
						if(used[pos]) {
							f = true;
							break;
						}
						used[pos] = true;
					}
					if(f) continue;
					if(d[pos] > d[v] + 1){
						d[pos] = d[v] + 1;
						que.push(P(d[pos],pos));
					}
				}else{
					d[v + i] = d[v] + 1;
					used[v + i] = true;
					que.push(P(d[v + i],v + i));
				}
			}
		}
	}
	//for(int i = 0;i < n;i++) cout << d[i] << endl;
	cout << d[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdlib.h>

int ASIZE;

void moveLeft(int *a) { *a = (*a + ASIZE - 1) % ASIZE; }
void moveRight(int *a) { *a = (*a + 1) % ASIZE; }

int main()
{
  int *A;
  int q, p, x, i;
  int head, tail, pos;

  scanf("%d", &ASIZE);
  A = (int*)malloc(sizeof(int) * ASIZE);

  head = 0;
  tail = ASIZE - 1;
  for (i = 0; i < ASIZE; i++)
  {
    scanf("%d", &q);
    switch (q)
    {
    case 0:
      scanf("%d %d", &p, &x);
      if (p == 0)
      {
        moveLeft(&head);
        A[head] = x;
      }
      else if (p == 1)
      {
        moveRight(&tail);
        A[tail] = x;
      }      
      break;
    case 1:
      scanf("%d", &p);
      pos = (p + head) % ASIZE;
      printf("%d\n", A[pos]);
      break;
    case 2:
      scanf("%d", &p);
      if (p == 0)
      {
        moveRight(&head);
      }
      else if (p == 1)
      {
        moveLeft(&tail);
      }
      break;
    }
  }

  free(A);

  return 0;
}


Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.nextLine().toCharArray();
		int[] ans = new int[S.length];

		int r = 0;
		int l = 0;
		int R = -1;
		int L = -1;
		boolean isR = true;
		for (int i = 0; i < S.length; i++) {
			if (S[i] == 'R') {
				if (isR) {
					r++;
					if (r > 1) {
						ans[i - 1] = 0;
					}
				} else {
					ans[R] = (r + 1) / 2 + l / 2;
					ans[L] = r / 2 + (l + 1) / 2;
					r = 1;
					l = 0;
					isR = true;
				}
			} else {
				if (isR) {
					R = i - 1;
					L = i;
					isR = false;
					l = 1;
				} else {
					l++;
					ans[i] = 0;
				}
			}
		}
		ans[R] = (r + 1) / 2 + l / 2;
		ans[L] = r / 2 + (l + 1) / 2;
		for(int i = 0;i < S.length;i++) {
			System.out.print(((i==0)?"":" ") + ans[i]);
		}
	}

}


Measured memory_bytes: 43960
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))


bool comp(const ll x,const ll y){
    return x>y;
}

int main(){
    ll x,y,z,k;
    cin >>x>>y>>z>>k;
    ll ans[3000],kouho[3000000];
    ll a[x],b[y],c[z];
    for(int i=0;i<3000000;i++){
        kouho[i]=0;
    }
    
    for(int i=0;i<x;i++){
        cin >>a[i];
        dbg cout <<a[i]<<endl;
    }
    for(int i=0;i<y;i++){
        cin >>b[i];
        dbg cout <<b[i]<<endl;
    }
    for(int i=0;i<z;i++){
        cin >>c[i];
        dbg cout <<c[i]<<endl;
    }
    sort(a,a+x, comp);
    sort(b,b+y, comp);
    sort(c,c+z, comp);
    for(int i=0;i<k;i++){
        if(i>x){
            ans[i]=0;
        }else{
            ans[i]=a[i];
        }
    }

    int cnt=0;
    for(int i=0;i<min(x,k);i++){
        for(int j=0;j<y;j++){
            kouho[cnt]=ans[i]+b[j];
            cnt+=1;
        }
    }
    sort(kouho,kouho+cnt, comp);
    /*for(int i=0;i<k;i++){
        cout <<kouho[i]<<endl;
    }*/
    for(int i=0;i<k;i++){
        ans[i]=kouho[i];
    }
    cnt=0;
    for(int i=0;i<k;i++){
        for(int j=0;j<z;j++){
            kouho[cnt]=ans[i]+c[j];
            cnt++;
        }
    }
    sort(kouho,kouho+cnt, comp);

    for(int i=0;i<k;i++){
        cout <<kouho[i]<<endl;
    }
    


    return 0;

}

Measured memory_bytes: 23808
void main(){
	int n = _scan();
	int[] a = _scanln();
	a.sort!("a>b");
	int ans;
	foreach(i, elm; a){
		if(i&1)ans-=elm;
		else ans+=elm;
	}
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main() {
	
	string s;
	map<string,int>mp;
	map<string,int>::iterator it;
	int n,x,y=0,count = 0;
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s>>x;
		count+=x;
		mp[s]=count;
	}
	cin>>s;
	it=mp.find(s);
	if(it!=mp.end()) y = it->second;
	cout<<count-y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
int main()
{
    int n;
    int x=0;
    std::cin>>n;
    x = n%10;
    if(x== 3){
        std::cout<<"bon"<<std::endl;
    }
    else if(x== 0 || x==1 || x==6 || x==8){
        std::cout<<"pon"<<std::endl;
    }
    else{
        std::cout<<"hon"<<std::endl;
    }

    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
 freopen("input","r",stdin);
 freopen("output","w",stdout);
*/

ll MOD = 1E9 + 7;

ll A[3010], B[3010], C[3010], D[3010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    string s;
    cin >> N;
    cin >> s;
    memset(A, 0, sizeof(A));
    memset(B, 0, sizeof(B));
    A[0] = 1;
    for (int i = 1;i < N;i++) {
        memset(B, 0, sizeof(B));
        memset(C, 0, sizeof(C));
        memset(D, 0, sizeof(D));
        C[0] = A[0];
        for (int j = 1;j < i;j++) {
            C[j] = C[j - 1] + A[j];
            C[j] %= MOD;
        }
        D[i] = 0;
        for (int j = i - 1;j >= 0;j--) {
            D[j] = D[j + 1] + A[j];
            D[j] %= MOD;
        }
        if (s[i - 1] == '<') {
            for (int j = 1;j <= i;j++) {
                B[j] = C[j - 1];
            }
        } else {
            for (int j = i - 1;j >= 0;j--) {
                B[j] = D[j];
            }
        }
        swap(A, B);
    }
    ll sol = 0;
    for (int i = 0;i < N;i++) {
        sol += A[i];
        sol %= MOD;
    }
    cout << sol << endl;
    return 0;
}


Measured memory_bytes: 384
# https://atcoder.jp/contests/abc159/submissions/11139734

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    *a, = map(int, input().split())

    dp = [0] * (S + 1)

    ret = 0
    for i, x in enumerate(a):
        dp[0] += 1
        if x > S: continue
        ret = (ret + dp[S - x] * (N - i)) % MOD
        for k in range(S - 1, x - 1, -1):
            dp[k] = (dp[k] + dp[k - x]) % MOD

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
fn main() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut mat = vec![vec![0; m]; n];
    for i in 0..n {
        for j in 0..m {
            mat[i][j] = read();
        }
    }
    let mut v: Vec<usize> = vec![];
    for i in 0..m {
        v.push(read());
    }
    let mut resv = vec![0; n];
    for i in 0..n {
        for j in 0..m {
            resv[i] += v[j] * mat[i][j];
        }
    }
    for r in resv {
        println!("{}", r);
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: isize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



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

int m, n;
int a[110];

int chk(int w){
  int ind = 0;
  for(int i=0; i<m; i++){
    int t = 0;
    for(;;){
      if(ind==n) break;
      if(t+a[ind]>w) break;
      
      t += a[ind];
      ind++;
    }
  }
  if(ind==n) return 1;
  else return 0;
  
}

int main(){
  for(;;){
    cin >> m >> n;
    if(m==0 && n==0) break;
    
    for(int i=0; i<n; i++) cin >> a[i];
    
    int il = 0, ir = 1500001;
    while(ir-il>1){
      int mid = (il+ir)/2;
      if(chk(mid)){
        ir = mid;
      }else{
        il = mid;
      }
    }
    cout << il+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	
	Scanner scan = new Scanner(System.in);
		
	long M = 1;
	
	int m = scan.nextInt();
	int n = scan.nextInt();
		
	if(n%4!=0){
		for(int i=0; i<n%4; i++){
			M *= m;}
		n -= n % 4;}
			
	for(int i=0; i<n/4; i++){
		M *= m * m * m * m;
		if(M > 1000000007){
			M %= 1000000007;}
	}
	
	System.out.println(M);
	}
}


Measured memory_bytes: 26436
def palindrome(word):
  if len(word) <= 1:
    return True
  if word[0] != word[-1]:
    return False
  return palindrome(word[1:-1])
 
word = input()
n = len(word) // 2
issuper = palindrome(word[:n]) and palindrome(word[n+1:]) and palindrome(word)
print("Yes" if issuper else "No")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<climits>
#include<cstring>
#include<cmath>
#include<stdio.h>
#include<map>

using namespace std;

typedef struct node{
	int val;
	struct node *link;
}node;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef pair<pi,pi > pi2;
typedef vector<node> vn;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
typedef vector<pi2 > vpi2;

int main(){
	int n;
	cin>>n;
	int a[n];
	map<int,int> m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(m[a[i]-1]==0)
			m[a[i]]=1;
		else
			m[a[i]]=m[a[i]-1]+1;
	}

	/*for(int i=0;i<n;i++)
		cout<<"map["<<i<<"]: "<<m[a[i]]<<endl;;
	cout<<endl;*/

	int max=0;

	for(int i=0;i<n;i++){
		if(m[a[i]]>max)
			max=m[a[i]];
	}

	cout<<n-max;
	return 0;
}

Measured memory_bytes: 10368
from sys import stdin

def main():
    from collections import deque
    import copy
    input = stdin.readline

    h, w = map(int, input().split())
    cm = [[0] * (w + 2) for _ in range(h + 2)]
    que = deque([])
    a = deque([])
    for i in range(1, h + 1):
        s = input()
        for j in range(1, w + 2):
            if s[j - 1] == ".":
                cm[i][j] = -1
                a.append([i, j])
    ans = 0
    for b in a:
        dm = copy.deepcopy(cm)
        que.append(b[0])
        que.append(b[1])
        que.append(0)
        dm[b[0]][b[1]] = 0
        while len(que) > 0:
            y = que.popleft()
            x = que.popleft()
            r = que.popleft()
            if ans < r + 1:
                ans = r + 1
            if dm[y + 1][x] == -1:
                dm[y + 1][x] = r + 1
                que.append(y + 1)
                que.append(x)
                que.append(r + 1)
            if dm[y - 1][x] == -1:
                dm[y - 1][x] = r + 1
                que.append(y - 1)
                que.append(x)
                que.append(r + 1)
            if dm[y][x + 1] == -1:
                dm[y][x + 1] = r + 1
                que.append(y)
                que.append(x + 1)
                que.append(r + 1)
            if dm[y][x - 1] == -1:
                dm[y][x - 1] = r + 1
                que.append(y)
                que.append(x - 1)
                que.append(r + 1)
    print(ans - 1)
main()

Measured memory_bytes: 3572
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
#define N 100001
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
template <class x>
void max(x &a,x &b)
{
	return (a>=b?a:b);
}
template <class x>
void min(x &a,x &b)
{
	return (a>=b?b:a);
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string a;
	cin>>a;
	if(a.size()==2)
	{
		cout<<a;
	}
	else
	{
      	reverse(a.begin(),a.end());
		cout<<a;
	}
	return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var tList = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();
			var m = int.Parse(Console.ReadLine());

			var totalTime = tList.Sum();

			var sumList = new List<long>();

			for(int i = 0; i < m; i++)
			{
				var line = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();
				var p = (int)line[0] - 1;

				var sum = totalTime - tList[p] + line[1];
				sumList.Add(sum);
			}

			foreach(var value in sumList)
			{
				Console.WriteLine(value);
			}
		}
	}
}


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

int main(){

int W,H,x,y,r;

cin>>W>>H>>x>>y>>r;
if(x-r<0 || x+r>W || y-r<0 || y+r>H){
    cout<<"No"<<endl;
}else{
    cout<<"Yes"<<endl; 
}

return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <iomanip>

#include <stdlib.h>
#include <math.h>

using namespace std;

long double MinkowskiDistance(const vector<int> &v1, const vector<int> &v2, const int p)
{

    long double ret = 0;
    size_t N = v1.size();

    if(p==-1)
    {
        for(size_t i = 0; i < N; i++)
        {
            ret = max(ret, (long double)abs(v1[i] - v2[i]));
        }
    }
    else
    {
        for(size_t i = 0; i < N; i++)
        {
            ret += pow((long double)abs(v1[i] - v2[i]), (long double)p);
        }
        ret = pow(ret, 1.0 / (long double)p);
    }


    return ret;


}


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

    vector<int> v1(n,0), v2(n,0);
    for(int i = 0; i < n; i++){ cin >> v1[i]; }
    for(int i = 0; i < n; i++){ cin >> v2[i]; }

    cout << fixed << setprecision(6);
    cout << MinkowskiDistance(v1, v2,  1) << endl;
    cout << MinkowskiDistance(v1, v2,  2) << endl;
    cout << MinkowskiDistance(v1, v2,  3) << endl;
    cout << MinkowskiDistance(v1, v2, -1) << endl;

    return 0;
}

Measured memory_bytes: 3412
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>

using namespace std;

int main()
{
    pair<int,int> a,b;
    int x,y,z;
    cin >> x >> y>> z;
    a.first = x;a.second=1;
    if(a.first == y){
        a.second++;
        cout<<z<<endl;
    }else{
        if(a.first == z){
            cout<<y<<endl;
        }else{
            cout<<x<<endl;
        }
    }
    return 0;
}


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

int main() {
  string b;
  cin >> b;
  if (b == "A") {
    cout << "T" << endl;
  }
  else if (b == "T") {
    cout << "A" << endl;
  }
  else if (b == "G") {
    cout << "C" << endl;
  }
  else {
    cout << "G" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
char st[50];
deque<int >q1;
deque<int >q2;
int main()
{
	//freopen("fkstring.in","r",stdin);
	//freopen("fkstring.out","w",stdout);
	long long n;
	scanf("%lld",&n);
	int cnt=0;
	n++;
	while(n)
	{
		st[++cnt]=n&1;
		n>>=1;
	}
	int tmp=0;
	for(int i=cnt-1;i>=1;i--)
	{
		tmp++;
		q1.push_back(tmp);
		q2.push_back(tmp);
		if(st[i]==1)
		{
			tmp++;
			q1.push_back(tmp);
			q2.push_front(tmp);
		}
	}
	int end=q1.size()+q2.size();
	printf("%d\n",end);
	while(q1.size())
	{
		printf("%d ",q1.front());
		q1.pop_front();
	}
	while(q2.size())
	{
		printf("%d ",q2.front());
		q2.pop_front();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = x;
    ll num = (x - a) / (a - b);
    num = max(num, 0ll);
    num = num % mod;
    ans += num * (b % mod);
    ans %= mod;
    //cout << ans <<" " <<  num << endl;
    x -= num * (a - b);
    if(x >= a) ans += b;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << ((a+b==c||b+c==a||c+a==b)?"Yes":"No") << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll a,b;
ll ans;

int main(){
  cin >> a >> b;
  ll x = 1;
  while(x < b){
    x += a-1;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int result = a * b;
        if ((a+b) >= (a-b) && (a+b) >= result) {
            result = a + b; 
        } else if ((a-b) >= (a+b) && (a-b) >= result) {
            result = a - b;
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35656
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n - 1, -1, -1):
        if (sum(ans[i::i + 1]) % 2) == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1
    print(sum(ans))
    print(*[i + 1 for i in range(n) if ans[i] == 1])


Measured memory_bytes: 13112
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
void add(int &x,int y){
	x=(x+y)%mod;
}
int f[1005][1005],c[1005][1005],a[1005];
signed main(){
	int n,k;
	cin>>n>>k;
	c[0][0]=1;
	for(int i=1;i<=1000;++i){
		c[i][0]=1;
		for(int j=1;j<=i;++j)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for(int i=1;i<=k;++i)
		cin>>a[i];
	f[0][0]=1;
	for(int i=0;i<k;++i)
		for(int j=0;j<=n;++j)
			for(int l=0;j+l<=n && a[i+1]-l>=0;++l)
				add(f[i+1][j+l],c[n-j][l]*c[n-l][a[i+1]-l]%mod*f[i][j]%mod);
	cout<<f[k][n];
	return 0;
}

Measured memory_bytes: 10632
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

const int MAX_N = 1e6 + 10;
ll suf[MAX_N], pref[MAX_N];
int n, k, c;
string in;
bool ok[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k >> c >> in;
    c ++;
    for(int i = 0; i < n; i ++) {
        if(in[i] == 'o' && i + c < n) {
            chkmax(pref[i + c], pref[i] + 1);
        }
        if(i + 1 < n) {
            chkmax(pref[i + 1], pref[i]);
        }
    }
    for(int i = n - 1; i >= 0; i --) {
        if(in[i] == 'o' && i - c >= 0) {
            chkmax(suf[i - c], suf[i] + 1);
        }
        if(i > 0) {
            chkmax(suf[i - 1], suf[i]);
        }
    }
    ll r = -1;
    for(int i = 0; i < n; i ++) {
        if(pref[i] + suf[i] >= k) {
            ok[i] =  true;
        }
        if(i <= r) {
            ok[i] = true;
        }
        if(in[i] == 'o' && pref[i] + suf[i] + 1 >= k) {
            r = i + c - 1;
        }
    }
    int l = n + 1;
    for(int i = n - 1; i >= 0; i --) {
        if(i >= l) {
            ok[i] = true;
        }
        if(in[i] == 'o' && pref[i] + suf[i] + 1 >= k) {
            l = i - c + 1;
        }
    }
    for(int i = 0; i < n; i ++) {
        if(!ok[i]) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
const int N=500;
struct E{
    int v,C,flow,rev;
    E(int V,int c,int F,int R){
        v=V;C=c;flow=F;rev=R;
    }
};
class G{
    public:
    vector<int>lev;
    vector<vector<E>>g;
    G(int n){
        lev=vector<int>(n,0);
        g={};
        for(int i=0;i<N;i++)g.push_back({});
    }
    void add(int u,int v,int c){
        E a(v,c,0,(int)g[v].size());
        E b(u,0,0,(int)g[u].size());
        g[u].push_back(a);
        g[v].push_back(b);
    }
    bool bfs(int s,int t);
    int send(int s,int flow,int t,vector<int>&st);
    int DinicMaxflow(int s,int t);
};
bool G::bfs(int s,int t){
    //cout<<s<<' '<<t<<endl;
    lev= vector<int>(N,-1);
    lev[s]=0;
    deque<int>q={s};
    while(q.size()){
        int u=q.front();q.pop_front();
        //cout<<u<<' ';
        for(auto &e:g[u]){
            if(lev[e.v]<0&&e.flow<e.C){
                lev[e.v]=lev[u]+1;
                q.push_back(e.v);
            }
        }
    }
    //cout<<endl;
    return lev[t]>=0;
}
int G::send(int s,int flow,int t,vector<int>&st){
    if(s==t)return flow;
    for(;st[s]<(int)g[s].size();st[s]++){
        auto &e=g[s][st[s]];
        if(lev[e.v]==lev[s]+1&&e.flow<e.C){
            int cur=min(flow,e.C-e.flow);
            int tmp=send(e.v,cur,t,st);
            if(tmp>0){
                e.flow+=tmp;
                g[e.v][e.rev].flow-=tmp;
                return tmp;
            }
        }
    }
    return 0;
}
int G::DinicMaxflow(int s, int t)
{
    if (s == t)
        return 0;
    int total = 0;
    while (bfs(s, t) == true)
    {
        vector<int>st(N,0);
        while (int flow = send(s, INT_MAX, t, st))
            total += flow;
    }
    return total;
}
char ch[N][N];
int main()
{
    int h,w;
    cin>>h>>w;
    G a(N);
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>ch[i][j];
            if(ch[i][j]=='S'){
                a.add(0,i,N);
                a.add(0,j+h,N);
            }
            else if(ch[i][j]=='T'){
                a.add(i,300,N);
                a.add(j+h,300,N);
            }else if(ch[i][j]=='o'){
                a.add(i,j+h,1);
                a.add(j+h,i,1);
            }
        }
    }

    int v=a.DinicMaxflow(0,300);
    if(v>300)v=-1;
    cout<<v<<endl;
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;

    vector<int> start_index;
    for (auto i = 0; i <= (int)(s.size() - t.size()); i++) {
        int count = 0;
        for (auto j = 0; j < t.size(); j++) {
            if(s[i + j] == '?' or s[i + j] == t[j]) count++;
        }
        if(count == t.size()) start_index.push_back(i);
    }

    if(start_index.empty()) {
        cout << ("UNRESTORABLE") << endl;
        return 0;
    }

    vector<string> key;
    for (int start : start_index) {
        string tmp = "";
        for (auto j = 0; j < s.size(); j++) {
            if(j > start and start + t.size() > j) continue;
            if(j == start) {
                tmp += t;
                continue;
            }
            if(s[j] == '?') {
                tmp += 'a';
            } else {
                tmp += s[j];
            }
        }
        key.push_back(tmp);
    }
    sort(key.begin(), key.end());
    cout << key[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

const int MN = 2005;

int N, A[MN];
std::vector<int> G[MN];

int vis[MN];
void DFS(int u) {
	vis[u] = 1;
	for (int v = 1; v <= N; ++v)
		if (!vis[v] && std::__gcd(A[u], A[v]) > 1)
			G[u].push_back(v), DFS(v);
}

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	std::sort(A + 1, A + N + 1);
	std::priority_queue<int> q;
	for (int i = 1; i <= N; ++i) if (!vis[i]) DFS(i), q.push(i);
	while (!q.empty()) {
		int u = q.top(); q.pop();
		printf("%d ", A[u]);
		for (int v : G[u]) q.push(v);
	} puts("");
	return 0;
}

Measured memory_bytes: 3472
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using vv = vector<V<T>>;
template<class T> using VV = vector<V<T>>;

using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  string s,t;
  cin >> s >> t;
  int sz = s.size(),tz = t.size();
  vvi dp(sz+1,vi(tz+1,0)),from(sz,vi(tz));
  REP(i,sz)REP(j,tz){
    if(s[i]==t[j]){
      dp[i+1][j+1] = dp[i][j]+1;
      from[i][j]=0;
      continue;
    }
    if (dp[i+1][j]>=dp[i][j+1]) {
      dp[i+1][j+1] = dp[i+1][j];
      from[i][j] = 1;
    } else {
      dp[i+1][j+1] = dp[i][j+1];
      from[i][j] = 2;
    }
  }
  string ans;
  while(sz>0&&tz>0){
    if(from[sz-1][tz-1]==0){
      sz--; tz--;
      ans += s[sz];
    }else if(from[sz-1][tz-1]==1){
      tz--;
    }else{
      sz--;
    }
  }
  reverse(ALL(ans));
  cout << ans << endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <istream>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

class Node{
public:
	Node *parent;
	Node *l;
	Node *r;
	long key;
	
	Node() : parent(NULL), l(NULL), r(NULL), key(0){
		return;
	}
	~Node(){
		if(l != NULL){ delete l; l = NULL; }
		if(r != NULL){ delete r; r = NULL; }
	}
};

void insert(Node **root_handle, long key){
	Node *y = NULL;
	Node *x = *root_handle;

	while(x != NULL){
		y = x;
		if(key < x->key){
			x = x->l;
		}
		else{
			x = x->r;
		}
	}

	Node *z = new Node;
	z->parent = y;
	z->key = key;

	if(y == NULL){
		*root_handle = z;
	}
	else if(z->key < y->key){
		y->l = z;
	}
	else{
		y->r = z;
	}
	return;
}

void print_inorder(Node *n){
	if(n->l != NULL){
		print_inorder(n->l);
	}
	std::cout << " " << n->key;

	if(n->r != NULL){
		print_inorder(n->r);
	}
	return;
}

void print_preorder(Node *n){
	std::cout << " " << n->key;
	if(n->l != NULL){
		print_preorder(n->l);
	}

	if(n->r != NULL){
		print_preorder(n->r);
	}
	return;
}

int main(int argc, char **argv){
  int n,a;
  char str[100];
  Node *root = NULL;
  scanf("%d",&n);
   
  while(n--){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&a);
      insert(&root, a);
    }else{
      print_inorder(root);
      printf("\n");
      print_preorder(root);
      printf("\n");
    }
  }

	if(root != NULL){ delete root; root = NULL; }
	return 0;
}


Measured memory_bytes: 26608
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++)r[n]=t.in();for(var i=0,o=0,s=0;s<e;s++)r[s]==o+1?o++:i++;0!=o?console.log(i):console.log(-1)}}]);


Measured memory_bytes: 33640
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    vector<int> a, b;
    rep(i, n)
    {
        if (i % 2 == 0)
            a.push_back(v[i]);
        else
            b.push_back(v[i]);
    }
    sort(all(a));
    sort(all(b));
    a.push_back(INF);
    b.push_back(INF);
    P ma1 = P(0, 0), ma2 = P(0, 0), mb1 = P(0, 0), mb2 = P(0, 0);
    int cnt = 1;
    rep(i, n / 2)
    {
        if (a[i] == a[i + 1])
            cnt++;
        else
        {
            if (ma1.first <= cnt)
            {
                ma2 = ma1;
                ma1 = P(cnt, a[i]);
            }
            else if (ma2.first <= cnt)
                ma2 = P(cnt, a[i]);
            cnt = 1;
        }
    }
    rep(i, n / 2)
    {
        if (b[i] == b[i + 1])
            cnt++;
        else
        {
            if (mb1.first <= cnt)
            {
                mb2 = mb1;
                mb1 = P(cnt, b[i]);
            }
            else if (mb2.first <= cnt)
                mb2 = P(cnt, b[i]);
            cnt = 1;
        }
    }
    if (ma1.second != mb1.second)
        cout << n - ma1.first - mb1.first << endl;
    else
        cout << n - max(ma1.first + mb2.first, ma2.first + mb1.first) << endl;
}

Measured memory_bytes: 2044
n = int(input())
box = list(map(int, input().split())) 
ans = [0]*n
lst = []
for i in reversed(range(n)):
  count = 0
  for j in range(n//(i+1)):
    count += ans[(i+1)*(j+1)-1]
  if count % 2 == box[i]:
    ans[i] = 0
  else:
    lst.append(i+1)
    ans[i] = 1
    
print(sum(ans))
print(*lst)

Measured memory_bytes: 14032
n = int(input())
a = list(map(int, input().split()))

tmp = 0
sum_list = [0]
for i in range(n):
    tmp += a[i]
    sum_list.append(tmp)

diff = float('inf')
for i in range(1,n):
    diff = min(diff, abs(sum_list[-1]-2*sum_list[i]))

print(diff)


Measured memory_bytes: 24832
#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>;

int main() {
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    while (x < y) {
        x *= 2;
        ans++;
    }
    if (y == x) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n=int(input())
a = make_divisors(n)
ans = 11451481019191919191919
for i in a:
	ans = min(ans, i+n/i)
	
print(int(ans-2))

Measured memory_bytes: 3268
#include <stdio.h>

int main(void)
{
    int a, b, c, d, e, k;
    
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);
    printf("%s", (e - a <= k) ? "Yay!" : ":(");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> dp(n + 1, -1);
  queue<int> q;
  dp[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int temp = q.front();
    q.pop();
    if (temp + 1 <= n && dp[temp + 1] < 0) {
      dp[temp + 1] = dp[temp] + 1;
      q.push(temp + 1);
    }
    for (int i = 6; temp + i <= n; i *= 6) {
      if (dp[temp + i] < 0) {
        dp[temp + i] = dp[temp] + 1;
        q.push(temp + i);
      }
    }
    for (int i = 9; temp + i <= n; i *= 9) {
      if (dp[temp + i] < 0) {
        dp[temp + i] = dp[temp] + 1;
        q.push(temp + i);
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 3648
A,B,K=map(int,input().split())
N=101
ls=[]
LS=[]
for i in range(1,N):
  if A%i==0:
    ls.append(i)
  if B%i==0:
    LS.append(i)
r=set(ls)
R=set(LS)
r=set(r & R)
r=list(r)
r.sort(reverse=True)
print(r[K-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<long> enemy(N+1),hero(N);
  for(int i=0;i<N+1;i++)cin>>enemy.at(i);
  for(int i=0;i<N;i++)cin>>hero.at(i);
  
  long count=0;
  for(int i=0;i<N;i++){
    if(hero.at(i)<=enemy.at(i))count+=hero.at(i);
    else{
      if(enemy.at(i)+enemy.at(i+1)>hero.at(i)){
        count+=hero.at(i);
        enemy.at(i+1)-=hero.at(i)-enemy.at(i);
      }
      else{
        count+=enemy.at(i)+enemy.at(i+1);
        enemy.at(i+1)=0;
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;

ll wt[100],vl[100];
ll dp[101][100001];
ll ans(ll n,ll w){
    if(n==0||w==0) return 0;
    if(dp[n][w]!=0) return dp[n][w];
    if(wt[n-1]<=w){
        return dp[n][w]=max(vl[n-1]+ans(n-1,w-wt[n-1]),ans(n-1,w));
    }
    else{
        return dp[n][w]=ans(n-1,w);
    }
}
void solve(){
    ll n,w;
    for(int i=0;i<101;i++){
        for(int j=0;j<100001;j++) dp[i][j]=0;
    }
    cin>>n>>w;
    for(int i=0;i<n;i++){
        cin>>wt[i]>>vl[i];
    }
    cout<<ans(n,w)<<endl;

}
int main(){
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 82532
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll a, b;
    scanf("%lld %lld", &a, &b);
    if(a%2==b%2) printf("%lld\n", (a+b)/2);
    else printf("%lld\n", (a+b)/2+1);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128