akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll a,b;
cin>>a>>b;
if(b%a==0){
    cout<<a+b<<endl;
}else{
    cout<<b-a<<endl;
}
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n , p , ans=0;
bool a , b , c;
void k(long long x)
{
	if(x>n)
	{
		return;
	}
	if(x > 100)
	{
		a=b=c=false;
		p=x;
		while(p>0)
		{
			if(p%10==3)
			{
				a=true;
			}
			else if(p%10==5)
			{
				b=true;
			}
			else if(p%10==7)
			{
				c=true;
			}
			p/=10;
		}
		if(a&&b&&c)
		{
			ans++;
		}
	}
	k(x*10+3);
	k(x*10+5);
	k(x*10+7);
}
int main()
{
	cin>>n;
	k(3);
	k(5);
	k(7);
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
typedef long long ll;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = a + b;
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7

dp = [[0] * (2000 + 1) for _ in range(2000 + 1)]


def combination(n, k):
    return dp[n][k]


def main():
    N, K = map(int, input().split())

    dp[0][0] = 1
    for i in range(1, max(N - K + 1, K - 1) + 1):
        dp[i][0] = 1
        for j in range(1, K + 1):
            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % MOD

    for i in range(1, K + 1):
        print((combination(N - K + 1, i) * combination(K - 1, i - 1)) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75228
n,m = map(int,input().split())
a = []
stairs = [0]*(n+2)
for _ in range(m):
    a = int(input())
    stairs[a] = 1
mod = 10**9 + 7

dp = [0]*(n+2)
dp[0] = 1

for i in range(n):
    if i <= 1:
        if stairs[i+1] == 0:
            dp[i+1] += dp[i]
            dp[i+1] %= mod
            stairs[i+1] = 1
    if stairs[i+2] == 0:
        dp[i+2] += dp[i+1]+dp[i]
        dp[i+2] %= mod
        stairs[i+2] = 1

print(dp[n]%mod)


Measured memory_bytes: 13488
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
const int N=2e5+5;
struct node{
	string s;
	int num;
}a[N];
string b[N];
map<string,int> ma;

bool ok(node x,node y){
	int i,maxv=max(x.s.size(),y.s.size());
	for(i=0;i<maxv;i++)
		if(x.s[i]!=y.s[i])
			return x.s[i]<y.s[i];
	return x.s.size()<y.s.size();
}

bool cmp(node x,node y){
	if(x.num!=y.num)
		return x.num>y.num;
	else 
		return ok(x,y);
}

int main(){
	string s;
	int n,i,t=0;
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		cin>>s;
		ma[s]++;
		if(ma[s]==1) b[++t]=s;
	}
	
	for(i=1;i<=t;i++){
		a[i].num=ma[b[i]];
		a[i].s=b[i];
	}
	
	sort(a+1,a+1+t,cmp);
	
	for(i=1;i<=t;i++){
		cout<<a[i].s<<endl;
		if(a[i].num!=a[i+1].num) break;
	}
	
	return 0;
}

Measured memory_bytes: 30208
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;
using P = pair<int,int>;
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i,T x=1){
        for(i++;i<=n;i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++;i;i-= i&-i) {
            x += d[i];
        }
        return x;
    }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,d,a;
    cin >> n >> d >> a;
    d*= 2;
    vector<pair<int,int>> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(ALL(p));
    ll ans = 0;
    BIT<ll> bit(n+1);
    rep(i,n){
        ll x = p[i].first; // i 番目の地点の座標
        ll h = p[i].second; // i番目の地点のHP
        h -= bit.sum(i); // 1~i番目までの和を引く
        if(h<=0)continue; // HP がなかったら次
        ll num = (h+a-1)/a; // 爆弾を落とす回数はnum
        ans += num; // num回爆弾を落とす
        ll damage = num*a; // 今回与えるダメージは num * a ;
        bit.add(i,damage); // i地点に damegaを加算する
        ll rx = min(x+d,(ll)1e9+1);
        ll j = upper_bound(ALL(p),P(rx+1,-1)) - p.begin();
        bit.add(j,-damage);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
from sys import stdin, setrecursionlimit


def main():
    mod = 10 ** 9 + 7
    n, k = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a.sort()
    ans = 0

    m = n + 1

    fac = [0] * m
    finv = [0] * m
    inv = [0] * m

    def initialize_cmb(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % mod
                inv[i] = mod - inv[mod % i] * (mod // i) % mod
                finv[i] = finv[i - 1] * inv[i] % mod

    def cmb(n, k, mod=10 ** 9 + 7):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

    initialize_cmb(m)

    for i in range(n - k + 1):
        ans -= a[i] * cmb(n - 1 - i, k - 1)
        ans %= mod
    for i in range(k - 1, n):
        ans += a[i] * cmb(i, k - 1)
        ans %= mod
    print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Measured memory_bytes: 60144
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n,max = 0,x = 0;
	string m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		if (m[i] == 'I') { x++; }
		else { x--; }
		if (max < x) { max = x; }
	}
	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
S=A[0]+A[1]
X=0
for i in range(2,N):
    X=X^A[i]
if (S-X)%2==1 or S<X:
    print(-1)
    exit()
D=(S-X)//2
if X&D!=0:
    print(-1)
    exit()
a=0
#print(X,D)
B=[0 for i in range(42)]
for k in range(41,-1,-1):
    x=(X&(1<<k))>>k
    d=(D&(1<<k))>>k
    if (x,d)==(0,0):
        pass
    elif (x,d)==(0,1):
        a=a^(1<<k)
    elif (x,d)==(1,0):
        B[k]=1
    else:
        pass
for k in range(41,-1,-1):
    if B[k]==0:
        continue
    if a^(1<<k)<A[0]:
        a=a^(1<<k)
if 0<a<=A[0]:
    print(A[0]-a)
else:
    print(-1)

Measured memory_bytes: 62204
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadLongArray(N + 1);
            var B = cin.ReadLongArray(N);

            var count = new long[N];
            for (int i = 0; i < N; i++) count[i] = 0;

            for (int i = N - 1; i >= 0; i--)
            {
                var c = Min(B[i], A[i + 1]);
                count[i] += c;
                A[i + 1] -= c;
                B[i] -= c;
                var c2 = Min(B[i], A[i]);
                count[i] += c2;
                A[i] -= c2;
            }

            Console.WriteLine(count.Sum());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b);
int lcm(int a, int b);

void solve_A(){
    int n, m;
    cin >> n >> m;

    if(n <= m) cout << "Yes";
    else cout << "No";
}

void solve_B(){
    int a, b, ans = 0;
    cin >> a >> b;

    if(a > b){
        REP(i,a){
            cout << b;
        }
    }else{
        REP(i,b){
            cout << a;
        }
    }
}

void solve_C(){
    
}

int main(void){
    
    solve_B();
    solve_C();
    
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);

    int r = a % b;
    while(r != 0){
        a = b;  b = r;  r = a % b;
    }
    return b;
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int H,A;
    cin>> H >> A;
    int count = 0;
    while(H>=1)
    {
        H -= A;
        count++;
    }
    
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, k;
    cin >> n >> k;
    cout << (n>=k*2-1?"YES":"NO") << endl;
    return 0;
}

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

