akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
//Optimizations
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//save time
#define endl '\n'
#define db(x) cerr << "> " << #x << ": " << x << endl
typedef long long ll;
 
//for sorting
#define all(a) a.begin(),a.end()
 
//Constants
#define PI   3.141592653593
#define MOD  1000000007LL
#define EPS  0.000000001
#define INF  0X3f3f3f3f
 
//loops
#define REP(i,n) 	    for(int i=0;i<(n);++i)
#define FOR(i,a,b)      for(int i=(a);i<(b);++i)
#define DFOR(i,a,b)     for(int i=(a);i>=(b);--i)
 
//vectors
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int>>
#define vlll vector<pair<ll,ll>>
#define pb 	push_back
 
//pairs
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define F first
#define S second
 
//fast I/O
#ifndef _WIN32
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
#define gc getchar
#define pc putchar
 
//If using cin and cout
#define IOS ios::sync_with_stdio(false)
#define TIE cin.tie(NULL);cout.tie(NULL)
 
//queue
#define di deque<int>
#define dll deque<ll>
#define qi queue<int>
#define PQ priority_queue
 
//general
#define E empty()
 
//Declare all variables and methods needed between this comment and the next one(OCD lol)
void solve(){

}
const int MAXN=1000;

int main(){
    int n , m ; cin >> n >> m;
    vector<string> g(n);
    vector<vi> dp(n, vi(m,0));
    REP(i,n)
    cin >> g[i];
    dp[0][0]=1;
    REP(i,n){
        REP(j,m){
            for(int row : {i, i+1}){
                int col = j;
                if(row == i)col++;
                if(row< n && col < m && g[row][col] == '.'){
                    dp[row][col]+=dp[i][j];
                    dp[row][col]%=MOD;
                }
            }
        }
    }
    cout << dp[n-1][m-1] << endl;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=k;i<n;i++){
    if(a[i]>a[i-k])
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 4372
import * as fs from "fs"

const process = (a: number, b: number): string => {
  const sum = a + b
  const sub = a - b
  const multi = a * b
  if (sum > sub && sum > multi) {
    return sum + ""
  }
  if (sub >= sum && sub > multi) {
    return sub + ""
  }
  return multi + ""
}

const Main = (input: string): string => {
  const a: string[] = input.split(" ")
  const na: number[] = a.map((e) => parseInt(e))

  const res = process(na[0], na[1]) + ""
  console.log(res)
  return res
}
Main(fs.readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int N, K, Q; cin >> N >> K >> Q;
    int answer[100010];
    REP(i, 100010) answer[i] = K;
    REP(i, Q){
        int tmp; cin >> tmp;
        answer[tmp - 1]++;
    }
    REP(i, N){
        if(answer[i] - Q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


}

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

int main(){

  long long A,B,c,tmp;
  long long ans;
  cin >> A >> B;
  ans = A*B;
  if(B>A) swap(A, B);
  while(A%B){
    c = A%B;
    A %= B;
   tmp = A;
   A = B;
   B = tmp;
  }
  cout << ans/B << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 55;

ll n, k, a[N], dp[N][N * N][N];

ll solve(int i, int sum, int cnt) {
    if (i == n) 
        return cnt && sum % cnt == 0 && 
            sum / cnt == k ? 1 : 0;
    ll& ret = dp[i][sum][cnt];
    if (~ret)
        return ret;
    ret = solve(i + 1, sum, cnt) + 
        solve(i + 1, sum + a[i], cnt + 1);
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n >> k;

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

    memset(dp, -1, sizeof(dp));

    cout << solve(0, 0, 0) << endl;
}


Measured memory_bytes: 71808
{-# LANGUAGE RankNTypes #-}
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import Control.Monad.State
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = readContents 2 >>= print . solve

solve :: [[Int]] -> Int
solve [[n, x0], ss] = runST (initialize >>= evalMemo calc (x0, 0))
    where
        initialize :: forall s. ST s (Table s (Int, Int) Int)
        initialize = newArray ((0, 0), (x0, n)) Nothing
        vs = V.fromList $ sortBy (flip compare) ss
    
        calc f (x, i)
            | i < n = add <$> a <*> b
            | otherwise = return x
            where
                a = f (x `mod` (vs V.! i), i + 1)
                b = (mul (n - i - 1)) <$> f (x, i + 1)

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

infixl 6 `add`
infixl 7 `mul`

add :: Int -> Int -> Int
add x y = val $ x + y

mul :: Int -> Int -> Int
mul x y = val $ x * y

inv :: Int -> Int
inv x = pow x $ modVal - 2

pow :: Int -> Int -> Int
pow b e
    | e == 0 = 1
    | odd e = mul b . pow b $ e - 1
    | otherwise = mul v v
    where
        v = pow b $ e `div` 2

val :: Int -> Int
val = (`mod` modVal)

modVal :: Int
modVal = 10 ^ 9 + 7

primes :: [Int]
primes = build [2..]
    where
        build (x : xs) = x : build (filter (\n -> n `mod` x /= 0) xs)
        
isPrime :: Int -> Bool
isPrime n = check primes
    where
        check (x : xs)
            | x == n = True
            | x > n = False
            | otherwise = check xs


type Table s a b = STArray s a (Maybe b)
type Memo s a b = a -> StateT (Table s a b) (ST s) b

evalMemo :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> a -> Table s a b -> ST s b
evalMemo f k = evalStateT (memoizeFix f k)

memoizeFix :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> forall s. Memo s a b
memoizeFix f k = get >>= (\arr -> (lift $ readArray arr k) >>= maybe (f (memoizeFix f) k >>= ((<$) <*> (lift . writeArray arr k . Just))) return)

Measured memory_bytes: 480124
<>;($x,$y)=glob,printf"%f\n",sort{$b<=>$a}0,map+(-$~+($~=$_))/$P-.5,(@b=sort{$a<=>$b}map+(/ /*atan2$'-$y,$`-$x)x!/^$x $y/,@a),"@b"+($P=6.2831853)for@a=<>

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


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

  for(int k=0;k<10;++k){
    for(int i=0;i<10;++i){
      for(int j=0;j<10;++j){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  int ans=0;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      int a;
      cin >> a;
      if(a>=0){
        ans+=c[a][1];
      }
    }
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

map<PLL,bool> mp;

bool dfs(ll x, ll y){
  if(x<y) swap(x,y);

  if(mp.count(PLL(x,y))) return mp[PLL(x,y)];

  repp(i,1,x/2) if(!dfs(x-2*i,y+i)) return mp[PLL(x,y)] = true;
  repp(i,1,y/2) if(!dfs(x+i,y-2*i)) return mp[PLL(x,y)] = true;

  return mp[PLL(x,y)] = false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll X,Y;cin >> X >> Y;
  if(abs(X-Y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String[] word = new String[n];
        boolean jdg = true;
        for(int i = 0;i < n;i++)
            word[i] = sc.next();

        for(int i = 0;i < n;i++){
            for(int j = i+1;j < n;j++){
                if(word[i].equalsIgnoreCase(word[j])){
                    jdg = false;
                    break;
                }
            }
            if(jdg == false)
            break;
        }

        if(jdg == true){
            for(int i = 0;i < n-1;i++){
                if(word[i].charAt(word[i].length()-1) != word[i+1].charAt(0)){
                    jdg = false;
                    break;
                }
            }
        }
        System.out.println(jdg == true?"Yes" : "No");
        
    }
}

Measured memory_bytes: 21332
N,M = map(int,input().split())
#ks[i][0]がk_i
ks = [[int(i) for i in input().split()]for i in range(M)]
p=list(map(int,input().split()))
ans=0
for i in range(2**N):
    flag=0
    #Onoff[i]=0はスイッチiのOFFを、=1はONを表す
    OnOff = [0]*N
    for j in range(N):
        if (i>>j) & 1:
            OnOff[j]=1
    
    for j in range(M):
        count=0
        for l in range(1,len(ks[j])):
            if(OnOff[ks[j][l]-1]==1):#-1に注意（スイッチxはOnOff[x-1]に対応）
                count+=1
        if(p[j]==0 and count%2==0):
            flag+=1
        elif(p[j]==1 and count%2==1):
            flag+=1
        else:
            pass
    #全ての電球が点くならばansに+1
    if(flag==len(p)):
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    long long sum=0;
    cin>>n>>m;
    priority_queue<int>Q;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        Q.push(a);
    }
    for(int i=0;i<m;i++){
        int t=Q.top();
        Q.pop();
        t/=2;
        Q.push(t);
    }
    for(int i=0;i<n;i++){
        sum+=Q.top();
        Q.pop();
    }
    cout<<sum<<"\n";
    return(0);
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		if (str.equals("A")) {
			System.out.println("T");
		} else if (str.equals("T")) {
			System.out.println("A");
		} else if (str.equals("C")) {
			System.out.println("G");
		} else {
			System.out.println("C");
		}
	}
}


Measured memory_bytes: 32504
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long [] L = new long[n];
        for(int i=0;i<n;i++) L[i] = sc.nextLong();
        int q = sc.nextInt();
        for(int i=0;i<q;i++){
            int cmd = sc.nextInt();
            int b = sc.nextInt();
            int e = sc.nextInt();
            long opt = L[b];
            if(cmd==0){
                for(int j=b+1;j<e;j++) if(opt>L[j]) opt = L[j];
            }
            else {
                for(int j=b+1;j<e;j++) if(opt<L[j]) opt = L[j];
            }

            System.out.println(opt);
        }
    }
}


Measured memory_bytes: 33620
#include<stdio.h>
int main(){
    int a,i,n,b,s;
    double w;
    b=-1000000;
    s=1000000;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        if(a<s)
            s=a;
        if(b<a)
            b=a;
        w=w+a;
    }
    printf("%d %d %.0lf\n",s,b,w);
    return 0;
}

Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/***********************/

int main(){
    ssd;
    long double a,b,c;
    cin>> a>> b >>c;
    if( ( a+b+2.0*sqrt(a*b) )< c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $N,$L);

$sum = 0;
$now=$L;
$mi=1000;
for($i=0;$i<$N;$i++){
  $now=$L+$i;
  $sum +=$now;
  if(abs($mi)>abs($now)){
    $mi=$now;
  }
}

  echo  ($sum-$mi)."\n";

 
?>

Measured memory_bytes: 4728
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n,W;
  cin>>n>>W;
  int v[n],w[n];
  for(int i=0;i<n;i++) cin>>v[i]>>w[i];
  int dp[n+1][W+1];
  memset(dp,0,sizeof(dp));
  for(int i=0;i<n;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i]) dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
    }
  }
  cout<<dp[n][W]<<endl;
}


Measured memory_bytes: 7064
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
namespace one {
  int a, b, c, d, k;

  inline int gao(int a, int b) {
    return ceil(1.0 * max(a, b) / (min(a, b) + 1));
  }
  
  inline bool check(int mid) {
    int ra = a - mid * k;
    int rb = b - mid * 1;
    return gao(ra, rb + (!!mid)) <= k;
  }

  inline void doit(int cut) {
    vector<int> ans;
    int r = cut * (k + 1);
    // cout << " r = " << r << "\n";
    // AAAAABAAAAAB
    if (c <= r) {
      for (int i = c; i <= min(d, r); i ++)
        ans.push_back((i - 1) % (k + 1) == k);
    }
  
    // for (int i : ans) putchar(i + 'A'); putchar('\n');
  
    // AAAAABBBBBBB
  
    int ra = a - cut * k;
    int rb = b - cut * 1;
    int up = ceil(1.0 * rb / k) - 1;
    ra -= up; rb -= up * k;
    for (int i = max(c, r + 1); i <= min(d, r + 1 + ra - 1); i ++)
      ans.push_back(0);
    for (int i = max(c, r + 1 + ra - 1 + 1); i <= min(d, r + 1 + ra - 1 + 1 + rb - 1); i ++)
      ans.push_back(1);

    // ABBBBBABBBBB
  
    int pos = r + 1 + ra - 1 + 1 + rb - 1 + 1;
    for (int i = max(c, pos); i <= min(d, a + b); i ++)
      ans.push_back((i - pos) % (k + 1) != 0);

    for (int i : ans) putchar(i + 'A'); putchar('\n');
  }

  void main(void) {
    read(a); read(b); read(c); read(d);
    k = gao(a, b);
    int l = 0, r = min(b, a / k);
    while (l < r) {
      int mid = l + (r - l + 1) / 2;
      if (check(mid)) l = mid;
      else r = mid - 1;
    }
    // cout << (gao(4, 8) <= k) << "\n";
    // cout << check(2) << " " << check(6) << "\n";
    // cout << l << "\n";
    doit(l);
  }
}

main(void) {
  int T; for(read(T); T --; one::main());
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
const int N = 1e6;
ll fac[N],inv[N];
ll binpow(ll a,ll pow)
{
	ll res = 1ll;
	while(pow)
	{
		if(pow&1)		res = (res*a)%mod;
		a = (a*a)%mod;
		pow/=2;		
	}
	return res;
}
void build()
{
	fac[0] = fac[1] = 1ll;
	for(int i=2;i<N;++i)		fac[i] = (fac[i-1]*i)%mod;
	inv[N-1] = binpow(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--)		inv[i] = (inv[i+1]*(i+1))%mod;
}
ll nCk(int n,int k)
{
	return fac[n]*inv[k]%mod*inv[n-k]%mod;
}
int main()
{
	build();
	int i,j,n,k;
	cin>>n>>k;
	ll ans = 0ll;
	ll dp[k+1];
	for(i=0;i<=k;++i)		dp[i] = 0ll;
	for(i=k;i>=1;i--)
	{
		int d = k/i;
		dp[i] = binpow(d,n);
		for(j=i*2;j<=k;j+=i)
		{
			dp[i] = (dp[i] - dp[j] + mod)%mod;
		}
		ans = (ans + i*dp[i])%mod;
	}
/*	for(i=1;i<=k;++i)
	{
		int d = k/i;
		ans = (ans + binpow(d,n))%mod;
	}		*/
	cout<<ans;
}

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

int main() {
    int h,w;
    cin >> h >> w;
    char c[h][w];
    char d[h*2][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
            d[2*i][j]=c[i][j];
            d[2*i+1][j]=c[i][j];
        }
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cout << d[i][j];
            if(j==w-1){
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 256
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""

N = int(input())
mp = [[0 for j in range(10)]for i in range(10)]
for i in range(1,N+1):
	j = i
	while j >= 10:
		j //= 10
	mp[j][i%10] += 1
ans = 0
for i in range(1,10):
	for j in range(1,10):
		ans += mp[i][j]*mp[j][i]
print(ans)

Measured memory_bytes: 4464
//
//  Created by Ruslan Jankurazov.
//  Copyright © 2018 Ruslan Jankurazov. All rights reserved.
//

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int

using namespace std;


int main() {
#define FILE_INPUT 0
#define FILE ""
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if (k == 0) {
        cout << n*n;
        return 0;
    }
    for (ll i = 1; k + i <= n; ++i) {
        ll e = k + i;
        ans += (n/e)*i + (n%e >= k?n%e - k + 1:0);
    }
    cout << ans;
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	
	cin >> n;
	
	vector<int> seq(n, 0);
	int __max__ = -1;
	
	for(int i = 0; i < n; ++i)
	{
		int brick;
	
		cin >> brick;
		
		if(brick == 1)
        {
			 seq[brick - 1] = 1;
			__max__ = max(__max__, 1);
        }
      
		else if(seq[brick - 2])
		{
			seq[brick - 1] = seq[brick - 2] + 1;
			__max__ = max(__max__, seq[brick - 1]);	
		}
	}
	
	if(__max__ == -1)
		cout << -1 << '\n';
	
	else
		cout << n - __max__ << '\n';
	
	return 0;	
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    V<bool> b(n,0);
    ll ans=0;
    ll cnt=0;
    for(int i=0;i<n;i++){
        ans+=a[i]/2;
        if(a[i]==0){
            ans+=cnt/2;
            cnt=0;
        }
        if(a[i]%2==1) cnt++;
    }
    ans+=cnt/2;
    cout<<ans<<endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const f64 PI = acos(-1);
f64 a, b, x;

f64 ang(f64 x) {
  return x * 180 / PI;
}

f64 solve1() {
  f64 lb = 0;
  f64 ub = 0.5 * PI;

  while (ub - lb > 0.000000001) {
    f64 mid = (lb + ub) / 2;

    if (x > (a * a * b - 0.5 * a * a * a * tan(mid))) {
      ub = mid;
    } else {
      lb = mid;
    }
  }

  return ang(ub);
}

f64 solve2() {
  // 体積半分以下
  f64 lb = 0;
  f64 ub = atan(a / b);

  while (ub - lb > 0.000000001) {
    f64 mid = (lb + ub) / 2;

    if (x < 0.5 * a * b * b * tan(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }

  return (90 - ang(ub));
}

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

  f64 ans;
  f64 v = 0.5 * a * a * b;
  if (x == v) {
    ans = ang(atan(a / b));
  } else if (x > v) {
    ans = solve1();
  } else {
    ans = solve2();
  }

  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Point struct {
	X, Y int
}

const Inf = 1 << 60

func main() {
	N := ReadInt()
	points = make([]*Point, N)
	for i := 0; i < N; i++ {
		points[i] = &Point{
			X: ReadInt(),
			Y: ReadInt(),
		}
	}

	v1 := make([]int, N)
	v2 := make([]int, N)
	for i := 0; i < N; i++ {
		v1[i] = points[i].X + points[i].Y
		v2[i] = points[i].X - points[i].Y
	}

	sort.Ints(v1)
	sort.Ints(v2)

	// v := []int{
	// 	v1[N-1],
	// 	-v1[0],
	// 	-v2[0],
	// 	v2[N-1],
	// }
	// max := -Inf
	// for i := 0; i < 4; i++ {
	// 	for j := 0; j < 4; j++ {
	// 		max = Max(max, v[i]-v[j])
	// 	}
	// }

	vv := []int{
		v1[N-1] - v1[0],
		-v2[0] - -v2[N-1],
		v2[N-1] - v2[0],
		-v1[0] - -v1[N-1],
	}
	fmt.Println(Max(vv...))
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var points []*Point

func dist(i, j int) int {
	return Abs(points[i].X-points[j].X) + Abs(points[i].Y-points[j].Y)
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    
    ll d = c - a - b;
    
    if (d > 0 && d * d > 4 * a * b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

void solve(long long N, std::vector<long long> d)
{
    vector<long long> d2(N, 0);
    for (size_t i = 0; i < N; i++)
    {
        d2[i] = d[i] * d[i];
    }

    long long sum1 = 0LL, sum2 = 0LL;
    for (size_t i = 0; i < N; i++)
    {
        sum1 += d[i];
        sum2 += d2[i];
    }

    cout << (sum1 * sum1 - sum2) / 2LL << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> d(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int ok;
int main() {
	cin >>s;
	for(int i = 0;i < s.length();++i)
		if(s[i] == '7') ok = 1;
	puts(ok ? "Yes" : "No");
	return 0;
}


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

int main() {
  	int N, K;
  	cin >> N >> K;
  	int d[K];
  	int A[500][500];
  
  	long long int num[N];
  	for (int i = 0; i < N; i++){
      	num[i] = 0;
    }
  
  	for (int i = 0; i < K; i++){
      	cin >> d[i];
      	for (int j = 0; j < d[i]; j++){
          	cin >> A[i][j];
          	num[A[i][j] - 1]++;
        }
    }
  
  	int res = 0;
  	for (int i = 0; i < N; i++){
      	if (num[i] == 0) res++; 
    }
  
  	cout << res << endl;
}

Measured memory_bytes: 3796
ls=list(input())
r_count=0
l_count=0
ans_ls=[]

for i,s in enumerate(ls[:-1]):
    ans_ls.append(0)
    if s=="R":
        r_count+=1
        if ls[i+1]=="L":
            r_idx=i
            l_idx=i+1
    elif s=="L":
        l_count+=1
        if ls[i+1]=="R":
            ans_ls[r_idx]=(r_count+1)//2+l_count//2
            ans_ls[l_idx]=r_count//2+(l_count+1)//2
            r_count,l_count=0,0
    if i+2==len(ls):
        l_count+=1
        ans_ls.append(0)
        ans_ls[r_idx]=(r_count+1)//2+l_count//2
        ans_ls[l_idx]=r_count//2+(l_count+1)//2
print(" ".join(list(map(str,ans_ls))))

Measured memory_bytes: 54668
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<char>poss;
map<char,int>m;
int n,k,r,s,p;
const int N=1e5+510;
int dp[N][3];
int score(char x,char y)
{
    if(x=='p' && y=='r')   return p;
    if(x=='r' && y=='s')   return r;
    if(x=='s' && y=='p')   return s;
    return 0;  
}
int func(int index,char curr,string &str)
{
    if(index==str.size()){
        return 0;
    }
    if(dp[index][m[curr]]!=-1) return dp[index][m[curr]];
    int ans=0;
    for(auto x:poss){
        if(x!=curr)    ans=max(ans,score(curr,str[index])+func(index+1,x,str));
    }
    return dp[index][m[curr]]=ans;
}
main() 
{
    poss.push_back('r');poss.push_back('p');poss.push_back('s');
    m['r']=0;m['p']=1;m['s']=2;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    int ans=0;
    for(int i=0;i<k;i++){
        string str="";
        for(int j=i;j<n;j+=k){
            str+=t[j];
        }
        for(int i=0;i<(int)str.size()+5;i++){
            for(int j=0;j<3;j++)
                dp[i][j]=-1;
        }
        int temp=0;
        for(auto x:poss){
            for(auto y:poss)
                if(y!=x){
                    
                    temp=max(temp,score(x,str[0])+func(1,y,str));
                }
        }
        ans+=temp;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 15232
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	k := getNextInt(scanner)

	cake := makeInts(h, w)
	for i := 0; i < h; i++ {
		s := getNextString(scanner)
		for j := 0; j < w; j++ {
			if s[j] == '.' {
				cake[i][j] = 0
				continue
			}
			cake[i][j] = k
			k--
		}
		for j := 1; j < w; j++ {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i][j-1]
			}
		}
		for j := w - 2; j >= 0; j-- {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i][j+1]
			}
		}
	}

	for i := 1; i < h; i++ {
		for j := 0; j < w; j++ {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i-1][j]
			}
		}
	}
	for i := h - 2; i >= 0; i-- {
		for j := 0; j < w; j++ {
			if cake[i][j] == 0 {
				cake[i][j] = cake[i+1][j]
			}
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			fmt.Fprint(writer, cake[i][j])
			if j < w-1 {
				fmt.Fprint(writer, " ")
			}
		}
		fmt.Fprintln(writer, "")
	}

	writer.Flush()
}

func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	int a,b;
	cin>>a>>b;
	if(a*b%2==1)
		printf("Yes\n");
	else
		printf("No\n"); 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <limits>
using namespace std;

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

if(a+b<a+c&&a+b<b+c)
   cout<<a+b;
else if(b+c<a+c)
    cout<<b+c;
else
   cout<<a+c;
}

Measured memory_bytes: 3580
def main(k):
    r0 = 7 % k
    if r0 == 0:
        print(1)
        return
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    rs = [r0]
    while True:
        ri = (10 * rs[-1] + r0) % k
        if ri == 0:
            break
        rs.append(ri)
        if len(rs) >= 3 and rs[-1] == rs[-2] == rs[-3]:
            print(-1)
            return
    print(len(rs) + 1)


main(int(input()))

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	bool res = true;
	for (int i = 0; i < n; i++) {
		int a = ri();
		if (a % 2 == 0 && a % 3 && a % 5) res = false;
	}
	puts(res ? "APPROVED" : "DENIED");
	return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

struct IDX{
	int P; vector<int> val;
	IDX() {}
	IDX(vector<int> nr) {
		int n = SZ(nr);
		for(P=1; P<n; P<<=1);
		val = vector<int>(2*P, INF);
		for(int i=0; i<P; i++) val[P+i] = (i<n ? nr[i] : INF);
		for(int i=P-1; i>=1; i--) val[i] = min(val[i*2], val[i*2+1]);
	}
	int getMin(int a, int b) {
		int res = INF;
		for(a+=P, b+=P; a<=b; a>>=1, b>>=1) {
			if(a%2==1) res = min(res, val[a++]);
			if(b%2==0) res = min(res, val[b--]);
		}
		return res;
	}
};

IDX idx[2];
int N, Nr[MAX_N], Re[MAX_N];
struct NODE{
	int l, r, a, b;
	NODE(int lv, int rv) : l(lv), r(rv) {
		a = Re[idx[l%2].getMin(l/2, (r-1)/2)];
		b = Re[idx[r%2].getMin((a+1)/2, r/2)];
	}
	pi getLR() const {return pi(l, r);}
	pi getAB() const {return pi(a, b);}
	bool operator<(const NODE &o) const{return Nr[a] > Nr[o.a];}
};
int main() {
	vector<int> nr[2];
	cin >> N; for(int i=0; i<N; i++) scanf("%d", &Nr[i]), Re[Nr[i]] = i, nr[i%2].push_back(Nr[i]);
	for(int k=0; k<2; k++) idx[k] = IDX(nr[k]);
	priority_queue<NODE> Q;
	Q.emplace(0, N-1);
	while(!Q.empty()) {
		int l, r; tie(l, r) = Q.top().getLR(); 
		int a, b; tie(a, b) = Q.top().getAB(); Q.pop();
		printf("%d %d ", Nr[a], Nr[b]);
		pi val[3] = {pi(l, a-1), pi(a+1, b-1), pi(b+1, r)};
		for(int k=0; k<3; k++) {
			int x, y; tie(x, y) = val[k];
			if(x > y) continue;
			Q.emplace(x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 7016
#pragma region include
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <map>
    #include <string>
    #include <queue>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <cstdio>
    #define ALL(obj) (obj).begin(),(obj).end()
    #define RALL(obj) (obj).rbegin(),(obj).rend()
    #define REP(i, n) for(int i = 0; i < n; i++)
    #define REPR(i, n) for(int i = n; i >= 0; i--)
    #define FOR(i, m, n) for(int i = m; i < n; i++)
    #define MOD 1000000007
    #define INF 1000000000
    #define LLINF 4000000000000000000
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    #pragma endregion
     
    //#define __DEBUG__
    #ifdef  __DEBUG__
    #define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
    // vector出力
    template<typename T>
    ostream& operator << (ostream& os, vector<T>& v) {
        os << "{";
        REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
        os << "}";
        return os;
    }
    // pair出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, pair<T, U>& p) {
        return os << "(" << p.first << ", " << p.second << ")";
    }
    // map出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, map<T, U>& map_var) {
        os << "{";
        for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
            os << "(" << itr->first << ", " << itr->second << ")";
            itr++;
            if (itr != map_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    // set 出力
    template<typename T>
    ostream& operator << (ostream& os, set<T>& set_var) {
        os << "{";
        for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
            os << *itr;
            ++itr;
            if (itr != set_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    #endif
     
    int main() {
        cin.tie(0); ios::sync_with_stdio(false);
        int N, K;
        string S;
        cin >> N >> K >> S;
        S[K-1] = (char)(S[K-1] - 'A' + 'a');
        cout << S << endl;
        getchar(); getchar();
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int A,B;
    cin >> A >> B;
    bool ok = false;
    for(int i = 1; i <= 3; i++) {
        if((A*B*i)%2 != 0) ok = true;
    }
    cout <<(ok ? "Yes" : "No")<< endl;
}


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

int main(void)
{
	int N;
	string lottery ;
	set<string> item;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>lottery;
		item.insert(lottery);
	}
	
	cout<<item.size();
}


Measured memory_bytes: 19264
n, m = list(map(int, input().split(" ")))

def clc(n, m):
  s_c = {}
  for _ in range(m):
    s, c = list(map(int, input().split(" ")))
    if c == 0:
      if n in (2, 3) and s == 1:
        return -1
    if s not in s_c:
      s_c[s] = c
    else:
      if s_c[s] != c:
        return -1
  if n == 1:
    number = [0]
  elif n == 2:
    number = [1, 0]
  elif n == 3:
    number = [1, 0, 0]

  for i in range(n):
    j = i + 1
    if j in s_c:
      number[i] = s_c[j]
  return "".join(map(str, number))
r = clc(n,m)
if r == -1:
  print(-1)
else:
  print(r)
  


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <deque>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    int n, p;
    while (cin >> n >> p) {
        string s;
        cin >> s;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            a[i] = s[i] - '0';
        }
        ll ans = 0;
        if (p == 2 || p == 5) {
            for (int i = 0; i < n; ++i) {
                if (a[i] % p == 0) {
                    ans += i + 1;
                }
            }
        } else {
            vector<int> b(n);
            int d = 1;
            for (int i = n - 1; i >= 0; --i) {
                b[i] = (a[i] * d) % p;
                d = (d * 10) % p;
            }
            vector<int> s(n);
            for (int i = 1; i < n; ++i) {
                b[i] += b[i - 1];
                b[i] %= p;
            }
            vector<int> c(p, 0);
            c[0] = 1;
            for (int i = 0; i < n; ++i) {
                ans += c[b[i]]++;
            }
        }
        cout << ans << "\n";
    }



    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


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

#define MOD 1'000'000'007

char s[1000001];

inline long long p0w(long long n, long long k)
{
    if (k == 0) return 1;
    else if (k == 1) return n;
    else if (k % 2) return p0w(n, k - 1) * n % MOD;
    else
    {
        auto h = p0w(n, k / 2);
        return h * h % MOD;
    }
}

int main()
{
    int k;
    scanf("%d %s", &k, &s);
    int l = strlen(s);
    long long r = 0;
    long long c = 1;
    for (int a = 0; a <= k; a++)
    {
        if (a != 0)
        {
            c = c * (l + a - 1) % MOD;
            c = c * p0w(a, MOD - 2) % MOD;
        }
        r = (r + p0w(25, a) * p0w(26, k - a) % MOD * c % MOD) % MOD;
    }
    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;
int a[100010];
int f,d,o;
signed main(){
  int n;
  cin>>n;
  rep(i,n)cin>>a[i];

  rep(i,n){
    if(a[i]%4==0){
      f++;
    }else if(a[i]%2==0){
      d++;
    }
  }
  o=n-f-d;

  o-=f;
  if(o>=2 || (o==1 && d>0)){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }

}


Measured memory_bytes: 1024
N=int(input())
S=input()
ans = 0
for i in range(1,N):
    tmp1 = S[0:i]
    tmp2 = S[i:N+1]
    count=0
    for j in set(tmp1):
        if j in tmp2:
            count+=1
    ans = max(ans,count)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
 
#define PI 3.141592653689793238
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
 
using namespace std;
 
int main(void){
    double a, b, x;
    cin>>a>>b>>x;
    if(a*a*b/2<=x){
        double height = (2*a*a*b-2*x)/(a*a);
        cout << setprecision(20)<<atan(height/a)*180/PI << endl;
    }
    else{
        double height = (x*2)/(b*a);
        cout<<setprecision(20)<<atan(b/height)*180/PI<<endl;
    }
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    char c[3][3];
    rep(i, 3)rep(j, 3) cin >> c[i][j];
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  string S = "No";
  for (int f=0; f<=N; f+=4) {
    for (int s=0; f+s<=N; s+=7) {
      if(N == f+s ) S = "Yes";
    }
  }

  cout << S << endl;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;



struct Sol {
    int w, s;
};

bool operator<(const Sol &x, const Sol &y) {
    bool ok = x.s * (y.w + y.s) < y.s * (x.w + x.s);
    return ok;
}

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;


    auto gw = [&](int ai, int bi) -> int {
        int ua = ai * 100 * a;
        int ub = bi * 100 * b;
        return ua + ub;
    };

    auto gs = [&](int ci, int di) -> int {
        int s = ci * c + di * d;
        return s;
    };

    auto g = [&](int ai, int bi, int ci, int di) -> int {
        int w = gw(ai, bi);
        int s = gs(ci, di);
        return w + s;
    };

    auto check_rate = [&](int ai, int bi, int ci, int di) -> bool {
        int w = gw(ai, bi);
        int s = gs(ci, di);
        int t = e * (s + w);
        int u = (100 + e) * s;
        return u <= t;
    };

    Sol ans = {a * 100, 0};

    for (int ai = 0; g(ai, 0, 0, 0) <= f; ai++) {
        for (int bi = 0; g(ai, bi, 0, 0) <= f; bi++) {
            if (ai + bi == 0) continue;
            for (int ci = 0; g(ai, bi, ci, 0) <= f && check_rate(ai, bi, ci, 0); ci++) {
                for (int di = 0; g(ai, bi, ci, di) <= f && check_rate(ai, bi, ci, di); di++) {
                    Sol now = {gw(ai, bi), gs(ci, di)};
                    cmax(ans, now);
                }
            }
        }
    }

    cout << ans.w + ans.s << ' ' << ans.s << endl;

}

Measured memory_bytes: 3624
import bisect
s = list(input())
t = list(input())
ls = len(s)
check = [[] for i in range(26)]
for i in range(len(s)):
    o = ord(s[i])-ord("a")

    check[o].append(i+1)
ans = 0
c1 = 0

for i in t:
    o =ord(i)-ord("a")
    if check[o]:
        x = bisect.bisect_right(check[o],ans) 
        if x == len(check[o]):
            c1 += 1
            ans = check[o][0]
        else:
            ans = check[o][x]
            

    else:
        print(-1)
        exit()
 
print(ans+c1*ls)


Measured memory_bytes: 60576
N, M, X, Y = list(map(int,input().split(' ')))
x = list(map(int,input().split(' ')))
y = list(map(int,input().split(' ')))

ans = 'War'
for i in range(X+1,Y+1):
  if  max(x) < i <= min(y):
    ans ='No War'
    break
    

print(ans)    
    
    
    
    
  


Measured memory_bytes: 3060
use std::io::*;
use std::str::*;

fn main() {
    let n: u32 = read_one();
    let mut result = false;
    for s in 0..26 {
        for t in 0..15 {
            result |= 4 * s + 7 * t == n;
        }
    }
    println!("{}", if result {"Yes"} else {"No"})
}

fn read_one<T: std::str::FromStr>() -> T {
    let mut s = stdin().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v;
    pair<string, long long> n;
    set<string> y;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=1,l=0,r=0,z,m,h,p;
    string t,s,x;
    double q,u;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main()
{
long long i,N,K,n;
cin >> N >> K;
n==0;
for (long long i=K+1; i<=N; i=i+1 ){
n=n+(N-N%i)*(i-K)/i;
if(N%i-K>=0){
n=n+N%i-K+1;
if(K==0){n=n-1;}
;}
;}
printf("%lld",n)
;}

Measured memory_bytes: 256
#include <stdio.h>
int abs(int a){
    if(a>0)return a;
    return -a;
}
int max(int a,int b,bool f){
    if((a<b)^f)return a;
    return b;
}
int n,a[5000],d[5000][2];
int dp(int now,int l,int r,bool f){
    if(now==n)return abs(l-r);
    if(d[now][f]!=-1)return d[now][f];
    int temp;
    if(!f){
        temp=dp(now+1,l,a[now],!f);
        for(int i=now+1;i<n;i++)temp=max(temp,dp(i+1,l,a[i],!f),f);
    }
    else{
        temp=dp(now+1,a[now],r,!f);
        for(int i=now+1;i<n;i++)temp=max(temp,dp(i+1,a[i],r,!f),f);
    }
    return d[now][f]=temp;
}
int main(){
    int l,r;
    scanf("%d%d%d",&n,&l,&r);
    for(int i=0;i<n;i++){scanf("%d",&a[i]);
        d[i][0]=d[i][1]=-1;
    }
    printf("%d\n",dp(0,l,r,true));
}

Measured memory_bytes: 256