akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a;
    char s[max];
    
    scanf("%s", s);
    rep(i, 3){
        printf("%c", s[i]);
    }
    
    return 0;
}



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

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

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var values = cin.ReadIntArray(2);
            var N = values[0];
            var X = values[1];
            int[] mlist = new int [N];
            var ans = 0;
            
            for(int i= 0; i<N; i++){
                mlist[i]= cin.ReadInt;
            }
            
            ans = ans + N;
            
            X = X - mlist.Sum();
            var min = mlist.Min();
            //WriteLine(X);
            
            ans = N + (X/min);
        
            
            WriteLine(ans);
        }
    }

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

Measured memory_bytes: 13524
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 21332
H,W,K=map(int,input().split())
S=[[int(x) for x in list(str(input()))] for _ in range(H)]
T=[[0]*(W+1) for x in range(H+1)]

for h in range(H):
  for w in range(W):
    T[h][w]=T[h][w-1]+S[h][w]

for h in range(1,H):
  for w in range(W):
    T[h][w]=T[h][w]+T[h-1][w]

m=(H-1)*(W-1)
for p in range(2**(H-1)):
  D=[x for x in range(H-1) if p&(2**x)!=0]+[H-1]
  c,b=0,-1
  f=False
  for w in range(W):
    u=-1
    for d in D:
      if T[d][w]-T[u][w]-T[d][b]+T[u][b]>K:
        if b==w-1:
          f=True
        c,b=c+1,w-1
        break
      u=d
    if f==True:
      break
  else:
    m=min(m,c+len(D)-1)
print(m)




Measured memory_bytes: 3444
#include<stdio.h>

int main(){
  long long int a,b,c,k;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
  if(k%2==0)
    printf("%lld\n",a-b);
  else
    printf("%lld\n",b-a);
}

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

#define ll long long 
#define pb push_back
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()

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

	char c; cin >> c;
	cout << (char)(c + 1);

	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n;
  string t[2],k[2];
  int anst=0,ansh=0;
  cin >> n;
  while(cin>>t[0]>>t[1]){
    k[0] = t[0];
    k[1] = t[1];
    //cout << t[0] << ' ' << t[1] << endl;
    sort(t,t+2);
    //cout << t[0] << ' ' << t[1] << endl;
    if(t[0]==t[1]){
      anst += 1;
      ansh += 1;
    }
    else if(t[0]==k[0]&&t[1]==k[1]) ansh += 3;
    else anst += 3;
  }
  cout << anst << ' ' << ansh << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

const int mod = (int) 1e9 + 7;
const int Mx = (int) 1e6 + 9;

ll fact[Mx + 9];
ll factInv[Mx + 9];
ll dp[Mx + 9];

ll C(const int n, const int k) {
	return fact[n] * factInv[k] % mod * factInv[n - k] % mod;
}

ll modPow(ll n, ll k) {
	ll res = 1;
	for (n %= mod; k; k >>= 1) {
		if (k & 1)
			res = res * n % mod;
		n = n * n % mod;
	}
	return res;
}

ll modInv(const ll x) {
	return modPow(x, mod - 2);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	fact[0] = factInv[0] = 1;
	for (int i = 1; i <= Mx; ++i) {
		fact[i] = fact[i - 1] * i % mod;
		factInv[i] = modInv(fact[i]);
	}

	int N, H, D;
	cin >> N >> H >> D;

	ll K = 0;
	for (int i = 0; i < N; ++i) {
		K += fact[i + 1];
		K %= mod;
	}

	dp[H] = 1;

	for (int h = H - 1; h >= 1; --h) {
		dp[h] = K * (dp[h + 1] - dp[min(H, h + D) + 1]) % mod;
		dp[h] += dp[h + 1];
		dp[h] %= mod;
	}

	const ll res = fact[N] * (dp[1] - dp[min(H, D) + 1]);
	cout << (res % mod + mod) % mod;
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= 13) ans = b;
    else if (a >= 6) ans = b/2;
    else ans = 0;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

typedef unsigned long long ull;

