akhauriyash/Code-Regression huggingface dataset:
package main

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

/***********************************************************************
最大積載量Pを決めた時に、k台以内のトラックで何個の荷物を積むことができるか
を考える。→各トラックについて積載量を超えない限り荷物を積んでいくことで求まる
最大積載量を入力としてk台以内のトラックで積むことのできる荷物の個数vを出力する関数
v = f(P)を作る。これを使ってPを0から順にひと続く増やしていく。この時、最初にvがnを
超える時のPが答え。
ここで、Pが増える時にvは減らないのでPを求める時に二分探索を用いることができる。
Pの最大値は問題の制約から1台のトラックで100000この荷物が10000の重さであるとき。
***********************************************************************/

func check(n int, k int, w []int, P int64) int {
	i := 0
	for j := 0; j < k; j++ {
		sum := 0
		for int64(sum + w[i]) <= P {
			sum += w[i]
			i++
			if i == n {
				return n
			}
		}
	}
	return i
}

func solve(n int, k int, w []int) int64 {
	var left, mid, right int64
	left, right = 0, 100000*10000
	for right - left > 1 {
		mid = int64((right + left) / 2)
		v := check(n, k, w, mid)
		if v >= n {
			right = mid
		} else {
			left = mid
		}
	}
	return right
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	n, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	n := nextInt(scanner)
	k := nextInt(scanner)
	var w []int
	for i := 0; i < n; i++ {
		w = append(w, nextInt(scanner))
	}
	P := solve(n, k, w)
	fmt.Println(P)
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

const int mod = 1000000007;

int main() {
  string S;
  cin >> S;
  int n = S.size();
  int k = n;
  for (int i = 1; i < n; i++) {
    if (S[i] != S[i - 1])
      k = min(k, max(i, n - i));
  }
  cout << k << endl;
}

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

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int n;
    cin >> n;
    bool ok = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) ok = true;
        }
    }
    if (ok) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
	ll n,t,i,j,x,k,ans=0;
    string s,u;
    cin>>s>>u;
    n=s.length();
    k=u.length();
    
    for(i=0;i<=n-k;i++){
        x=0;
        for(j=0;j<k;j++){
            if(s[i+j]==u[j])
            x++;
        }
        ans=max(ans,x);
    }
    cout<<k-ans;
    
	return 0;
}

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

int f(int x) {
	if (x % 2)
        return 3 * x + 1;
    else
        return x / 2;
}

int main() {
	int s; cin >> s;
    int arr[10000000];
    arr[0] = s;
    for (int i = 1; i < 10000000; ++i) {
    	arr[i] = f(arr[i-1]);
    }
	for (int i = 1; i < 10000000; ++i) {
    	int a_m = arr[i];
    	for (int j = 0; j < i; ++j) {
        	if (a_m == arr[j]) {
            	cout << i + 1 << endl;
        		return 0;
            }
        }
    }
}

