akhauriyash/Code-Regression huggingface dataset:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
# from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    # sys.setrecursionlimit(int(pow(10,5)))
    sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass



n,x,m=L()
A=[x]
d={}
k=1
d[x]=1
while(A[-1]!=0 and k<n):
    y=A[-1]*A[-1]%m
    if y in d:
        break
    else:
        d[y]=1
    A.append(y)
    k+=1
if A[-1]==0:
    print(sum(A))
elif k==n:
    print(sum(A))
elif k<n:
    # print(n,k,A,y)

    # idx=A.index(y)
    # # print(idx)
    # ans=sum(A[:idx])
    # z=A[idx:]
    # # print(z)
    # ans+=sum(z)*(n-idx)//len(z)
    # total=idx+((n-idx)//len(z))*len(z)
    # rem=n-total
    # ans+=sum(z[:rem])

    # print(ans)
    pref=0
    ans=0
    rem=-2
    cnt=-1
    # print(A[:10])
    for i in range(len(A)):
        if A[i]==y:
            ans+=pref
            pref=0
            cnt=0
            rem=(n-i)%(len(A)-i)
            # print(ans)
        if rem==cnt:
            ans+=pref
        if cnt>=0:
            cnt+=1
        pref+=A[i]
    ans+=pref*((n-k+cnt)//(cnt))
    print(ans)

endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")



Measured memory_bytes: 15624
#include <stdio.h>

int main(void){   
	int a;
	scanf("%d", &a);
	int x, y;
	int z;
	for (x = 1;x <= 9;x++) {
		for (y = 1;y <= 9;y++) {
			z = x * y;
			if (a == z) {
				printf("Yes");
				goto A;
			}
		}
		
	}
	printf("No");
	A:

	return 0;
}

Measured memory_bytes: 128
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];





int main(){
   int n;
   cin>>n;
   vector<int> vec(n);
   rep(i,n){
       cin>>vec.at(i);
   }
   bool flag=true;
   rep(i,n){
       if(vec.at(i)%2==0){
           if(vec.at(i)%3!=0&&vec.at(i)%5!=0){
               flag=false;
               break;
           }
       }
   }
   if(flag){
       cout<<"APPROVED"<<endl;
   }
   else{
       cout<<"DENIED"<<endl;
   }
}



Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    v=parseMap(split(readline()))
    c=parseMap(split(readline()))
    ans=0
    for i in 1:n
        if v[i]>=c[i]
            ans+=v[i]-c[i]
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 110204
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var N = Console.ReadLine().ToInt32();

        var dn = Console.ReadLine().SplittedStringToInt32List();

        var dndict = new Dictionary<int, int>();
        foreach (var item in dn)
        {
            if (dndict.ContainsKey(item))
                dndict[item]++;
            else
                dndict.Add(item, 1);
        }

        var K = Console.ReadLine().ToInt32();
        var tn = Console.ReadLine().SplittedStringToInt32List();
        var isok = true;
        foreach (var item in tn)
        {
            if (!dndict.ContainsKey(item))
                isok = false;
            else
            {
                var num = dndict[item];
                if (num <= 0)
                {
                    isok = false;
                
                }
                else
                {
                    dndict[item]--;
                }
            }
        }
        Console.WriteLine(isok ? "YES" : "NO");

        Console.ReadLine();
    }

    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    
  
  

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 48316
#include <iostream>
using namespace std;
static const int N = 1000000;

