akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int inf = numeric_limits<int>::max();
const ll mod = 1e9 + 7;

int isp[300000];

void solve(int n){
  int cnt = 0;
  for(int i = n+1;i <= 2*n;++i){
    if(isp[i])++cnt;
  }
  cout << cnt << endl;
}

int main(void){
  fill(isp,isp+300000,1);
  isp[1] = 0;
  for(int i = 2;i*i < 300000;++i){
    if(isp[i]){
      for(int j = i*i;j < 300000;j += i){
        isp[j] = 0;
      }
    }
  }
  int n;
  while(cin >> n,n)solve(n);
  return 0;
}

Measured memory_bytes: 4240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder178
{
    class Program
    {
        const long Mod = 1000000007;

        static void Main(string[] args)
        {
            // n: 整数の長さ
            var n = long.Parse(Console.ReadLine());

            // a. 0-9のn桁の整数の組み合わせ(全体): 10^n
            // b. 全体に条件「0を含まない」を追加: 9^n
            // c. 全体に条件「9を含まない」を追加: 9^n
            // d. 全体に条件「0、9を含まない」を追加: 8^n

            // 全体に「0を1つ以上、9を1以上含む」を追加:
            // a - b - c + d

            var ans = powMod(10, n);
            ans -= powMod(9, n) * 2 % Mod; // 大きくなるためModする
            ans += powMod(8, n);

            // Modしている関係でadが小さくbcが大きくなり、
            // 答えが0以下になる場合があるため
            // Modを足して一旦正の値にする
            ans += Mod;

            // Modを足して大きくなっている場合があるためModする
            ans %= Mod;

            Console.WriteLine(ans);

            // これだとnの桁数が大きいとNaNになってしまう
            //var ans = Math.Pow(10, n) % Mod;
            //ans -= Math.Pow(9, n) % Mod * 2;
            //ans += Math.Pow(8, n);
        }

        private static long powMod(long x, long y)
        {
            var ans = 1L;
            for(var i = 0L; i < y; i++)
            {
                ans *= x;
                ans %= Mod;
            }

            return ans;
        }
    }
}

Measured memory_bytes: 27536
import java.util.Scanner;

public class Main {
	
	public static int solution(int x, int y) {
		if ((x%y)==0) {
			return y;
		}
		return solution(y, (x-((x/y)*y)));
	}
	
	public static void main(String[] Args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int out = solution(x,y);
		System.out.println(out);
	}
}



Measured memory_bytes: 26224
import numpy as np

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
 
ma = -np.inf
for i in range(N-1):
  if sum(A1[:i+1]) + sum(A2[i:]) > ma:
    ma = sum(A1[:i+1]) + sum(A2[i:])
    
if N == 1:
  ma = A1[0] + A2[0]
  
print(ma)

Measured memory_bytes: 12508
{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import qualified Data.HashMap.Strict as Map
 
main = do
  [_,capa] <- map (read :: String -> Int) . words <$> getLine
  goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
  print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)
 
resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] (capa-w)
    koushin capaMap [v,w] n
      | n == 0 && capaMap Map.! w <= v        = Map.insert w v capaMap
      | n == 0                                = capaMap
      | oldValue == 0                         = next
      | capaMap Map.! (n+w) >= v + oldValue   = next
      | otherwise = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n-1)
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n-1)

Measured memory_bytes: 7832
use proconio::*;
use proconio::marker::Usize1;
use std::collections::BinaryHeap;

fn my_pop(heap: &mut BinaryHeap<(usize, usize, usize)>, charge: &mut [usize]) -> Option<(usize, usize, usize)> {
    while let Some(x) = heap.pop() {
        if charge[x.2] > 0 {
            heap.push((x.0 - charge[x.2], x.1, x.2));
            charge[x.2] = 0;
        }
        else {
            return Some(x);
        }
    }

    None
}

fn solve() -> Option<Vec<usize>> {
    input!{
        n: usize,
        a: [Usize1; n],
        b: [Usize1; n],
    }

    let mut cnt_a = vec![0usize; n];
    let mut cnt_b = vec![0usize; n];

    for i in 0..n {
        cnt_a[a[i]] += 1;
        cnt_b[b[i]] += 1;
    }

    // let mut max_a = 0;
    // let mut max_b = 0;
    // for i in 0..n {
    //     max_a = max_a.max(cnt_a[i]);
    //     max_b = max_b.max(cnt_b[i]);
    // }

    // if n-max_a < max_b {
    //     println!("No");
    //     return;
    // }

    let mut heap = BinaryHeap::new();
    for i in 0..n {
        if cnt_b[i] == 0 {
            continue;
        }
        heap.push((cnt_a[i], cnt_b[i], i));
    }

    let mut charge = vec![0; n];
    let mut ans = Vec::new();
    for i in 0..n {
        // println!("{:?}", ans);
        // println!("{}", i);
        let tmp = my_pop(&mut heap, &mut charge);
        if tmp.is_none() {
            return None;
        }
        let tmp = tmp.unwrap();
        // println!("{:?}", tmp);
        if a[i] == tmp.2 {
            let tmp2 = my_pop(&mut heap, &mut charge);
            if tmp2.is_none() {
                return None;
            }
            let tmp2 = tmp2.unwrap();
            ans.push(tmp2.2);
            if tmp2.1 != 1 {
                heap.push((tmp2.0, tmp2.1-1, tmp2.2));
            }
            heap.push(tmp);
        }
        else {
            ans.push(tmp.2);
            if tmp.1 != 1 {
                heap.push((tmp.0, tmp.1-1, tmp.2));
            }
        }
        charge[a[i]] += 1;
    }

    Some(ans)

    
}

