akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from random import randint
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
import math
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
import sys
import os
import re
sys.setrecursionlimit(9999)
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353
N = 5001
 
'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

def main():
	a, b, x = map(int, input().split())
	if a*a*b/2 <= x:
		rad = math.atan(2 * (a * a * b - x)/(a * a * a))
	else:
		rad = math.pi/2 - math.atan(2 * x / (a * b * b))
	print(rad*(180/math.pi))

BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0
 
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()
 
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)
 
	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()

Measured memory_bytes: 31212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;i<b;i++)
#define INF 0x3f3f3f3f


int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe";
    else cout<<"safe";
    return 0;
}

Measured memory_bytes: 3584
def f(i,ans):
    if int(i) > N:
        return ans
    i = str(i)
    ans += 1 if all([i[1:].count(a) for a in A]) else 0
    for a in A:
        ans += f(i+a,ans)-ans
    return ans
  
N = int(input())
ans = 0
A = '357'
print(f(0,0))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a; cin >> a;
  cout << a + a * a + a * a * a << '\n';
  return 0;
}


Measured memory_bytes: 3636
#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(){
   int n, k, keta, ans;
   ans = 1;
   
   cin >> n >> k;
   keta = k;

   while(n/keta > 0){
      keta *= k;
      ans += 1;
   }
   cout << ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final int MAX = 1000;
    
    public static void main(String[] args) {
        int[] ans = new int[-~MAX];
        
        int base = 1;
        for(int i = 2; i <= MAX / 2; i++) {
            for(int now = base + i; now <= MAX; now += i) {
                ans[now]++;
            }
            base += i;
        }

        try(Scanner scn = new Scanner(System.in)) {
            int n;
            while((n = scn.nextInt()) > 0) {
                System.out.println(ans[n]);
            }
        }
    }
}

Measured memory_bytes: 26240
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    string s;
    bool a;
    while (cin >> s)
    {
        a = 0;
        if (s[0] == s[1] && s[2] == s[3])
            a = 1;
        if (s[0] == s[2] && s[1] == s[3])
            a = 1;
        if (s[0] == s[3] && s[1] == s[2])
            a = 1;
        if (s[0] == s[3] && s[1] == s[2] && s[0] == s[1])
            a = 0;
        if (a == 1)
            cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

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

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

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

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

    public static void main(String[] args) {    //throws FileNotFoundException {
        InputStream inputStream = System.in;    //new FileInputStream("input.txt");
        OutputStream outputStream = System.out; //new FileOutputStream("output.txt");
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task newTask = new Task();
        newTask.solve(in, out);

        out.close();
    }

    private static class Task {
        //.constant
        private final int INF = Integer.MAX_VALUE;
        private final int MOD = (int)1e9 + 7;

        //.data
        private int[] t = new int[101];
        private int[] v = new int[101];
        private int[] maxv = new int[101];

        //.code
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            for (int i = 0; i < n; ++i) {
                t[i] = in.nextInt();
            }
            for (int i = 0; i < n; ++i) {
                v[i] = in.nextInt();
            }

            for (int i = n - 1; i > 0; --i) {
                int minV = Math.min(v[i - 1], v[i]);
                maxv[i] = minV - maxv[i + 1] <= t[i] ? minV : maxv[i + 1] + t[i];
            }

            double s = 0;
            double curV = 0;
            for (int i = 0; i < n; ++i) {
                double nextV = Math.min(curV + t[i], maxv[i + 1]);
                double diffV = Math.abs(nextV - curV);
                double c = Math.abs(t[i] - diffV);
                s += c * Math.max(curV, nextV) + diffV * Math.min(curV, nextV) + diffV * diffV / 2.0;
                if (c / 2.0 + Math.max(curV, nextV) > v[i]) {
                    double h = v[i] - Math.max(curV, nextV);
                    s += h * (c - h);
                } else {
                    s += c * c / 4.0;
                }
                curV = nextV;
            }

            out.println(s);

        }//end

    }

}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

ll MAX = 1e18;//10^18


