akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
   int N;
   int A,B,C;
   scanf("%d",&N);
   if(N==1)
   {
      printf("Hello World\n");
   }
   else if(N==2)
   {
      scanf("%d%d",&A,&B);
      C=A+B;
      printf("%d\n",C);
   }
}

Measured memory_bytes: 128
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int[] c = new int[8];
        c[0] = 1;c[1] = 2;c[2] = 1;c[3] = 2;c[4] = 1;c[5] = 4;c[6] = 1;c[7] = 4;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            int[] b = a.Split(' ').Select(int.Parse).ToArray();
            int[] f = new int[3];
            f[0] = 1000000000;
            for (int i = 0; i < 8; i++)
            {
                int e = 0;
                char[] h = new char[8];
                for (int j = 0; j < 8; j++)
                {
                    int d = j + i;
                    if (d >= 8)
                        d -= 8;
                    int g = b[j] - c[d];
                    if (g < 0)
                        g = 0;
                    e += g;
                    h[j] = (char)(c[d] + '0');
                }
                if (f[0] > e)
                {
                    f[0] = e;
                    f[1] = i;
                    string k = new string(h);
                    f[2] = int.Parse(k);
                }
                if (f[0] == e)
                {
                    string k = new string(h);
                    int l = int.Parse(k);
                    if (f[2] > l)
                    {
                        f[1] = i;
                        f[2] = l;
                    }
                }
            }
            int m = f[1];
            for (int i = 0; i < 8; i++)
            {
                int n = m + i;
                if (n >= 8)
                    n -= 8;
                if (i == 0)
                    Console.Write(c[n]);
                else
                    Console.Write(" " + c[n]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9552
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
void plusle (int &a, int b) {
    if ((a += b) >= MOD ) a -= MOD;
}

void minun (int &a, int b) {
    if ((a -= b) < 0) a += MOD;
}
int add (int a, int b) {
    return ((a += b) >= MOD) ? a - MOD : a;
}
int sub (int a, int b) {
    return (( a -= b) < 0) ? a + MOD : a;
}
int mul (int a, int b) {
    return 1LL * a * b % MOD;
}
int power (int a, int b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res ;
}

int n;

int main() {
    cin >> n;
    int tot = power(10, n);
    int a = mul(2, power(9, n));
    minun(a, power(8, n));
    cout << sub(tot, a) << '\n';
}


Measured memory_bytes: 3628
from collections import defaultdict
dp=defaultdict(int)
mod1,mod2=10**9+7,998244353
mod=mod2

n,k=map(int,input().split())
f=0
dp[1]=1
ls=[tuple(map(int,input().split())) for i in range(k)]

#   [i-1-l,i-1-r]
#   [ i-l, i-r ]
for i in range(1,1+n):
    for r,l in ls:
        f=(f+-dp[i-1-l]+dp[i-r])%mod
    dp[i]=(dp[i]+f)%mod
print(dp[n])

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

bool isPrime(int x)
{
	if(x<2) return false;
	else if(x==2) return true;
	else if(x%2==0) return false;
	else
	{
		for(int i=3;i*i<=x;i+=2)
		{
			if(x%i==0) return false;
		}
	}
	return true;
}
int main()
{
	int n,t,cot=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		if(isPrime(t)) cot++;
	}
	cout<<cot<<endl;
	return 0;
}


Measured memory_bytes: 3080
use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut nums = HashSet::new();
    for ai in a {
        if nums.contains(&ai) {
            nums.remove(&ai);
        } else {
            nums.insert(ai);
        }
    }
    println!("{}", nums.len());
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
 
using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;
 
 
 
int main()
{
int s ;
cin >> s ;
 
cout << s/3600<<":"<<s%3600/60<<":"<<s%60<<endl ;
 
  return 0 ;
}


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

int main()
{
    string S;
    cin >> S;
    if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
 
int main() {
ll a,v,b,w,t;
cin>>a>>v>>b>>w>>t;
ll counter=0;
ll f=abs(b-a);
if((v-w)*t>=f){
cout<<"YES"<<endl;}
else{
cout<<"NO"<<endl;}}


Measured memory_bytes: 3624
#include<stdio.h>

int main()
{
    char a[4];
    int i,count=0;
    for(i=0;i<4;i++){

    scanf("%c",&a[i]);
    }
    for(i=0;i<4;i++){
    if(a[i]=='+'){
    count++;
    }
    else{
    count--;
    }
    }

    printf("%d\n",count);


return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int  h[110000];
int dp[110000];
const int INF = 1001001001;
int main()

{   int n,k;
    cin >> n >> k;
    
    rep(i,n){
        cin >> h[i];
    }
    
    dp[1] = 0;
    for(int i = 2;i <= n;i++){
        dp[i] = INF;
    }
    for(int i = 2;i <= n; i++){
        for(int j = k;j >=1;j--){
            if (i-j<=0) continue;
            dp[i] = min(dp[i],dp[i-j]+abs(h[i-1]-h[i-j-1]));
        }

    }
    cout << dp[n] << endl;

 

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a%2==0){
      if(a%3!=0 && a%5 != 0){
        cout << "DENIED" << endl;
        return 0;
      }
    } 

  }
  cout << "APPROVED" << endl; 
  
  return 0;
}

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

int main() {
  int N,K;
  cin >> N>>K;
  vector<long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  sort(H.begin(), H.end());

 long a=0;
  if(N>K){
 for(int i=0; i<N-K; i++){
  a+=H.at(i);
 }
  }
   
  
  cout<<a<<endl;
    
  

}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a,b,c;

int main()
{
	
	scanf("%d%d%d",&a,&b,&c);
	if(b*c>=a)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
	
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll ans=0, tmp=0;
    rep(i,0,N){
        if      (S[i] == 'I') tmp++;
        else if (S[i] == 'D') tmp--;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    W, H, N = map(int, input().split())
    x = [0 for i in range(N)]
    y = [0 for i in range(N)]
    a = [0 for i in range(N)]
    for i in range(N):
        x[i], y[i], a[i] = map(int, input().split())
        
    left = 0
    right = W
    top = H
    bottom = 0
    
    for i in range(N):
        if a[i] == 1 and left < x[i]:
            left = x[i]
        elif a[i] == 2 and x[i] < right:
            right = x[i]
        elif a[i] == 3 and bottom < y[i]:
            bottom = y[i]
        elif a[i] == 4 and y[i] < top:
            top = y[i]
    
    if left < right and bottom < top:
        print((top - bottom) * (right - left))
    else:
        print(0)
    

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

#define pb push_back
     
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
	string s;
	cin>>s;
	if((s[0]=='A' && s[1]=='A' && s[2]=='A') || (s[0]=='B' && s[1]=='B' && s[2]=='B'))
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			long[]A = new long[N];
			for(int i = 0;i<N;i++)A[i] = scan.nextLong();


			long ki = A[0];
			long goukei = 0;
			for(int i = 1;i<N;i++) {
				if(ki<=A[i]) {
					ki=A[i];
					//System.out.println(0);
				}else {
					goukei+=ki-A[i];
					//System.out.println(ki-A[i]);
				}

			}

			System.out.println(goukei);




		}


	}


}