int main()
{
   int N;
   cin >> N;
   vector<int> vec(N);
   for (int i = 0; i < N; i++)
   {
      cin >> vec.at(i);
   }
   
   //
   int max = 101;
   int tmp = 0;
   int count = 0;
   for (int i = 0; i < N; i++)
   {
      for (int j = 0; j < N; j++)
      {
         if (max > vec.at(j) && vec.at(j) > tmp)
         {
            tmp = vec.at(j);
         }
      }
      max = tmp;
      if (max > 0)
      {
         count++;
      }
      tmp = 0;
   }
   

   cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] array = new int[200001];
		Arrays.fill(array, Integer.MAX_VALUE);
		int cnt = 0;
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    if(array[a] == Integer.MAX_VALUE){
		        array[a] = 1;
		        cnt++;
		    }else{
		        array[a]++;
		    }
		}
		Arrays.sort(array);
		
		// 計算
		int result = 0;
		for(int i = 0; i < cnt - k; i++){
		    result += array[i];
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 65380
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)
int maxi(int a,int b)
{
    if(a>b)return a;
    return b;
}
signed main(){
    fast
    int n;
    cin>>n;
    int a[n];
    f0(i,0,n)cin>>a[i];
    int c=0;
    f0(i,1,n)
    {
       c+=maxi(0,a[i-1]-a[i]);
       a[i]+=maxi(0,a[i-1]-a[i]);
    }cout<<c<<endl;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll n;
  cin>>n;
  string s;
  n--;
  s+=char('a'+n%26);
  n/=26;
  //vector <int> v;
  while(n>0){
    if(n%26==0){
      s+='z';
      n=(n-26)/26;
    }
    else{
      s+=char('a'+n%26-1);
      //v.push_back(n%26);
      n/=26;
    }
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}

Measured memory_bytes: 3636
def p_c():
    n = int(input())
    *H, = map(int, input().split())
    ans = 0
    while sum(H) > 0:
        bf = False
        st = 0
        while H[st] == 0:
            st += 1
        for i in range(st, n):
            if H[i] == 0:
                if bf:
                    ans += 1
                bf = False
            else:
                H[i] -= 1
                bf = True
                if i == n - 1:
                    ans += 1
    print(ans)
    
p_c()

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

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        char p = (s[i] - 3 >= 'A' ? s[i] - 3 : s[i] + 23);
        cout << p;
    }
    cout << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    int N_given;
    cin >> N_given;
    
    int a_given[N_given];
    int b_given[N_given];
    int c_given[N_given];
    
    rep(i,N_given){
        cin >> a_given[i] >> b_given[i] >> c_given[i];
    }
    
    ll dp[N_given][3];
    rep(i,N_given){
        rep(j,3){
            dp[i][j] = INF;
        }
    }
    
    dp[0][0] = a_given[0];
    dp[0][1] = b_given[0];
    dp[0][2] = c_given[0];
    
    rep(i,N_given-1){
        dp[i+1][0] = max(dp[i][1],dp[i][2]) + a_given[i+1];
        dp[i+1][1] = max(dp[i][0],dp[i][2]) + b_given[i+1];
        dp[i+1][2] = max(dp[i][0],dp[i][1]) + c_given[i+1];
    }
    ll ans = 0;
    rep(i,3){
        ans = max(ans,dp[N_given-1][i]);
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   ll ans = 0;
   rep(i, 1, n + 1) {
      int cnt = n / i;
      ll res = (ll)cnt * (cnt + 1) / 2 * i;
      ans += res;
   }
   cout << ans << endl;
   return 0;
}

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

