akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int n; cin >> n;
    
    int amari = n % 1000;
    if (amari == 0) cout << 0 << endl;
    else cout << 1000 - amari << endl;
    
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 310
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")

long long dis[range][range];
long long fills[range][range];

int main(){

 //   freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();

    ll n, m, l; cin >> n >> m >> l;

    forn(i, range) {
        forn(j, range) {
            dis[i][j] = (i == j)? 0 : 1e15;
        }
    }

    forn(i, m) {
        ll a, b, c; cin >> a >> b >> c;
        if(c > l) continue;
        dis[a][b] = min(dis[a][b], c);
        dis[b][a] = min(dis[b][a], c);
    }

    forn1(k, n) {
        forn1(i, n) {
            forn1(j, n) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }

    forn1(i, n) {
        forn1(j, n) {
            if(dis[i][j] <= l) fills[i][j] = 0;
            else fills[i][j] = 1000;
        }
    }

    forn1(k, n) {
        forn1(i, n) {
            forn1(j, n) {
                fills[i][j] = min(fills[i][j], fills[i][k] + fills[k][j] + 1);
            }
        }
    }

    int q; cin >> q;

    while(q --) {
        int a, b; cin >> a >> b;
        long long  t = fills[a][b];
        if(t >= 1000) cout << -1 << endl;
        else cout << t << endl;
    }

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


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

using namespace std;

int main(){
	//~ freopen("input.txt", "r", stdin);
	//~ freopen("output.txt", "w", stdout);
	int n, k;
	scanf("%d %d", &n, &k);
	vector <int> v(n);
	for (int i = 0; i < n; i++){
		scanf("%d", &v[i]);
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i < k; i++){
		ans += v[i];
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3792
A, B, C = map(int, input().split())
s = sorted([A, B, C])
a = s[2] - s[0]
b = s[2] - s[1]

a_odd = a % 2 == 1
b_odd = b % 2 == 1

ans = a // 2 + b // 2

if a_odd and b_odd:
    ans += 1
elif a_odd and not b_odd:
    ans += 2
elif not a_odd and b_odd:
    ans += 2

print(ans)

Measured memory_bytes: 9132
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def satisfaction(d, last, c):
    res = 0
    for i in range(26):
        res += c[i] * (d - last[i])
    return res


def main():
    d = I()
    c = LI()
    s = LIR(d)
    t = IR(d)
    last = [0] * 26
    satis = 0
    for day in range(d):
        j = t[day] - 1
        last[j] = day + 1
        satis += s[day][j]
        satis -= satisfaction(day + 1, last, c)
        print(satis)


main()


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int nb = 0;
  vector<bool> t(n);
  for (int i = 0; i < n; ++i) {
    if (!t[i]) {
      for (int j = i; j < min(n, i + c) && a[j] <= a[i] + k; ++j) {
        t[j] = true;
      }
      ++nb;
    }
  }
  cout << nb << endl;
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll>
#define INF 1123456789012
using namespace std;



int main(){
	ll n, k; cin >> n >> k;
	vl vec(pow(10,5)+1);
	rep(i, n){
		ll a, b; cin >> a >> b;
		vec[a] += b;
	}rep(i, vec.size()){
		k -= vec[i];
		if (k <= 0){ 
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

const MOD: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let ans = (mod_pow(2, n) - 1 + 2 * MOD - comb(n, a) - comb(n, b)) % MOD;
    println!("{}", ans);
}

fn comb(n: usize, k: usize) -> usize {
    let mut n_per = 1;
    let mut k_fac = 1;
    for i in 1..(k + 1) {
        n_per = n_per * (n - i + 1) % MOD;
        k_fac = k_fac * i % MOD;
    }
    return n_per * mod_pow(k_fac, MOD - 2) % MOD;
}

fn mod_pow(r: usize, n: usize) -> usize {
    if n == 0 {
        return 1;
    }
    if n % 2 == 0 {
        let tmp = mod_pow(r, n / 2);
        return tmp * tmp % MOD;
    } else {
        return r * mod_pow(r, n - 1) % MOD;
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
    int a, b;
    char op;
    cin >> a >> op >> b;
    while(op != '?'){
        if(op == '+'){
            cout << a+b << endl;
        }else if(op == '-'){
            cout << a-b << endl;
        }else if(op == '*'){
            cout << a*b << endl;
        }else if(op == '/'){
            cout << a/b << endl;
        }
        cin >> a >> op >> b;
    }
    
    return 0;
}


Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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 = new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		*/


		ArrayList<Integer> list = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			list.add(a);
		}

		Collections.sort(list);

		int count = 0;
		int index = n-1;
		while(count <m){
			list.set(index, list.get(index)/2);
			count++;
			if(index==0) {
				index = n-1;
			}else {
				if(list.get(index-1)>list.get(n-1)) {
					index--;
				}else {
					index=n-1;
					Collections.sort(list);
				}
			}


		}

		long sum=0;
		for(int i =0;i<list.size();i++) {
			sum+=list.get(i);
		}

		System.out.println(sum);

		/*
		TreeMap<Integer,Integer> treeMap = new TreeMap<>();
		treeMap.put(b[n], n);
		*/

	}
}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/

Measured memory_bytes: 62944
#include<bits/stdc++.h>
using namespace std;
char str[4003];
int freq[3][4003];
int main()
{
    int n;
    scanf("%d %s", &n, str);
    for(int i=0; i<n; i++)
    {
        if(str[i]=='R')str[i]= '0';
        else if(str[i]=='G')str[i]= '1';
        else str[i]= '2';
    }
    for(int i=n-1; i>=0; i--)
    {
        for(int j=0; j<3; j++)
        freq[j][i]= freq[j][i+1];
        freq[ str[i]-'0' ][i]++;
    }
    long long res= 0;
    for(int i=0; i<n-2; i++)
    for(int j=i+1; j<n-1; j++)
    if(str[i]!=str[j])
    {
        char ch;
        if((str[i]=='0' || str[j]=='0') && (str[i]=='1' || str[j]=='1'))ch= '2';
        else if((str[i]=='0' || str[j]=='0') && (str[i]=='2' || str[j]=='2'))ch= '1';
        else ch= '0';

        res+= freq[ ch-'0' ][j+1];
        int d= j-i;
        if(j+d<n && str[j+d]==ch)res--;
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define pb push_back
#define mem(a, b) memset(a, b, sizeof(a))

int main() {
	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	if(x > y) swap(a, b), swap(x, y); 
	int ans = 0x7f7f7f7f;
	ans = min(ans, a*x + b*y);
	ans = min(ans, x*c*2 + (y-x) * b);
	ans = min(ans, y*c*2);
	printf("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, res, ans;
std::string S;

int main()
{
	in >> N >> S;
	rep(i, N)
	{
		std::vector<bool>flag1(26, false), flag2(26, false);
		res = 0;
		rep(j, i) flag1[S[j] - 'a'] = true;
		for (int j = i; j < N; ++j) flag2[S[j] - 'a'] = true;
		rep(j, 26)
		{
			if (flag1[j] && flag2[j]) ++res;
		}
		ans = std::max(ans, res);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
require "prime"

# n - 1 の約数で、１以外であれば題意を満たす
def solve_1(n)
  Prime.prime_division(n-1).map(&:last).map(&:succ).inject(1,:*)-1
end

# nの約数について、割りきれなくなるまで破った後、mod==1なら題意を満たす
# また、n,n-1の両方に含まれる約数は無い
def solve_2(n)
  a = []
  1.upto(n) do |i|
    break if i*i > n
    if n % i == 0
      a << i
      a << n/i if i != n/i
    end
  end
  a = a - [1]
  ans = 0
  a.each do |i|
    m = n
    m /= i while m % i == 0
    if m % i == 1
      ans += 1
    end
  end
  ans
end

n = gets.to_i
ans = solve_1(n) + solve_2(n)
puts ans

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

map<lli,lli> makePrimeList2(lli n){
    map<lli,lli> m;
    lli a = 2;
    while(n>=a*a){
        if(n%a==0){
            m[a]++;
            n /= a;
        }
        else a++;
    }
    if(n!=1)m[n]++;
    return m;
}

void func(long long N){

    map<lli,lli> dd;

    REP(i,2,N+1){
        map<lli,lli> ddd = makePrimeList2(i);
        for(auto e:ddd){
            dd[e.first] += e.second;
        }
    }

    lli ans = 0;

    lli tCnt=0,twCnt=0;
    lli fCnt=0;
    lli cnt14=0;
    //prime 75 only
    for(auto e:dd){
        LOG2(e.first,e.second);
        if(e.second>=74)ans++;
        
        if(e.second>=24)twCnt++;
        if(e.second>=14)cnt14++;
        if(e.second>=4)fCnt++;
        if(e.second>=2)tCnt++;
    }

    LOG3(twCnt,fCnt,tCnt);
    LOG(ans);

    //prime 24,2
    ans += (twCnt * (tCnt-1));

    LOG(ans);
    //prime 2,4,4
    ans += (fCnt*(fCnt-1)*(tCnt-2))/2;

    //prime 15,5
    ans += (cnt14*(fCnt-1));

    LOG(ans);
    cout<<ans<<endl;


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}


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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n = 0;
	double x1, y1, x2, y2, x3, y3, x4, y4;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

//#if INPUT_FROM_FILE
//	ifs >> n;
//#else
//	std::cin >> n;
//#endif
	scanf("%d", &n);

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
#else
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		//std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
#endif

		//if(x2 - x1 == 0 && x4 - x3 == 0){
		//	std::cout << "YES" << std::endl;
		//}
		//else if(x2 - x1 == 0 || x4 - x3 == 0){
		//	std::cout << "NO" << std::endl;
		//}
		//else{
		//	double a0 = (y2 - y1) / (x2 - x1);
		//	double a1 = (y4 - y3) / (x4 - x3);

		//	if(a0 == a1){
		//		std::cout << "YES" << std::endl;
		//	}
		//	else{
		//		std::cout << "NO" << std::endl;
		//	}
		//}

		if(fabs((y2 - y1)*(x4 - x3) - (y4 - y3)*(x2 - x1)) < 0.0000000001){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}

	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> vec(3);
  for (int i = 0; i < 3; i++) {
  	cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  cout << vec.front() + vec.back() * 10 + vec[1] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
 
 
int main(){
    string s;
    cin >> s;
    if (s=="Sunny"){
    	cout << "Cloudy";
	}
	else if (s=="Cloudy"){
		cout << "Rainy";
	}
	else {
		cout << "Sunny";
	}
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int A,B;
    cin >> A >> B;
    cout << (A+B)%24 << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
S = [[]for i in range(M)]
for i in range(M):
    k_s = list(map(int, input().split()))
    for j in range(len(k_s)-1):
        S[i].append(k_s[j+1])
p = list(map(int, input().split()))
Answer = 0
#print(S)

for i in range(2 ** N):
    switch = [0]*N
    for j in range(N):  # このループが一番のポイント
        a = 0
        if ((i >> j) & 1):
            a = 1

        switch[j] = a


    flag = True
    for j in range(M):
        Sum = 0
        for k in range(len(S[j])):
            #print(j,k)
            Sum += switch[S[j][k]-1]

        if (Sum%2) != p[j]:
            break

        if j == M-1:
            Answer += 1

print(Answer)


Measured memory_bytes: 74028
#include <stdio.h>

int main(void){
    
    int n;
    scanf("%d",&n);
    
    for(int i=1; i<10;++i){
        int ans=111*i;
        if(n<=ans){
            printf("%d",ans);
            break;
        }
        
    }
    
    return 0;
}


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

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line[] = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int m = Integer.parseInt(line[1]);
			if(n==0){break;}

			int[] vote = new int[m];
			Arrays.fill(vote, 0);
			for(int i=0; i<n; i++){
				String poll[] = br.readLine().split(" ");
				for(int j=0; j<m; j++){
					if (poll[j].equals("1")) {vote[j]++;}
				}
			}

			String ans = "";
			for(int i=n; i>=0; i--){
				for(int j=0; j<m; j++){
					if (vote[j] == i) {
						if(!ans.equals("")){ans += " ";}
						ans += (j+1);
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 44056
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
using namespace std;
typedef long long int llint;
const llint big=((llint)1<<(llint)30);
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pub push_back
#define res resize
//JOI 2017 semiexp O(NlogN)
//3:25~
//Tmin 
int main(void){
	llint N,M,K,A,B,C,T,ans=0,i,j,it,bef,stenum,minit,nokori;
	priority_queue<tuple<llint,llint,llint>> kyu;//next_ste_num,minite,nokori_ste
	cin>>N>>M>>K>>C>>A>>B>>T;
	cin>>bef;
	bef--;
	for(i=1;i<M;i++){
		cin>>it;
		it--;
		stenum=min((T-bef*A+C)/C,it-bef);
		ans+=max((llint)0,stenum);
		minit=bef*A;
		nokori=it-bef;
		kyu.push(mt(min((T-minit-stenum*B+C)/C,nokori-stenum),minit+stenum*B,nokori-stenum));
		
		//if(min((T-bef*A+C)/C,it-bef)<=0){printf("hsdlakj\n");}
		bef=it;
	}
	it=N;
	stenum=min((T-bef*A+C)/C,it-bef);
	ans+=max((llint)0,stenum);
	minit=bef*A;
	nokori=it-bef;
	kyu.push(mt(min((T-minit-stenum*B+C)/C,nokori-stenum),minit+stenum*B,nokori-stenum));
	//if(min((T-bef*A+C)/C,it-bef)<=0){printf("asaj\n");}
	K-=M;
	for(i=0;i<K;i++){
		stenum=get<0>(kyu.top());
		minit=get<1>(kyu.top());
		nokori=get<2>(kyu.top());
		kyu.pop();
		if(stenum<=0){break;}
		ans+=stenum;
		//if(ans==0){printf("de%d\n",i);}
		kyu.push(mt(min((T-minit-stenum*B+C)/C,nokori-stenum),minit+stenum*B,nokori-stenum));
		//if(min((T-minit-stenum*B+C)/C,nokori-stenum)<=0){printf("ko%d\n",i);}
	}
	cout<<ans-1<<endl;
}

Measured memory_bytes: 3160
#include<iostream>

using namespace std;
int main()
{
  int N;
  cin >> N;

  bool res=false;
  for (int i=0; i < N; i++) {
    for (int j=0; j < N; j++) {
    int total = 4*i + 7*j;
    if (total == N) res=true;
    }
  }

  if (res == true) cout << "Yes" << endl;
  else if (res == false) cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <string>
#include <cmath>
using namespace std;

typedef long long ll;

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

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

    cin >> a >> b >> c;

    ll ans = a * b / 2;
    cout << ans;
}

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

void SieveOfEratosthenes(lli n) 
{ 
    
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (lli p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (lli i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    lli x;
    cin>>x;
    for(lli i=x;i<=n;i++)
    if(prime[i])
    {
        cout<<i<<endl;
        return;
    }
} 


int main()
{
    lli q=1;
    //cin>>q;
    
    while(q--)
    {
        SieveOfEratosthenes(300000);
    }
    return 0;

}

Measured memory_bytes: 512
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int w, h;
	scanf("%d%d", &w, &h);
	vector<int> v;
	for(int i = 0; i < w; ++i){
		int p;
		scanf("%d", &p);
		v.push_back(p << 1);
	}
	for(int i = 0; i < h; ++i){
		int p;
		scanf("%d", &p);
		v.push_back(p << 1 | 1);
	}
	sort(ALL(v));
	LL ans = 0;
	LL c[2] = {w + 1LL, h + 1LL};
	for(int x : v){
		int tp = x & 1;
		LL cs = x >> 1;
		ans += cs * c[!tp];
		--c[tp];
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;

int dp[maxn][3];

int main() {
	string s; cin >> s;
	int N = s.size();
	memset(dp, -1, sizeof(dp));

	dp[0][0] = 0;

	rep(i, N) {
		rep(j, 3) if (dp[i][j] != -1) {
			for (int k = 1; k <= 2; ++k) {
				if (i + k <= N) {
					string a, b;
					rep(t, j) a.pb(s[i-j+t]);
					rep(t, k) b.pb(s[i+t]);
					bool f = (j != k || a != b);
					if (f) {
						dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
					}
				}
			}
		}
	}

	cout << max(dp[N][1], dp[N][2]) << endl;

	return 0;
}

Measured memory_bytes: 2948
#include <stdio.h>

int main(){
  int i,n,k;
  char s[100];

  scanf("%d %d %s",&n,&k,s);

  for(i=0; i<n; i++){
    if(i+1==k)
      s[i] += 32;
  }

  printf("%s\n",s);

  return 0;
}

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


int main() {
    

    int a;
    cin>>a;
    vector<int>m;
    for(int i = 1 ; i <10 ; i++){
        for(int j=1; j<10 ; j++){
            m.push_back(i*j);
        }
    }
    bool b = false;
    for(int i = 0; i< m .size() ; i++){
        if(a==m[i]){
            b=true;
        }
    }
    if(b){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    

    int l ; cin>>l;

}

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

int main()
{
	int v;
	cin >> v;
	v = v | (v >>  1);
	v = v | (v >>  2);
	v = v | (v >>  4);
	v = v | (v >>  8);
	v = v | (v >> 16);
	cout << (v ^ (v >> 1)) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

n = int(rl())

li = list(map(int, rl().split()))

dp = np.zeros(n)

dp[0] = 0
dp[1] = abs(li[0] - li[1])

for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(li[i] - li[i-2]), dp[i-1] + abs(li[i] - li[i-1]))
print(int(dp[n-1]))

Measured memory_bytes: 22636
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cstdio>
#include <string>
#include <utility>
#include <iomanip>
#include <numeric>
#include <functional>
#include <list>
#include <regex>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <climits>
using namespace std;


typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

#define pb(c,num) c.push_back(num)

// loops
#define rep(i,n) for (int i = 0; i < n; ++i)
#define repi(i,k,n) for (int i = k; i <= n; ++i)
#define repr(i,k,n) for (int i = k; i >= n; --i)
#define tr(c, it) \
for(auto it = c.begin(); it != c.end(); ++it)


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

// set,map
#define present(c, element) (c.find(element) != c.end())
//vectors
#define cpresent(c, element) (find(all(c), element) != c.end())





int main(){
    std::ios_base::sync_with_stdio(false);

//    ifstream input;
//    ofstream output;
//    input.open("input.in");
//    output.open("output.out");
    


int n;
cin >> n;

for(int i = 1; i < 10; ++i){
    for(int j = 1; j < 10; ++j){
        if(i*j == n){
            cout << "Yes";
            return 0;
        }
    }
}

cout << "No";

//    input.close();
//    output.close();
//
    
    return 0;
}
    


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    print(["NO","YES"][N==len(set(A))])
if __name__ == '__main__':
    main()

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

class Program
{
	public static void Main()
	{
		var n = ReadLine();
		var sb = new StringBuilder();
		for(int i = 0; i < n.Length; i += 2)
		{
			sb.Append(n[i]);
		}
		WriteLine(sb.ToString());
	}
}


Measured memory_bytes: 17396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			int K = sc.nextInt();
			int count = 0;
		
			while(A>=B) {
				B *= 2;
				count++;
			}
			
			while(B>=C) {
				C *=2;
				count++;
			}
			
			if(count <= K) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}	
	}
}


Measured memory_bytes: 35676
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> r(n);
    int x;
    for (int i = 0; i < q; i++)
    {
        cin >> x;
        r[x - 1]++;
    }

    for (int i = 0; i < n; i++)
    {
        if (k - (q - r[i]) > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	long K;
	int[] A;
	long mod, amari;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		K = Long.parseLong(tokens[1]);
		A = new int[N];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i]) - 1;
		}
		init();
	}

	void init() {
		Set<Integer> check = new HashSet<>();
		int[] dist = new int[N];
		Arrays.fill(dist, 0);
		int current = 0;
		int loopLength = 0;
		int d = 0;
		while (true) {
			if (check.contains(current)) {
				loopLength = d - dist[current];
				break;
			}
			dist[current] = d;
			check.add(current);

			current = A[current];
			++d;
		}
		amari = dist[current];
		mod = loopLength;
	}

	void calc() {
		long k = K;
		if (k >= amari + mod) {
			k = (K - amari) % mod + amari;
		}
		int current = 0;
		for (long i = 0; i < k; ++i) {
			current = A[current];
		}
		System.out.println((current + 1));
	}

	void showResult() {
	}

}

Measured memory_bytes: 71220
import sys

# 文字の読み込み
st = input().split()

fl = [ int(x) for x in st]

num_sum = 0

# 作業を2回繰り返す
for k in range(2):
    if fl[0] >= fl[1]:
        i = 0
    else:
        i = 1

    num_sum += fl[i]
    fl[i] -= 1

print(num_sum)

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

public class Main { //m-solutions2019 A -  
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		System.out.println((n-2)*180);
	}

}


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

using namespace std;
int k,r,nr;
int fr[1000005];
int main()
{
    cin>>k;
    if(k%7==0)
        k/=7;

    if(k==1)
    {
        cout<<1;
        return 0;
    }

    r=1;
    nr=1;
    while(true)
    {
        if(!r)
            break;

        if(fr[r])
        {
            cout<<-1;
            return 0;
        }

        fr[r]=1;
        r=r*10+1;
        r%=k;
        nr++;
    }

    cout<<nr;
    return 0;
}


Measured memory_bytes: 7496
#include<iostream>

using namespace std;

int n, q, a[29], b[209];

bool search(int rest, int idx){
  if(rest == 0)return true;
  else if(idx>=n || rest < 0)return false;
  else return search(rest - a[idx], idx+1) || search(rest, idx+1);
}

int main(){
  cin >>n;
  for(int i=0;i<n;i++)cin >> a[i];
  cin >> q;
  for(int i=0;i<q;i++)cin >> b[i];
  for(int i=0;i<q;i++){
    cout << (search(b[i], 0) ? "yes": "no") << endl;
  }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
char s[10];
int cnt[10];
int n;
int main(){
	//freopen("data.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",s);
		if(s[0]=='A') cnt[0]++;
		if(s[0]=='W') cnt[1]++;
		if(s[0]=='T') cnt[2]++;
		if(s[0]=='R') cnt[3]++;
	}
	printf("AC x %d\n",cnt[0]);
	printf("WA x %d\n",cnt[1]);
	printf("TLE x %d\n",cnt[2]);
	printf("RE x %d\n",cnt[3]);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    queue<P> index;

    int ans = 0;

    rep(si, h)rep(sj, w){
        if(s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x){
            if(dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i, j)); //q.emplace(i, j)
        };
        update(si, sj, 0);
        while(!q.empty()){
            int i = q.front().fi;
            int j = q.front().se; q.pop();
            rep(dir, 4){
                int ni = i+di[dir], nj = j+dj[dir];
                if(ni<0||ni>=h||nj<0||nj>=w) continue;
                if(s[ni][nj] == '#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i, h)rep(j, w){
            if(dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    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<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int n,m,c,count=0;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,m) cin >> b[i];
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    rep(i,n){
        ll sum=0;
        rep(j,m){
            sum+=b[j]*a[i][j];
        }
        sum+=c;
        if(sum>0) count++; 
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  int n,c=0,cc=0;
  cin>>n;
  string s;
  cin>>s;
  vector<int>pref(n),suff(n);
  int p,ans;
  for(int i=0;i<n;i++) {
  	if(s[i]=='W') { c++; pref[i]=c; }
  	else { pref[i]=c; }
  }
  for(int i=n-1;i>=0;i--) {
  	if(s[i]=='R') { cc++; suff[i]=cc; }
  	else { suff[i]=cc; }
  }
  ans=min(c,cc);
  for(int i=0;i<n-1;i++) {
  	p=max(pref[i],suff[i+1]);
  	ans=min(p,ans);
  }
  cout<<ans;
  //} 
  return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    //IOS;
    //ll t;cin>>t;while(t--)
    {
        ll x,a,b,c,d,i,j,k,l,m,n,sum=0,temp=0,f=0,cnt=0,t;
        cin>>n;
        ll arr[n];
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        for(i=0;i<n-1;i++)
        {
            sum+=max(1LL*0,arr[i]-arr[i+1]);
            arr[i+1]+=max(1LL*0,arr[i]-arr[i+1]);
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 5156
#include <iostream>
#include <algorithm>

using namespace std;

int n;
int a[1001];

int _read()
{
    char ch=getchar();
    while (ch<'0'||ch>'9')
        ch=getchar();
    int x=0;
    while (ch>='0'&&ch<'=9')
        x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x;
}

int main(int argc,char ** argv)
{
    n=_read();
    for (int i=1;i<=n;i++)
        a[i]=_read();
    sort(a+1,a+n+1);
    cout<<abs(a[1]-a[n])<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define H ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
using namespace std;
const ll  mod = 1000000007;


int solve(int n, int m, int counter){
	//base case
	if (n == m) return counter;
	if (m < n) return counter + (n - m);

	//sol steps
	if (m % 2 == 0)
		return solve(n, m / 2, counter + 1);
	return solve(n, m + 1, counter + 1);
}

int main()
{
	H
	int n;
	cin >> n;
	int arr[n + 1];
	for (int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	int dp[n + 1];
	dp[0] = dp[1] = 0;
	dp[2] = abs(arr[1] - arr[2]);
	for (int i = 3; i <= n; i++){
		dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], abs(arr[i] - arr[i - 2]) + dp[i - 2]);
	}
	cout << dp[n];
	return 0 ;
}


Measured memory_bytes: 1024
n, k = map(int,input().split())
a = list(map(int,input().split()))

a.sort()
count = []
c = 1
for i in range(n-1):
    if a[i] != a[i+1]:
        count.append(c)
        c = 1
    else:
        c += 1
    if i == n - 2:
        count.append(c)

l = len(count)
#print(a)
#print(count)
c = 0
if l <= k:
    print(0)
else:
    count.sort()
    for i in range(l):
        l -= 1
        c += count[i]
        if l <= k:
            print(c)
            quit()

Measured memory_bytes: 85328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;cin >> q;
    vector<bool> p(100001,true);
    p[0]=false;
    p[1]=false;
    for(int i=2;i*i<=100000;i++){
        if(p[i]){
            for(int j=2;j*i<=100000;j++){
                p[i*j]=false;
            }
        }
    }
    vector<int> sum(100001);
    for(int i=1;i<=100000;i++){
        if(p[i]&&p[(i+1)/2]){
            sum[i]=sum[i-1]+1;
        }
        else{
            sum[i]=sum[i-1];
        }
    }
    while(q--){
        int l,r;cin >> l >> r;
        cout << sum[r]-sum[l-1] << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<P> a(n);
    rep(i,n) {
        cin>>a[i].first;
        a[i].second = i+1;
    }
    sort(a.begin(), a.end());
    rep(i,n) {
        cout << a[i].second;
        if (i!=n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

const int maxn = 1e+5 + 5;
int a[maxn], b[maxn];

void solve()
{
    int n;
    cin >> n;
    
    int m1 = 0, m2 = 0;
    int m12 = 0, m22 = 0;
    
    int m1_val = -1, m2_val = -1;
    
    for(int i = 0; i < maxn; i++)
    {
        a[i] = b[i] = 0;
    }
    
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if(i & 1)
        {
            a[x]++;
            
            if(m1 < a[x])
            {
                m1 = a[x];
                m1_val = x;
            }
            
            if(m12 < a[x] && x != m1_val)
            {
                m12 = a[x];
            }
        }
        else
        {
            b[x]++;
            
            if(m2 < b[x])
            {
                m2 = b[x];
                m2_val = x;
            }
            
            if(m22 < b[x] && x != m2_val)
            {
                m22 = b[x];
            }
        }
    }
    
    //cout << m12 << " " << m22 << "\n";
    
    if(m1_val != m2_val)
    {
        cout << n - m1 - m2;
    }
    else
    {
        cout << min(n - m1 - m22, n - m2 - m12);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>//bit DP
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
  int n;
  cin>>n;
  cout<<(1000-n%1000)%1000<<endl;

}


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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BIMissYou {
public:
    void solve(std::istream& in, std::ostream& out) {
        string S;
        in >> S;
        REP(i,0,S.size()) {
            out << 'x';
        }
        out << "\n";
    }
};


signed main() {
    BIMissYou 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;
int main(){
    int n,k;
    cin>>n>>k;
    int count=0;
    vector<int> p(n);
    for(int i=0;i<n;i++){
       cin>>p[i];
    }
    sort(p.begin(),p.end());
    for(int i=0;i<k;i++){
       count+=p[i];
    }
  cout<<count<<endl;
}

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i < b+1; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class MODnCk {
    private static final int mod = 1000000007;

    private static int[] factorialCache = new int[2000];
    private static int factorialCacheIdx = 0;

    static{
        factorialCache[0] = 1;
    }
    
    static int nCk(int n, int k){
        return div((div(factorial(n), factorial(k))), factorial(n-k));
    }

    private static int factorial(int n){
        if(factorialCacheIdx < n){
            setFactorialCache(factorialCacheIdx+1, n);
        }

        return factorialCache[n];
    }

    private static void setFactorialCache(int s, int e){
        for(int i=s; i<=e; i++){
            factorialCache[i] = mul(factorialCache[i-1], i);
        }
        factorialCacheIdx = e;
    }

    private static int div(int a, int b){
        return mul(a, modinv(b));
    }

    static int mul(int a, int b){
        long x = (long)a * (long)b;
        return (int)(x % mod);
    }

    private static int modinv(int a) {
        int b = mod;
        int u = 1;
        int v = 0;
        while (b != 0) {
            int t = a / b;
            a -= t * b;
            int temp = a; a = b; b = temp; // swap(a, b)
            u -= t * v;
            temp = u; u = v; v = temp; // swap(u, v)
        }
        u %= mod;
        if (u < 0) u += mod;
        return u;
    }
}

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

		for(int i=1; i<=k; i++){
			if(n-k+1 < i){
				System.out.println(0);
			}else{
				System.out.println(MODnCk.mul(MODnCk.nCk(k-1, i-1), MODnCk.nCk(n-k+1, i)));
			}
		}
	}
}


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

int main ()
{
	//a,bの定義及び入力
	int a;
	cin >> a;

	int b;
	cin >> b;

	//出力
	if(a*b%2==0){cout << "Even" <<endl;}
	else{cout << "Odd" << endl;}

	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >    

using namespace std;   


        
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
  	cin>>s;
  	int l = s.length();
  	if(s[l-1]=='s') cout<<s<<"es"<<endl;
  	else cout<<s<<"s"<<endl;
	return 0;
}

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

map<ll,ll>mp ;
int main() {
    ll n ;
    scanf("%lld",&n) ;
    ll i ;
    vector<ll>a(n) ;
    for(i=0;i<n;i++) {
        scanf("%lld",&a[i]) ;
        mp[a[i]]++ ;
    }
    ll ans = 0 ;
    for(i=1;i<=n;i++) {
        ans+= ((mp[i]*(mp[i]-1))/2 ) ;
    }
    for(i=0;i<n;i++) {
        ll tans = ans ;
        tans-= ((mp[a[i]]*(mp[a[i]]-1))/2) ;
        tans+= ((((mp[a[i]]-1)*(mp[a[i]]-2))/2)) ;
        cout << tans << endl ;
    }

    return 0 ;
}


Measured memory_bytes: 16640