fn main() {
    if let Some(ans) = solve() {
        println!("Yes");
        for i in 0..ans.len() {
            if i > 0 {
                print!(" ");
            }
            print!("{}", ans[i]+1);
        }
        println!("");
    }
    else {
        println!("No");
    }
}


Measured memory_bytes: 18588
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n,0),sum(n+1,0);
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    vector<ll> data(n*(n+1)/2,0),v(n*(n+1)/2,0);
    ll cnt=0;
    for(ll i=0;i<n;i++)for(ll j=i;j<n;j++){
        data[cnt]=sum[j+1]-sum[i];
        cnt++;
    }
    ll K=0;
    while((1LL<<K)<sum[n]) K++;
    ll ans=0,p=0;
    for(ll i=K;i>=0;i--){
        cnt=0;
        rep(j,n*(n+1)/2){
            if(p>v[j]) continue;
            if((1LL<<i)&data[j]){
                cnt++;
                v[j]=p+1;
            }
            else v[j]=p;
        }
        if(cnt>=k){
            ans+=(1LL<<i); p++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8064
from collections import deque


def main():
    N = int(input())
    d = list(map(int, input().split(' ')))
    d.sort()
    d = deque(d)
    threshold_min, threshold_max = 0, 0
    for _ in range(N // 2):
        threshold_min = d.popleft()
        threshold_max = d.pop()
    print(threshold_max - threshold_min)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14908
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
char s[4005];
ll ans;
int main(){
	int n,a[3]={};
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='R') a[0]++;
		else if(s[i]=='G') a[1]++;
		else a[2]++;
	}
	ans=(ll)a[0]*a[1]*a[2];
	for(int i=1;i<n;i++)
		for(int d=1;i+d+d<=n;d++)
			if((s[i]^s[i+d]^s[i+d+d])==('R'^'G'^'B')) --ans;
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 3784
// B - ATCoder
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; cin>>S;
	string T = "ACGT";

	vector<int> A(S.size());

	A[0] = T.find(S[0])<T.size()? 1:0;

	for(int i=1; i<S.size(); ++i)
		A[i] = T.find(S[i])<T.size()? A[i-1]+1:0;

	int maxi = 0;
	for(int a:A) maxi = max(maxi, a);
	cout<< maxi <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N,A,B,C;cin>>N>>A>>B>>C;
  vector<string> s(N+1);rep(i,N)cin>>s[i];
  char ans[N];
  bool flag=true;
  rep(i,N){
    if(A==0 && B==0 && C==0){flag=false;break;}
    if(s[i]=="AB"){
      if(A==0 && B==0){flag=false;break;}
      else if(A>B || A==B&&s[i+1]=="BC"){ans[i]='B';++B;--A;}
      else {ans[i]='A';++A;--B;}
    }
    if(s[i]=="BC"){
      if(C==0 && B==0){flag=false;break;}
      else if(B>C || B==C&&s[i+1]=="AC"){ans[i]='C';++C;--B;}
      else {ans[i]='B';++B;--C;}
    }
    if(s[i]=="AC"){
      if(A==0 && C==0){flag=false;break;}
      else if(C>A || C==A&&s[i+1]=="AB" && B==0){ans[i]='A';++A;--C;}
      else {ans[i]='C';++C;--A;}      
    }
    //cout << "A" << A << "B" << B << "C" << C << endl;
  }
  if(flag){cout<<"Yes"<<endl;rep(i,N)cout<<ans[i]<<endl;}
  else cout<<"No"<<endl;
}

Measured memory_bytes: 6428
#include <stdio.h>

int hamming[3000000];

int main(void)
{
	int i;
	int m, n;
	
	hamming[1] = 1;
	for (i = 1; i <= 500000; i++){
		if (hamming[i] == 1){
			hamming[i * 2] = 1;
			hamming[i * 3] = 1;
			hamming[i * 5] = 1;
		}
	}
	for (i = 2; i <= 1000000; i++){
		hamming[i] += hamming[i - 1];
	}
	
	while (scanf("%d %d", &m, &n) * m != 0){
		printf("%d\n", hamming[n] - hamming[m - 1]);
	}
	
	return (0);
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[105][5][5][5];


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  
  dp[0][0][0][0]=1;
  
  // a=0,g=1,c=2,t=3
  rep(ki,n){
    rep(i,5){
      rep(j,5){
        rep(k,5){
          irep(nxt,1,5){
            if(dp[ki][i][j][k]==0) continue;
            
            if(ki==1&&k==0) continue;
            if(ki==2&&(j==0||k==0)) continue;
            if(ki>=3&&(i==0||j==0||k==0)) continue;
            
            if(j==1&&k==2&&nxt==3) continue;// agc
            if(j==2&&k==1&&nxt==3) continue;// gac
            if(j==1&&k==3&&nxt==2) continue;// acg
            if(i==1&&k==2&&nxt==3) continue;// axgc
            if(i==1&&j==2&&nxt==3) continue;// agxc
            
            (dp[ki+1][j][k][nxt]+=dp[ki][i][j][k])%=MOD;
          }
        }
      }
    }
  }
  
  ll ans=0;
  irep(i,1,5) irep(j,1,5) irep(k,1,5) {
    (ans+=dp[n][i][j][k])%=MOD;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3728
#include<iostream>
using namespace std;
int main(){
	int r,c;
	//input r,c
	cin >> r >> c;
	//declare sheet vector
	int sheet[r+1][c+1];
	//input sheet
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++)
			cin >> sheet[i][j];
	//calculate r
	for(int i=0;i<r;i++){
		sheet[i][c]=0;
		for(int j=0;j<c;j++){
			sheet[i][c]+=sheet[i][j];
		}}
	//calculate c
	for(int i=0;i<c+1;i++){
		sheet[r][i]=0;
		for(int j=0;j<r;j++){
			sheet[r][i]+=sheet[j][i];
	}}
	//output
	for(int i=0;i<r+1;i++){
		for(int j=0;j<c+1;j++){
			cout<<sheet[i][j];
			if(j!=c)	cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
import Control.Monad
import Control.Applicative
import Data.List

white :: [Char]
white = repeat '.'

solver :: [String] -> Int ->  [String]
solver xs c =
    let row = take c white
        ys  = filter (\x -> x /= row) xs
        len = length ys
        col = take len white
        zs  = filter (\y -> y /= col) $ transpose ys
        in transpose zs

main :: IO ()
main = do
    [r, c] <- (map read) . words <$> getLine
    table  <- replicateM r getLine
    mapM_ putStrLn $ solver table c


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define N 10000000
typedef long long ll;
vector<ll> v(N+1);
int main()
{
    // precalc();
    ll n;
    cin>>n;
    for (ll x=1; x<=n; x++){
        ll y = n/x;
        v[x] = (y*(y+1)*x)/2;
    }
    ll ans = 0;
    for (int i=1; i<=n; i++){
        ans += v[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81104
import sys
sys.setrecursionlimit(10 ** 8)


class Solve():
    def __init__(self):
        self.N = int(input())
        self.route = [dict() for _ in range(self.N)]
        for _ in range(self.N - 1):
            a, b, c = map(int, input().split())
            self.route[a - 1][b - 1] = c
            self.route[b - 1][a - 1] = c
        self.Q, self.K = map(int, input().split())
        self.K -= 1
        self.query = []
        for _ in range(self.Q):
            x, y = map(int, input().split())
            self.query.append([x - 1, y - 1])
        self.depth = [0 for _ in range(self.N)]

    def DFS(self, v, p, d):
        self.depth[v] = d
        for dest, cost in self.route[v].items():
            if dest == p:
                continue
            self.DFS(dest, v, d + cost)

    def execute(self):
        self.DFS(self.K, -1, 0)
        for x, y in self.query:
            print(self.depth[x] + self.depth[y])


if __name__ == '__main__':
    Solve().execute()

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

const long long INF = 1LL<<60;

// 漸化式を作る
// magic[i][h] : i種類の魔法でダメージhを与えるときの消費魔力の最小値と定義する
// 調べる必要がある範囲 : H <= j <= H + max(a1,..., aN)


int main(){
    int H, N;
    cin >> H >> N;
    
    vector<long long> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
    
    // magic tableを用意する
    // INfで初期化するためlong long型で用意する
    // 魔法はat most 1000種類
    // ダメージはat most 20000
    // 最小値を求める問題だから, INFで初期化しておく
    vector<vector<long long>> magic(1010, vector<long long>(101010, INF));
    
    // 0種類の魔法で体力を0減らすための魔力は0である
    magic[0][0] = 0;
    
    //魔法の種類を1からNまで動かす
    for (int i = 0; i < N; i++){
        
        // damageを0からH+max(a)まで動かす
        for (int j = 0; j <= H + 10101; j++){
            
            
            // 魔法を使わない更新
            magic[i+1][j] = min(magic[i+1][j], magic[i][j]);
            
            // 魔法を使う更新
            if (j - a[i] >= 0) magic[i+1][j] = min(magic[i][j], magic[i+1][j - a[i]] + b[i]);
        }
    }
    
    // 調べる必要がある範囲 : H <= j <= H + max(a1,..., aN)
    long long ans = INF;
    
    for (int i = H; i < H+10101; i++) ans = min(ans, magic[N][i]);
    cout << ans << endl;
}

Measured memory_bytes: 801152
#include<bits/stdc++.h>
using namespace std;
 
// #define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define     ff 				first
#define 	ss 				second
#define 	pb 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
// vll pwx(32);
// void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve(){
    ll n; cin >> n;

    vll a(n);
    for(auto &i : a) cin >> i;

    ll g = a[0];

    rep(i, 1, n) g = __gcd(g, a[i]);

    if(g != 1) {
        cout << "not coprime\n"; return ;
    }

    vll mp(1e6+1, 0);
    ll flag = 1;

    rep(i, 0, n) {
        ll num = a[i], tmp = 0;

        while(num % 2 == 0) {
            tmp++;
            num /= 2;
        }

        mp[2] += tmp > 0;

        for(ll i = 3 ; i*i <= num ; i += 2) {
            tmp = 0;
            while(num % i == 0) {
                tmp++;
                num /= i;
            }

            mp[i] += tmp > 0;
        }

        if(num > 2) mp[num]++;
    }

    for(auto i : mp) {
        if(i > 1) flag = 0;
    }

    if(flag) {
        cout << "pairwise coprime\n"; return;
    }

    cout << "setwise coprime\n";
}
 
int main(){
    // boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 18748
def overflow(s):
    if len(s) > 80:
        print('overflow')
    else: 
        print(s)

def string_sum(la, lb):
    d = abs(len(la) - len(lb))
    if len(la) > len(lb):
        lb = "0" * d + lb
    else:
        la = "0" * d + la
    ls = []
    carry = 0
    for a, b in zip(la[::-1], lb[::-1]):
        s = int(a) + int(b) + carry
        ls.append(str(s % 10))
        carry = s // 10
    if carry == 1:
        ls.append('1')
    return ''.join(ls[::-1])

n = int(input()) 
while n > 0:
    one = input()
    two = input()
    overflow(string_sum(one, two))
    n -= 1

Measured memory_bytes: 7624
// ---------- begin snipet ----------
pub trait MoOperator {
    type Answer;
    fn size(&self) -> usize;
    fn insert(&mut self, x: usize);
    fn delete(&mut self, x: usize);
    fn answer(&self) -> Self::Answer;
}

pub struct MoSolver<S> {
    query: Vec<(usize, usize)>,
    phantom: std::marker::PhantomData<S>,
}

impl<State: MoOperator> MoSolver<State> {
    fn new() -> Self {
        MoSolver {
            query: vec![],
            phantom: std::marker::PhantomData,
        }
    }
    fn add(&mut self, l: usize, r: usize) {
        self.query.push((l, r));
    }
    fn solve_with_size(&mut self, state: &mut State, answer: &mut [State::Answer], batch: usize) {
        let size = state.size();
        let mut q = vec![vec![]; size / batch + 1];
        for (k, &(l, r)) in self.query.iter().enumerate() {
            q[l / batch].push((r, l, k));
        }
        let mut x = 0;
        let mut y = 0;
        for (i, mut q) in q.into_iter().enumerate() {
            q.sort_unstable_by_key(|p| p.0);
            if i % 2 == 1 {
                q.reverse();
            }
            for (r, l, k) in q {
                while l < x {
                    x -= 1;
                    state.insert(x);
                }
                while y < r {
                    state.insert(y);
                    y += 1;
                }
                while x < l {
                    state.delete(x);
                    x += 1;
                }
                while r < y {
                    y -= 1;
                    state.delete(y);
                }
                answer[k] = state.answer();
            }
        }
    }
}
// ---------- end Mo algorithm ----------

struct State {
    c: Vec<usize>,
    cnt: Vec<u32>,
    ans: u32,
}

impl MoOperator for State {
    type Answer = u32;
    fn size(&self) -> usize {
        self.c.len()
    }
    fn insert(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&self) -> Self::Answer {
        self.ans
    }
}

fn solve(c: &[usize], ask: &[(usize, usize)]) -> Vec<u32> {
    let mut solver = MoSolver::new();
    for &(l, r) in ask {
        solver.add(l, r);
    }
    let mut state = State {
        c: c.iter().cloned().collect(),
        cnt: vec![0; c.len()],
        ans: 0,
    };
    let mut ans = vec![0; ask.len()];
    solver.solve_with_size(&mut state, &mut ans, 1024);
    ans
}

use proconio::*;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ans = solve(&c, &ask);
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 55556
#include<iostream>
using namespace std;
int main (){
	int W,V;
	for(;;){
		cin>>V>>W;
		if(W==0&&V==0){
			break;}
	for(int z = 0; z < V; z++ ){
	for(int y = 0; y < W; y++ ){
		if(z==0){
		    cout<<"#";
		}else if(y==0){
			cout<<"#";
		}else if(y==W-1){
			cout<<"#";
		}else if(z==V-1){
			cout<<"#";
        }else if(y!=0&&y!=W){
			cout<<".";}
		}cout<<endl;

	
	}cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i,n-2){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

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

    //列の数
    int n = stdIn.nextInt();
    //各マスの飴の個数
    int[][] a = new int[2][n];
    for (int i = 0 ; i < 2 ; i++ ) {
      for (int j = 0; j < n ; j++ ) {
        a[i][j] = stdIn.nextInt();
      }
    }

    //右下に向かって飴を取りながら進む、全パターン
    int sum = 0;
    int cmp = 0;

    for (int k = n ; k > 0 ; k-- ) {
      sum = 0;
      //1段目
      for (int j = 0; j < k ; j++ ) {
        sum += a[0][j];
      }
      //2段目
      for (int j = k - 1 ; j < n ; j++ ) {
        sum += a[1][j];
      }
      //今までの合計の最大値と比較
      if (sum >= cmp) {
        cmp = sum;
      } else {
        sum = cmp;
      }
    }

    System.out.println(sum);
  }
}


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

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        boolean[] ans = new boolean[4];
        
        ans[scan.nextInt()] = true;
        ans[scan.nextInt()] = true;
        
        for(int i = 1; i <4; i++){
            if(!ans[i]){
                out.println(i);
            }
        }
        out.close();
        
    }
}

Measured memory_bytes: 35860
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();

		for (int i = 0; i < s.length(); i++) {
			if ((int) (s.charAt(i) + n) <= 90) {
				System.out.print((char) (s.charAt(i) + n));
			} else {
				{
					System.out.print((char) ((s.charAt(i) + n) % 90 + 64));
				}

			}

		}
	}
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    int N;
    cin >> N;

    vector<int> order;
    for (int i = 0; i < N; i++)
    {
        int count;
        cin >> count;
        for (int j = 0; j < count; j++)
            order.push_back(i+1);
    }

    vector<vector<int>> grid(H, vector<int>(W));
    int h = 0, w = 0, direction = 1;
    for (const int x : order)
    {
        grid[h][w] = x;

        if (w == W-1 && direction == 1)
        {
            h++;
            direction = -1;
        }
        else if (w == 0 && direction == -1)
        {
            h++;
            direction = 1;
        }
        else w += direction;
    }

    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
            cout << grid[h][w] << " ";
        cout << endl;
    }
}


Measured memory_bytes: 384
//totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N=2e5+(33);
int h[N];
int a[N];
int tree[N];
void add(int change, int pos)
{
	while(pos<N)
	{
		tree[pos]=max(tree[pos],change);
		pos+=(pos&-pos);
	}
}
int query(int idx)
{
	int ans=0;
	while(idx>0)
	{
		ans=max(ans,tree[idx]);
		idx-=(idx&-idx);
	}
	return ans;
}
int32_t main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=n;i++)cin>>a[i];
	int upd;
	for(int i=1;i<=n;i++)
	{
		upd=a[i]+query(h[i]-1);
		add(upd,h[i]);
	}
	cout<<query(n);
	
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
const ll INF = 1LL << 60;
ll dp[1000010];

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

int main(){
    rep(i, 100010) dp[i] = INF;
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    dp[0] = 0;
    for (int i = 1; i < n;i++){
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i>1){
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[n - 1] << endl;
    
}

Measured memory_bytes: 4808
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


int main(){
    int N;
    cin >> N;
    int t_point = 0, h_point = 0;
    for(int i = 0; i < N; i++){
        string t, h;
        cin >> t >> h;
        if(t > h) t_point += 3;
        else if(t < h) h_point += 3;
        else {
            t_point++;
            h_point++;
        }
    }
    cout << t_point << ' ' << h_point << endl;
}


Measured memory_bytes: 3156
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] s = new String[10];
		s[0] = "0111111";
		s[1] = "0000110";
		s[2] = "1011011";
		s[3] = "1001111";
		s[4] = "1100110";
		s[5] = "1101101";
		s[6] = "1111101";
		s[7] = "0100111";
		s[8] = "1111111";
		s[9] = "1101111";
		
		while(true){
			int n = sc.nextInt();
			if(n==-1)break;

			String a = "0000000";
			int t = 0;
			
			for(int i=0;i<n;i++){
				StringBuffer sb = new StringBuffer();
				t = sc.nextInt();
				
				for(int j=0;j<7;j++){
					if(a.codePointAt(j)==s[t].codePointAt(j)){
						sb.append("0");
					}else{
						sb.append("1");
					}
				}
				System.out.println(sb.toString());
				a = s[t];
			}
		}
	}	
}