int  main()
{
	int n; cin >> n;
	vector<ll>  a(n);
	ll sum = 1;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n)
	{
		if (1000000000000000000/sum < a[i])
		{
			cout << -1; return 0;
		}
		sum *= a[i];
		if (sum > 1000000000000000000)
		{
			cout << -1;
			return 0;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4052
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab,key=lambda x: x[0])
tmp=0
ans=0
for x in ab:
  if m-tmp<x[1]:
    ans+=x[0]*(m-tmp)
    break
  else:
    ans+=x[0]*x[1]
    tmp+=x[1]
print(ans)

Measured memory_bytes: 29792
from itertools import product
h,w,k = map(int, input().split())
a =[]
for i in range(h):
  a.append(input().split())
f=list(product([0,1], repeat=h))
f2=list(product([0,1], repeat=w))
b=0
su=0
for i in f:
    for j in f2:
        for i2 in range(h):
            for j2 in range(w):
                if i[i2]==0 and j[j2]==0:
                    if a[i2][0][j2]=="#":
                        b+=1
        if b==k:
            su+=1
        b=0
print(su)







        



Measured memory_bytes: 68156
N=int(input())
aN=[int(input()) for _ in range(N)]
c=0
i=1
while True:
  c+=1
  if aN[i-1]==2:
    print(c)
    break
  elif aN[i-1]==0:
    print(-1)
    break
  t=aN[i-1]
  aN[i-1]=0
  i=t


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

int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    long long x = 0;
    for(int i = n-1; i >= 0; i--){
        if((a[i] + x) % b[i] != 0){
            x += b[i] - (a[i] + x) % b[i];
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 4376
N = int(input())
S = list(input())


a = 65
z = 90

for i in range(len(S)):
        if (ord(S[i]) + N) > 90:
                S[i] = chr(((ord(S[i]) + N) - 91) + 65)
        else:
                S[i] = chr(ord(S[i]) + N)

for i in S:
        print(i, end="")

Measured memory_bytes: 43352
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;
typedef unsigned int UINT;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int n;
	cin >> n;
	vector<int> v, v2;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
		v2.push_back(tmp);
	}
	sort(v2.begin(), v2.end());
	int max = v2[n - 1];
	int max1 = v2[n - 2];

	for (auto i : v) {
		if (i != max) {
			cout << max << endl;
		}
		else {
			cout << max1 << endl;
		}
	}

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 3436
N = int(input())
A = list(map(int, input().split()))

score_a = 0
score_b = 0

while len(A):
	max_i = A.index(max(A))
	score_a += A.pop(max_i)

	if len(A):
		max_i = A.index(max(A))
		score_b += A.pop(max_i)

print(score_a - score_b)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, l;
  cin >> n >> l;
  
  vector<string> a(n);  
  rep(i, 0, n) {
    cin >> a[i];
  }
  sort(all(a));
  string s;
  rep(i, 0, n) {
    s += a[i];
  }
  
  cout << s << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 500
#define rt register int
using namespace std;
int n,m;
int a[maxn][maxn],vis[maxn],cnt[maxn];
inline int min(int a,int b){
	return a<b?a:b;
}
inline int read()
{
    int x=0,f=0;char s=getchar();
    while(!isdigit(s))f|=s=='-',s=getchar();
    while( isdigit(s))x=(x<<1)+(x<<3)+s-48,s=getchar();
    return !f?x:-x;
}
inline void print(int x)
{
    if(x/10>0)print(x/10);
    putchar(x%10+'0');
}
int main(){
    n=read();m=read();
    for (rt i=1;i<=n;i++)
        for (rt j=1;j<=m;j++)
            a[i][j]=read();
    int ans=n;
    for (rt i=1;i<=m;i++){
        memset(cnt,0,sizeof(cnt));
        for (rt j=1;j<=n;j++)
            for (rt k=1;k<=m;k++)
                if (!vis[a[j][k]]){
                    cnt[a[j][k]]++;
                    break;
                }
        int s,sum=0;
        for (rt j=1;j<=m;j++)
            if (sum<cnt[j])
                s=j,sum=cnt[j];
        vis[s]=1;
        ans=min(ans,sum);
    }
    print(ans);
    return 0;
}

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

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

    vector<int> p(n);
    rep(i,n){
        cin >> p.at(i);
    }

    int cnt=0;
    rep(i,n){
        if(i+1!=p.at(i)) cnt++;
    }
    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <cstdint>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for(int i=0;i<n;i++) cin >> a[i];
    unordered_set<int> s;
    s.insert(0);
    vector<int> will_inserted;
    will_inserted.reserve(n);
    for(auto x = a.cbegin(); x != a.cend(); ++x) {
        for(auto y = s.cbegin(); y != s.cend(); ++y) {
            will_inserted.push_back(*x + *y);
        }
        for(auto it = will_inserted.cbegin(); it != will_inserted.cend(); ++it) {
            s.insert(*it);
        }
        will_inserted.clear();
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++) {
        int t;
        cin >> t;
        cout << (s.count(t) ? "yes" : "no") << endl;
    }
}

Measured memory_bytes: 3176
#include<stdio.h>
int main(){
  int A[100][100],i,j,k,x,y;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&A[i][j]);
    }
  }
  scanf("%d",&x);
  for(k=0;k<x;k++){
    scanf("%d",&y);
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	if(y==A[i][j])
	  A[i][j]=0;
      }
    }
  }
 
  if(A[0][0]==0&&A[0][1]==0&&A[0][2]==0)
    printf("Yes\n");
  else if(A[1][0]==0&&A[1][1]==0&&A[1][2]==0)
    printf("Yes\n");
  else if(A[2][0]==0&&A[2][1]==0&&A[2][2]==0)
    printf("Yes\n");
  else if(A[0][0]==0&&A[1][0]==0&&A[2][0]==0)
    printf("Yes\n");
  else if(A[0][1]==0&&A[1][1]==0&&A[2][1]==0)
    printf("Yes\n");
  else if(A[0][2]==0&&A[1][2]==0&&A[2][2]==0)
    printf("Yes\n"); 
  else if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0)
    printf("Yes\n");
  else if(A[0][2]==0&&A[1][1]==0&&A[2][0]==0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 128
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    
    ll n,m ; cin >> n >> m;
    if( n != m ) cout << "No\n";
    else cout << "Yes\n";
 return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using BI = System.Numerics.BigInteger;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] C = new int[] {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
		BI[] dp = new BI[N + 1];
		for(int i=0;i<N;i++){
			if(i != 0 && dp[i] == 0) continue;
			for(int j=0;j<A.Length;j++){
				if(C[A[j]] + i > N) continue;
				var nv = dp[i] * 10 + A[j];
				if(nv > dp[i + C[A[j]]]){
					dp[i + C[A[j]]] = nv;
				}
			}
		}
		
		Console.WriteLine(dp[N]);
		
	}
	int N, M;
	int[] A;
	public Sol(){
		var d = ria();
		N= d[0]; M = d[1];
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27852
#include <iostream>
using namespace std;
void ABC130(void);
void ABC131(void);
void ABC132(void);
void ABC133(void);
void ABC134(void);
void ABC135(void);
void ABC136(void);
void ABC137(void);
void ABC138(void);
void ABC139(void);

int main(void){
    ABC137();
}

void ABC137(){
    int a,b,max;
    cin>>a>>b;
    max=a+b;
    if(a-b>max)max=a-b;
    if(a*b>max)max=a*b;
    cout<<max<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<string.h>
#include<iostream>
#include<stdio.h>
using namespace std;

const int N = 2e4;
int h, n, f[N], a, b;
int main() {
	cin >> h >> n;
	memset(f, 0x3f, sizeof f);
	f[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b;
		for (int j = a; j < N; j++)
			f[j] = min(f[j], f[j - a] + b);
	}
	int ans = 1e9;
	for (int j = h; j < N; j++)
		ans = min(ans, f[j]);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        List<int> b = new List<int>();
        for (int i = 0; i < n; i++)
            b.Add(a[i] - (i + 1));
        b.Sort();
        int ans_b = b[n / 2];
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            ans += Math.Abs(a[i] - (ans_b + i + 1));
        }
        Console.WriteLine(ans);
    }
}

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