int main(void){
	int N, A, max = -1;
	int x[51] = {0};
	scanf("%d %d",&N,&A);
	for(int a = 1; a < N+1; a++) scanf("%d", &x[a]);
	for(int a = 1; a < N+1; a++){
		if(x[a] > max) max = x[a];
	}
	if(max < A) max = A;

	ull list[N+1][N+1][N*max+1];
	ull result = 0;

	for(int a = 0; a < N+1; a++){
		for(int b = 0; b < N+1; b++){
			for (int c = 0; c < N*max+1; c++){
				if(!a && !b && !c){
					list[a][b][c] = 1; //first principle
				} else if(a >= 1 && c < x[a]){
					list[a][b][c] = list[a-1][b][c]; // second principle
				} else if(a >= 1 && b >= 1 && c >= x[a]){
					list[a][b][c] = list[a-1][b][c] + list[a-1][b-1][c-x[a]]; // third principle
				} else {
					list[a][b][c] = 0; // fourth principle
				}
			}
		}
	}

	for(int a = 1; a < N+1; a++) result += list[N][a][a*A];
	printf("%llu\n",result);
	return 0;
}

Measured memory_bytes: 50944
cards = []
nums = []
while True:
    card = raw_input()
    if card == '-': 
        break   
    cards += [card]
    n = 0   
    for _ in range(int(raw_input())):
        n += int(raw_input())
    nums += [n]

for c, n in zip(cards, nums):
    w = c * ((max(len(c), n)/n)+10)
    print w[n:n+len(c)]

Measured memory_bytes: 6448
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
using u8t = std::uint64_t;
using i8t = std::int64_t;

int main() {
  i8t A,B;
  std::cin>>A>>B;
  if(A==B){
    std::cout<<1<<std::endl;
  }else{
    std::vector<i8t> a,b;
    while(A!=B){
      a.push_back(A&1);
      b.push_back(B&1);
      A>>=1;B>>=1;
    }

    i8t AA=0;
    for(int i=0;i<a.size();i++)AA|=a[i]<<i;
    i8t count1 = ((i8t)1<<a.size()-1) - AA;
    int msb=0;
    for(msb=b.size()-2;msb>=0&&b[msb]==0;msb--);
    i8t count2a = (i8t)1<<msb+1;
    i8t count2=std::min(count1+count2a, (i8t)1<<b.size()-1);
    std::cout <<count1+count2<<std::endl;

    // std::cout<<"AA="<<AA<<std::endl;;
    // std::cout<<"c1="<<count1<<std::endl;;
    // std::cout<<"c2.1="<<count2a<<std::endl;;
  }

  return 0;
}

Measured memory_bytes: 256
let words str = Str.split (Str.regexp " ") str |> List.map int_of_string

let bs elem (a: int array) =
  let rec loop (i_min,i_max) =
    match i_min > i_max || i_max < i_min with
      true -> false
    | false ->
      let mid = (i_min+i_max)/2 in
      match a.(mid) = elem with
        true -> true
      | false ->
        loop (match a.(mid) < elem with true -> mid+1,i_max | false -> i_min,mid-1)
  in loop (0,(Array.length a) -1)

let () =
  let _ = read_int () in
  let s = read_line () |> words |> Array.of_list in
  let _ = read_int () in
  let t = read_line () |> words in
  List.fold_left (fun acc x -> match bs x s with true -> acc+1 | false -> acc)
    0 t
  |> Printf.printf "%d\n"