Measured memory_bytes: 20580
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){

	int cnt, N, W, value, weight, v[1001][1001], w[1001][1001];

	cnt = 0;

	while(1){
		cin >> W;
		if(W == 0) break;
		
		cnt++;
		cin >> N;

		for(int i=0; i<=N; i++){
			for(int j=0; j<=W; j++){
				v[i][j] = 0;
				w[i][j] = 0;
			}
		}
		
		for(int i=1; i<=N; i++){
			scanf("%d, %d", &value, &weight);
			for(int j=0; j<=W; j++){
				for(int k=0; k<=j; k++){
					if(w[i-1][k] + weight <= j && v[i-1][k] + value > v[i][j]){
						v[i][j] = v[i-1][k] + value;
						w[i][j] = w[i-1][k] + weight;
					}
					else if(v[i-1][k] > v[i][j]){
						v[i][j] = v[i-1][k];
						w[i][j] = w[i-1][k];
					}
					else if(v[i-1][k] == v[i][j] && w[i-1][k] < w[i][j]){
						w[i][j] = w[i-1][k];
					}
				}
			}
		}

		cout << "Case " << cnt << ":" << endl;
		cout << v[N][W] << endl;
		cout << w[N][W] << endl; 
		
	}

	return 0;

}

Measured memory_bytes: 9072
import math
N = 1
while True:
    n = int(input())
    if n == 0:
        break
    N = math.factorial(n)
    
    c = 0    
    while True:
        if N % 10 != 0:
            break
        else:
            N = N // 10
            c = c + 1
            
    print(c)