typedef long long int ll;
string s, t;

int main() {
    cin >> s >> t;
    if(s.length() == t.length() - 1 && t.substr(0, t.length() - 1) == s) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  int T[N], sum = 0, P, X;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }
  for (cin >> M; M; M--) {
    cin >> P >> X;
    cout << sum-T[P-1]+X << endl;
  }
}

Measured memory_bytes: 256
//ABC112A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << endl;
		return 0;
	}else{
		int a, b;
		cin >> a >> b;
		cout << a+b << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
ll a[maxn];
ll b[maxn];
int main() {
	cin>>n>>m;
	for(ll i=1;i<=n;i++)
		cin>>a[i],b[i]= a[i]/2;
	int cnt = unique(a+1,a+1+n)-a-1;
	sort(a+1,a+1+cnt);
	for(int i=1;i<=cnt;i++)
		b[i] = a[i]/2;
	int l = 1;
	int r = 1000000000;
	ll temp1=0,temp2 = 0;
	ll pos=0;
	if(cnt==1){
		cout<<(m-b[1])/a[1]+1<<endl;
		return 0;
	}
	int fl = 0;
	int fr = 0;
	for(ll i=0;1;i++,pos = i){
		ll t = a[cnt]*i+b[cnt];
		if(t>m) break;
		int flag = 0;
		for(ll j=1;j<=cnt;j++){
		//	cout<<111<<endl;
			if((t-b[j])%a[j]!=0){
				flag = 1;
				break;
			}		
		}
		if(!flag){
			temp1 = (t-b[i])/a[1];
			fl = 1;
			break;
		}
	//	cout<<i<<endl;
	} 
	//cout<<2222<<endl;
	for(ll i=pos+1;1;i++){
		ll t = a[cnt]*i+b[cnt];
		if(t>m) break;
		ll flag = 0;
	//	cout<<t<<endl;
		for(ll j=1;j<=cnt;j++){
			if((t-b[j])%a[j]!=0){
				flag = 1;
				break;
			}		
		}
		if(!flag){
			temp2 = (t-b[i])/a[1];
			fr = 1;
			break;
		}
	}//cout<<temp1<<endl;
//	cout<<temp2<<endl;
	if(fl&&fr){cout<<((m-b[1]-a[1]*temp1)/a[1]/(temp2-temp1))+1<<endl;
	} 
	else if(fl){
		cout<<1<<endl;
		return 0;
	}
	else {
		cout<<0<<endl;
	}
    return 0;
}



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

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			var inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var N = inputNum[0];
			var M = inputNum[1];

			var dicInput = new Dictionary<int, List<int>>();

			for(int i = 0; i < M; i++)
			{
				var inputRule = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

				if(dicInput.ContainsKey(inputRule[0]))
				{
					dicInput[inputRule[0]].Add(inputRule[1]);
				}
				else
				{
					dicInput[inputRule[0]] = new List<int> { inputRule[1] };
				}
			}

			var flag = true;

			if(dicInput.ContainsKey(1))
			{
				if(dicInput[1].Any(x => x == 0))
				{
					flag = false;
				}
			}

			if(flag)
			{
				for (int i = 1; i <= N; i++)
				{
					if(dicInput.ContainsKey(i))
					{
						if (dicInput[i].Distinct().Count() > 1)
						{
							flag = false;
							break;
						}
					}
				}
			}

			var answer = "";
			// 出力
			if(flag)
			{
				if(dicInput.ContainsKey(1))
				{
					answer += dicInput[1].First();
				}
				else
				{
					if(N == 1 && M == 0)
					{
						answer = "0";
					}
					else
					{
						answer += "1";
					}
				}

				if(N > 1)
				{
					if (dicInput.ContainsKey(2))
					{
						answer += dicInput[2].First();
					}
					else
					{
						answer += "0";
					}
				}

				if (N > 2)
				{
					if (dicInput.ContainsKey(3))
					{
						answer += dicInput[3].First();
					}
					else
					{
						answer += "0";
					}
				}
				Console.WriteLine(answer);
			}
			else
			{
				if(N == 1)
				{
					if (dicInput.ContainsKey(1))
					{
						if (dicInput[1].Distinct().Count() == 1 && dicInput[1].First() == 0)
						{
							Console.WriteLine(0);
						}
						else
						{
							Console.WriteLine(-1);
						}
					}
					else
					{
						Console.WriteLine(-1);
					}
				}
				else
				{
					Console.WriteLine(-1);
				}

			}

		}
	}
}