int b[N];

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

    for (int i = 0; i < n - 1; i++) cin >> b[i];

    int sum = b[0] + b[n - 2];
    int pre = b[0];
    for (int i = 1; i < n - 1; i++) {
        sum += b[i] < pre ? b[i] : pre;
        pre = b[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()

set_s = set(s)

abc = 'abcdefghijklmnopqrstuvwxyz'

if len(abc) != 26:
	print('err')

set_abc = set(abc)

set_abc -= set_s

ans =[]

for c in set_abc:
	ans.append(c)
	
ans.sort()

if len(ans) == 0:
	print('None')
else:
	print(ans[0])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9+7;

signed main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int ans = 0;
    for(int digit = 0; digit <= 60; digit++){
        int c0 = 0, c1 = 0;
        for(int i = 0; i < N; i++){
            if(1 & (a[i] >> digit)) c1++;
            else c0++;
        }
        ans += ((c0 * c1)%MOD) * ((1ll << digit)%MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}


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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var K = input[0];
            var X = input[1];

            Console.WriteLine(500 * K >= X ? "Yes" : "No");
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from collections import deque  # 双方向キュー

def main():
    S = i2s()
    q = deque()
    for s in S:
        if not q:
            q.append(s)
        else:
            t = q.pop()
            if s == t:
                q.append(t)
                q.append(s)
    n = len(S) - len(q)
    print(n)

main()


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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  int min;
  for (int i=0; i<N; i++){
    int A;
    cin >> A;
    if(A % 2 != 0){
      min = 0;
      break;
    }
    
    int num = 0;
    int temp = A;
    while(temp %2 != 1){
      temp /= 2;
      num++;
    }
    if(i == 0)
      min = num;
    min = num < min ? num : min;
  }
  cout << min << endl;
}
  

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

public class Main {
	public static void main (String[] args) {
		//code
		Scanner in=new Scanner(System.in);
		int sum=0;
      	String s=in.nextLine();
      char ch[]=s.toCharArray();
      for(int i=0;i<s.length();i++)
      {
        	sum=sum+(int)(ch[i]-'0');
      }
      if(sum%9==0)
      {
        	System.out.println("Yes");
      }
      else
      {
        	System.out.println("No");
      }
}
}

Measured memory_bytes: 41244
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n, q;
char a[N];

int p[N];

int main()
{
    cin >> n >> q;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 2; i <= n; ++i)
    {
        p[i] = p[i - 1];
        if (a[i] == 'C' && a[i - 1] == 'A')
            p[i]++;
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << p[r] - p[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int x;
cin>>x;
int ans=1;
int k;
reps(i,(int)sqrt(x)+1,2){
    int val=1;
    while(val*i<=x){
        val*=i;
    }

    ans=max(val,ans);
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gc();}
	}
};
using io::gi;
template<class IT>inline void _int(      IT &a,      IT &b  ){if(a>b)swap(a,b);}
template<class IT>inline void cmin(      IT &a,const IT &b=0){if(a>b)a=b;}
template<class IT>inline void cmax(      IT &a,const IT &b=0){if(a<b)a=b;}
template<class IT>inline IT   _min(const IT &a,const IT &b=0){return a>b? b:a;}
template<class IT>inline IT   _max(const IT &a,const IT &b=0){return a<b? b:a;}
template<class IT>inline IT   _abs(const IT &a              ){return a<0?-a:a;}

const int N=200005;
const double qwqwq=180.0/M_PI;
struct qwq{
	int a,b;
	inline qwq(){}
	inline qwq(int a,int b):a(a),b(b){}
	inline bool operator<(const qwq &x)const{return a<x.a;}
};

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	double a,b,ab,x;
	scanf("%lf%lf%lf",&a,&b,&x);x=(x+x)/a;ab=a*b;
	if(x<=ab)printf("%.12lf",atan(b*b/x)*qwqwq);
	else printf("%.12lf",atan((ab+ab-x)/(a*a))*qwqwq);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool ans=true;
  vector<int64_t> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      ans=false;
      break;
    }
  }
  if(ans==true)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[100], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    for(int i = 1 ; i < n - 1 ; i++){
      average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    ll int n,ans=0,x;
    cin>>n;
    ll int a[n];
    map<ll int,ll int> mp;
    for(ll int i=0;i<n;i++){
    	cin>>a[i];
    	mp[(a[i]+i+1)]++;
	}
	for(ll int i=0;i<n;i++){
		x=(i+1)-a[i];
		ans+=mp[x];
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 27924
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>i_i;
int main() {
	map<int,int> student;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int x;
		cin>>x;
		student[x]=i+1;
	}
	for(int i=1;i<N+1;i++){
	cout<<student[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//int a[5];
	int ans,x,i;
	for(i=0;i<5;i++)
	{
		cin>>x;
	    if(x==0)
		ans=i+1;	
	}
	cout<<ans;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  re0 x=0,f=1;rec c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;re0 f=1;rec c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  re0 bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  rec c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int x,y,lt,n=read();
int main(){
for (;n--;){
  int t=read(),nx=read(),ny=read();
  if (((t-lt)^(nx-x+ny-y))&1||t-lt<abs(nx-x+ny-y)) return puts("No"),0; 
  lt=t,x=nx,y=ny;
  }puts("Yes");
}

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

int main(){
  int n, m, sum = 0;
  cin >> n >> m;
  vector<int> a(n);
  for (int i=0 ; i<n ; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  int pop = 0;
  float basis = sum*0.25/m;
  
  for (int i=0 ; i<n ; i++){
    if (a.at(i) >= basis)
      pop++;
  }
  
  if (pop >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    int M; cin >> M;
    int ans = -1;
    vector<int> s(M);
    vector<char> c(M);
    for (int i=0;i<M;i++) cin >> s[i] >> c[i];
    if (N==1) {
        for (int i=0;i<10;i++){
        string x = to_string(i);
        bool can = true;
        for (int j=0;j<M;j++){
            if (x[s[j]-1]!=c[j]) can = false;
        }
        if (can) {
            ans = i;
            break;
        }
    }
    }else{
            for (int i=pow(10,N-1);i<pow(10,N);i++){
        string x = to_string(i);
        bool can = true;
        for (int j=0;j<M;j++){
            if (x[s[j]-1]!=c[j]) can = false;
        }
        if (can) {
            ans = i;
            break;
        }
    }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int last = s[s.size()-1] - '0';
  if(last == 3) cout << "bon";
  else if(last == 1) cout << "pon";
  else if(last == 2 || last == 4) cout << "hon";
  else if(last%2) cout << "hon";
  else cout << "pon";
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3604
if __name__ == '__main__':

	A = list(map(int,input()))

	if A[0]==A[1] and A[1]==A[2] and A[0]==A[2]:
		print("Yes")
	elif A[1]==A[2] and A[2]==A[3] and A[1]==A[3]:
		print("Yes")
	else:
		print("No")

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

int main() {
  long long A,B,L;
  cin >> A;
  B = 9;
  long long sum=1;
  if(A % 7 == 0) {
    L = 9 * A / 7;
    for (long long i=1; i<=A; i++) {
      B = B % L;
      if (B == 0) {
        break;
      }
      else {
        B = ((B+1)*10)-1;
        sum++;
      }
    }
  }
  else if(A % 2 == 1) {
    L = 9 * A;
    for (long long i=1; i<=A; i++) {
      B = B % L;
      if (B == 0) {
        break;
      }
      else {
        B = ((B+1)*10)-1;
        sum++;
      }
    }
  }
  else {
    sum = -1;
  }
  int C =0;
  C = sum;
  if (C == A+1) {
    sum = -1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double Pi = acos(-1.0);
const int INF = 1000000000;

int A[1000];

int main()
{
	//freopen("in.txt","r",stdin);
	int n;
	cin >> n;
	FOR(i, 0, n*2) {
		cin >> A[i];
	}

	sort(A, A + n*2);

	int res = 0;
	FOR(i, 0, n) {
		res += A[i * 2];
	}

	cout << res << endl;

}


Measured memory_bytes: 764
def list_rindex(li, x):
    for i in reversed(range(len(li))):
        if li[i] == x:
            return i
    raise ValueError("{} is not in list".format(x))

N = int(input())
S = [input() for _ in range(N)]
T = input()

aS = [s.replace("?", "a") for s in S] + [T]  
zS = [s.replace("?", "z") for s in S] + [T]

aS.sort()
zS.sort()

asf = list_rindex(aS, T)
zsf = zS.index(T)

ans = [i for i in range(zsf + 1, asf + 2)]
print(*ans)

Measured memory_bytes: 5364
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint cal(lint n,lint b){
	lint ret=0;
	while(n>0){
		ret+=n%b;n/=b;
	}
	return ret;
}
int main()
{
	lint b=2,n,s;
	cin>>n;cin>>s;
	if(n==s){
		cout<<n+1<<endl;return 0;
	}
	if(n<s){
		cout<<-1<<endl;return 0;
	}
	for(;b*b<=n;b++){
		if(cal(n,b)==s){
			cout<<b<<endl;return 0;
		}
	}
	b=1145141919810893LL;
	for(lint c=1;c*c<=n-s;c++){
		if((n-s)%c>0) continue;
		if(cal(n,(n-s)/c+1)==s) b=min(b,(n-s)/c+1);
		if(cal(n,c+1)==s) b=min(b,c+1);
	}
	if(b>=1145141919810893LL){
		cout<<-1<<endl;return 0;
	}
	cout<<b<<endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    for i in a:
        if i % 2 == 0:
            if i % 5 == 0 or i % 3 == 0:
                continue
            else:
                print("DENIED")
                exit()

    print("APPROVED")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

int main() {
#ifdef __APPLE__
    freopen("input2.txt", "r", stdin);
#endif
    int N;
    cin >> N;
    long a[N];
    unordered_map<long, long> aMap;

    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        if (aMap.find(a[i]) == aMap.end()) {
            aMap[a[i]] = 1;
        } else {
            ++aMap[a[i]];
        }
    }

    if (N % 2 == 1) {
        if (aMap[0] != 1) {
            cout << "0" << endl;
            return 0;
        }

        for (int i = 1; i < N; ++i) {
            if (i % 2 == 0) {
                if (aMap[i] != 2) {
                    cout << "0" << endl;
                    return 0;
                }
            } else {
                if (aMap[i] != 0) {
                    cout << "0" << endl;
                    return 0;
                }
            }
        }

        int ans = 1;
        for (int j = 0; j < (N - 1) / 2; ++j) {
            ans = ans * 2;
            ans = ans % 1000000007;
        }

        cout << ans << endl;
    } else {
        if (aMap[0] != 0) {
            cout << "0" << endl;
            return 0;
        }
        for (int i = 1; i < N; ++i) {
            if (i % 2 == 0) {
                if (aMap[i] != 0) {
                    cout << "0" << endl;
                    return 0;
                }
            } else {
                if (aMap[i] != 2) {
                    cout << "0" << endl;
                    return 0;
                }
            }
        }

        int ans = 1;
        for (int j = 0; j < N / 2; ++j) {
            ans = ans * 2;
            ans = ans % 1000000007;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5156
import sys
n=int(input())
a=list(map(int,input().split()))

max_v=[0 for _ in range(n+1)]

max_v[0]=1-a[0]
if(n==0 and a[0]==1):
    print(1)
    sys.exit()
elif(max_v[0]<=0 or a[-1]<=0):
    print(-1)
    sys.exit()
#print(0,max_v[0])

for i in range(1,n+1):
    max_v[i]=2*max_v[i-1] - a[i]
#    print(i,max_v[i])
    if(max_v[i]<=0 and i<n):
        print(-1)
        sys.exit()
#print(max_v)
ans=a[-1]
v=a[-1]
for i in range(n-1,-1,-1):
    if(v>2*max_v[i]):
        print(-1)
        sys.exit()
    v=min(v,max_v[i])
    v+=a[i]
    ans+=v
#    print(i,v,ans)
print(ans)

Measured memory_bytes: 668604
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;

P ps[550];
int xs[550];
int N;

int a[550 * 550];

vector<int> vec;

void solve(){
	for(int i = 1; i <= N * N + 1; ++i) a[i] = -1;
	sort(ps, ps + N);
	int iter = 1;
	for(int i = 0; i < N; ++i){
		int val = ps[i].second;
		int id = ps[i].first;
		a[id] = val;
		for(int j = 1; j < val; ++j){
			while(a[iter] != -1) iter++;
			if(iter == N * N + 1 || iter > id){
				printf("No\n");
				exit(0);
			}
			a[iter++] = val;
		}
	}
	iter = 0;
	for(int i = 0; i < N; ++i){
		int val = ps[i].second;
		int id = ps[i].first;
		iter = max(iter, id);
		for(int j = 0; j < N - val; ++j){
			while(a[iter] != -1) iter++;
			if(iter == N * N + 1){
				printf("No\n");
				exit(0);
			}
			a[iter++] = val;
		}
	}/*
	for(int i = 1; i <= N; ++i){
		for(int j = 0; j < N - i; ++j){
			vec.push_back(i);
		}
	}
	int c = 0;
	for(int i = 1; i <= N * N; ++i){
		if(a[i] == -1){
			a[i] = vec[c++];
		}
	}
	return;*/
}

void input(){
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i){
		int x;
		scanf("%d", &x);
		ps[i - 1] = P(x, i);
	}
}

int main(){
	input();
	solve();
	printf("Yes\n");
	for(int i = 1; i <= N * N; ++i){
		printf("%d%c", a[i], i == N * N ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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 maxv = a[a.size()-1];

    if(maxv%2 == 0){
        auto itr = lower_bound(a.begin(), a.end(), maxv/2);
        int tmp1 = *itr;
        itr--;
        int tmp2 = *itr;
        if(abs(maxv/2 - tmp1) < abs(maxv/2 - tmp2)){
            printf("%d %d\n", maxv, tmp1);
            return 0;
        }
        else{
            printf("%d %d\n", maxv, tmp2);
            return 0;
        }
    }
    else{
        auto itr = lower_bound(a.begin(), a.end(), (double)maxv/2);
        int tmp1 = *itr;
        itr--;
        int tmp2 = *itr;
        if(abs((double)maxv/2 - tmp1) < abs((double)maxv/2 - tmp2)){
            printf("%d %d\n", maxv, tmp1);
            return 0;
        }
        else{
            printf("%d %d\n", maxv, tmp2);
            return 0;
        }
    }
}

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

int main()
{
  vector<int> a(3);
  for(int i=0;i<3;i++)
  {
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(2)-a.at(0)<<endl;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,0,n-1) cin>>ara[i];
	f(i,0,n-1) cin>>ara2[i];

	f(i,1,n-1) ara[i]+=ara[i-1];
	rf(i,n-2,0) ara2[i]+=ara2[i+1];

	f(i,0,n-1){
        maxi=max(maxi,ara[i]+ara2[i]);
	}

    cout<<maxi<<endl;

}


Measured memory_bytes: 256
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		
		for(int i=0; i < totalVertex; i++) {
			for(int j=0; j < totalVertex; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		
		for(int i=0; i < totalVertex; i++) {
			
			for(Iterator iter = adjList.get(i).iterator(); iter.hasNext();) {
				adjMatrix[i][(int)iter.next()] = 1;
			}
			
		}
		
		for(int i=0; i < totalVertex; i++) {
			
			for(int j=0; j < totalVertex; j++) {
				System.out.print(adjMatrix[i][j]);
				if(j < totalVertex-1) System.out.print(" ");
			}
			System.out.println();
			
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 34696
from itertools import *
from math import *

INF = int(1e18)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
before = sum(A)

for i in range(N):
    remainder = B[i]
    for j in range(i, i + 2):
        if remainder >= A[j]:
            remainder -= A[j]
            A[j] = 0
        else:
            A[j] -= remainder
            remainder = 0
after = sum(A)

print(before - after)

Measured memory_bytes: 82148
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define ll long long int 
#define fon(n) for(ll i=0;i<n;i++)

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,m,t,sum = 0,temp;
    cin>>n>>m;
    t=m;
    // cout<<n<<" "<<m<<endl;
    while(t--){
    	cin>>temp;
    	sum+=temp;
    }
    if(sum<=n){
    	cout<<n-sum;
    }
    else{
    	cout<<-1;
    }
	return 0;
}

Measured memory_bytes: 3656
// @prefix atcoder
// @description atcoder template

#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
VI a(100);
VI col(8, 0);

signed main() {
    cin >> n;
    a.resize(n);
    REP(i, n) {
        cin >> a[i];
    }
    sort(ALL(a));
    int res = 0;
    int wild = 0;
    REP(i, n) {
        if (a[i] >= 3200) {
            wild++;
        } else {
            col[a[i] / 400]++;
        }
    }

    for (auto c : col) {
        if (c > 0) {
            res++;
        }
    }

    int mi, ma;
    mi = max(res, 1LL);
    ma = res + wild;
    cout << mi << " " << ma << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

fib = [-1 for _ in range(50)]
fib[0] = 1
fib[1] = 2

for n in range(2, 50):
    fib[n] = fib[n - 1] + fib[n - 2]

N = int(input())
print(fib[N - 1])


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

using namespace std;

int n,m,w[105],v[105],s=0;
long long f[105][100005];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n; i++) {cin>>w[i]>>v[i];s+=v[i];}
    for(int i=0;i<=n;i++) for(int j=0;j<=s;j++) f[i][j]=1e18;
    f[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=s;j++)
        {
            f[i][j]=f[i-1][j];
            if (j>=v[i] && f[i][j]>f[i-1][j-v[i]]+w[i])
                f[i][j]=f[i-1][j-v[i]]+w[i];
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=s;j++)
            if (f[i][j]<=m && ans<j)
                ans=j;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 80128
#include <cstdio>
#include <string>
#include <map>
using namespace std;

int main()
{
	char text[32];
	string str[1001];
	map<string, int> test;
	int i = 0, len = 0, max = 0, now;
	
	while(scanf("%s", text) != EOF){
		str[i] = text;
		
		test[str[i]]++;
		
		now = str[i].size();
		if(max < now){
			len = i;
			max = str[len].size();
		}
		i++;
	}
	now = 0;
	for(i = 0; i < 1001; i++){
		if(test[str[i]] > test[str[now]]){
			now = i;
		}
	}
	
	printf("%s %s\n", str[now].c_str(), str[len].c_str());
	
	
	return(0);
}

Measured memory_bytes: 1064
M = 10**9+7
H, W, A, B = gets.split.map(&:to_i)

# https://abc003.contest.atcoder.jp/submissions/1710595
# 最初にNCR.init(<nの最大値>)を呼ぶこと
# 定数Mを定義すること
class NCR
  @fac = []
  class << self
    def init(n); calc_fact(n); end
    def calc_fact(n)
      @fac[0] = 1
      @fac[1] = 1
      i = 2
      while i <= n
        @fac[i] = (@fac[i-1]*i)%M
        i += 1
      end
    end
    def power(a, b)
      x = 1; y = a
      while b > 0
        x = (x*y)%M if b.odd?
        y = (y*y)%M
        b /= 2
      end
      x%M
    end
    def mod_inv(n); power(n, M-2); end
    def nCr(n, r)
       (@fac[n] * (mod_inv(@fac[r]) * mod_inv(@fac[n-r])%M))%M
    end
  end
end

NCR.init(H+W)

def n_pats(h, w)
  NCR.nCr(h+w, h)
end

mid_row = Array.new(W){|x|
  n_pats(H-A-1, x) if x >= B
}

last_row = Array.new(W){|x|
  (mid_row[x] * n_pats(A-1, W-x-1)) % M if x >= B
}

p last_row.compact.inject{|a, b| (a + b) % M }


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());

    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < n; i++){
        if(i%2 == 0){
            Alice += a[i];
        }
        else{
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;
    return 0;
}

Measured memory_bytes: 3576
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

# MOD = 10 ** 9 + 7
MOD = 998244353
# sys.setrecursionlimit(10**8)

n, s = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]

for i in range(n+1):
    dp[i][0] = i + 1

ans = 0
for i in range(n):
    for j in range(s + 1):
        if s > j > 0:
            dp[i + 1][j] += dp[i][j]
        if j + A[i] <= s:
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= MOD

    ans += dp[i + 1][s] * (n - i)
    ans %= MOD

print(ans)


Measured memory_bytes: 113244
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 1e9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int h,w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    int cnt = 0;
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            if(s[i][j] == '#') cnt++;
        }
    }

    vector<vector<int>> dist(h,vector<int>(w));
    rep(i,h){
        rep(j,w){
            dist[i][j] = inf;
        }
    }

    queue<pii> que;
    que.push(pii(0, 0));
    dist[0][0] = 0;

    while(!que.empty()){
        pii p = que.front(); que.pop();
        rep(i,4){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#' && dist[nx][ny] == inf){
                que.push(pii(nx, ny));
                dist[nx][ny] = dist[p.first][p.second] + 1;
            }
        }
    }

    if(dist[h-1][w-1] == inf) cout << "-1" << endl;
    else cout << h*w - dist[h-1][w-1] - 1 - cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;
    string str;
    cin >> str;
    set<int> s[26];
    for(int i = 0 ; i < n ; i++)
    {
        s[str[i]-97].insert(i);
    }
    int q;
    cin >> q;
    while(q--)
    {
        int num;
        cin >> num;
        if(num == 2)
        {
            int l , r;
            cin >> l >> r;
            l-- , r--;
            int cnt = 0;
            for(int i = 0 ; i < 26 ; i++)
            {
                auto it = s[i].lower_bound(l);
                if(it == s[i].end())continue;
                else
                {
                    if(*it <= r)cnt++;
                }
            }
            cout << cnt << endl;
        }
        else
        {
            int idx;
            char c;
            cin >> idx >> c;
            for(int i = 0 ; i < 26 ; i++)
            {
                if(s[i].find(idx-1) != s[i].end())
                {
                    s[i].erase(idx-1);
                    s[c-97].insert(idx-1);
                }
            }
        }
    }
    return 0;
}

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

using namespace std;

#define ll unsigned long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)
#define pii pair<ll,ll>
#define mp make_pair
#define din cin
#define dout cout
#define dontinue continue

const ll INF=1e9+7;
ll a,n,m;
int main(){
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	din>>a>>n>>m;
	if(n>m){
		swap(n,m);
	}
	if((m-n)%2){
		ll x=n;
		ll t1=(m-x-1)/2+x;
		x=a-m+1;
		ll t2=(a-n-x)/2+x;
		dout<<min(t1,t2);
	}
	else{
		dout<<(m-n)/2;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int l = 0;
    int r = 0;
    for (int i = 0; i < m; ++i) {
        int tmp;
        cin >> tmp;
        if (tmp < x) ++l;
        else ++r;
    }

    int ans = (l < r) ? l : r;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[100000];


 int partition(int p, int r){
   int j,temp;
   int x = A[r];
   int i = p-1;
   for(j=p; j<=r-1; j++){
     if(A[j] <= x){
       i++;
       temp = A[i];
       A[i] = A[j];
       A[j] = temp;
     }
   }
   temp = A[i+1];
   A[i+1] = A[r];
   A[r] = temp;

   return i+1;
 }

 int main(){
   int n,i,p,r,q;

   scanf("%d",&n);
   for(i=0; i<n; i++){
     scanf("%d",&A[i]);
   }

   p = 0;
   r = n-1;

   q = partition( p, r);

   for(i=0; i<n; i++){
     if(i == q){
       printf("[%d]",A[i]);
     }else{
       printf("%d",A[i]);
     }
     if(i < n-1){
       printf(" ");
     }
   }
   printf("\n");

   return 0;
   
 }



Measured memory_bytes: 2100
n = gets.to_i

x = 0
$data = Array.new(10) { |i| x += 10 ** i * 2 } << 0 << 0 << 0 << 0

def f(num)
  digits = num.to_s.each_char.map(&:to_i)
  return 0 if digits[-1] == 0
  
  d = digits.length
  return 1 if d == 1

  rev = digits.reverse.join.to_i

  if digits[0] == digits[-1]
    $data[d - 3] + digits[1...-1].join.to_i * 2 + 3
  elsif num < rev
    $data[d - 3]
  else
    $data[d - 2]
  end
end

puts (1..n).inject(0) { |sum, i| sum + f(i) }


Measured memory_bytes: 2044
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
    a:i64,
        }
    println!("{}", if a == 0 { 1 } else { 0 });
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <cstring>
#include <utility>
#include <cmath>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define F first
#define S second 
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"


void print() { cout << endl; }

template <typename T, typename... Types>
void print(T arg, Types... args) {
    cout << arg << " ";
    print(args...);
}

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef vector < int > vi;

const int mod = 1e9 + 7;
const int N = 2e5 + 7;


ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}
 
 
ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
 
ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}
 
bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}



int main()
{
    IOS;
    int n;
    cin >> n;
    vector<string> dp(10);
    dp[1] = '1';
    for (int i = 2; i < 10; i++)
    {
        dp[i] = ('0' + i);
    }
    int cur = 1, i = 10;
    while (i < n+5)
    {
        int l = dp[cur].size()-1;
        char x = dp[cur][l];
        for (char k = x-1; k <= x+1; k++)
        {
            if (k <= '9' and k >= '0')
            {
                dp.push_back(dp[cur] + k);
                i++;
            }
        }
        cur++;
    }
    cout << dp[n] << endl;
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<vector<int>> A(2, vector<int> (N));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    vector<vector<int>> dp(2, vector<int> (N));
    dp[0][0] = A[0][0];
    dp[1][0] = dp[0][0]+A[1][0];
    for (int i = 1; i < N; i++) {
        dp[0][i] = dp[0][i-1] + A[0][i];
    }
    for (int i = 1; i < N; i++) {
        dp[1][i] = max(dp[1][i-1], dp[0][i]) + A[1][i];
    }
    cout << dp[1][N-1] << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int H = sc.nextInt();
        int S = sc.nextInt();
        int D = sc.nextInt();

        int N = sc.nextInt();

        long ans = 0;
        long Q1 = 4*Q;
        long H1 = 2*H;
        long S1 = 1*S;
        long min1 = Math.min(Math.min(Q1, H1), S1);
        // 2l price
        if (N >= 2) {
            long min2 = Math.min(min1 * 2, D); 
            ans = (N/2) * min2;
            N %= 2;
        }   

        if (N == 1) {
            ans += min1;
        }   

        System.out.println(ans);
    
        return;
    }   

}


Measured memory_bytes: 21716
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int n,h[100000],i,mx,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	cnt=0;
	mx=0;
	for(i=0;i<n-1;i++){
		if(h[i]>=h[i+1]){
			cnt++;
			mx=max(mx,cnt);
		}
		else{
			cnt=0;
		}
	}
	printf("%d\n",mx);
	return 0;
}

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

int main(){
	int n,ans=0,cnt=0;
	string s;
	cin>>n>>s;
	for(int i=1; i<n; i++){
		set<int> x,y;
		cnt=0;
		for(int j=0; j<i; j++)x.insert(s[j]);
		for(int j=i; j<n; j++)y.insert(s[j]);
		for(auto q:x)if(y.count(q))cnt++;
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k;
  cin>>n>>k;
  vecll p(n);
  for(auto&&e:p){
    cin>>e;
    --e;
  }
  vecll c(n);
  for(auto&&e:c)cin>>e;
  UnionFind uf(n);
  REP(i,n) {
    uf.merge(i, p[i]);
  }
  map<int,ll> sz;
  REP(i,n) {
    ++sz[uf.root(i)];
  }
  vector dp(n+1, vecll(n, 0));
  vecint to(n);
  iota(ALL(to), 0);
  REP(i,n) {
    REP(j,n) {
      to[j] = p[to[j]];
      dp[i+1][j] = dp[i][j] + c[to[j]];
    }
  }
  ll mx = -1e10;
  REP(i,n) {
    ll lsz = sz[uf.root(i)];
    ll score = 0;
    bool ok_0 = false;
    ll my_k = k;
    if (my_k >= 2 * lsz){
      ll loop = my_k / lsz - 1;
      if (dp[lsz][i] >= 0) {
        score += dp[lsz][i] * loop;
        ok_0 = true;
      }
      my_k -= loop * lsz;
    }
    FOR(j,0,my_k+1) {
      if (j == 0 && !ok_0) continue;
      if (j <= lsz) {
        mx = max(mx, score + dp[j][i]);
      } else {
        mx = max(mx, score + dp[lsz][i] + dp[j-lsz][i]);
      }
    }
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 199008
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main(){
    int t;
    cin >> t;
    long long sum=0;
    for (int i=1; i<=t; i++){
        if (i%3!=0 ){
            if (i%5!=0 ){
                sum+=i;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n],sub[n];
    //memset(arr,0,n);
    memset(sub,0,n);
    int t;
    cin>>t;
    int mn = 1000000007;
    for(int i=0;i<n;i++)
    {
        int tmp;
        cin>>tmp;
        mn = min(tmp,mn);
        sub[i] = abs(tmp-mn);
    }
    sort(sub,sub+n);
    reverse(sub,sub+n);
    int cnt = 1;
    for(int i=0;i<n;i++)
    {
       if(sub[i]==sub[i+1])
        cnt++;
       else{
        cout<<cnt<<endl;
        return 0;
       }
    }
    cout<<cnt<<endl;

}


Measured memory_bytes: 640