Measured memory_bytes: 62628
#include <stdio.h>

int main(void)
{
    char moji;
    scanf ("%c", &moji);
    switch (moji)
    {
        case 'A':
            printf ("T");
            break;

        case 'T':
            printf ("A");
            break;

        case 'C':
            printf ("G");
            break;

        case 'G':
            printf ("C");
            break;
    }
    return (0);
}

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

int main(){
    int n;
    cin >> n;
    int h[n];
    vector<bool> t(n,false);
    rep(i,n) cin >> h[i];
    rep(i,n-1){
        if(h[i] >= h[i+1]) t[i] = true;
    }
    int ans[n] = {};
    for(int i = n-1; i >= 0; i--){
        if(!t[i]) ans[i] = 0;
        else ans[i] = ans[i+1] + 1;
    }
    sort(ans,ans+n);
    cout << ans[n-1] << endl;
    return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
S = input()

print(S.count('ABC'))


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

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int s;
    cin >> s;
    vector<int> a;

    a.push_back(s);
    int i = 1;
    while(true) {
        if (a[i-1] % 2 == 0) {
            a.push_back(a[i-1]/2);
        } else {
            a.push_back(3 * a[i-1] + 1);
        }
        i++;

        for (int j = 0; j < a.size() - 1; j++) {
            if (a[j] == a[a.size() - 1]) {
                cout << i + 0 << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
if N==0:
  print(0)
  exit()
ans=[]
while N!=0:
  tmp=N%(2)
  if tmp<0:
    tmp+=2
  N=(N-tmp)//(-2)
  ans.append(str(tmp))
  
ans=ans[::-1]
Ans=''.join(ans)
print(Ans)

Measured memory_bytes: 3064
# D-Knapsack 1
N,W = map(int,input().split())
Weight = [0 for _ in range(N)]
Value = [0 for _ in range(N)]
for i in range(N):
    Weight[i],Value[i] = map(int,input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    # あらゆる合計重量sum_wに対して品物iを入れるべきか計算する
    for sum_w in range(W+1):
        # i番目を選ぶ場合
        if sum_w - Weight[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - Weight[i]] + Value[i])

        #　i番目を選ばない場合
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

# for d in dp:
#     print(d)

print(dp[N][W])

Measured memory_bytes: 171784
def solve(N, M, A):
    total = sum(A)
    if sum([1 if i >= total/(4*M) else 0 for i in A]) >= M:
        return 'Yes'
    else:
        return 'No'

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ans = solve(N, M, A)
    print(ans)

if __name__ == "__main__":
    # test()
    main()

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

int main(){
  int n; cin >> n;
  vector<int> l(n);
  for(int i=0; i<n; i++){
    cin >> l[i];
  }
  int ans = 0;
  sort(l.begin(), l.end());
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int k=n-1; j<k; k--){
        if(l[i]+l[j] > l[k]){
          ans += k - j;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	long long int a; 
	long long int number[100000];
	scanf("%lld", &a);
	for(long long int i=0; i<a; i++){
		scanf("%lld", &number[i]);
	}
	for(long long int i = 0; i<a; i++){
		if(number[i]==0){
			printf("0\n");
			return(0);
			
		}
	}
	long long int ans = 1;
	for(int i = 0; i<a; i++){
		if(number[i]<= (1000000000000000000/ans) ){
			ans=ans*number[i];
		
		}else {
			printf("-1\n");
			return(0);
		}
	} printf("%lld\n", ans);
	return 0;
}


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

int main()
{
	int A, B, C;
	int Times = 0;
	cin >> A >> B >> C;
	if(A*C <= B ) 
	{
		cout << C << endl;
	}
	else
	{
		if((B/A) >= 0)
		{
			cout << B/A << endl;
		}
	}
	
	
	
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <ctype.h>
int main(){
  char s[1200];
  int i=0;
  char c;
  while((c=getchar())!=EOF){
    char u_c,l_c;
    u_c=toupper(c);
    l_c=tolower(c);
    if(c!=u_c)s[i]=u_c;
    else if(c!=l_c)s[i]=l_c;
    else s[i]=c;
    i++;
  }
  s[i]='\0';
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 2684
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use permutohedron::LexicalPermutation;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(dead_code)]
const MOD: i32 = 1e9 as i32 + 7;

fn main() {
    input!(n: i32, m: i32, a: [i32; n]);
    let mut a: Vec<i32> = a.clone();
    let sum = a.iter().fold(0, |sum, i| sum + i);
    let sum = (sum as f32) / (4.0 * m as f32);
    let mut cnt = 0;
    for x in a {
        if x as f32 >= sum {
            cnt += 1;
        }
    }
    println!("{}", if cnt >= m { "Yes" } else { "No" });
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;


int main(){
    int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
    if(a==0) cout << 1 << endl;
    if(b==0) cout << 2 << endl;
    if(c==0) cout << 3 << endl;
    if(d==0) cout << 4 << endl;
    if(e==0) cout <<5 << endl;
     
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,M;
vector<int>G[100005];
int dist[100005];
int ans[100005];
void bfs(){
	REP(i,N)dist[i]=inf;
	queue<int>que;que.push(0);
	while(!que.empty()){
		int i=que.front();que.pop();
		for(int j:G[i]){
			if(dist[j]==inf){
				ans[j]=i;dist[j]=dist[i]+1;
				que.push(j);
			}
		}
	}
}
signed main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;cin>>a>>b;a--;b--;
		G[a].pb(b);G[b].pb(a);
	}
	bfs();
	cout<<"Yes"<<endl;
	REP(i,N)cout<<ans[i]+1<<endl;
}


Measured memory_bytes: 13816
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main(){
    int n ;
    cin >> n;
    vector<pair<int64_t,int64_t> > a(n,pair<int64_t,int64_t>());
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i).first >> a.at(i).second ;
    }
    for (size_t i = 0; i < n; i++)
    {
        int64_t temp1 = 0;
        int64_t temp2 = 0;
        temp1 = a.at(i).first - a.at(i).second ;
        temp2 = a.at(i).first + a.at(i).second ;
        a.at(i).first = temp2 ;
        a.at(i).second = temp1 ;
    }
    
    sort(a.begin(),a.end()) ;
    int ans = 1;
    int now = a.at(0).first ;
    for (size_t i = 1; i < n; i++)
    {
        if (a.at(i).second >= now)
        {
            ans ++ ;
            now = a.at(i).first ;
        }
        
    }
    
    cout << ans << endl ;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    int ans;
    cin>>a>>b;
    c=a+b;
    if(c%2==0)
    {
        ans=c/2;
    }
    else ans=(c/2)+1;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
    lli n;
    cin>>n;
    lli dig = n%10;
    set <lli> s1 =  {2,4,5,7,9};
    set <lli> s2 = {0,1,6,8};
    set <lli> s3 = {3};
    if(s1.count(dig))
        cout<<"hon";
    if(s2.count(dig))
        cout<<"pon";
    if(s3.count(dig))
        cout<<"bon";
    
}

Measured memory_bytes: 3616
import sys

n = list(map(int,input().split()))
a_list = list(map(int,input().split()))

zero_search = 0 in a_list
ans = 1

if zero_search:
    ans = 0
else:
    for i in a_list:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
            
print(ans)

Measured memory_bytes: 84596
using System;

namespace _0024
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string now = Console.ReadLine();
                if (now == null)
                {
                    break;
                }
                double v = double.Parse(now);
                double t = v / 9.8;
                double y = 4.9 * t * t;
                int N = 0;
                if (y % 5 == 0)
                {
                    N = (int)y / 5 + 1;
                }
                else
                {
                    N = (int)y / 5 + 2;
                }
                Console.WriteLine(N);
            }
            Console.ReadLine();
        }
    }
}

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

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