int n,r,b;
char s[1000];

int main()
{	
	cin >> n;
	cin >> s+1;
    for (int i=1;i<=n;i++)
    {
        if (s[i]=='R') r++;
        if (s[i]=='B') b++;
    }
    if (r>b) printf("Yes\n");
    else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 998244353;
const lint INF = mod*mod;
const int MAX = 100010;

int R[4010], B[4010];
lint dp[4010][4010];

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int curr=0, curb=0;
    rep(i, n){
        if(s[i]=='0') {
            R[curr++]=i; R[curr++]=i;
        }
        else if(s[i]=='1'){
            R[curr++]=i; B[curb++]=i;
        }
        else{
            B[curb++]=i; B[curb++]=i;
        }
    }

    rep(i, curr+1)rep(j, curb+1) dp[i][j]=0;
    dp[0][0]=1;
    rep(i, curr+1)rep(j, curb+1)if(dp[i][j]){
        if(i<curr && R[i]<=i+j) (dp[i+1][j]+=dp[i][j])%=mod;
        if(j<curb && B[j]<=i+j) (dp[i][j+1]+=dp[i][j])%=mod;
    }
    printf("%lld\n", dp[curr][curb]);
}

Measured memory_bytes: 123392
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=2e5+10;
using namespace std;
int id(int l,int r){return l+r|l!=r;}
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,a[maxn],b[maxn],op[maxn],cnt;
int main()
{
    int i,j;
    ll p;
    scanf("%lld",&p);
    p++;
    while(p>=2)
    {
        if(p&1)op[++cnt]=1,p--;
        else op[++cnt]=2,p/=2;
    }
    printf("%d\n",2*cnt);
    int l=1,r=cnt;
    rep(i,1,cnt)
    {
        if(op[i]==1)a[l++]=cnt-i+1;
        else a[r--]=cnt-i+1;
    }
    rep(i,1,cnt)b[i]=a[i];
    sort(b+1,b+cnt+1);
    rep(i,1,cnt)printf("%d ",a[i]);
    rep(i,1,cnt)printf("%d%c",b[i],i==cnt?'\n':' ');
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for (int i=0;i<n;i++)
#define ll long long 
using namespace std;
int T;
void solve()
{int k,n; scanf("%d%d",&n,&k); vector<int> h(n);
vector<int> dp(n,1e9+5);dp[0]=0;
for(int& x:h)
	scanf("%d",&x);
for(int i=0;i<n;i++)
{for(int j=i+1;j<=k+i;j++){
if(j<n)dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));}
}
printf("%d\n",dp[n-1]);	
}

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