Measured memory_bytes: 39296
/**
 *  author: Behradm
 *  Created: 2020.06.21 16:15:45
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int maxn = 1e6;
long long cnt[maxn] = {0};

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> s;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    s.insert(a[i]);
    sum += (long long) a[i];
  }

  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    if (s.find(b) == s.end()) {
      cout << sum << '\n';
      continue;
    }
    
    s.erase(s.find(b));
    s.insert(c);
    //debug(cnt[b], cnt[c]);
    sum -= cnt[b] * b * 1LL;
    //cnt[b] = 0;
    sum += cnt[b] * c * 1LL;
    cout << sum << '\n';
    cnt[c] += cnt[b];
    cnt[b] = 0;
    //sum = (sum - cnt[b] * b * 1LL) + cnt[b] * c * 1LL;
    //cnt[c] = cnt[b] + cnt[c];
    //cnt[b] = 0;
  }
  return 0;
}


Measured memory_bytes: 7340
#include<iostream>
#include<cstdio>
#include<vector>
const int N=505;
int a[N][N];
int main() {
    int n;
    scanf("%d",&n);
    int p=0;
    --n;
    while((1<<p+1)<=n) p++;
    for(int x=0;x<=p;x++) {
        std::vector<int> L,R;
        for(int i=0;i<=n;i++) {
            if(i>>x&1) R.push_back(i);
            else L.push_back(i);
        }
        for(int u:L) for(int v:R) {
            a[std::min(u,v)][std::max(u,v)]=x+1;
        }
    }
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<=n;j++) {
            printf("%d%c",a[i][j]," \n"[j==n]);
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int dat[100000];
int sum[100000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int now=0;
	for(int i=1;i<a;i++){
		int c;
		scanf("%d",&c);
		dat[i]=c;
		sum[i]=now+=c;
	}
	int ret=0;
	int at=0;
	for(int i=0;i<b;i++){
		int d;
		scanf("%d",&d);
		if(d<0)ret=(ret+sum[at]-sum[at+d])%100000;
		else ret=(ret+sum[at+d]-sum[at])%100000;
		at+=d;
	}
	printf("%d\n",ret);
}

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

int main(){
	string s;
	int n[4],memo[3] = {0},tmp,ans = 0;
	char op[3];
	cin >> s;
	
	rep(i,0,4){
		n[i] = (int)s[i]-48;
	}
	
	rep(i,0,8){
		tmp = i;
		ans = n[0];
		rep(j,0,3){
			memo[j] = tmp % 2;
			tmp /= 2;
		}
		
		rep(j,0,3){
			if(memo[j] == 0){
				op[j] = '+';
				ans += n[j+1];
			}
			else{
				op[j] = '-';
				ans -= n[j+1];
			}
		}
		
		if(ans == 7){
			rep(j,0,3){
				cout << n[j] << op[j];
			}
			cout << n[3] << "=7" << endl;
			return 0;
		}
	}
	return 0;
}

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

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    x: usize,
    m: usize
    }
    let mut dm = vec![0; m];
    let mut s = vec![0; m + 2];
    for i in 0..m {
        dm[i] = i * i % m;
    }
    let (mut l, mut r) = (0, 0);
    let mut nums = vec![0; m + 1];
    let mut t = x;
    for i in 1..=m + 1 {
        s[i] = s[i - 1] + t;
        if nums[t] > 0 {
            l = nums[t] - 1;
            r = i - 1;
            break;
        }
        nums[t] = i;
        t = dm[t];
    }
    if n <= r {
        print!("{}", s[n]);
        return;
    }
    let mut ans: usize = s[l];
    ans += (n - l) / (r - l) * (s[r] - s[l]) + s[l + (n - l) % (r - l)] - s[l];
    println!("{}", ans);
}


Measured memory_bytes: 3892
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
using namespace std;

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

	cin >> a >> b >> c;

	if (a + b + c < 22) {
		cout << "win";
	} else {
		cout << "bust";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main()
{
  int K;
  cin >> K;
  if (1<=K && K <= 9) {
    cout << K << endl;
    return 0;
  }
  queue <long long> lunlun;
  for (int i = 1; i <= 9; i++) {
    lunlun.push(i);
  }
  int order = 9;
  for (;;) {
    long long num = lunlun.front();
    lunlun.pop();
    int lsd = num%10;
    long long next;
    if (lsd!=0) {
      next = num*10+lsd-1;
      order++;
      if (order==K) {
        cout << next << endl;
        return 0;
      }
      lunlun.push(next);
    }
    next = num*10+lsd;
    order++;
    if (order==K) {
      cout << next << endl;
      return 0;
    }
    lunlun.push(next);
    if (lsd!=9) {
      next = num*10+lsd+1;
      order++;
      if (order==K) {
        cout << next << endl;
        return 0;
      }
      lunlun.push(next);
    }
  }
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
string s,t,ans;
bool check(string x,string y){
	for(int i=0;i<x.size();i++){
		if(x[i]!='?'&&x[i]!=y[i])return 0;
	}
	return 1;
}
int main(){
	cin>>s>>t;
	ans="~";
	for(int i=(int)s.size()-(int)t.size();i>=0;i--){
		string st=s.substr(i,t.size());
		if(check(st,t)){
			s.replace(i,t.size(),t);
			for(int j=0;j<s.size();j++)if(s[j]=='?')s[j]='a';
			cout<<s<<endl;
			return 0; 
		}	
	}
	cout<<"UNRESTORABLE"<<endl;
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
cnt = [0] * N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(cnt[r-1] - cnt[l-1])

print('\n'.join(list(map(str, ans))))

Measured memory_bytes: 16464
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	public class Activity implements Comparable<Activity> {
		int start;
		int end;
		public Activity(int start, int end) {
			this.start = start;
			this.end = end;
		}
		@Override
		public int compareTo(Activity o) {
			if (this.start != o.start) {
				return this.start - o.start;
			}
			return this.end - o.end;
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Activity[] activities = new Activity[n];
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int start = Integer.parseInt(st.nextToken());
			int end = Integer.parseInt(st.nextToken());
			activities[i] = new Activity(start, end);
		}
		reader.close();
		
		Arrays.sort(activities);
		Stack<Activity> stack = new Stack<Activity>();
		stack.push(activities[0]);
		for (int i = 1; i < n; i++) {
			Activity last = stack.peek();
			Activity acti = activities[i];
			if (acti.start > last.end) {
				stack.push(acti);
			} else if (acti.end < last.end) {
				stack.pop();
				stack.push(acti);
			}
		}
		System.out.println(stack.size());
	}
}


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

int n;
int main() {
	int i, j, fl;
	cin>> n;
	for(i=n; ; i++) {
		fl = 1;
		for(j=2; j*j<=i; j++) {
			if(i%j==0) {fl=0; break;}
		}
		if(fl) break;
	}
	cout<< i;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int x[N];
    double mean = 0;
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
        mean += x[i];
    }
    mean = round(mean / N);
    int cost = 0;
    for (int i = 0; i < N; ++i) {
        cost += (int)pow(x[i] - mean, 2);
    }
    cout << cost << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int main2() {
  ll N; cin >> N;
  ll X[5]; REP(i, 5) cin >> X[i];
  ll T[6];

  ll m = 1LL << 61;
  T[0] = 0;
  for (int i = 0; i < 5; i++) {
    if (m <= X[i]) {
      T[i+1] = 1 + T[i];
    } else {
      T[i+1] = i + (N+X[i]-1)/X[i];
      m = X[i];
    }
  }
  cout << T[5] << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main() {
	string str, func, x;
	int a, b, num;
	cin >> str;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> func >> a >> b;
		//cout << x;
		if (func == "replace") {
			cin >> x;
			for (int j = 0; j < b - a + 1; j++) {
				str[j + a] = x[j];
			}
		}
		if (func == "reverse") {
			for (int j = 0; j < (int)((b - a + 1) / 2); j++) {
				char ch = str[a + j];
				str[a + j] = str[b - j];
				str[b - j] = ch;
			}
		}
		if (func == "print") {
			for (int i = 0; i < b - a + 1; i++) {
				cout << str[a + i];
			}
			cout << endl;
		}
	}

	return 0;
}

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

int main()
{
  while(1){
    
    int n,m;
    cin>>n>>m;
    if(n==0){return 0;}
    vector<int>a(m);
    REP(i,n)
    {
        int d,v;
        cin>>d>>v;
        
        d--;
        if(v>a.at(d))
        {
            a.at(d)=v;
        }
    }
    int sum=0;
    REP(i,m)
    {
        sum+=a.at(i);
    }
    cout<<sum<<endl;
  }
}


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

template <typename T>
T power(const T &a, long long n, const T &e){
  T ret = e;
  T beki = a;
  for(long long i = 1LL; i <= n; i <<= 1){
    if( (n & i) > 0 )
      ret *= beki;
    beki = beki * beki;
  }
  return ret;
}

const int MOD = 1e9+7;
class Z_nZ {
public:
  long long m;
  Z_nZ() { ; }
  Z_nZ(long long v){
    if(v < 0)
      m = v + (- v / MOD + 1) * MOD;
    else
      m = v;
    m %= MOD;
  }
  Z_nZ operator + (const Z_nZ &a){ return Z_nZ( m + a.m ); }
  Z_nZ operator - (const Z_nZ &a){ return Z_nZ( m - a.m ); }
  void operator += (const Z_nZ &a){ m = (m + a.m) % MOD; }
  void operator -= (const Z_nZ &a){ m = (m - a.m + MOD) % MOD; }
  Z_nZ operator * (const Z_nZ &a){ return Z_nZ( m * a.m ); }
  void operator *= (const Z_nZ &a){ m = (m * a.m) % MOD; }
  Z_nZ pow(int k){ return power( Z_nZ(m), k, Z_nZ(1) ); }
  Z_nZ inv(){ return this->pow( MOD - 2 ); }
  Z_nZ operator / (Z_nZ a){ return Z_nZ( m * a.inv().m ); }
  void operator /= (Z_nZ a){ m = (m * a.inv().m) % MOD; }
  friend ostream& operator << (ostream& os, const Z_nZ & a);  
};
ostream& operator << (ostream& os, const Z_nZ & a){
  os << a.m;
  return os;
};
Z_nZ factorial(long long n){
  Z_nZ ret(1);
  for(int i = 2; i <= n; i++) ret *= Z_nZ( i );
  return ret;
}
Z_nZ binomial(long long a, long long b){
  Z_nZ ret(1);
  for(int i = a; i > a - b; i--)
    ret *= Z_nZ( i );
  ret /= factorial( b );
  return ret;
}
Z_nZ fact[1000001];
int main(){
  long long H, W, A, B;
  cin >> H >> W >> A >> B;
  H--; W--; A--; B--;
  Z_nZ ans(0);
  Z_nZ f(1);
  Z_nZ g = binomial( W + A - B, H);
  fact[0] = Z_nZ(1);
  for(int i = 1; i <= 1000000; i++){
    fact[i] = fact[i-1] * Z_nZ(i);
  }
  for(int i = 0; i < H - A; i++){
    //ans += binomial( H - A + B, i ) * binomial( W + A - B, H - i);

    //cout << binomial( H - A + B, i ) << " " <<  binomial( W + A - B, H - i) << endl;
    //cout << f << " " << g << endl;
    ans += f * g;

    f *= Z_nZ(i+1).inv() * Z_nZ( H - A + B - i );
    if( W+A-B >= 0 &&  W + A - B - H + i + 1 >= 0 && H-i-1 >= 0 ){
      g = fact[W+A-B] / (fact[H-i-1] * fact[W + A - B - H + i + 1]);
      //cout << "g" << endl;
    }else{
      g = Z_nZ(0);
    }
    //cout << i << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8192
h, w = map(int, input().split())
S = [input() for i in range(h)]
DP = [[0 for j in range(w)] for i in range(h)]
if S[0][0] == '#':
    DP[0][0] = 1
for j in range(1, w):
    if S[0][j - 1] == '.' and S[0][j] == '#':
        DP[0][j] = DP[0][j - 1] + 1
    else:
        DP[0][j] = DP[0][j - 1]
for i in range(1, h):
    if S[i - 1][0] == '.' and S[i][0] == '#':
        DP[i][0] = DP[i - 1][0] + 1
    else:
        DP[i][0] = DP[i - 1][0]
    for j in range(1, w):
        if S[i - 1][j] == '.' and S[i][j] == '#':
            up = DP[i - 1][j] + 1
        else:
            up = DP[i - 1][j]
        if S[i][j - 1] == '.' and S[i][j] == '#':
            left = DP[i][j - 1] + 1
        else:
            left = DP[i][j - 1]
        DP[i][j] = min(up, left)
print(DP[-1][-1])


Measured memory_bytes: 3188
from math import ceil
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
  p, q = map(int, input().split())
  a.append(p)
  b.append(q)
b.sort(reverse=1)
ans=0
m=max(a)
for i in b:
  if i < m or h<=0:
    break
  h-=i
  ans+=1
if h>0:
  ans+=ceil(h/m)
print(ans)

Measured memory_bytes: 61528
#include <iostream>
#include <vector>

struct node{
	int depth;
	int parent;
	std::vector<int> parent_candidates;

	node(): depth(-1), parent(-1)
	{}
};

int set_node(
	int depth,
	std::vector<node>& tree,
	node& node
){
	if(node.depth >= 0){
		return node.depth + 1;
	}else{
		if(node.parent_candidates.size() == 0){ // root
			node.depth = 0;
			return 1;
		}else{
			int max = 0;
			for(int i : node.parent_candidates){
				int tmp_dpth = set_node(depth, tree, tree[i]);
				if(max < tmp_dpth){
					max = tmp_dpth;
					node.parent = i;
				}
			}
			node.depth = max;
			return node.depth + 1;
		}
	}
}

int main(){
	int N, M;
	std::cin >> N >> M;

	std::vector<node> tree(N);

	for(int i = 0; i < N+M - 1; i++){
		int u, v;
		std::cin >> u >> v;
		tree[v - 1].parent_candidates.push_back(u - 1);
	}

	for(int i = 0; i < N; i++){
		set_node(0, tree, tree[i]);
		std::cout << tree[i].parent + 1 << std::endl;
	}
}


Measured memory_bytes: 12032
import Control.Monad
import Data.List

sep = replicate 20 '#'

count b f r i = count' b f r 0 i 
  where
    count' _ _ _ x [] = x
    count' b f r x ([bb, ff, rr, xx]:ii) = count' b f r (if b==bb && f==ff && r==rr then x+xx else x) ii

main = do
    n <- readLn
    info <- fmap (map (map read . words)) $ replicateM n getLine
    putStrLn $ intercalate "\n" $ intersperse sep [intercalate "\n" [(' ':unwords [show $ count b f r info | r <- [1..10]]) | f <- [1..3]] | b <- [1..4]]
    

Measured memory_bytes: 4260
#include<stdio.h>

int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0&&y-r>=0&&W>=x+r&&H>=y+r){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <tuple>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using namespace std;

int N, W;
int w[110];
int v[110];
ll dp[110][100000 + 10]; //dp[i][j]:i番目までの品物, 容量jで価値合計の最大値

int main(void) {
    cin >> N >> W;
    REP(i, 1, N) {
        cin >> w[i] >> v[i];
    }
    REP(i, 0, W) {
        dp[1][i] = (w[1] <= i) ? v[1] : 0;
    }
    REP(i, 2, N) {
        REP(j, 0, W) {
            if (w[i] <= j) {
                dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    
    cout << dp[N][W] << endl;
    return 0;
}



Measured memory_bytes: 79360
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
#include<numeric>
using namespace std;

 
int mod = 1000000007;

long Gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

long lcm(long m, long n)
{
	return m * n / Gcd(m,n); 
}
 
int main(){
    long ans = 0;
    long a, b, c, d, e;
    cin >> a >> b >> c >> d;
    e = lcm(c, d);
    long ans1, ans2;
    ans1 = b - (b/c + b/d - b/e);
    ans2 = a - (a/c + a/d - a/e);
    ans = ans1 - ans2;
    if(a%c!=0 && a%d!=0)ans++;
    cout << ans << endl;
    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);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long s = (m * 1900) + ((n - m) * 100);
		System.out.println(s * (long) Math.pow(2, m));
	}
}


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

const ll DICE_SIZE = 6;
struct Dice{
    array<ll, DICE_SIZE> num;
    ll top, front, right;
    Dice(const array<ll, DICE_SIZE>& num) : num(num), top(0), front(1), right(2) {}

    void move(char c){
        if(c == 'N'){
            const ll old_top = top;
            top = front;
            front = 5 - old_top;
        }else if(c == 'S'){
            const ll old_front = front;
            front = top;
            top = 5 - old_front;
        }else if(c == 'W'){
            const ll old_top = top;
            top = right;
            right = 5 - old_top;
        }else{
            assert(c == 'E');
            const ll old_right = right;
            right = top;
            top = 5 - old_right;
        }
    }

    ll get_top() const { return num.at(top); }
};

int main(){
    array<ll, DICE_SIZE> num;
    REP(i, DICE_SIZE){ cin >> num.at(i); }
    Dice d(num);
    string op;
    cin >> op;
    for(char c: op){
        d.move(c);
    }
    cout << d.get_top() << endl;
    return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int h,w,k;
  scanf("%d%d%d",&h,&w,&k);

  int ans=0;
  for(int i=0;i<=h;i++){
    for(int j=0;j<=w;j++){
      int now=(w*i)+(h*j)-2*i*j;

      if(now==k){
        ans=1;
      }
    }
  }

  if(ans==1){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	string s,t;
	bool flag=1;
	cin>>s>>t;
	int i,temp,temp2,j;
	vector<int> tra(26,100),falp(26,1);
	for(i=0;i<s.size();i++){
		if(tra.at(s.at(i)-97)==100){
			tra.at(s.at(i)-97)=t.at(i)-97;
		}else{
			if(tra.at(s.at(i)-97)!=t.at(i)-97){
				flag=0;
				break;
			}
		}
	}
	/*for(i=0;i<26;i++){
		if(tra.at(i)!=100){
		printf("%02d %02d\n",i,tra.at(i));
		}
	}*/
	if(flag){
		for(i=0;i<26;i++){
			if((falp.at(i))&&(tra.at(i)!=100)){
				falp.at(i)=2;
				temp=i;
				while(true){
					temp2=tra.at(temp);
					/*for(j=0;j<26;j++){
						printf("%d",falp.at(j));
					}
					printf("%02d %d",i,flag);
					cout<<endl;*/
					if(temp2==100){
						falp.at(temp)=0;
						break;
					}else if(falp.at(temp2)==2){
						falp.at(temp2)=0;
						break;
					}else if(falp.at(temp2)==0){
						flag=0;
						break;
					}else{
						falp.at(temp2)=0;
						temp=temp2;
					}
				}
			}
		}
	}
	if(flag){
		cout<<"Yes";
	}else{
		cout <<"No";
	}
}