Measured memory_bytes: 16236
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char S[15];
int main() {
	scanf("%s", S);
	string s = S;
	printf(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi" ? "Yes\n" : "No\n");
}


Measured memory_bytes: 3760
S=input()
N=len(S)
A=0
Z=0
for i in range(N):
  if S[i]=='A':
    A=i
    #print(A)
    break
    
for i in range(N)[::-1]:
  if S[i]=='Z':
    Z=i
    #print(Z)
    break
    
ans=Z-A+1
print(ans)

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    map<int,int>mp;
    int cnt=1;
    for(int i=2;i<=13;i++)
        mp[i]=cnt++;
    mp[1]=cnt;
    int a,b;
    cin>>a>>b;
    if(mp[a]>mp[b])
        cout<<"Alice"<<endl;
    else if(mp[b]>mp[a])
        cout<<"Bob"<<endl;
    else
        cout<<"Draw"<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int k,s;
	cin>>k>>s;
	int ans = 0;
	for (int x = 0; x <= k; x++){
		for (int y = 0; y <= k; y++){
			if(0<= s-(x+y) && s-(x+y) <= k) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
  int A,B;
  cin>>A>>B;
  if(A<B){
  	int a=A;
    A=B;
    B=a;
  }//A>B
  for(int k=0;A-k>0;k++){
  	int a=A-k;
    int b=B-k;
    if(a<0){a=a*-1;}
    if(b<0){b=b*-1;}
    if(a==b){
      cout<<k;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE";
  return 0;
}

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

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	if (s == "SUN") {
		cout << 7 << endl;
	} else if (s == "MON") {
		cout << 6 << endl;
	} else if (s == "TUE") {
		cout << 5 << endl;
	} else if (s == "WED") {
		cout << 4 << endl;
	} else if (s == "THU") {
		cout << 3 << endl;
	} else if (s == "FRI") {
		cout << 2 << endl;
	} else if (s == "SAT") {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

ll choose2(ll n){
  return n*(n-1)/2;
}
 
int main(){
  double n,k;
  cin>>n>>k;
  double ans=0;
  rep(i,n){
    double tot=1/n;
    int cnt=i+1;
    while(cnt<k){
      tot/=2;
      cnt*=2;
    }
    ans+=tot;
  }
  printf("%.10f\n",ans);
}

Measured memory_bytes: 3736
k=[]
def abc(n,s,i,b):
    if b:
        if b==n:
            k.append(s)
            return
        k.append(s)
        if i==0:
            abc(n,s*10+0,0,b+1)
            abc(n,s*10+1,1,b+1)
        elif i==9:
            abc(n,s*10+9,9,b+1)
            abc(n,s*10+8,8,b+1)
        else:
            abc(n,s*10+(i-1),i-1,b+1)
            abc(n,s*10+i,i,b+1)
            abc(n,s*10+i+1,i+1,b+1)
    else:
        for i in range(1,10):
            abc(n,s*10+i,i,b+1)
abc(10,0,0,0)

k.sort()
n=int(input())
print(k[n-1])


Measured memory_bytes: 12332
#include <bits/stdc++.h>
#define maxn 51
#define mod (int)(1e9+7)
using namespace std;

#define mask (1<<17)-1

int f[maxn][mask];
inline int Append(int st,int x){
	st = ((st << x) | (1 << (x-1))) & mask;
	return st;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n,x,y,z;
	cin>>n>>x>>y>>z;
	
	int stc = 0;
	stc = Append(stc,x);
	stc = Append(stc,y);
	stc = Append(stc,z);
	
	f[0][0] = 1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=mask;j++)
			for (int k=1;k<=10;k++){
				int ns = Append(j,k);
				if ((stc & ns) != stc){
					f[i][ns] = (f[i-1][j] + f[i][ns]) % mod;
				}
			}
			
	int ans = 1;
	for (int i=1;i<=n;i++) ans = 10LL * ans % mod;
	
	for (int i=1;i<=mask;i++) ans = (ans - f[n][i]) % mod;
	
	cout<<(ans+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 22272
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
using vi = vector<int>;

string str;
string stra;
int id = 0;

void pt(vector<int> v){
  for(int r=0;r<v.size();r++){
    cout << v[r];
  }
  cout << endl;
}

vi number(){
  vi res;
  for (;'0'<=stra[id]&&stra[id]<='9'; id++) {
    res.push_back(stra[id] - '0');
  }
  reverse(res.begin(),res.end());
  return res;
}
int solve(){
  stra = str;
  for (int i = 9; i >= 0; i--) {
    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }
    vi b = number();

    //a.resize(max(b.size() + 1,a.size()+1),0);

    a.push_back(0);
    while(a.size()<=b.size()){
      a.push_back(0);
    }
    for (int j = 0; j < (int)b.size(); j++) {
      a[j] += b[j];
      // if (a[j]>=10) {
      //   a[j] -= 10;
      //   a[j+1]++;
      // }
    }
    // for (int j = b.size(); j < (int)(a.size()-1); j++) {
    //   if (a[j] >= 10) {
    //     a[j] -= 10;
    //     a[j+1]++;
    //   }
    // }
    for(int j=0;j<(int)a.size()-1;j++){
      if(a[j]>=10){
        a[j]-=10;
        a[j+1]++;
      }
    }

    if(a[a.size()-1]==0){
      a.pop_back();
    }

    //pt(a);
    // int j;
    // int k=0;
    // int l=0;
    // vi ab;
    // for(j=0;j<int(a.size())&&j<int(b.size());j++){
    //   k=0;
    //   if(a[j]+b[j]+l>=10){
    //     k++;
    //     ab.push_back(a[j]+b[j]+l-10);
    //   }
    //   else{
    //     ab.push_back(a[j]+b[j]+l);
    //   }
    //   l=k;
    // }
    // for(;j<int(a.size());j++){
    //   k=0;
    //   if(a[j]+l>=10){
    //     k++;
    //     ab.push_back(a[j]+l-10);
    //   }
    //   else{
    //     ab.push_back(a[j]+l);
    //   }
    //   l=k;
    // }
    // for(;j<int(b.size());j++){
    //   k=0;
    //   if(b[j]+l>=10){
    //     k++;
    //     ab.push_back(b[j]+l-10);
    //   }
    //   else{
    //     ab.push_back(b[j]+l);
    //   }
    //   l=k;
    // }
    // if(l>0){
    //   ab.push_back(l);
    // }
    // a=ab;
    /////////
    if (stra[id] == '=') {
      id++;
    }

    vi c = number();
    if (a.size() != c.size()) {
      continue;
    }
    int flag = 0;
    for (int j = 0; j < (int)a.size(); j++) {
      if (a[j] == c[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    }

  }
  return -1;
}
int main(){
  cin >> str;
  while(str.size()){
  int ans = solve();
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    cout << "NA" << endl;
  }
  str="";
  cin >> str;
}
  return 0;
}



Measured memory_bytes: 3048
#include<iostream>
#include<string>
int main(void) {
	int NumberOfCombat;
	std::cin >> NumberOfCombat;
	struct STATUS {
		std::string card;
		int points;
	};
	STATUS Taro, Hanako;
	Taro.points = 0;
	Hanako.points = 0;
	for (int i = 0; i < NumberOfCombat; ++i) {
		Taro.card, Hanako.card;
		std::cin >> Taro.card >> Hanako.card;
		if (Taro.card == Hanako.card) {
			Taro.points += 1;
			Hanako.points += 1;
		}
		int CardSizeMax = (Taro.card).size();
		if ((Taro.card).size() < (Hanako.card).size()) {
			CardSizeMax = (Hanako.card).size();
		}
		for (int j = 0; j < CardSizeMax; ++j) {
			int CRITERION = ((Taro.card).size() <= CardSizeMax ? Taro.card[j] : 0) - ((Hanako.card).size() <= CardSizeMax ? Hanako.card[j] : 0);
			if (CRITERION > 0) { Taro.points += 3; break; }
			else if (CRITERION < 0) { Hanako.points += 3; break; }
		}
	}
	std::cout << Taro.points << " " << Hanako.points << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3184
// Problem : F - Range Set Query
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 500005

//Solution

int a[N],n,q;
int cnt[N],cur_ans;

void remove(int idx){
    cnt[a[idx]]--;
    if(cnt[a[idx]] == 0) cur_ans--;
} 
void add(int idx){
    if(cnt[a[idx]] == 0) cur_ans++;
    cnt[a[idx]]++;
}     
int get_answer(){
    return cur_ans;
}

int block_size;

struct Query {
    int l, r, idx;
    bool operator<(Query other) const
    {
        return make_pair(l / block_size, r) <
               make_pair(other.l / block_size, other.r);
    }
};

vector<Query> queries;

vector<int> mo_s_algorithm(vector<Query> &queries) {
    vector<int> answers(queries.size());
    sort(queries.begin(), queries.end());

    // TODO: initialize data structure

    int cur_l = 0;
    int cur_r = -1;
    // invariant: data structure will always reflect the range [cur_l, cur_r]
    for (Query q : queries) {
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        answers[q.idx] = get_answer();
    }
    return answers;
}

void solve(){
    cin>>n>>q;
    block_size = sqrt(n)+5;
    for(int i=0;i<n;i++) cin>>a[i];
    queries.resize(q);
    for(int i=0;i<q;i++){
        cin>>queries[i].l>>queries[i].r;
        queries[i].l--; queries[i].r--;
        queries[i].idx = i;
    }
    vi ans = mo_s_algorithm(queries);
    for(int i : ans) cout<<i<<'\n';
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 15516
H, W = gets.split(' ').map(&:to_i)
grid = []
H.times do
  grid.push(gets.chomp)
end

ans = 'Yes'
H.times do |i|
  W.times do |j|
    if grid[i][j] == '#'
      if i > 0 && grid[i - 1][j] == '#'
        next
      elsif i < (H - 1) && grid[i + 1][j] == '#'
        next
      elsif j > 0 && grid[i][j - 1] == '#'
        next
      elsif j < (W - 1) && grid[i][j + 1] == '#'
        next
      else
        ans = 'No'
        break
      end
    end
  end
end

puts ans

Measured memory_bytes: 3836
#include<stdio.h>

int a;
int b;
int c;
int chukan;

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

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	cout << fixed << std::setprecision(6);
	int n;
	static int s[1000];
	while (1) {
		cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n; ++i) {
			cin >> s[i];
		}
		double sum=0;
		double m;
		for (int i = 0; i < n; ++i) {
			sum += s[i];
		}
		m = sum / n;
		//cout << m << endl;
		double sigma2 = 0;
		for (int i = 0; i < n; ++i) {
			sigma2 += pow(s[i] - m, 2);
		}
		sigma2 /= n;
		cout << sqrt(sigma2) << endl;
	}
	return 0;
}



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

void go(string& s, char prev_max_char, int N){
  if(s.length() == N){
    cout << s << endl;
    return;
  }

  for(char c = 'a'; c <= prev_max_char + 1; c++){
    s.push_back(c);
    go(s, max(prev_max_char, c), N);
    s.pop_back();
  }
}

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

  string s = "a";
  go(s, 'a', N);
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    ll x; cin >> x;
    ll now = 100;
    ll ans = 0;
    while(now < x){
        ll add = now/100;
        now += add;
        ans++;
    }
    cout << ans << endl;
}



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

int main(){
  string s;
  int ans=0;
  while(cin>>s){
    int flag=1;
    for(int i=0;i<s.size()/2;i++){
      if(s[i]!=s[s.size()-1-i]){
        flag=0;
        break;
      }
    }
    if(flag)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3000
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<int> vec;
  ll res = 0;
  int maxi = -1;
  rep(i, n){
    int x;
    cin >> x;
    res += x;
    maxi = max(x, maxi);

  }
  cout << res - maxi / 2 << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n;
  cin >> n;
  n %= 10;

  if(n==0 || n==1|| n==6 || n == 8){
    cout << "pon" << endl;
  }else if(n==3){
    cout << "bon" << endl;
  }else{
    cout << "hon" << endl;
  }
}



Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <algorithm>

using namespace std; 

int main()
{
	int a, b, k;

	cin >> a >> b;

   if((a+b)%2==0){
     k=(a+b)/2;
  	  cout << k << endl;
   }
   else{
     cout << "IMPOSSIBLE" << endl;
   }

	return 0;
}

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

class Main {
	int n;
	long[] a;
	long grundy = 0;

	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			grundy ^= a[i];
		}
		boolean[] flip = new boolean[64];
		for (int i = 0; i < n; ++i) {
			flip[cnt(a[i] & -a[i])] = true;
		}
		int ans = 0;
		while (grundy > 0) {
			long c = 1;
			while (2 * c <= grundy) {
				c <<= 1;
			}
			if (!flip[cnt(c)]) {
				System.out.println(-1);
				return;
			} else {
				++ans;
				while (c > 0) {
					grundy ^= c;
					c /= 2;
				}
			}
		}
		System.out.println(ans);
	}

	int cnt(long x) {
		int ret = 0;
		while (x > 0) {
			++ret;
			x /= 2;
		}
		return ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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

Measured memory_bytes: 50100
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
ll S(ll x){
    ll ans=0;
    string s=to_string(x);
    REP(i,0,s.size())ans+=(s[i]-'0');
    return ans;
}
int main(){
  ll k;
  cin>>k;
  ll ans=1;
  ll d=1;
  REP(i,0,k){
    cout<<ans<<endl;
    if(1.0*(ans+d)/S(ans+d)>d) d*=10;
    ans+=d;
  }
  return 0;
}

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

int main(){
  int T;
  cin >> T;
  while(T--){
    int n,m;
    cin >> n >> m;
    if(n <= m){
      int a;
      for(int i=0;i<n;i++) cin >> a;
      cout << 0 << endl;
    } else {
      int p[100000], dis, x[100000];
      p[0] = 0;
      for(int i=0;i<n;i++){
        cin >> x[i];
        if(i > 0) p[i-1] = x[i] - x[i-1];
      }
      sort(p,p+n-1);
      dis = x[n-1] - x[0];
      for(int i=0;i<m-1;i++) dis -= p[n-i-2];
      cout << dis << endl;
    }
  }
}

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

int main(){
	int tmp,i = 0,j,k = 0,f[11];
	vector<int> ans;

	while(cin>>tmp){
		if(tmp == 0){
			ans.push_back(f[i-1]);
			f[i-1] = '\0';
			i--;
			k++;
		}
		else{
		f[i] = tmp;
		i++;
		}
	}
	for(j = 0;j < k;j++){
		cout<<ans[j]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(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 nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static long findGCD(long number1, long number2) {
        if (number2 == 0) {
            return number1;
        }
        return findGCD(number2, number1 % number2);
    }
    static class node implements Comparator<node>{
        long first;
        long second;

        public node(long a, long b){
            this.first = a;
            this.second = b;
        }
        @Override
        public int compare(node o1, node o2) {
            return (int)(o1.second-o2.second);
        }
    }

        public static void main(String[] args) {
            FastReader sc = new FastReader();
            int n = sc.nextInt();
            PriorityQueue<node> pq = new PriorityQueue<>(new node(0,0));
            for(int i=0; i<n; i++){
                pq.add(new node(sc.nextLong(),sc.nextLong()));
            }
            boolean check = true;
            long time = 0;
            while (!pq.isEmpty()){
                node temp = pq.poll();
                time+=temp.first;
                if(time>temp.second){
                    check=false;
                    break;
                }
            }
            if(check){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
            }
        }









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

int main() {
  int N;
  cin >> N;
  int M = N;
  int sum=0;
  while(M>=1){
    sum+=M%10;
    M/=10;
  }
  if(N%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CNextPrime {
public:
    bool is_prime(int x){
        for(int i=2;i*i<=x;++i){
            if(x%i==0) return false;
        }
        return true;
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int X;
        in>>X;
        while(true){
            if(is_prime(X)){
                out<<X<<'\n';
                return;
            }
            ++X;
        }
    }
};


int main() {
	CNextPrime solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
vector<vector<int>>s(100030);
vector<vector<int>>sb(100030);
int tomodati[100030] = {};
int seen[100030] = {};
int namaes[100030] = {};
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		s[a].push_back(b);
		s[b].push_back(a);
	}

	for (int i = 0; i < k; i++) {
		int c, d;
		cin >> c >> d;
		sb[c].push_back(d);
		sb[d].push_back(c);
	}
	int namae = 0;
	for (int i = 1; i <= n; i++) {
		if (seen[i] == 1) {
			continue;
		}
		namae++;
		tomodati[i] = namae;
		seen[i] = 1;
		queue<int> q;
		q.push(i);
		while (q.size()) {
			int p = q.front();
			q.pop();
			for (auto j : s[p]) {
				if (seen[j] == 0) {
					q.push(j);
					seen[j] = 1;
					tomodati[j] = namae;
					namaes[namae]++;
				}
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		int count = 0;
		count = namaes[tomodati[i]];
		count = count - s[i].size();
		for (auto j : sb[i]) {
			if (tomodati[i] == tomodati[j]) {
				count = count - 1;
			}
		}
		if (count < 0) {
			cout << 0 << " ";
		}
		else {
			cout << count << " ";
		}
	}
}


Measured memory_bytes: 13048
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int i,j;
  int sum=0,ok=0;
  vector<int> a(3,0),b(3,0);
  vector<vector<int>> c(3,vector<int>(3,0));
  for(i=0;i<3;++i)
    for(j=0;j<3;++j)
      cin>>c.at(i).at(j);
  a.at(0)=min(min(c.at(0).at(0),c.at(0).at(1)),c.at(0).at(2));
  a.at(1)=min(min(c.at(1).at(0),c.at(1).at(1)),c.at(1).at(2));
  a.at(2)=min(min(c.at(2).at(0),c.at(2).at(1)),c.at(2).at(2));
  b.at(0)=c.at(0).at(0)-a.at(0);
  b.at(1)=c.at(0).at(1)-a.at(0);
  b.at(2)=c.at(0).at(2)-a.at(0);
  
  if(a.at(1)+b.at(1)==c.at(1).at(1))++ok;
  if(a.at(1)+b.at(2)==c.at(1).at(2))++ok;
  if(a.at(2)+b.at(1)==c.at(2).at(1))++ok;
  if(a.at(2)+b.at(2)==c.at(2).at(2))++ok;
  
  
  if(ok==4)cout<<"Yes"<<endl;
  else if(ok!=4)cout<<"No"<<endl;
}

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

int N;
string S;
bool mem[100];

int main()
{
    cin >> S;
    N = S.size();

    if(N < 26)
    {
        for(int i = 0; i < N; i++)mem[S[i] - 'a'] = true;
        for(int i = 0; i < 26; i++)if(!mem[i])
        {
            S += i + 'a';
            break;
        }
        cout << S << endl;
        return 0;
    }
    int cnt;
    for(int i = N - 1; i >= 0; i--)
    {
        cnt = i;
        if(i != 0 && S[i - 1] < S[i])break;
    }
    if(cnt == 0)
    {
        printf("-1\n");
        return 0;
    }
    int MIN = 1001001001;
    for(int i = cnt; i < N; i++)
    {
        if(S[i] > S[cnt - 1])MIN = min(MIN,(int)(S[i] - 'a'));
    }
    for(int i = 0; i < cnt - 1; i++)printf("%c",S[i]);
    printf("%c\n",'a' + MIN);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rem(i, s, n) for (int i = (s); i >= (n); --i)
using ll = long long;
const int MOD = 1e9 + 7;

bool IsPrime(int num)
{
    if (num < 2)
        return false; 
    else if (num == 2)
        return true; 
    else if (num % 2 == 0)
        return false; 

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false; 
        }
    }

    return true;
}

int main(){
    ll x; cin >> x;

    while (!IsPrime(x)) x++;

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
 
int main(void)
{
	int a,b,c,d,e,f;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<b)	e=a;
	else e=b;
	if(c<d)	f=c;
	else f=d;
	printf("%d\n",e+f);
    return 0;
}

Measured memory_bytes: 128
L, R = gets.split.map(&:to_i)

if (L..R).any? {|x| x % 2019 == 0 }
  puts 0
  exit
end

l = L % 2019
r = R % 2019

ans = (l..r).to_a.combination(2).map do |a, b|
  if a == b
    2018
  else
    (a * b) % 2019
  end
end.min

puts ans


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

using namespace std;
using ll = long long;

int main()
{
    string s;
    string t;
    ll c = 0;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  for (int i=0; i<n; i++){
    cin >> num[i];
  }
  sort(num.begin(), num.end());
  cout << num[n/2] - num[n/2 - 1] << endl;
}


Measured memory_bytes: 640
N, K = map(int, input().split(" "))
R, S, P = map(int, input().split(" "))
T = input()

score_by_hand = {"r": P, "s": R, "p": S}
result = 0
score = 0
for k in range(K):
    column = T[k::K]
    before = None
    for hand in column:
        if hand == before:
            before = None
        else:
            score += score_by_hand[hand]
            before = hand

print(score)

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

int main() {
  string s;
  int k;
  cin>>k>>s;
  
  if(s.size()<=k)cout<<s<<endl;
  if(s.size()>k){
    for (int i = 0; i < k; i++) {
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
  
}

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

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}


int main () {
	int x, y;
	cin >> x >> y;
	bool f = false;
	rep(i, 0, x + 1) {
		int h = 2  * i + 4 * (x - i);
		if (h == y) {
			f = true;
			break;
		}
	}
	if (f)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

int main(){
	int d,n;
	cin >> d >> n;
	int ans = 1;
	rep(i,d) ans*=100;
	if(n!=100){
		ans *= n;
		cout << ans << endl;
	}else{
		ans *= n;
		int temp = 1;
		rep(i,d) temp *= 100;
		ans += temp;
		cout << ans << endl;
	}
    return 0;
}



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

ll choose(ll n){
    return n*(n-1)/2;
}

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    rep(i,n)a[i]--;
    vector<int>cnt(n);
    rep(i,n)cnt[a[i]]++;
    ll tot=0;
    rep(i,n){
       tot+=choose(cnt[i]);
    }
    rep(i,n){
        ll ans=tot;
        ans-=choose(cnt[a[i]]);
        ans+=choose(cnt[a[i]]-1);
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int a,b,c;

  cin>>a>>b>>c;

  int i;
  
  for(i=0;i<=10000;i++){
    if((a*i)%b==c){
      cout<<"YES"<<endl;
      break;
    }
  }
  if(i==10001){
    cout<<"NO"<<endl;
  }
  
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<cmath>
#define fi first
#define se second
#define ll long long
using namespace std;
ll n,s,ans;
map<ll,ll> Map,D,vis;
int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&s);ll nw=1,de=1;
		for(ll j=2,p=0;j*j*j<=s;j++,p=0)
		{
			while(s%j==0) s/=j,p++;p%=3;
			if(p) nw*=pow(j,p),de*=pow(j,3-p);
		}
		if(((int)sqrt(s))*((int)sqrt(s))==s) de*=sqrt(s);
		else de*=s*s;nw*=s;
		D[de]=nw,D[nw]=de,Map[nw]++;
	}
	for(auto x:Map) if(!vis[x.fi]&&x.fi!=1)
					{
						ans+=max(x.se,Map[D[x.fi]]);
						vis[x.fi]=vis[D[x.fi]]=1;
					}
	cout<<ans+(Map[1]>0)<<endl;return 0;
}


Measured memory_bytes: 37760
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll M=1e9+7;
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power((x*x)%M,n/2);
    else                             //n is odd
        return (x*power((x*x)%M,(n-1)/2))%M;

}
ll power1(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power((x*x),n/2);
    else                             //n is odd
        return (x*power((x*x),(n-1)/2));

}

int main() {
	// your code goes here
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans;
    //cout<<ans<<"\n";
	ll x=1,y=1,z1,z2;
	// for a
	for(ll i=n-a+1;i<=n;i++)
	{
		x=x*i;
		x=x%M;
	}
	for(ll i=2;i<=a;i++)
	{
		y=y*i;
		y=y%M;
	}
	z1=( x* power(y,M-2))%M;
	//cout<<z;
	
	
	// for b
	x=1,y=1;
	for(ll i=n-b+1;i<=n;i++)
	{
		x=x*i;
		x=x%M;
	}
	for(ll i=2;i<=b;i++)
	{
		y=y*i;
		y=y%M;
	}
	z2=( x* power(y,M-2))%M;
    //ans=(( ans%M)-(z%M)+z)%M;
	//cout<<z;
	ans=power(2,n)-z1-z2-1;
	while(ans<0)
	ans+=M;
	
	cout<<ans%M;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = 0;
		int counter = 0;
		for (int j = 1; j <= n; j+=2) {

			y = 0;
			for (int i = 1; i <= j; i++) {
				if (j % i == 0) {
					y++;
				}
			}
				if (y == 8) {
					counter++;
				}
			
		}
		System.out.println(counter);

	}

}

Measured memory_bytes: 23636
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    }
    println!("{}",min(b/a,c))
}

Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  int n,x,t;
  cin>>n>>x>>t;
  cout<<((n/x)+(n%x!=0))*t<<endl;
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B ;

  int a = 0;
  a = A + B; //
  int b = 0;
  b = A - B;
  int c = 0;
  c = A * B;
 
  int d = 0;
  d = max(max(a, b), c);
  cout << d << endl;
  
}


Measured memory_bytes: 256