Measured memory_bytes: 3952
#include <stdio.h>

#define MAXN 400

long S[MAXN+1][MAXN+1];
int A[MAXN+1];
long SUM[MAXN+1];

long slime ( int n, int i, int j )
{
  if ( S[i][j] != -1 ) return S[i][j];

  int k;
  long min,tmp;
  min = slime(n,i,i) + slime(n,i+1,j) + SUM[i]-SUM[i-1]+SUM[j]-SUM[i];
  for ( k = 0; k < j-i; k++ ) {
    tmp = slime( n, i, i+k ) + slime(n, i+k+1, j) + SUM[i+k]-SUM[i-1]+SUM[j]-SUM[i+k];
    if ( min > tmp ) min = tmp;
  }
  return S[i][j] = min;
}


int main(void)
{
  int n, i,j;

  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  SUM[0] = 0;
  for ( i = 1; i <= n; i++ ) SUM[i] = SUM[i-1]+A[i];
  for ( i = 0; i <= n; i++ ) for ( j = 0; j <= n; j++ ) S[i][j] = -1;
  for ( i = 1; i <= n; i++ ) S[i][i] = 0;
  

  printf("%ld\n", slime(n,1,n));


  return 0;

}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 1 << 29;
const ll INF2 = 9000000000000000000LL;
const double INF3 = 900000000000000;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()

struct edge { ll to, cap, rev; };

vector<edge>g[101000];
bool used[101000] = { 0 };
ll h, w;
char c[110][110];

void add(ll from, ll to, ll cap) {
	g[from].push_back(edge{ to, cap, (ll)g[to].size() });
	g[to].push_back(edge{ from, (ll)0, (ll)g[from].size() - 1 });
}

ll dfs(ll v, ll t, ll f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0;i < g[v].size();i++) {
		edge &e = g[v][i];
		if (!used[e.to] && e.cap > 0) {
			ll d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

ll max_flow(ll s, ll t) {
	ll flow = 0;
	for (;;) {
		fill(used, used + 20010, 0);
		ll f = dfs(s, t, INF);
		if (f <= 0)return flow;
		flow += f;
	}
}


int main() {
	cin >> h >> w;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			cin >> c[i][j];
		}
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			for (int k = 1; k <= w; k++) {
				add((i - 1)*w + j + h*w, (i - 1)*w + k, INF);
			}
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= h; j++) {
			for (int k = 1; k <= w; k++) {
				add((i - 1)*w + k + h*w, (j - 1)*w + k, INF);
			}
		}
	}

	ll s, t;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == 'o') {
				add((i - 1)*w + j, (i - 1)*w + j + h*w, 1);
			}
			if (c[i][j] == 'S')s = (i - 1)*w + j + h*w;
			if (c[i][j] == 'T')t = (i - 1)*w + j;
		}
	}
	ll ans = max_flow(s, t);
	if (ans >= INF)cout << -1 << endl;
	else cout << ans << endl;

}

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