Measured memory_bytes: 13408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer lS(int key){

  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key)
    cur = cur->next;
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void pL(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(lS(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i,a[10];
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  pL();
  return 0;
}



Measured memory_bytes: 33020
X, Y = map(int, input().split())
ans = 0

if X>3 and Y>3:
  print(0)
  exit()

if X == 3:
  ans += 10
elif X == 2:
  ans += 20
elif X == 1:
  ans += 30
if Y == 3:
  ans += 10
elif Y == 2:
  ans += 20
elif Y == 1:
  ans += 30
if X == 1 and Y == 1:
  ans += 40
print(ans*10000)

Measured memory_bytes: 3064
def main():
    a, b, c = map(int, input().split())

    cnt = 0
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and cnt < 100:
        a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
        cnt += 1

    if cnt == 100:
        cnt = -1

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7; 
int mod_fact(int n,int p){
	if(n>=p)return 0;
	if(n<0)return -1;
	long long res=1;
	for (int i =1; i <= n; i++){
		res=(res*i)%p;
	}
	return int(res);
}

int main(void)
{
	int n;
	int a[100005];
	cin>>n;
	for (int i = 1; i <= n; i++){
		cin>>a[i];
	}
	ll res=1;
	stack<int> st;
	for (int i = 1; i <= n; i++){
		st.push(a[i]);
		if(a[i]<2*st.size()-1){
			res=(res*st.size())%mod;
			st.pop();
		}
	}
	res=(res*ll(mod_fact(st.size(),mod)))%mod;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
    IOS;
    int n; cin >> n;
    string s; cin >> s;
    vector<int> prefW(n),prefE(n);
    int W = 0, E = 0;
    rep(i,0,n){
        if(s[i] == 'W') W++;
        else E++;
        prefW[i] = W;
        prefE[i] = E;
    }
    int ans = 999999999;
    rep(i,0,n){
        int m = 0;
        if(i != 0) m+=prefW[i-1];
        ans=min(m+prefE[n-1]-prefE[i],ans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5396
n = int(input())
vl = list(map(int,input().split()))
v1 = vl[::2]
v2 = vl[1::2]

def count(a):
  d = dict()
  for i in a:
    if i not in d:
      d[i] = 1
    else:
      d[i] += 1
  l = []
  for i in d:
    l.append([d[i],i])
  l.append([0,0])
  l.sort(reverse=1)
  return l

v1 = count(v1)
v2 = count(v2)
if v1[0][1] != v2[0][1]:
  print(n-v1[0][0]-v2[0][0])
elif v1[1][0]+v2[0][0] > v1[0][0]+v2[1][0]:
  print(n-v1[1][0]-v2[0][0])
else:
  print(n-v1[0][0]-v2[1][0])

Measured memory_bytes: 21980
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A1=sc.nextInt();
		int A2=sc.nextInt();
		int A3=sc.nextInt();
		if (A1+A2+A3<=21)
		System.out.println("win");
		else System.out.println("bust");
		
	}

}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

string s;



signed main(){
    cin>>s;
    int cnt=1111111;
    rep(i,1,s.size()){
        if(s[i-1]!=s[i]){
            int n=s.size();
            int x=max(i,n-i);
            cnt=min(cnt,x);
        }
    }
    if(cnt==1111111)cnt=s.size();
    cout<<cnt<<endl;
    
    
    
    
    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    if(n==1&&m!=1){cout<<max(0,m-2)<<endl; return 0;}
    else if(n!=1&&m==1){cout<<max(0,n-2)<<endl; return 0;}
    else{cout<<(ll)(n-2)*(m-2)<<endl; return 0;}
}

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

long long N, L, cnts; string S[100009]; vector<int>x[100009], M;

void add(string V) {
	int cx = 0;
	for (int i = 0; i < V.size(); i++) {
		if (V[i] == '0') {
			if (x[cx][0] == -1) { x[cnts] = vector<int>{ -1,-1 }; x[cx][0] = cnts; cnts++; }
			cx = x[cx][0];
		}
		else {
			if (x[cx][1] == -1) { x[cnts] = vector<int>{ -1,-1 }; x[cx][1] = cnts; cnts++; }
			cx = x[cx][1];
		}
	}
}
void dfs(int pos, int depth) {
	for (int i = 0; i < x[pos].size(); i++) {
		if (x[pos][i] == -1) M.push_back(depth + 1);
		else dfs(x[pos][i], depth + 1);
	}
}
long long val(long long v) {
	v++;
	for (int i = 0; i < 63; i++) {
		if (v % (1LL << i) != 0) return (1LL << i) / 2;
	}
	return -1;
}

int main() {
	cin >> N >> L; x[0] = vector<int>{ -1,-1 }; cnts = 1;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		add(S[i]);
	}
	dfs(0, 0);
	long long grundy = 0;
	for (int i = 0; i < M.size(); i++) {
		if (M[i] > L) continue;
		grundy ^= val(L - M[i]);
	}
	if (grundy == 0) cout << "Bob" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 13564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;


public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while(!(str = br.readLine()).equals("0")){
        	List<String> list =Arrays.asList(br.readLine().split(" "));
        	double average = list.stream().mapToDouble(s-> Double.parseDouble(s)).average().getAsDouble();
        	double d = list.stream().mapToDouble(s-> Double.parseDouble(s)).map(s-> (s-average) * (s-average)).sum();
        	System.out.println(Math.sqrt(d/Integer.parseInt(str)));
        }
    }
}

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

const int mod = 1000000007;
vector<int> cnt(1001, 0);

void prime_factorize(long long N) {
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        cnt[a] += ex;
    }
    if (N != 1) ++cnt[N];
}

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

    for (int i = 1; i <= N; ++i) prime_factorize(i);
    ll ans = 1;
    for (int i = 2; i <= N; ++i) {
        if (cnt[i]) ans = (ans * (cnt[i] + 1)) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const int INF=1001001001;

int main(){
  int N;cin>>N;
  int n=0;
  int a;
  int m=INF;
  rep(i,N){
    cin>>a;
    if(m>=a){
      m=a;
      n++;
    }
  }
  cout<<n<<endl;
}

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

template<typename T>
struct MP {
  int n;
  T t;
  vector<int> a;
  MP() {}
  MP(const T& t): t(t) {
    n = t.size();
    a = vector<int>(n+1);
    a[0] = -1;
    int j = -1;
    for (int i = 0; i < n; ++i) {
      while (j != -1 && t[j] != t[i]) j = a[j];
      j++;
      a[i+1] = j;
    }
  }
  int operator[](int i) { return a[i];}
  vector<int> findAll(const T& s) {
    vector<int> res;
    int j = 0;
    for (int i = 0; i < s.size(); ++i) {
      while (j != -1 && t[j] != s[i]) j = a[j];
      j++;
      if (j == n) {
        res.push_back(i-j+1);
        j = a[j];
      }
    }
    return res;
  }
};

vector<int> f(vector<int>& a) {
  int n = a.size();
  vector<int> res(n);
  rep(i,n) res[i] = a[i]^a[(i+1)%n];
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  vector<int> xa = f(a);
  vector<int> xb = f(b);
  MP<vector<int>> mp(xa);
  xb.insert(xb.end(), xb.begin(), xb.end());
  vector<int> res = mp.findAll(xb);
  vector<int> ks;
  for (int p : res) ks.push_back(n-p);
  sort(ks.begin(), ks.end());
  for (int k : ks) {
    if (k >= n) continue;
    int x = a[k]^b[0];
    printf("%d %d\n", k, x);
  }
  return 0;
}

Measured memory_bytes: 11724
#include<stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);	
	if(x>=r && x<=W-r && y>=r && y<=H-r){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n + 1]; //1オリジンにする
        for (int i = 1; i <= n; i++) h[i] = scanner.nextInt();

        for (int i = n / 2; i >= 1; i--) maxHeapify(h, i);

        for (int i = 1; i <= n; i++)
            System.out.print(" " + h[i]);
        System.out.print("\n");

    }

    private static void maxHeapify(int[] h, int i) {

        int n = h.length - 1;
        int left = 2 * i;
        int right = 2 * i +1;

        int largest;
        if (left <= n && h[left] > h[i])
            largest = left;
        else
            largest = i;
        if (right <= n && h[right] > h[largest])
            largest = right;

        if (largest != i) {
            swap(h, i, largest);
            maxHeapify(h, largest);
        }
    }

    private static void swap(int[] h, int i, int i2) {
        int tmp = h[i];
        h[i] = h[i2];
        h[i2] = tmp;
    }
}