Measured memory_bytes: 5784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int n, m, x, ans[15], res = 1e9;
int a[15][15];
void dfs(int sum, int num) {
    if(sum == n + 1) {
        int flag = 0;
        for(int i = 1; i <= m; i++) {
            if(ans[i] < x) flag = 1;
        }
        if(!flag) res = min(res, num);
        return;
    }
    for(int i = 1; i <= m; i++) ans[i] += a[sum][i];
    dfs(sum + 1, num + a[sum][0]);
    for(int i = 1; i <= m; i++) ans[i] -= a[sum][i];
    dfs(sum + 1, num);
}
int main(){
    scanf("%d%d%d", &n, &m, &x);
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    dfs(1, 0);
    if(res == 1e9) printf("-1\n");
    else printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h> 
using namespace std; 
  
long long Zeros(long long  n) 
{ 
    if (n & 1LL) 
        return 0; 
  
    else { 
        long long ans = 0; 
  
        n /= 2; 
        while (n) { 
            ans += n / 5; 
            n /= 5; 
        } 
  
        return ans; 
    } 
} 
  
int main() 
{ 
long long n;
    cin>>n;
    
  
    cout << Zeros(n); 
  
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    size_t minlen = N;

    for (int64_t a = 1; a < sqrt(N)+1; ++a) {
        if (N % a == 0) {
            auto b = N / a;

            auto longer = std::max(boost::lexical_cast<std::string>(a).size(),
                                   boost::lexical_cast<std::string>(b).size());

            minlen = std::min(minlen, longer);
        }
    }

    std::cout << minlen << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DUMP(x) cout << #x << " = " << (x) << endl
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  if (a + b == c + d) cout << "Balanced" << endl;
  else if (a + b > c + d) cout << "Left" << endl;
  else cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
A = [int(x) for x in input().split()]

l = [0]*(N-1)
r = [0]*(N-1)

l[0] = A[0]
r[N-2] = A[-1]

for i in range(1, N-1):
    l[i] = l[i-1] + A[i]

for i in range(N-2)[::-1]:
    r[i] = r[i+1] + A[i+1]

ans = float('inf')
for i, j in zip(l,r):
    ans = min(ans, abs(i-j))
print(ans)


Measured memory_bytes: 30956
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		
		while(scan.hasNext()){
			int n=scan.nextInt();
			int c=0;
			for (int i = 0; i <= 9; i++) {
				for (int j = 0; j <= 9; j++) {
					for (int k = 0; k <= 9; k++) {
						for (int l = 0; l <= 9; l++) {
							if((i+j+k+l)==n)
								c++;
						}
					}
				}
			}
			System.out.println(c);
		}
		
	}

}