int p[10010];

int main() {
    while(1){
        int m, nmin, nmax;
        cin >> m >> nmin >> nmax;
        if(m == 0 and nmin == 0 and nmax == 0) break;
        memset(p, 0, sizeof(p));
        rep(i,m) cin >> p[i];

        int ans = 0, mx = -1;
        for(int i = nmin-1; i < nmax; i++){
            int diff = p[i] - p[i+1];
            if(diff >= mx){
                mx = diff;
                ans = i+1;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 100005
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;

int main()
{
    FAST;
    int n;
    cin>>n;
    int l,r;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>l>>r;
        ans+=(r-l+1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())


if k <= q:
    
    A = []
    for _ in range(q):
        a = int(input())
        A.append(a)

    ans = [0]*n

    from collections import Counter
    cnt = Counter(A)
    for key,v in cnt.items():
        if v >= q-k+1:
            ans[key-1] = 1

    for i in range(n):
        if ans[i] == 0:
            print('No')
        else:
            print('Yes')
        
else:
    for _ in range(n):
        print('Yes')

Measured memory_bytes: 12324
#include <stdio.h>

int main() {
	int N, L[10], max = 0, sum = 0, i;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &L[i]);
		sum = sum + L[i];
		if (L[i] > max) max = L[i];
	}

	if (sum > max * 2) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
import sys
S = input()
S = S[::-1]

AR = []
A = ["dream","dreamer","erase","eraser"]
for a in A:
    AR.append(a[::-1])

i = 0
while i < len(S):
    for ar in AR:
        l = len(ar)
        if ar == S[i:i+l]:
            i += l
            break
    else:
        print("NO")
        sys.exit()

print("YES")



Measured memory_bytes: 3188
#include <iostream>

using namespace std;

typedef long long Long;

Long extgcd(Long a, Long b, Long& x, Long& y) {
    Long g = a; x = 1LL; y = 0LL;
    if (b != 0LL) {
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return g;
}

int main() {
    int a, b; cin >> a >> b;
    Long x, y; extgcd(a, b, x, y);
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

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


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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n = scanner.nextInt();
        int od =  0;
        for(int i =1 ; i <= n; i++) {
            if (i % 2 == 1) od++;
        }
        out.println((double)od/(n));
        out.flush();
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    for (int ans = 0; ; ++ ans) {
        if (a & 1) std::cout << ans, exit(0);
        if (b & 1) std::cout << ans, exit(0);
        if (c & 1) std::cout << ans, exit(0);
        if (a == b && b == c) std::cout << -1, exit(0);
        int na = b + c >> 1;
        int nb = a + c >> 1;
        int nc = a + b >> 1;
        a = na, b = nb, c = nc;
    }
}


Measured memory_bytes: 256
N = int(input())
*H, = map(int, input().split())
 
T = [0]*N
ans = 0
i = 0
while i<N:
    #積み上げるべきスタート地点を探す
    if T[i]<H[i]:
        start = i
        high  = T[i]+1
        ans = ans + 1
        i = 0
        for j in range(start, N, 1):
            if T[j]<H[j]:
                T[j] = T[j] + 1
            else:
                break
    else:
        i = i + 1

print(ans)

Measured memory_bytes: 3064
# import sys
import math

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize

# ===CODE===
q = int(input())

condition = 10 ** 5

data = []
for i in range(q):
    l, r = map(int, input().split())
    data.append((l, r))

kodoku = {2}

for i in range(3, condition + 5, 2):
    lim = i ** (1 / 2)
    flg = True
    for j in range(2, int(lim)+1):
        # if div > lim:
        #     break
        if i % j == 0:
            flg = False
            break

    if flg:
        kodoku.add(i)

ruisekiwa = [0] * (condition + 5)

for i in range(3, condition + 5):
    ruisekiwa[i] = ruisekiwa[i - 1]
    if i in kodoku and (i + 1) // 2 in kodoku:
        ruisekiwa[i] += 1

for l, r in data:
    ans = ruisekiwa[r] - ruisekiwa[max(0, l - 1)]
    print(ans)


Measured memory_bytes: 18980
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

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

    int n = sc.nextInt();
    ArrayList<Integer> as = new ArrayList<>();
    ArrayList<Integer> bs = new ArrayList<>();
    ArrayList<Integer> cs = new ArrayList<>();

    for (int i = 0; i < n; i++) {
      as.add(sc.nextInt());
    }
    for (int i = 0; i < n; i++) {
      bs.add(sc.nextInt());
    }
    for (int i = 0; i < n -1 ; i++) {
      cs.add(sc.nextInt());
    }

    int ans = 0;
    int prev = -1;
    for (int a : as) {
      ans += bs.get(a -1);
      if (a - prev == 1) {
        ans += cs.get(a - 2);
      }
      prev = a;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
n = int(input())
dp = []
for _ in range(n):
  dp.append(list(map(int,input().split())))

for j in range(1,n):
    dp[j][0] += max(dp[j-1][1],dp[j-1][2])
    dp[j][1] += max(dp[j-1][0],dp[j-1][2])
    dp[j][2] += max(dp[j-1][0],dp[j-1][1])

print(max(dp[-1]))

Measured memory_bytes: 30192
BIG_NUM = 2000000000
 
while True:
 
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
 
    print()


Measured memory_bytes: 7008
package main

import (
  "fmt"
  "strconv"
)

func absInt(x int) int {if x < 0 {x *= -1}; return x}

// argument type must be []rune, not string.
func substr(rs []rune, l, r int) string {
  if l < 0 {l = 0}
  if r > len(rs) {r = len(rs)}
  if l >= r {return ""}
  return string(rs[l:r])
}

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var s string 
  fmt.Scan(&s)
  n := len(s)
  rs := []rune(s)
  res := 1001
  for i := 0; i < n - 2; i++  {
    d, _ := strconv.Atoi(substr(rs, i, i + 3))
    res = minInt(res, absInt(753 - d))
  }
  fmt.Println(res)
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
ans=0
i=1
up=0
down=0
while i<n:
  if up==down:
    if a[i]>a[i-1]:
      up+=1
      down=0
    elif a[i]<a[i-1]:
      down+=1
      up=0
    elif a[i]==a[i-1]:
      up+=1
      down+=1
  elif up==0 and down!=0:
    if a[i]<=a[i-1]:
      down+=1
    else:
      ans+=1
      down=0
  elif down==0 and up!=0:
    if a[i]>=a[i-1]:
      up+=1
    else:
      ans+=1
      up=0
  i+=1
print(ans+1)

Measured memory_bytes: 20384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

ll N, K ;

ll possible_case[112345];

ll cal(ll num, ll aim){
    ll ans = power(num, N);
    ll idx = 2;
    
    while(aim * idx <= K){
        ans -= possible_case[aim * idx];
        idx ++;
    }
    
    while(ans < 0) ans += MOD;
    
    return ans;
}

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


    cin >> N >> K ;
    // (1~K), N
    
    ll ans = power(K, N);
    for(ll i = K; i >= 2; i--){
        ll num = K / i;
        possible_case[i] = cal(num, i);
        ans -= possible_case[i];
        
        if(ans < 0) ans += MOD;
    }
    
    possible_case[1] = ans;
    
    ans = 0;
    
    for(ll i = 1; i <= K; i++){
        ans += i * possible_case[i];
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
char str[200005];
int a[200005];
int t[200005][26];

bool check(int l,int r){
  for(int i=0;i<26;i++){
    if( t[r][i] - t[l][i] == 0 )return false;
  }
  return true;
}

int mem[200005];
int find(int x){
  if(mem[x]!=-1)return mem[x];
  int left=x+1,right=n,mid;
  while(left<right){
    mid=(left+right)/2;
    if( check(x, mid ) )right=mid;
    else left=mid+1;
  }
  return mem[x]=left;
}

int dp[200005];
int solve(int p){
  if(dp[p]!=-1)  return dp[p];
  if(!check(p,n))return dp[p]=1;
  int nex=find(p);
  return dp[p]=solve(nex)+1;
}

int main(){
  memset(mem, -1, sizeof(mem));
  memset(dp, -1, sizeof(dp));

  set<int> st[26];
  
  scanf("%s",str);
  n=strlen(str);
  for(int i=0;i<n;i++){
    a[i]=str[i]-'a';
    t[i+1][ a[i] ]++;

    st[ a[i] ].insert(i);
  }
  
  
  for(int i=1;i<=n;i++)
    for(int j=0;j<26;j++)
      t[i][j]+=t[i-1][j];
  
  int len=solve(0);
  int x=-1;
  string ans="";
  
  for(int i=0;i<len;i++){
    for(int ch=0;ch<26;ch++){
      set<int> :: iterator it = st[ch].upper_bound(x);
      if(it!=st[ch].end())
        if( (int)ans.size() + 1 + solve( (*it)+1 ) > len)continue;
      
      if(it!=st[ch].end())  x=*it;
      ans+= ('a'+ch);
      break;
    }
  }
  
  cout<<ans<<endl;
  return 0;  
}


Measured memory_bytes: 32640
s = list(map(str, input()))
flag = 0
for i in range(len(s)):
    if i%2 == 1 and s[i] != 'i':
        flag = 1
    elif i % 2 ==0 and s[i] != 'h':
        flag = 1
if len(s)%2 == 1:
    flag = 1
if flag == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll H, W, N;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
ll ans[11];

int main()
{
    cin >> H >> W >> N;
    set<pair<int, int>> st, br;
    ans[0] = (H - 2) * (W - 2);
    for (int i = 0; i < N; i++)
    {
        int y, x;
        cin >> y >> x;
        y--, x--;
        pair<int, int> p = make_pair(y, x);
        br.insert(p);
        st.insert(p);
        for (int i = 0; i < 8; i++)
        {
            ll ny = y + dy[i], nx = x + dx[i];
            if (ny < 1 || ny > H || nx < 1 || nx > W)
                continue;
            st.insert({ny, nx});
        }
    }
    for (auto &p : st)
    {
        ll y = p.first, x = p.second, cnt = 0;
        if (br.find(p) != br.end())
            cnt++;
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
            {
                cnt = -1;
                break;
            }
            if (br.find({ny, nx}) != br.end())
                cnt++;
        }
        if (cnt != -1)
            ans[cnt]++, ans[0]--;
    }
    for (int i = 0; i < 10; i++)
        cout << ans[i] << endl;
}

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

using namespace std;




int main(){

	int n, k; cin >> n;


	vector <int> a(n), b(n), c(n);


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

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

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



	int sum = accumulate(b.begin(), b.end(), 0);


	for(int i = 0; i < n - 1; i++){
		if(a[i] == a[i + 1] - 1){
			sum += c[a[i] - 1];
		}
	}


	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;



int32_t main(){
    FAST;

    int a , b;  cin >> a >> b;
    int c;  cin >> c;

    int ans = c;

    int time = b /a;
    if(time <= c)
        ans = time;
        cout << ans;

    return 0;
}




Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int N = 500000 + 500;
const int B = 1000000 + 1000;
const int M = 500000 + 200;

int Yuyuko;
int n, m;
int b[B], a[N], block[N], ans[M], cans = 1;
struct operation{
	int l, r, id;
}o[M];

inline int read()
{
	int a = 0;
	char ch;
	int f = 1;
	while(!((((ch = getchar()) >= '0') && (ch <= '9')) || (ch == '-')));
	if(ch == '-')
		f = -1;
	else
	{
		a = a * 10;
		a += ch - '0';
	}
	while((((ch = getchar()) >= '0') && (ch <= '9')) || (ch == '-'))
	{
		a = a * 10;
		a += ch - '0';
	}
	return a * f;
}

inline bool cmp(operation x, operation y)
{
	if(block[x.l] != block[y.l])
		return block[x.l] < block[y.l];
	else
		return x.r < y.r;
}

inline void add(int x)
{
	if(!b[a[x]])
		++cans;
	++b[a[x]];
}

inline void minu(int x)
{
	--b[a[x]];
	if(!b[a[x]])
		--cans;
}

int main()
{
	n = read(), m = read();
	Yuyuko = sqrt(n) + 1;
	for(int i = 1;i <= n;++i)
	{
		a[i] = read();
		block[i] = (i - 1) / Yuyuko + 1;
	}
	for(int i = 1;i <= m;++i)
	{
		o[i].l = read(), o[i].r = read();
		o[i].id = i;
	}
	sort(o + 1, o + 1 + m, cmp);
	int L = 1, R = 1;
	b[a[1]] = 1;
	for(int i = 1;i <= m;++i)
	{
		while(L < o[i].l)
			minu(L++);
		while(L > o[i].l)
			add(--L);
		while(R < o[i].r)
			add(++R);
		while(R > o[i].r)
			minu(R--);
		ans[o[i].id] = cans;
	}
	for(int i = 1;i <= m;++i)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 17360
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define exact(x) { return (x); }

#define sum(v) accumulate(all(v), 0)
#define stlice(s, l) substr(s, (s) + (l) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1e9
#define MOD (1e9 + 7)

#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define str string
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<str>

using namespace std;

// clang-format on

main {
  int n;
  cin >> n;
  int es = 0, os = 0;
  rep(i, n) {
    int a;
    cin >> a;
    es += even(a);
    os += odd(a);
  }
  cout << (odd(os) ? "NO" : "YES") << endl;
  bye;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, T[100], M, P[100], X[100], ans=0;
    in(N);
    rep(i, N) in(T[i]);
    in(M);
    rep(i, M) in2(P[i], X[i]);
    rep(i, N) ans += T[i];
    rep(i, M) put(ans - T[--P[i]] + X[i]);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}



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

    int D, M;
    cin >> M >> D;

    int ans = 0;
    for (int i=4; i<=M; i++) {
        for (int j=2; j<10; j++) {
            for (int k=2; k<10; k++) {
                if  (j*k == i && 10*j+k <= D) ans++;
            }
        }
    }

    cout << ans;

    return 0;
}


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

set<string> st;
int n, k;

void solve(int a, int b, string str){
        if(a == n && b == k){
                st.insert(str);
                return;
        }

        if(a > n || b > k){
                return;
        }

        if(a == 5 && b <= 3 || a <= 3 && b == 5){
                return;
        }

        if(a == 5 && b == 5){
                return;
        }

        if(a == 6 && b == 4 || a== 4 && b == 6){
                return;
        }

        solve(a+1, b, str +"A");
        solve(a, b+1,str + "B");
}

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

        solve(0, 0, "");

        for(auto itr = st.begin(); itr != st.end(); itr++){
                cout << *itr << endl;
        }

        return 0;
}



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

long long md = 1000000007;

long long fp(long long n, int k)
{
	long long s = 1;
	while (k) {
		if (k % 2) s = (s * n) % md;
		k /= 2; n = (n * n) % md;
	}
	return s;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k; cin >> n >> m >> k;
	long long ans = 0, s = 0;
	for (int i = 1; i < n; i++) 
		s = (s + 1LL * i * (n - i)) % md;
	ans = (ans + ((s * m) % md) * m) % md;
	s = 0;
	for (int i = 1; i < m; i++)
		s = (s + 1LL * i * (m - i)) % md;
	ans = (ans + ((s * n) % md) * n) % md;
	long long r = 1LL * n * m - 2, t = 1;
	for (int i = 2; i < k; i++) {
		ans = (ans * r) % md;
		r = (r - 1 + md) % md;
		t = (t * (i - 1)) % md;
	}
	cout << (ans * fp(t, md - 2)) % md << '\n';
	return 0;
}	

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

			long a = sc.nextLong();
			long b = sc.nextLong();
			long n = sc.nextLong();
			
//			long axb = (long)Math.floor(a*n/b);
//			
//			//aとbの最小公倍数を求める --> それがn以内
//			
//			
//			//axbとなるxの幅を求める
////			System.out.println(axb);
//			long minx = 0;
//			if ( axb * b % a == 0 ) {
//				minx = (long)(axb * b / a);
//			}
//			else {
//				minx = (long)(axb * b / a) + 1;
//			}
//			long maxx = 0;
//			
//			if  ( (axb+1) * b % a == 0 ) {
//				maxx = (long)((axb+1) * b / a) - 1;
//			}
//			else {
//				maxx = (long)((axb+1) * b / a);
//			}
//			
////			System.out.println("min: " + minx);
////			System.out.println("max: " + maxx);
//			
//			long minLater = Long.MAX_VALUE; 
//			
//			for(long i = minx ; i <= maxx ; i++ ) {
//				//calc min 
//				long tmp = (i / b);
//				
//				if ( tmp < minLater ) {
//					minLater = tmp;
//				}
//			}
//			
//			long ans = axb - a * minLater;
//			
//			//other case
//			// x = b -1
//			long ans2 = a * (b-1) / b;
//			
//			if ( ans2 > ans) {
//				ans2 = ans;
//			}
			
			long c = 0;
			if ( n < b -1 ) {
				c = n;
			}
			else {
				c = b -1;
			}
			long ans2 = a * c / b;
			
			System.out.println(ans2);
		}
	}

}

Measured memory_bytes: 35760
# input
k, n = gets.chomp.split.map(&:to_i)
house = gets.chomp.split.map(&:to_i)
house.push(k+house[0])
dist = []
cand = []

# main
n.times do |i|
  dist.push(house[i+1]-house[i])
end  

n.times do |i|
  cand.push(k-dist[i])
end

# output
puts cand.min
  

Measured memory_bytes: 20100
#include <iostream>
#include <cmath>
using namespace std;
int sosu(int a){
    double p;
    if(a==2)return 1;
    if(a%2==0&&a>2)return -1;
    p=sqrt(a);
    for(int i=3;i<=p;i=i+2){
        if(a%i==0)return -1;
    }
    return 1;
}
int main(void){
    int n,num,ret,cnt;
    cin>>n;
    cnt=0;
    
    for(int i=0;i<n;i++){
        cin>>num;
        ret=sosu(num);
        if(ret==1)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  int N,D,X,sum=0;
  cin >> N >> D >> X;
  int A[N+10];
  for(int i=1; i<=N; i++){
    sum += 1;
    cin >> A[i];
    sum += (D-1)/A[i];
}
sum += X;
cout << sum << endl;
}

Measured memory_bytes: 256