using namespace std;



int main() {

  int N;
  cin >> N;
  while(N>6){
    if (N%4==0){
      N = 0;
      break;
    }
    N-=7;
  }
  if (N%4==0){
    N = 0;
  }
  if (N!=0) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define DEBUG 0

typedef long long LL;
constexpr int kMax = 400;

struct Point {
  int r;
  int c;
};

int main() {
  int table[kMax][kMax] = {};
  constexpr int dr[] = {1, -1, 0, 0};
  constexpr int dc[] = {0, 0, 1, -1};

  int H, W; std::cin >> H >> W;
  bool checked[kMax][kMax];
  for (int r = 0; r < H; ++r) {
    std::string s; std::cin >> s;
    for (int c = 0; c < W; ++c) {
      if (s[c] == '#') table[r][c] = 1;
      checked[r][c] = false;
    }
  }

#if DEBUG
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      std::cout << table[r][c];
    }
    std::cout << std::endl;
  }
#endif

  LL cnt = 0;
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      if (checked[r][c]) continue;

      LL cnt_b = 0;
      LL cnt_w = 0;
      std::queue<Point> que;
      que.push({r, c});
      checked[r][c] = true;

      while(!que.empty()) {
        Point p = que.front();
        que.pop();
#if DEBUG
        std::cout << "(" << p.r << "," << p.c << ")" << std::endl;
#endif

        if (table[p.r][p.c] == 0) ++cnt_w;
        else                      ++cnt_b;

        for (int i = 0; i < 4; ++i) {
          int nr = p.r + dr[i];
          int nc = p.c + dc[i];

          if (nr < 0 || nr >= H) continue;
          if (nc < 0 || nc >= W) continue;
          if (checked[nr][nc]) continue;

          if (table[p.r][p.c] != table[nr][nc]) {
            que.push({nr, nc});
            checked[nr][nc] = true;
          }
        }
      }
      cnt += cnt_b * cnt_w;
#if DEBUG
      std::cout << "black: " << cnt_b << ", white:" << cnt_w << std::endl;