Measured memory_bytes: 18892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int D;
	long long G;
	vector<long long> p, c;

	cin >> D >> G;
	p.resize(D);
	c.resize(D);
	rep(i, D) cin >> p[i] >> c[i];

	long long res = 1 << 29;
	for (int bit = 0; bit < (1 << D); bit++) {
		long long sum = 0;
		long long num = 0;
		rep(i, D) {
			if (bit & (1 << i)) sum += c[i] + p[i] * 100 * (i+1), num += p[i];
		}
		if (sum >= G) res = min(res, num);
		else {
			for (int i = D-1; i >= 0; i--) {
				if (bit & (1 << i)) continue;
				for (int j = 0; j < p[i]; j++) {
					if (sum >= G) break;
					sum += 100 * (1+i);
					++num;
				}
			}
			res = min(res, num);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

q,r = divmod(n, 7)

res = 0
for i in range(n):
  for j in range(n):
    t = 7*i + 4 *j 
    if t == n:
      res += 1

if res > 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>

#include <functional>
using namespace std;

int main()
{
    int N, X;
    cin >> N >> X;
    int *m;
    int sum = 0;
    int tmp = 0;

    int ans, start, end;

    m = new int[N];
    for (int i = 0; i < N; i++)
    {
        cin >> m[i];
    }

    int min = m[0];
    for (int i = 1; i < N; i++)
    {
        if (min > m[i])
        {
            min = m[i];
        }
    }

    for (int i = 0; i < N; i++)
    {
        sum = sum + m[i];
    }

    X -= sum;

    tmp = X / min;

    cout << tmp + N << endl;
}


Measured memory_bytes: 3528
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

string vec[105];
int is_col_ok[105];

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	for (i = 0; i < n; i++){
		cin >> vec[i];
		for (j = 0; j < m; ++j)
			if (vec[i][j] != '.')
				break;
		if (j == m){
			--i;
			--n;
		}
	}
	int k;
	for (j = 0; j < m; j++){
		for (i = 0; i < n; i++){
			if (vec[i][j] != '.')
				break;
		}
		if (i == n){
			is_col_ok[j] = 1;
		}
	}
	for (i = 0; i < n; i++){
		for (j = 0; j < m; j++){
			if (is_col_ok[j] == 0)
				printf("%c", vec[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int v[1000001];
int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int i,j;
        int n=1000000;
        for(i=2; i*i<=n; i++){
            if(v[i]==0){
                for(j=i*i; j<=n; j=j+i){
                    v[j]=1;
                }
            }
        }
        int x;
        cin >> x;
        for(i=x; i<=n; i++){
            if(v[i]==0){
                cout <<i;
                return 0;
            }
        }

}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
using namespace std;
typedef long long unsigned int ll;

#define rep(i,n)for(i=0;i<n;i++)

#define INF (1e9)
#define PI  (acos(-1))


int dx[] = { 0, 0, 1,-1 };
int dy[] = { 1,-1, 0, 0 };

int main()
{
	int  i, j, H, W, dir;
	string s[50];
	cin >> H >> W;
	rep(i, H) {
		cin >> s[i];
	}
	rep(i, H) {
		rep(j, W) {
			if (s[i][j] == '.') continue;
			rep(dir, 4) {
				int ny = i + dy[dir];
				int nx = j + dx[dir];
				if (ny < 0 || nx < 0 ||
					ny >= H || nx >= W) continue;
				if (s[ny][nx] == '#') {
					break;
				}
			}
			if (dir == 4) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	return 0;

}



Measured memory_bytes: 256
/*
 © 2020-07-11 06:54:04 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli l, r, d; cin >> l >> r >> d;
  cout << (r / d) - ((l - 1) / d) << ENDL;
  return 0;
}


Measured memory_bytes: 3660
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String result = "No";
	
		if (a < b && b < c) {
			result = "Yes";
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 26332
#include<stdio.h>
#include<string.h>

int main ()
{
   
    int a,b,i,s=0;
    scanf("%d",&a);
    int x[a];
    for(i=0;i<a;i++)
    {
        x[i]=0;
    }
    for(i=0;i<(a-1);i++)
    {
        scanf("%d",&b);
        x[b]++;
    }
    for(i=1;i<a;i++)
    {
        printf("%d\n",x[i]);
    }
    printf("%d\n",0);
    
    return 0;
}


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

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

using namespace std;

int main(){
	string a[3];
	rep(i,3) cin>>a[i];

	int t=0,idx[3]={};
	while(idx[t]<a[t].size()) t=a[t][idx[t]++]-'a';
	cout<<(char)('A'+t)<<'\n';

	return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		byte[] asciiCodes;
		String s = next();
        try {
            asciiCodes = s.getBytes("US-ASCII");
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        asciiCodes[0]++;
        if(asciiCodes[0]==123)asciiCodes[0] = 97;
        String res;
        try {
			res = new String(asciiCodes, "US-ASCII");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
            return;
		}

		out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
  int D, G; cin >> D >> G;
  vector<int> p(D), c(D);

  for(int i = 0; i < D; i++) cin >> p[i] >> c[i];

  ll res = 1<<29;
  for(int bit = 0; bit < (1<<D); bit++) {
    ll sum = 0, num = 0;
    for(int i = 0; i < D; i++) {
      if(bit & (1<<i)) sum += c[i]+p[i]*100*(i+1), num += p[i];
    }
    if(sum >= G) res = min(res, num);
    else {
      for(int i = D-1; i >= 0; i--) {
        if(bit & (1<<i)) continue;
        for(int j = 0; j < p[i]; j++) {
          if(sum >= G) break;
          sum += (i+1)*100;
          num++;
        }
      }
      res = min(res, num);
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

std::string S;

int main()
{
  std::cin >> S;

  rep( i, S.size()-1 )
  {
    if( S[i] == S[i+1] )
    {
      std::cout << "Bad" << std::endl;

      return 0;
    }
  }

  std::cout << "Good" << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <iostream>
#define ll long long
using namespace std;

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a + b + c >= 22)
		printf("bust\n");
	else
		printf("win\n");
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0]*m
c = [0]*m
sortsecond = lambda val: val[1]

x = [list(map(int, input().split())) for _ in range(m)]

x.sort(key=sortsecond)

a.sort()


i = 0
for j in range(m):
    times = x[-(j+1)][0]
    number = x[-(j+1)][1]
    while times > 0 :

        try:
            temp = a[i]
        except IndexError:
            print(sum(a))
            exit()
        
        if temp < number:
            a[i] = number
        else:
            print(sum(a))
            exit()
        times -= 1
        i += 1
print(sum(a))

Measured memory_bytes: 74648
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int A,B,C;
    cin >> A >> B >> C;
    cout << min(A,C)+B+min(B+1,max(0LL,C-A)) << endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector< vector<char> > a((H+2), vector<char> ((W+2), '#'));
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      if (i!=0 && i!=H+1) {
        if (j!=0 && j!=W+1) {
          cin >> a.at(i).at(j);
        }
      }
    }
  }
  
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      cout << a.at(i).at(j) << flush;
      if (j==W+1) {
        cout << endl;
      }
    }
  }
  
  
  
  /*
  vector<char> a((H+2)*(W+2), "#");
  for (int i=0; i<(H+2)*(W+2); i++) {
    if ( (i !< W+2) || (i !> (H+2)*(W+2)-(W+2)-1 ) ) {
      if ( (i%(W-1)==0) || (i%*W==0) ) {
        cin >> a.at(i);
      }
    }
  }
  
  for (int i=0; i<(H+2)*(W+2); i++) {
    cout << a.at(i) << flush;
    if(i%(W-1)==0) cout << endl;
  }
  */
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int n; cin >> n;
    vector<string> blue;
    string x;
    string y;
    for(int i = 0;i < n;i++){
        cin >> x;
        blue.push_back(x);
    }
    
    int m; cin >> m;
    vector<string> red;
    for(int i = 0;i < m;i++){
        cin >> y;
        red.push_back(y);
    }
    
    vector<string> bluecopy(n);
    copy(blue.begin(),blue.end(),bluecopy.begin());
    
    vector<string> redcopy(m);
    copy(red.begin(),red.end(),redcopy.begin());
   
    redcopy.insert(redcopy.end(),bluecopy.begin(),bluecopy.end());
    redcopy.erase(unique(redcopy.begin(),redcopy.end()),redcopy.end());
    
    
    int cnt1,cnt2,ans = 0;
    string h;
    for(int i = 0;i < redcopy.size();i++){
        cnt1 = 0;
        cnt2 = 0;
        h = redcopy[i];
        for(int j = 0;j < blue.size();++j){
            if(blue[j] == h){
                cnt1++;
            }
        }
        
        for(int j = 0;j < red.size();++j){
            if(red[j] == h){
                cnt2++;
            }
        }
        ans = max(ans,cnt1-cnt2);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int cnt=0,mc=0,mi=1000;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<s.size();j++){
      if(s[i]==s[j]){
        mc=max(mc,cnt);
        cnt=0;
      }else{
        cnt++;
      }
    }
    mc=max(mc,cnt);
    cnt=0;
    mi=min(mc,mi);
    mc=0;
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 256
import io.StdIn._
 
object Main extends App {
  val n = readInt
 
  require(2 <= n && n <= 100000)
 
  def isPrime(n: Int): Boolean = (2 until n).toList.forall(n % _ != 0)
 
  def minPrime(n: Int): Option[Int] = (n to 200000).find(isPrime)
 
  minPrime(n).map(println)
}

Measured memory_bytes: 70616