Measured memory_bytes: 776
#include<iostream>
using namespace std;
int main(){
    int k,s;
    cin >> k >> s;

    int cnt=0;
    for(int a=0; a<=k; a++){
        for(int b=a; b<=k; b++){
            for(int c=b; c<=k; c++){
                if(a+b+c == s){
                    if(a==b && b==c){
                        cnt++;
                    }else if((a!=b && b!=c)){
                        cnt = cnt+6;
                    }else{
                        cnt = cnt+3;
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

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


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

int main(){
    int ans=0 ;
    string s;
    cin >> s;
    for(int i;i<s.size();i++){
        if(s.at(i)=='x'){
            ans++;
        }
    }
    if(ans>=8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

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

int sum[2001][2001];
int solve(int i, int j) {
    if(i >= 0 && j >= 0)
        return sum[i][j];
    else 
        return 0;
}

int main()
{
    int N, K;
    scanf("%d %d", &N, &K);
    int X[N+3], Y[N+3], C[N+3];
    char d;
    for(int i = 0; i < N; ++i) { 
        scanf("%d %d %c", &X[i], &Y[i], &d);
        C[i] = ((d == 'B') ? 1 : 0);
        if(C[i] == 0) {
            Y[i] += K; C[i] = 1;
        }
        X[i] %= 2*K, Y[i] %= 2*K;
    }
    
    for(int i = 0; i < N; ++i) sum[X[i]][Y[i]]++;


    for(int i = 0; i < 2*K; ++i) {
        for(int j = 0; j < 2*K; ++j) {
            //(0, 0)と(i, j)を頂点とする長方形内の黒点の数を累積和で求める
            if(i == 0 && j == 0) continue;

            if(i == 0) {
                sum[i][j] += sum[i][j-1];
                continue;
            } else if(j == 0) {
                sum[i][j] += sum[i-1][j];
                continue;
            } else {
                sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
            }
        }
    }

    
    int ma = -1;
    for(int i = 0; i < K; ++i) {
        for(int j = 0; j < K; ++j) {
            int cnt = 0;
            cnt += solve(K-1+j, K-1+i) 
                    - solve(j-1, K-1+i) 
                    - solve(K-1+j, i-1) 
                    + solve(j-1, i-1);
            cnt += solve(2*K-1, 2*K-1)
                    - solve(K-1+j, 2*K-1)
                    - solve(2*K-1, K-1+i)
                    + solve(K-1+j, K-1+i);
            cnt += solve(j-1, i-1);
            cnt += solve(2*K-1, i-1) - solve(K-1+j, i-1);
            cnt += solve(j-1, 2*K-1) - solve(j-1, K-1+i);
            ma = max(ma, max(cnt, N - cnt));
            //全体の白黒を反転させれば、K<= j < 2K, K <= i < 2Kの場合の市松模様になり、
            //N - cntで求めることができる。
        }
    }

    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 17024
#include <stdio.h>
int main(void){
    
   int i,j,H,W;
   
   while(H!=0 || W!=0){
   scanf("%d %d",&H,&W);
   
for ( i = 1; i <= H; i++ ){
    for ( j = 1; j <= W; j++ ){
        if(i!=1 && i!=H && j!=1 && j!=W){
            printf(".");
        } else {
            printf("#");
        }
    }
    printf("\n");
}
    if(H!=0 || W!=0)
    printf("\n");
}
   return 0;

   }
   


Measured memory_bytes: 2048
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] bs = new int[m];
        for (int i = 0; i < m; i++) {
            bs[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            int tmp = c;
            for (int j = 0; j < m; j++) {
                int a = sc.nextInt();
                tmp += bs[j] * a;
            }

            if (tmp > 0) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main(){
  int x;
  for(int i = 0; i < 5; i++){
    scanf("%d", &x);
    v.push_back(x);
  }
  scanf("%d", &x);
  bool f = true;
  for(int i = 0; i < v.size() - 1; i++){
    for(int j = i + 1; j < v.size(); j++){
      if(abs(v[i] - v[j]) > x){
        f = false;
        break;
      }
    }
  }
  printf("%s\n", f ? "Yay!" : ":(");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector> //可変長配列
using namespace std;
int main()
{
    int n , m , j,sum,ans;
    sum=0;
    cin>>n>>m;
    vector<int> a(m); 
    for (int i=0;i<m;i++)
    {
        cin>>j;
        a[i]=j;
    }
    for (int i=0;i<m;i++)
    {
        sum = a[i]+sum;
    }
    ans=n-sum;
    if(ans<0)
        ans = -1;
        cout << ans;
}

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

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  set<int> As;
  map<int, int> x;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    As.insert(A[i]);
  }

  int first, second;
  int count = 0;
  for (auto it = As.rbegin(); it != As.rend(); it++) {
    if (count == 0) {
      first = *it;
    } else if (count == 1) {
      second = *it;
    } else {
      break;
    }
    for (int i = 1; i <= sqrt(*it); i++) {
      if (*it % i == 0) {
	if (*it / i == i) {
	  x[i]++;
	}
	else {
	  x[i]++;
	  x[*it / i]++;
	}
      }
    }
    count++;
  }

  int ans = 1;
  map<int, int> xx;
  for (int i = 0; i < N; ++i) {
    for (auto const& m: x) {
      if (A[i] % m.first == 0) {
	xx[m.first]++;
	if (xx[m.first] == N || xx[m.first] == N - 1) {
	  ans = max(ans, m.first);
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var sum = new List<long>();
        long temp = 0;
        for (int i = 0; i < a.Length; i++)
        {
            temp += a[i];
            sum.Add(temp);
        }
        sum = sum.OrderBy(f => f).ToList();
        long ans = 0;
        long cont = 1;
        for (int i = 0; i < sum.Count() - 1; i++)
        {
            if (sum[i] == sum[i + 1])
            {
                cont++;
            }
            else
            {
                ans += cont * (cont - 1) / 2;
                cont = 1;
            }
        }
        ans += cont * (cont - 1) / 2;
        ans += sum.Count(f => f == 0);
        Console.WriteLine(ans);
    }
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n,k;
	cin >> n >> k;
	vector<ll> ma(n);
	REP(i,n) cin >> ma[i];
	int ans = 0;
	REP(i,n) {
		if (ma[i] >= k) ans +=1;
	}

  cout << ans << endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int x, y, s;
    while(cin >> x >> y >> s, s) {
        int ans = 0;
        REP(a, 1, s) {
            REP(b, 1, s) {
                if (a*(100+x)/100 + b*(100+x)/100 == s)
                    ans = max(ans, a*(100+y)/100 + b*(100+y)/100);
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3164
import numpy as np

N = int(input())
L = list(map(int, input().split()))

if(len(L) != 2*N):
    print("wrong number !")
    exit()

x=0
L.sort(reverse=True)
for i in range(N):
    x = x + min(L[2*i:2*(i+1)])

print(x)


Measured memory_bytes: 13228
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int X, Y; cin >> X >> Y;
    int ans = 0;
    if (X == 1) ans += 300000;
    if (X == 2) ans += 200000;
    if (X == 3) ans += 100000;
    if (Y == 1) ans += 300000;
    if (Y == 2) ans += 200000;
    if (Y == 3) ans += 100000;
    if (X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

template<class Type>
Type func(Type a, Type n)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a;
		}
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main()
{
	ll h;
	cin >> h;
	if (h == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll ans = 1;
	ll i = 1;
	while (true) {
		h /= 2;
		ans += func(2LL, i);
		i++;
		if (h <= 1) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<time.h>
#include<set>
#include <random>
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define fore(i,fa,fb) for(i=fa;i<=fb;++i)
#define all(n) (n.begin(),n.end())
#define F first
#define S second
typedef long long ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int i, j, k, m, n;
	string a, b, c;
	cin >> a >> b;
	if (a == "H")
	{
		if (b == "H")
			cout << "H";
		else cout << "D";
	}
	else
	{
		if (b == "H")
			cout << "D";
		else cout << "H";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
 int W, H, x, y, r; 
 cin >> W >> H >> x >> y >> r;
 if(x-r < 0 || x+r > W || y-r < 0 || y+r > H) cout << "No" << endl;
 else cout << "Yes" << endl;
 return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int n, a, b;
    cin >> n >> a >> b;

    string str;
    cin >> str;

    int ca = 0, cb = 0;
    REP(i, n) {
        if ( str[i] == 'a' && ca + cb < a + b ) {
            ++ca;
            cout << "Yes" << endl;
        } else if ( str[i] == 'b' && ca + cb < a + b && cb < b ) {
            ++cb;
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5;
const int Inf = 1 << 30;
int n;
int l, r;
int p[maxx + 7];
int dd[maxx + 7];
bool vis[maxx + 7];
int cnt[maxx +7];
int ans;

void solve() {
	int t = 0;
	for(int i = 2; i <= maxx; i++) {
		bool flg = 1;
		for(int j = 2; j <= sqrt(i); j++) {
			if(i % j == 0) {
				flg = 0; break;
			}
		}
		if(flg) {
			p[++t] = i;
			vis[p[t]] = 1;
		}
	}
	int f = 0;
	for(int i = 3; i <= maxx; i++) {
		if(vis[i]) {
			int tmp = (i + 1) / 2;
			if(vis[tmp]) dd[++f] = i;
		}
	}
	memset(vis, 0, sizeof(vis));
	for(int i = 1; i <= f; i++) vis[dd[i]] = 1;
	cnt[1] = 0;
	for(int i = 2; i <= maxx; i++) {
		cnt[i] += cnt[i - 1];
		if(vis[i]) cnt[i]++;
	}
}

int main() {
	solve();
	cin >> n;
	while(n--) {
		cin >> l >> r;
		if(vis[l]) ans = cnt[r] - cnt[l] + 1;
		else ans = cnt[r] - cnt[l];
		cout << ans << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int A, B,C;
    cin>>A>>B>>C;
    if (C-A+B>-1){
        cout<< C-A+B<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 20000
#define MYSCAN scanf

int main(void){
	int n, m;
	int p[2000];
	int i, j;
	int ans, tmp;

	while (true){
		MYSCAN("%d%d", &n, &m);
		if (n == 0 && m == 0){	break;	}

		ans = 0;

		// テ」ツ?セテ」ツ?堙」ツつステ」ツδシテ」ツδ暗」ツ?凖」ツつ?
		for (i = 0; i < n; i++){
			p[i] = 0;
			MYSCAN("%d", &p[i]);
			for (j = i - 1; j >= 0; j--){
				if (p[j] < p[j+1]){
					tmp = p[j];
					p[j] = p[j+1];
					p[j+1] = tmp;
				}
				else{
					break;
				}
			}
		}

		for (i = 0; i < n; i++){
			if ((i+1) % m != 0){
				ans += p[i];
			}
		}

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


	}

	return 0;

}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	
	vector<int> vec(n + 1);
	for(int i = 1; i <= n; ++i){
		vec[i] = i;
	}
	
	for(int i = 0; i < m; ++i){
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(vec[a], vec[b]);
	}
	
	for(int i = 1; i <= n; ++i){
		cout << vec[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#define MAX 31


int main(void){
  int n,m,b,a,i,box[MAX+1],tmp;
  char comma;

  scanf("%d %d" ,&n ,&m);

  for( i = 0 ; i < n ; i++ ) box[i+1] = i+1;

  for( i = 0 ; i < m ; i++ ){
    scanf("%d %c %d" ,&b ,&comma ,&a );
    tmp = box[b];
    box[b] = box[a];
    box[a] = tmp;
  }

  for( i = 0 ; i < n ; i++ ) printf("%d\n" ,box[i+1]);


  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
#define ll long long
#define rep(i, n) for ((i)=0;(i)<(n);(i)++)
int G[1000000] = {};
int cnt = 0;
int generateInterval(int n) {
    int i = 0;
    do {
        G[i] = (pow(3, i+1)-1)/2;
        i++;
    } while ((pow(3, i+1)-1)/2 < n);
    return i;
}

int insertionSort(ll *a, int n, int g) {
    int i, j;
    ll v;
    for (i = g; i < n; i++) {
        v = a[i];
        j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j = j - g;
            cnt++;
        }
        a[j+g] = v;
    }
    return 0;
}

int shellSort(ll *a, int n) {
    int idx;
    int m = generateInterval(n);
    for (idx = m - 1; idx >= 0; idx--) insertionSort(a, n, G[idx]);
    return m;
}

int main (void) {
    int n, index, ans;
    scanf("%d", &n);
    ll A[n];
    
    rep(index, n) scanf("%lld", &A[index]);
    
    ans = shellSort(A, n);
    
    printf("%d\n", ans);

    for (index = ans - 1; index >= 0; index--) {
        printf("%d", G[index]);
        if (index > 0)  printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);

    rep(index, n) printf("%lld\n", A[index]);

    return 0;
}


Measured memory_bytes: 9700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5 + 10;
ll n , k;
ll a[N] , dp[N];
int check(int ind)
{
    ll sum = INT_MAX;
    if(ind > n) return INT_MAX;
    if(ind == n)  return 0;
    if(dp[ind] != -1)   return dp[ind];
    for(int i = 1 ; i <= k ; i ++)
    {
        sum = min(sum , abs(a[ind + i] - a[ind]) + check(ind + i));
    }
    dp[ind] = sum;
    return sum;
}
int main()
{
    cin >> n>> k;
    for(int i = 1 ; i <= n ; i ++)  cin >> a[i];
    memset(dp , -1 , sizeof dp);
    cout <<  check(1);
}

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

int main()
{
  int n;
  cin>>n;
  //string x ="YES";
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  unordered_set<int> s;
  for(int i=0;i<n;i++)
    s.insert(a[i]);
  
  if(s.size()==n)
    cout<<"YES";
  else
    cout<<"NO";
 return 0;
}
  


Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N;
    string S, ans;
    cin >> N >> S;
    ans = "";
    for(char c: S){
        char nc;
        nc = 'A' + (c - 'A' + N) % 26;
        ans += nc;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int numa, numb, numc;
    cin >> numa >> numb >> numc; 
    if((numc>=numa)&&(numc<=numb)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')]*n
    dp[0] = 0
    for i in range(n):
        a = h[i]
        for j in range(1, min(k+1, n-i)):
            num = dp[i]+abs(a-h[i+j])
            if num < dp[i+j]:
                dp[i+j] = num
    print(dp[-1])

main()


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

int main(){

	ios_base::sync_with_stdio(false);
	
	int n;	cin>>n;
	int ac=0, wa = 0, tle = 0, re = 0;
	string str;
	for(int i=0; i<n; i++){
		cin>>str;
		if(str=="AC")ac++;
		else if(str=="WA")wa++;
		else if(str=="TLE")tle++;
		else re++;
	}

	cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
	
return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[100];
	char b[100];
	scanf("%s",a);
	scanf("%s",b);
	int lena=0;
	while(a[lena]!=0)lena++;
	int result;
	result=strncmp(a,b,lena);
	if(result!=0)printf("No");
	else printf("Yes");
	return 0;
}

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

int main(){
    int K,A,B;
    cin >> K;
    cin >> A >> B;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

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

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
  FAST();

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a>0  || c>0){
    c -= b;
    if(c<=0){
        cout<<"Yes\n";
        break;
    }
    a -= d;
    if(a<=0){
        cout << "No\n";
        break;
    }
  }

  return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int a = 1800 * m + 100 * n;
    int b = a * (int)Math.pow(2, m);
    System.out.println(b);
  }
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    
    if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256