#endif
    }
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int N;
    scanf("%d", &N);

    if(N%7 == 0){
        printf("Yes\n");
        return 0;
    }
    while(N>=0){
        if(N % 4 == 0){
            printf("Yes\n");
            return 0;
        }
        N-=7;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
a = list(map(int,input().split()))
A=0
B=0
a_new = sorted(a)
for i in range (N):
	if N%2 == 0:
		if i%2 == 0:
			B += a_new[i]
		else:
			A += a_new[i]
	else:
		if i%2 == 1:
			B += a_new[i]
		else:
			A += a_new[i]
print(A-B)

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

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int main()
{
	int x, a;
	cin >> x >> a;
	if (x < a)cout << 0 << endl;
	else cout << 10 << endl;
	return 0;
}


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

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var tasks = new List<Tuple<int, int>>();
            var timeSum = 0;
            var deadline = 0;
            for (var i = 0; i < n; i++)
            {
                var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                tasks.Add(new Tuple<int, int>(ab[0], ab[1]));
                timeSum += ab[0];
                deadline = Math.Max(deadline, ab[1]);
            }
            if (timeSum > deadline)
            {
                Console.WriteLine("No");
                return;
            }
            var sortedTasks = tasks.OrderBy(x => x.Item2).ThenBy(x => x.Item1).ToList();
            timeSum = 0;
            deadline = 0;
            for (var i = 0; i < sortedTasks.Count; i++)
            {
                timeSum += sortedTasks[i].Item1;
                deadline = Math.Max(deadline, sortedTasks[i].Item2);
                if (timeSum > deadline)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 33928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<int> score(N);
	int sum = 0;
	int minus = 110;
	bool flag = true;
	
	rep(i, N){
		cin >> score.at(i);
		sum += score.at(i);
		if(score.at(i) % 10 != 0 && minus > score.at(i)){
			minus = score.at(i);
			flag = false;
		}
	}
	int ans;
	if(flag){
		ans = 0;
	} else {
		if(sum % 10 != 0){
			ans = sum;
		} else {
			ans = sum - minus;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
	cin >> n;
	int cc=0;
	int ans=0;
	REP(i,n){
		REP(j,i){
			if((i+1)%(j+1)==0&&(i+1)%2!=0) cc++;
		}
		if(cc==7){
			ans++;
		}
		cc=0;
	}
	cout << ans << endl;
/////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {int n,m,k,i,j;while (scanf("%d %d %d",&n,&k,&m) && (n || k || m)) {for (i=2,j=1;i<n;i++) j=(j+k-1)%i+1;printf("%d\n",(j+m-1)%n+1);} return 0;}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

LL f(LL b, LL n){
    LL sum = 0;
    while(n > 0){
        sum += n % b;
        n /= b;
    }
    return sum;
}

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

    LL n, s;
    cin >> n >> s;

    LL ans = INFL;
    // s == n の時はn+1しかない
    if(s == n){
        cout << n+1 << endl;
        return 0;
    }

    // s > n の時は作れない
    if(s > n){
        cout << -1 << endl;
        return 0;
    }

    // √n以下の値で全探索
    for(LL i = 2; i*i <= n; i++){
        if(s == f(i, n)){
            ans = min(ans, i);
        }
    }

    // pb + q = n
    // p + q = s
    // pb + (s - p) = n
    // b = (n - s + p) / p
    // b = (n - s) / p + 1
    // bは√n以上なのでpは√n未満になる
    for(LL p = 1; p*p < n; p++){
        LL b = (n - s) / p + 1;
        if(b < 2) continue;
        if(s == f(b, n)){
            ans = min(ans, b);
        }
    }

    cout << (ans != INFL ? ans : -1) << endl;

}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
 ll n;cin>>n;
 vl c(n),s(n),f(n);
 rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
 rep(i,n){
     ll t=0;
     for(ll j=i;j<n-1;j++){
         if(t<s[j])t=s[j];
         else if(t%f[j]!=0)t=t+f[j]-t%f[j];
         t+=c[j];
     }
     cout<<t<<endl;
 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

// デバッグを消し忘れるな！！！


int main() {
    ll n; cin >> n;
    Vl a(n);
    ll mx = 0;
    rep(i, 0, n){ cin >> a[i]; chmax(mx, a[i]);};
    set<ll> s, t;
    rep(i, 0, n){
        ll bf = sz(s);
        s.insert(a[i]);
        if(sz(s) == bf) t.insert(a[i]);
    }
    Vl table(mx+1, false);
    for(auto it : s){
        for(int i = 2*it; i <= mx; i += it) table[i] = true;
    }
    ll ans = 0;
    rep(i, 0, n) if(!table[a[i]]) ans++;
    for(auto it : t){
        if(table[it]) continue;
        rep(i, 0, n){
            if(a[i] == it) ans--;
        }
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 21832
fun main(arg: Array<String>) {
    val X = nextInt()
    for (t in 1 .. X) {
        if (t * (t + 1) / 2 >= X)
        return println(t)
    }
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)


Measured memory_bytes: 33788
#include <iostream>
#define ll long long
using namespace std;

ll mod=1000000007;
int t[3], a[100010];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> a[i];
	ll ans=1;
	for(int i=0; i<N; ++i){
		int p=0, cnt=0;
		for(int j=0; j<3; ++j){
			if(a[i]==t[j]){
				p=j;
				++cnt;
			}
		}
		if(cnt==0){
			cout << 0 << endl;
			return 0;
		}
		ans=(ans*cnt)%mod;
		++t[p];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
public class Main {
        public static void main (String[]args){
            Scanner scanner = new Scanner(System.in);
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            double rateA=.08;
            double rateB=.1;
            int potenialA=(int)(A/rateA);
            int potenialB=(int)(B/rateB);
            int smallestStart=0;
            if (potenialA<potenialB){
                smallestStart=potenialB;
            }else{
                smallestStart=potenialA;
            }
            int price=smallestStart;
            boolean answerFound=false;
            boolean possible=false;
            while(answerFound==false){
                if((int)(price*rateA)==A&&(int)(price*rateB)==B){
                    possible=true;
                    answerFound=true;
                    break;
                }
                if((int)(price*rateA)>A||(int)(price*rateB)>B){
                    answerFound=true;
                    break;
                }
                price++;
            }
            if(possible){
                System.out.println(price);
            }else{
                System.out.println(-1);
            }
        }
}





Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    public class Program
    {
        //static void SendAll()
        //{

        //    Console.WriteLine("Start!!!");
        //    int count = 0;

        //    // Read in the specified file.
        //    // ... Use async StreamReader method.

        //    for (int i = 0; i < 10; i++)
        //    {
        //        SendFinal("hello", "hi", "duongtrungvinh2711@gmail.com");
        //        count++;
        //        Console.WriteLine("Done {0}", count);
        //    }
        //    Console.WriteLine("End!!!");
        //}
        //static void SendFinal(string title, string content, string receiver)
        //{
        //    string myemail = "tomgiongvn.vn@gmail.com";
        //    string mypassword = "tomgiongvn@123";

        //    MailMessage message = new MailMessage();
        //    message.IsBodyHtml = true;
        //    message.From = new MailAddress(myemail, "PHÒNG TÀI VỤ HUFLIT");
        //    message.To.Add(new MailAddress(receiver));
        //    //message.CC.Add(new MailAddress(myemail));
        //    message.Subject = title + " | HUFLIT";
        //    message.Body = content;

        //    SmtpClient smtp = new SmtpClient();
        //    smtp.Host = "smtp.gmail.com";
        //    smtp.Port = 587;
        //    smtp.UseDefaultCredentials = false;
        //    smtp.EnableSsl = true;
        //    NetworkCredential nc = new NetworkCredential(myemail, mypassword);
        //    smtp.Credentials = nc;
        //    smtp.Send(message);
        //}
        static void Main(string[] args)
        {
            //Task task = new Task(SendAll);
            //task.Start();

            //for (int i = 0; i < 10000; i++)
            //    Console.Write(i);
            //var watch = System.Diagnostics.Stopwatch.StartNew();
            // the code that you want to measure comes here

            string[] a = Console.ReadLine().Split(' ');
                Console.WriteLine(a[1] + a[0]);


        }
    }

}


Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

int main() {
	set<int>s;
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	s = { a,b,c };
	if (s.size() == 2) {
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

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

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

  vector<int> b;
  long long b_num[n+1];
  for (int i=0; i<=n; i++) b_num[i] = 0;

  for (int i=n; i>n/2; i--) {
    if (a[i] == 1) {
      b.push_back(i);
      for (int j=1; j<=sqrt(i); j++) {
        if (i % j == 0) {
          ++b_num[j];
          if (j * j != i) {
            ++b_num[i/j];
          }
        }
      }
    }
  }
  for (int i=n/2; i>0; i--) {
    if (a[i] == 1 && b_num[i] % 2 == 1) {
      continue;
    } else if (a[i] == 0 && b_num[i] % 2 == 0) {
      continue;
    }
    b.push_back(i);
    for (int j=1; j<=sqrt(i); j++) {
      if (i % j == 0) {
        ++b_num[j];
        if (j * j != i) {
          ++b_num[i/j];
        }
      }
    }
  }
  reverse(b.begin(), b.end());
  cout<<b.size()<<endl;
  if (b.size() == 0) {
    return 0;
  }
  cout<<b[0];
  for (int i=1; i<b.size(); i++) {
    cout<<" "<<b[i];
  }
  cout<<endl;
}

Measured memory_bytes: 3832
N = int(input())
a = [0] + list(map(int, input().split()))

ans = [-1] * (N+1)
count = 0
for i in range(N, 0, -1):
    tmp = 0
    p = i
    p += p
    # print (i, p)
    while p <= N: #pの倍数について確認
        tmp += ans[p]
        p += i
    ans[i] = abs(a[i] - (tmp%2))
    if ans[i] == 1:
        count += 1
    # print (ans)
    
# print (ans)
print (count)
for i in range(1, N + 1):
    if ans[i] == 1:
        print (i)



Measured memory_bytes: 7220
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = 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")
}

fn is_prime(x: usize) -> bool {
    if x <= 1 {
        return false;
    }
    for i in 2..x {
        if i * i > x {
            break;
        }
        if x % i == 0 {
            return false;
        }
    }
    return true;
}

fn main() {
    let mut x: usize = read();

    while !is_prime(x) {
        x += 1;
    }
    println!("{}", x);
}


Measured memory_bytes: 4352
#include<stdio.h>

//float sisyagonyu(float i){
  //  int about, amari;
   // about = i * 10000;
  //  amari = about % 10;
   // if(amari < 5){
     //   about -= amari;
    //}
//    else{
  //      about = about + 10 - amari;
   // }
   // i = about / 10000;
   // return i;
//}

int main(void){
    float a, b, c, d, e, f, x, y;
    while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF){
        y = (c*d-a*f)/(b*d-a*e);
        x = (c-b*y)/a;
        
        //x = sisyagonyu(x);
        //y = sisyagonyu(y);
        
        
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}


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

using Lint=long long;

int main()
{
   int N; cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++) cin>>a[i];

   sort(a.begin(),a.end());
   int mn=a[0];
   int mx=a[N-1];

   bool ok=false;
   if(mx-mn==1){
      int K=count(a.begin(),a.end(),mn);
      if(mx>K and N>=K+(mx-K)*2) ok=true;
   }else if(mx-mn==0){
      if(mn==N-1 or N>=2*mn) ok=true;
   }
   cout<<(ok? "Yes":"No")<<endl;
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

using namespace std;

int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int modInverse(int n, int p) 
{ 
    return power(n, p - 2, p); 
} 

int nCrModPFermat(int n, int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
int32_t main()
{
    
    IOS;
    //fill(isprime, true);
    //pre();
    int mod=1000000007;
    int n;
    cin>>n;
    int ans=0;
    int i=1;
    while(n>=3*i)
    {
        ans=(ans+nCrModPFermat(n-1-(2*i),i-1,mod))%mod;
        i++;
    }
    cout<<ans;
}






Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=200005;
int size[N],val[N],ne[N],tot,fi[N],k,Max,zz[N],sl[N],n,x,y,z,ans;
void jb(int x,int y,int z){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
	sl[tot]=z;
}
void dfs(int x,int y){
	size[x]=1;
	for (int i=fi[x];i;i=ne[i])
		if (zz[i]!=y){
			dfs(zz[i],x);
			size[x]+=size[zz[i]];
			if (size[zz[i]]*2==n)Max=sl[i];
			ans+=min(size[zz[i]],n-size[zz[i]])*sl[i]*2;
			val[x]=max(val[x],size[zz[i]]);
		}
	val[x]=max(val[x],n-size[x]);
	if (!k||val[x]<val[k])k=x;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<n;i++){
		scanf("%lld%lld%lld",&x,&y,&z);
		jb(x,y,z);jb(y,x,z);
	}
	dfs(1,0);
	if (Max){
		printf("%lld\n",ans-Max);
		return 0;
	}
	Max=1e9;
	for (int i=fi[k];i;i=ne[i])Max=min(Max,sl[i]);
	printf("%lld\n",ans-Max);
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200010; 
int a[N], l[N], r[N], n;
LL solve() {
    stack<int> s;
    for (int i = 1; i <= n; i++) {
        while (s.size() && a[s.top()] >= a[i]) s.pop();
        l[i] = s.size() ? s.top() : 0;
        s.push(i);
    }
    while (s.size()) s.pop();
    for (int i = n; i >= 1; i--) {
        while (s.size() && a[s.top()] >= a[i]) s.pop();
        r[i] = s.size() ? s.top() : n + 1;
        s.push(i);
    }
    LL ans = 0;
    for (int i = 1; i <= n; i++) ans += 1LL * a[i] * (r[i] - i) * (i - l[i]);
    return ans;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    printf("%lld\n", solve());
    return 0;
}

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

int main() {
  int N, a, b, res;
  signed int invite[100000] = {0};

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> a >> b;
    invite[a-1]++;
    invite[b]--;
  }

  signed int sum = 0;
  for(int i = 0; i < N+1; i++) {
    sum += invite[i];
    if(i <= sum)
      res = i;
  }
  cout << res << endl;
}



Measured memory_bytes: 3500
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      	
      	int T = Integer.parseInt(sc.next());
      	int X = Integer.parseInt(sc.next());
      
      	double t = (T * 1.0) / X;
      	
      	System.out.println(t);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
using namespace std;
typedef long long ll;

class Edge
{
	public:
	int cost;
	int from;
	int to;

	Edge(int n,int c)
	{
		to=n;
		cost=c;
	}

	Edge(int f,int t,int c)
	{
		from=f;
		to=t;
		cost=c;
	}
};

vector<Edge> g[100000];

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(Edge(b,1));
		g[b].push_back(Edge(a,1));
	}
	bool ans=true;
	for(int i=0;i<n;i++)
	{
		if(g[i].size()&1)
			ans=false;
	}
	if(ans)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 6656
import sys

lines = sys.stdin.readlines()
N = int(lines[0])

stdin = list(map(int,lines[1].split(' ')))

lst = []
S1, S2 = 0, sum(stdin)
for i, a in enumerate(stdin):
    S1 += a
    S2 -= a
    lst.append(abs(S1-S2))

print(min(lst))

Measured memory_bytes: 86876