Measured memory_bytes: 166540
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e9)

int main(){
	int n;
	cin >> n;
	int l[n], max=0, sum=0;
	for(int i=0; i<n; i++){
		cin >> l[i];
		sum+=l[i];
		if(max<l[i]) max=l[i];
	}
	if(2*max<sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int n, m, x;

int main(void){
	cin >> n >> m >> x;
	vector<int> v(n+1);
	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		v[a] = 1;
	}
	int r1 = 0;
	for(int i = x+1; i < n+1; i++) r1+=v[i];
	int r2 = 0;
	for(int i = x-1; i >= 0; i--) r2+=v[i];
	cout << min(r1, r2) << endl;
	return 0;
}


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

int main(){
  int n, T, A, H;
  cin >> n >> T >> A;
  int mn = 1000000000;
  int res;

  for(int i=1; i<=n; ++i){
    cin >> H;
    int d = abs(T*1000-H*6 - A*1000);
    if(d < mn){
      mn = d;
      res = i;
    }
  }
  cout << res;
}

Measured memory_bytes: 256
solve :: Int -> [Int] -> [Int]
solve current [] = [current]
solve current (x:xs) = current:solve next xs
  where next = current + x

main :: IO ()
main = do
  [n, x] <- map read . words <$> getLine :: IO [Int]
  ls <- map read . words <$> getLine
  print . length $ filter (<=x) $ solve 0 ls


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

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int gcd(int a, int b){
    if(a < b){
        swap(a, b);
    }
    int r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

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

    vector<int> x(n), y(n);
    x[0] = a[0];
    y[n-1] = a[n-1];
    for(int i = 0; i < n - 1; i++){
        x[i+1] = gcd(x[i], a[i+1]);
    }
    for(int i = n - 1; i > 0; i--){
        y[i-1] = gcd(y[i], a[i-1]);
    }

    int ans = 0;
    rep(i, n){
        if(i == 0){
            ans = max(ans, y[i+1]);
            continue;
        }
        if(i == n - 1){
            ans = max(ans, x[i-1]);
            continue;
        }
        ans = max(ans, gcd(x[i-1], y[i+1]));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=1e3+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=1e9;
const double ep=1e-7;
using namespace std;
int main()
{
	ll a,b,k;
	scanf("%lld%lld%lld",&a,&b,&k);
	if(a<=k)k-=a,a=0;
	else a-=k,k=0;
	if(b<=k)b=0;
	else b-=k;
	printf("%lld %lld\n",a,b);
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
cond t f c = if c then t else f
-- end of templete

next c
  | c == 'z' = 'a'
  | isAsciiLower c = succ c
  | otherwise = c

caesar s = map next s

main = do
    lines <$> getContents >>= mapM_ (putStrLn . head . filter (flip any ["the", "this", "that"] . flip isInfixOf) . take 26 . iterate caesar )

Measured memory_bytes: 4000
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    as_ = list(map(int, input().split()))
    colors = [a // 400 for a in as_ if a <= 3199]
    free_num = len([a for a in as_ if a >= 3200])

    num_color = len(set(colors))
    print(max(num_color, 1), num_color + free_num)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

struct Plane {
	double x_point;
	double y_point;
};

int main() {
	
	int n;
	int count = 1;
	Plane *A;
	
	while( cin >> n && n != 0) {
		
		
		
		A = new Plane[n+1];
		double area = 0;
		
		for(int i=0;i<n;i++)
			cin >> A[i].x_point >> A[i].y_point;
			
		A[n] = A[0];
		
		for(int i=0;i<n;i++)		
			area = area + A[i].x_point * A[i+1].y_point - A[i+1].x_point * A[i].y_point;

		cout << count << " " << fixed << setprecision(1) << abs(area) / 2 << "\n";
		
		count++;
		delete [] A;
		A = NULL;
	
	}
	
	return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
int main(void){
int a, b, i;
char op;
for(i = 1; i > 0; i++){
scanf("%d %c %d", &a, &op, &b);
if(op == '+'){
  printf("%d\n", a + b);
}else if(op == '-'){
  printf("%d\n", a - b);
}else if(op == '*'){
  printf("%d\n", a * b);
}else if(op == '/'){
  printf("%d\n", a / b);
}else if(op == '?'){
  break; 
}
}
return 0; 
}


Measured memory_bytes: 2036
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def count(k, bins, N):
    current = 0
    for i in range(2, N+1):
        if k * i <=N:
            if bins[k*i] == -1:raise ValueError(f'bins{i} is not filled yet')
            current += bins[k*i]
        else:
            break
    return current % 2

def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    A = [-1] + A
    bins = [-1] * (N+1)

    for i in range(N, 0, -1):
        bins[i] = (A[i] - count(i, bins, N)) % 2


    print(sum(bins) + 1)
    ans = []
    for i, b in enumerate(bins):
        if b == 1:
            ans.append(str(i))
    print(' '.join(ans))


if __name__ == "__main__":
    run()

Measured memory_bytes: 22788
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) 
{
    ll n;
    cin >>n;
    mes(3 * n*n);
}


Measured memory_bytes: 3552
n=int(input())
a=[int(i) for i in input().split()]

def f(l):
    m=min(l)
    li=[m]
    if m==sum(l):
        return m
    else:
        for i in range(len(l)):
            if l[i]%m!=0:
                li.append(l[i]%m)
        return f(li)

print(f(a))

Measured memory_bytes: 14252
fun main(arg: Array<String>) {
    val INF = 1000000007
    val (N, M) = listOfInt()
    val G = Array(N) { IntArray(N) { INF } }
    val E = Array(N) { IntArray(N) }
    repeat(N) { n -> G[n][n] = 0 }
    repeat(M) {
        val (a, b, c) = listOfInt(-1, -1, 0)
        G[a][b] = c; G[b][a] = c
        E[a][b] = c; E[b][a] = c
    }
    repeat(N, N, N) { k, n, m ->
        G[n][m] = Math.min(G[n][m], G[n][k] + G[k][m])
    }
    val A = Array(N) { BooleanArray(N) }
    repeat(N, N, N, N) { s, t, n, m ->
        if (s != t && n != m)
            if (G[s][t] == G[s][n] + E[n][m] + G[m][t]) A[n][m] = true
    }
    var ans = 0
    repeat(N, N) { n, m ->
        if (!A[n][m] && E[n][m] != 0) ans += 1
    }
    println(ans / 2)
}
inline fun repeat(times1: Int, times2: Int, action: (Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2) {
            action(index1, index2)
        }
}
inline fun repeat(times1: Int, times2: Int, times3: Int, action: (Int, Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2)
            for (index3 in 0 until times3) {
                action(index1, index2, index3)
            }
}
inline fun repeat(times1: Int, times2: Int, times3: Int, times4: Int, action: (Int, Int, Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2)
            for (index3 in 0 until times3)
                for (index4 in 0 until times4) {
                    action(index1, index2, index3, index4)
                }
}


fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map(String::toLong)
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }


Measured memory_bytes: 42536
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        break
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21628
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, K = map(int, read().split())
count = 0

# [max(A, B), ..., 1]
for i in range(max(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        count += 1

    if count == K:
        print(i)
        exit()


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

long long n, p = 2;
int t = 0;

int main()
{
	cin >> n;

	while (n > 1 && p <= sqrt(n)) {
		int s = 0, u = 1;

		while (n % p == 0) {
			n /= p;
			s++;
		}

		while (u <= s) {
			s -= u;
			u++;
			t++;
		}

		p++;
	}

	if (n > 1)
		t++;

	cout << t << endl;
}


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

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

    long long rem = n % (a + b);
    long long sum = a * (n / (a + b));
    if (rem >= a) {
        sum += a;
    } else {
        sum += rem;
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N, A, B;
  ll mx, mn;

  cin >> N >> A >> B;
  mx = (ll)(N - 1) * B + A;
  mn = (ll)(N - 1) * A + B;
  cout << MAX(mx - mn + 1, 0) << endl;

  return 0;
}


Measured memory_bytes: 256