akhauriyash/Code-Regression huggingface dataset:
/// @file
/// referenced: https://beta.atcoder.jp/contests/abc101/submissions/2736002
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
int S(int n){
  int res=0;
  while(n){
    res+=n%10;
    n/=10;
  }
  return res;
}
main(){
  int K;
  cin>>K;
  int snuke=1,step=1;
  for(int i=1;i<=K;++i){
    if(i==1){
      printf("1\n");
      continue;
    }
    const int x=snuke+step;
    const int y=snuke+10*step;
    if(S(x)*y<x*S(y))step*=10;
    snuke+=step;
    cout<<snuke<<endl;
  }
}


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

int main()
{
    long long int a,b,c[13],Max = -9999999,i;
    cin>>a>>b;
    c[1] = a+b;
    c[2] = a-b;
    c[3] = a*b;
    for(i=1;i<=3;i++)
    {
        Max = max(Max,c[i]);
    }
    cout<<Max<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> field(h,vector<char>(w));
    rep(i,0,h){
        rep(j,0,w){
            cin >> field[i][j];
        }
    }
    set<int> ommith;
    set<int> ommitw;
    rep(i,0,h){
        int check = 0;
        rep(j,0,w){
            if(field[i][j]!='.'){
                check=1;
            }
        }
        if(check==0){
            ommith.insert(i);
        }
  
    }
    rep(i,0,w){
        int check = 0;
        rep(j,0,h){
            if(field[j][i]!='.'){
                check=1;
            }
        }
        if(check==0){
            ommitw.insert(i);
        }
  
    }
    rep(i,0,h){
        if(ommith.count(i)){
            continue;
        }
        rep(j,0,w){
            if(ommitw.count(j)){
                continue;
            }
            cout<<field[i][j];
            
        }
        cout<<endl;
    }
    
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

int main(){
    int N;
    cin >> N;
    
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size() - 2; i++){
        ans += (S.substr(i, 3) == "ABC");
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter

n, *s = open(0).read().split()
c = Counter(s[0])
for i in s[1:]:
    for j in c.keys():
        c[j] = min(c[j], i.count(j))
print(*sorted(i * j for i, j in c.items()), sep="")


Measured memory_bytes: 9148
//ITP1_2_A:   Small, Large, or Equal
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String[] ab = in.readLine().split(" ");

		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);

		if (a > b) {
			System.out.println("a > b");
		} else if (a < b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}

	}
}

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

int main()
{
    int n, k, i, ans;
    cin >> n >> k;
    vector<int> h(n);
    for (i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    ans = 2000000000;
    for (i = 0; i < n - k + 1; i++)
    {
        int h_min = h.at(i);
        int h_max = h.at(i + k - 1);
        int h_dif = h_max - h_min;
        ans = min(h_dif, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int n, d;
vector<string> vec;

bool contain(string &a, string &b)
{
	string s, t;
	if(a.size() > b.size()) s = a, t = b;
	else s = b, t = a;
	
	int pos = 0;
	for(int i = 0; i < s.size(); i++){
		if(pos < t.size() && s[i] == t[pos]) pos++;
	}
	return pos >= t.size();
}

bool check(string &s, string &t, int d)
{
	int dif = 0;
	vector<int> vec;
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]){
			dif++;
			vec.push_back(i);
		}
	}
	
	if(dif <= d) return true;
	
	if(d == 1){
		if(dif > 2) return false;
		return vec[0] + 1 == vec[1] && s[vec[0]] == t[vec[1]] && s[vec[1]] == t[vec[0]];
	}
	if(d == 2){
		for(int i = 0; i < s.size(); i++){
			string u = s.substr(0, i) + s.substr(i+1);
			if(contain(u, t)) return true;
		}
		if(dif == 4){
			return (vec[0] + 1 == vec[1] && s[vec[0]] == t[vec[1]] && s[vec[1]] == t[vec[0]])
			&& (vec[2] + 1 == vec[3] && s[vec[2]] == t[vec[3]] && s[vec[3]] == t[vec[2]]);
		}
		if(dif == 3){
			if(vec[0] + 1 != vec[1]) 
				return (vec[1] + 1 == vec[2] && s[vec[1]] == t[vec[2]] && s[vec[2]] == t[vec[1]]);
			if(vec[1] + 1 != vec[2]) 
				return (vec[0] + 1 == vec[1] && s[vec[0]] == t[vec[1]] && s[vec[1]] == t[vec[0]]);
			
			if(s[vec[0]] == t[vec[1]] && s[vec[1]] == t[vec[0]]) return true;
			if(s[vec[1]] == t[vec[2]] && s[vec[2]] == t[vec[1]]) return true;
			if(s[vec[0]] == t[vec[1]] && s[vec[1]] == t[vec[2]] && s[vec[2]] == t[vec[0]]) return true;
			if(s[vec[0]] == t[vec[1]] && s[vec[1]] == t[vec[2]] && s[vec[2]] == t[vec[0]]) return true;
			return false;
		}
	}
	return false;
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		cin >> d;
		
		string s;
		vec.clear();
		for(int i = 0; i < n; i++){
			cin >> s;
			vec.push_back(s);
		}
		sort(vec.begin(), vec.end());
		
		int cnt = 0;
		for(int i = 0; i < vec.size(); i++){
			for(int j = 0; j < vec.size(); j++){
				if(i >= j) continue;
				
				int dif = abs((int)vec[i].size() - (int)vec[j].size());
				if(dif > d) continue;
				if(dif == d){
					if(contain(vec[i], vec[j]) )goto NEAR;
					else continue;
				}
				
				if(d == 2 && dif == 1){
					string s, t;
					if(vec[i].size() > vec[j].size()) s = vec[i], t = vec[j];
					else s = vec[j], t = vec[i];
					for(int k = 0; k < s.size(); k++){
						string u = s.substr(0, k) + s.substr(k+1);
						if(check(u, t, 1)) goto NEAR;
					}
				}
				else if(check(vec[i], vec[j], d)) goto NEAR;
				continue;
				
				NEAR:;
				cnt++;
				cout << vec[i] << "," << vec[j] << endl;
			}
		}
		cout << cnt << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3168
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))


Measured memory_bytes: 6436
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,ans,a[100002];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	ans=a[0]=a[n+1]=0;
	for(int i=1;i<=n+1;i++)ans+=abs(a[i]-a[i-1]);
	for(int i=1;i<=n;i++)printf("%d\n",ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
}

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

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

  if (n == 3) {
    puts("2 5 63");
    return 0;
  }
  if (n == 4) {
    puts("2 5 20 63");
    return 0;
  }
  if (n == 6) {
    puts("2 3 4 5 6 10");
    return 0;
  }

  vector<int> a[3];
  for (int i = 2; i <= 30000; ++i) {
    if (i % 6 == 0)
      a[2].push_back(i);
    else if (i % 2 == 0)
      a[0].push_back(i);
    else if (i % 3 == 0)
      a[1].push_back(i);
  }

  vector<int64_t> r[2];
  for (int idx = 0; idx < 2; ++idx) {
    r[idx].resize(a[idx].size());
    r[idx][0] = a[idx][0];
    for (int i = 1; i < a[idx].size(); ++i) {
      r[idx][i] = r[idx][i - 1] + a[idx][i];
    }
  }

  vector<int> s;
  for (int i = 0; i < a[0].size(); ++i) {
    bool f = false;
    for (int j = 0; j < a[1].size(); ++j) {
      if ((r[0][i] + r[1][j]) % 6 == 0 && n - (i + j + 2) <= a[2].size()) {
        for (int k = 0; k <= i; ++k) {
          s.push_back(a[0][k]);
        }
        for (int k = 0; k <= j; ++k) {
          s.push_back(a[1][k]);
        }
        for (int k = 0; k < n - (i + j + 2); ++k) {
          s.push_back(a[2][k]);
        }

        f = true;
        break;
      }
    }

    if (f) break;
  }

  // cerr << s.size() << endl;
  for (int i = 0; i < n; ++i) {
    cout << s[i] << (i + 1 == n ? "\n" : " ");
  }
}


Measured memory_bytes: 768
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <bitset>
#define LL long long

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v;
    map<int, int> mapp;
    for (size_t i = 0; i < 2 * m; i++)
    {
        int tmp;
        cin >> tmp;
        v.emplace_back(tmp);
    }
    for (size_t i = 0; i < v.size(); i++)
    {
        auto itr = mapp.find(v[i]);
        if (itr == mapp.end())
        {
            mapp.insert(make_pair(v[i], 1));
        }
        else
        {
            itr->second++;
        }
    }
    if (m == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        for (size_t i = 0; i < n; i++)
        {
            cout << mapp[i + 1] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
local n = io.read("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
local sum = 0
for i = 1, n do
  a[i] = a[i] - io.read("*n")
  sum = sum + a[i]
end
if(sum < 0) then
  print(-1)
else
  table.sort(a)
  local task = 0
  local cnt = 0
  for i = 1, n do
    if(a[i] < 0) then
      task = task + a[i]
      cnt = cnt + 1
    else
      break
    end
  end
  for i = n, 1, -1 do
    if(0 <= task) then break end
    cnt = cnt + 1
    task = task + a[i]
  end
  print(cnt)
end


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main (){
float a,b=0;
cin>>a;
for (int i=1;i<=a;i++)
{
    b=b+800;
    if (i%15==0.0)
        b=b-200;
}
cout<<b;



return 0;
}





Measured memory_bytes: 256
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())

for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

Measured memory_bytes: 6724
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b;
  readf("%s %s\n", &a, &b);
  if (a < 6) {
    writeln("0");
  } else if (a < 13) {
    writeln(b/2);
  } else {
    writeln(b);
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

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

	int p = 0;
	while(true){
		if(p*(p+1)/2 >= N){
			break;
		}
		p++;
	}

	cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	for (int i=a;i<=b;i++)
		if (i%k==0)
		{
			cout<<"OK";
			return 0;
		}
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
 
#define srep(s, i, n) for (size_t i = s; i < (size_t)n; ++i)

typedef int32_t i32;

using namespace std;
 
int main() {
  size_t n, k;
  cin >> n >> k;
  auto vec = vector<i32>(n);
  for (auto &x : vec) {
    cin >> x;
  }
 
  auto dp = vector<i32>(n, 0);
  srep(1, to, n) {
 
    auto min = INT32_MAX;
    srep((to < k ? 0 : to - k), from, to) {
      auto cost = abs(vec[to] - vec[from]);
      auto result = dp[from] + cost;
      if (result < min) {
        min = result;
      }
    }
    dp[to] = min;
  }
 
  cout << dp.back() << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;
string s;

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

    int rcnt = 0;
    for(int i = 0; i < n; ++i) if(s[i] == 'R') rcnt++;
    int cnt = 0;
    for(int i = 0; i < rcnt; ++i) if(s[i] == 'W') cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, q;
  string s;
  cin>>n>>q>>s;
  int l[q], r[q];
  REP(i, q){
    cin>>l[i]>>r[i];
  }

  int ac[n+1];
  ac[0]=0;
  REP(i, n){
    ac[i+1]=ac[i];
    if(i==0) continue;
    if(s[i-1]=='A' && s[i]=='C') ++ac[i+1];
  }
  //REP(i, n)cout<<ac[i+1];
  //cout<<endl;
  REP(i, q){
    cout<<ac[r[i]]-ac[l[i]]<<endl;
  }

  return 0;
}


Measured memory_bytes: 2176
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;
#define X first
#define Y second

const int N = 100005;
const int M = 400005;

int n,m;
int hd[N],nt[M],to[M],dis[M],num=0;
int deg[N];
int vvis[N];

void conn(int u,int v,int w) {
	deg[v] ++;
	nt[num] = hd[u];
	to[num] = v;
	dis[num] = w;
	hd[u] = num++;
}

int len[N];
int que[N*2],qi,qn;

void go() {
	cin >> n >> m;
	memset(hd,-1,sizeof(hd));
	memset(deg,0,sizeof(deg));
	memset(vvis,0,sizeof(vvis));

	for(int i = 0; i < m; i++) {
		int u,v,w;
		cin >> u >> v >> w;
		u--; v--;
		conn(u,v,w);
		conn(v,u,-w);
	}
	int cnt = 0;
	int vcnt = 0;
	for(int i = 0; i < n; i++) if(vvis[i]==0) {
		vvis[i] = 1;
		memset(len,0x7f,sizeof(len));
		qi = qn = 0;
		que[qn++] = i;
		que[qn++] = 0;
		len[i] = 0;
		for(;qi<qn;) {
			int u = que[qi++];
			int w = que[qi++];
			for(int j = hd[u]; ~j; j=nt[j]) {
				int v = to[j];
				int vw = dis[j];
				// cout << i << " " << v << " " << w << " " << w+vw << " " << len[v] << endl;
				if(vvis[v]) {
					if(w+vw!=len[v]) {
						cout << "No" << endl;
						return;
					}
					continue;
				}
				vvis[v] = 1;
				len[v] = w+vw;
				que[qn++] = v;
				que[qn++] = w+vw;
			}
		}
	}
	// cout << cnt << " " << vcnt << endl;
	// if(cnt && cnt==vcnt) cout << "No" << endl; else 
	cout << "Yes" << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	// int t; cin >> t; for(;t--;)
	go();
	return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define swap(a,b) a^=b^=a^=b 
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 200010
using namespace std;
typedef long long ll;
struct point{
	int x,y,no;
}a[N];
struct e{
	int a,b,v;
	bool operator <(const e& c)const{return v<c.v;}
}b[2000010];
int n,cnt,fa[N];
ll ans,ans2;
inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
inline bool cmp1(const point a,const point b){return a.x<b.x;}
inline bool cmp2(const point a,const point b){return a.y<b.y;}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y),a[i].no=fa[i]=i;
	sort(a+1,a+1+n,cmp1);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=min(i+10,n);j++)b[++cnt]=(e){a[i].no,a[j].no,min(abs(a[i].x-a[j].x),abs(a[i].y-a[j].y))};
	}
	sort(a+1,a+1+n,cmp2);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=min(i+10,n);j++)b[++cnt]=(e){a[i].no,a[j].no,min(abs(a[i].x-a[j].x),abs(a[i].y-a[j].y))};
	}
	sort(b+1,b+1+cnt);
	for(int i=1;i<=cnt;i++){
		int x=find(b[i].a),y=find(b[i].b);
		if(x^y)fa[x]=y,ans+=b[i].v;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 25216
using System;
using System.Linq;

namespace ABC138
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(v);
            Decimal ans = v[0];
            for (int i = 1; i < n; i++)
                ans = (ans + v[i]) / 2;

            Console.WriteLine(ans);
        }
    }
}


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

string func(string s, int n) 
{ 
    
    string str = s; 
  
    for (int i=1; i<n;i++) 
        s += str;
  
    return s; 
} 

int main()
{
	string s ="ACL";
	int n;
	cin>>n;
	
	cout << func(s, n) << endl;
	return 0; 
}
  

Measured memory_bytes: 3632
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *CSP-S 2019 RP++                                          *
 ***********************************************************/
#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
	return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
ll n,a[mn],p[120],num,ans;
inline void f(ll x){
	FORD(i,62,0)if(!(num&(1ll<<i))&&(x&(1ll<<i))){
		if(!p[i]){p[i]=x;return;}
		x^=p[i];
	}
	FORD(i,62,0)if((num&(1ll<<i))&&(x&(1ll<<i))){
		if(!p[i]){p[i]=x;return;}
		x^=p[i];
	}
}
signed main(){
#ifdef LOCAL_LIGEN
	// freopen("0.in","r",stdin);
	// freopen("0.out","w",stdout);
	double be=clock();
#endif
	n=read();
	FOR(i,1,n)a[i]=read(),num^=a[i];
	FOR(i,1,n)f(a[i]);
	FORD(i,62,0)if(!(ans&(1ll<<i)))ans^=p[i];
	writeln(ans+(num^ans));
#ifdef LOCAL_LIGEN
	double en=clock();
	printf("Time: %.0lfms\n",en-be);
	fclose(stdin);fclose(stdout);
#endif
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

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

using ll = long long;
using namespace std;

struct Node{
	vector<int> childs;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	vector<Node> nodes(100000);
	bool flg[100000] = {0};
	cin >> n;
	REP(i, n - 1){
		int a,b;
		cin >> a >> b;
		nodes[a-1].childs.push_back(b-1);
		nodes[b-1].childs.push_back(a-1);
	}
	vector<int>fl, sl;
	int f = 0, s = 0;
	for(int i = 0; true; ++i){
		if(i == 0){
			flg[0] = 1; // 専攻は1
			fl.push_back(0);
			++f;
			flg[n - 1] = 2; // 高校は2
			sl.push_back(n - 1);
			++s;
		}
		else{
			vector<int>nfl, nsl;
			for(const auto& x : fl){
				for(const auto &y : nodes[x].childs){
					if(flg[y] == 0){
						nfl.push_back(y);
						flg[y] = 1;
						++f;
					}
				}
			}
			for(const auto& x : sl){
				for(const auto &y : nodes[x].childs){
					if(flg[y] == 0){
						nsl.push_back(y);
						flg[y] = 2;
						++s;
					}
				}
			}
			fl = nfl;
			sl = nsl;
		}
		if(fl.empty() && sl.empty())break;

	}

	if(s >= f)
		cout << "Snuke" << "\n";
	else
		cout << "Fennec" << "\n";

	return 0;
}


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

int main() {
    int K, S;
    cin >> K >> S;

    int result=0;
    for(int x=0; x<=K; x++){
        for(int y=0; y<=K; y++){
            int z = S - x - y;
            if (0 <= z && z <= K){ result++; }
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int):
    return YES if (N % sum([int(x) for x in str(N)]) == 0) else NO


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


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

int main(void){
    int a,b;
    cin >> a >> b;
    if(b == 100)b++;
    if(a == 0)cout << b << endl;
    if(a == 1)cout << b*100 << endl;
    if(a == 2)cout << b*100*100 << endl;
}

Measured memory_bytes: 256
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    N = input_string[0].rstrip()
    array = input_string[1].rstrip()
    c_b = 0
    c_r = 0
    for t in array:
        if t == 'R':
            c_r += 1
        else:
            c_b += 1
    if c_r > c_b:
        return "Yes"
    return "No"


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

int main(){
  int a;
  std::cin >> a;
  if(a % 1000 == 0){
    std::cout << 0 << std::endl;
  }else{
    std::cout << (((a / 1000) + 1) * 1000) - a << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;
using namespace std::chrono;

/*
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
*/

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k,r;


ll mob(ll i){
    if(i == 1)return 1;
    for(ll c1 = 2; c1*c1 <= i; c1++){

        if(i % c1 == 0){

            if(i % (c1*c1) == 0)return 0;
            return (-1) * mob(i / c1);
        }
    }
 return -1;
}


ll ans = 0;

 ll upp(ll i, ll j){

 if(j == 0)return 1;

 if(j%2 == 0){
    ll h = upp(i,j/2);
    return (h*h)%big;

 }
 return (i*upp(i,j-1))%big;
 }


ll g(ll i, ll m){
    ll a = mob(m/i) * upp(k, (i+1)/2);
    a += big;
    a %= big;
    //if(i % 2 == 0){a *= i/2;}
  //  else{
  //      a *= i;
  //  }
   // a%=big;

   // cout << i << " " << a << "\n";

    return a;
}



ll g2(ll i){
ll ans = 0;
for(ll c1 = 1; c1*c1 <= i; c1++){
    if(i % c1 == 0){
        ans += g(c1,i);
        if((c1*c1) != i){
            ans += g(i/c1,i);
        }
        ans %= big;
    }
}

//cout << i << " " << ans << "\n";
return ans;
}


int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,c,e;
    ll x;

    cin >> n >> k;


    for(ll c1 = 1; c1*c1 <= n; c1++){

        if(n%c1 == 0){
            a = 1;
            if(c1 % 2 == 0){a = c1/2;}
            else{a = c1;}
            ans += a*g2(c1);
            ans += big;
            ans %= big;

            if(c1*c1 != n){
                if(n/c1 % 2 == 0){a = (n/c1)/2;}
                else{a = n/c1;}
                ans += a*g2(n/c1);
                ans += big;
                ans %= big;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  vector<int> A(a);
  for(int i = 0;i<a;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int sum = 0;
  for(int i = 0;i<a-1;i++)
    sum += A.at(i);
  if(A.at(a-1)<sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll a[100010];
ll preIndex[100010];
ll ans[100010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>a[i];
    }
    ll now=0;
    for(ll i=0;i<N;i++){
        if(a[now]<a[i]){
            preIndex[i]=now;
            now=i;
        }
    }
    multiset<ll> st;
    ll cnt=0;
    for(ll i=now;i<N;i++){
        if(a[i]==a[now])cnt++;
        else st.insert(a[i]);
    }
    while(now>0){
        ll nowAns=cnt*(a[now]-a[preIndex[now]]);
        for(ll i=preIndex[now];i<now;i++){
            st.insert(a[i]);
        }
        vector<multiset<ll>::iterator> remove;
        for(auto it=st.lower_bound(a[preIndex[now]]);it!=st.end();it++){
            nowAns+=(*it)-a[preIndex[now]];
            remove.push_back(it);
        }
        cnt+=remove.size();
        for(auto it:remove){
            st.erase(it);
        }
        ans[now]=nowAns;
        now=preIndex[now];
    }
    ans[0]=cnt*a[0];
    for(auto it=st.begin();it!=st.end();it++){
        ans[0]+=*it;
    }
    for(ll i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }



    return 0;
}

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

using namespace std;

int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<"T"<<endl;
  }else if(b=='T'){
    cout<<"A"<<endl;
  }else if(b=='C'){
  	cout<<"G"<<endl;
  }else if(b=='G'){
    cout<<"C"<<endl;
  }
 	return 0; 
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (sx, sy, tx, ty) = get!(i32, i32, i32, i32);
    let dx = tx - sx;
    let dy = ty - sy;

    let mut r = String::new();
    for _ in 0..dx { r.push('R'); }
    for _ in 0..dy { r.push('U'); }
    for _ in 0..dx { r.push('L'); }
    for _ in 0..dy { r.push('D'); }
    r.push('D');
    for _ in 0..dx+1 { r.push('R'); }
    for _ in 0..dy+1 { r.push('U'); }
    r.push('L');
    r.push('U');
    for _ in 0..dx+1 { r.push('L'); }
    for _ in 0..dy+1 { r.push('D'); }
    r.push('R');

    println!("{}", r);
}

Measured memory_bytes: 4352
import fractions

def lcm(a,b):
    return (a*b)//fractions.gcd(a,b)

N=int(input())
a=list(map(int,input().split()))
tmp=a[0]
for i in range(1,N):
    tmp=lcm(tmp,a[i])
tmp-=1
ans=0
for i in range(N):
    ans+=tmp%a[i]
print(ans)

Measured memory_bytes: 5344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << max(0,in()-2*in()) << "\n";
}

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

int gcd(int a, int b)
{
	if (b > a)
		return gcd(b, a);
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
int gcd2(int a[], int n)
{
	int res = a[0];
	for (int i = 1; i < n; i++)
	{
		res = gcd(res, a[i]);
	}
	return res;
}
int32_t main()
{

	int n, a, b;
	cin >> n >> a >> b;

	string s;
	cin >> s;
	int bcnt = 0;
	int l = s.length();
	int res = 0;
	for (int i = 0; i < l; i++)
	{
		if (s[i] == 'a' && res < (a + b)) {
			cout << "Yes" << endl;
			res++;
		}
		else if (s[i] == 'b' && res < (a + b) && bcnt < b)
		{
			cout << "Yes" << endl;
			bcnt++;
			res++;
		}
		else
			cout << "No" << endl;

	}
}


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

ans = [0] * n

for j in range(k):
  ans[0] += (1 + p[j]) / 2
for i in range(1,n-k+1):
  ans[i] = ans[i-1] - (1 + p[i-1]) / 2 + (1 + p[i+k-1]) / 2

print(max(ans))

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

typedef long long int64;
#define REP(i,n) for(int64 i=0;i<(int64)(n);i++)
#define REPD(i,n) for(int64 i=(int64)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int64 i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int64)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define GSORT(x) sort(ALL(x), greater<int64>());
#define SUM(x) accumulate(ALL(A), 0);
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; }

using namespace std;

void Main()
{
	int64 N;
	cin >> N;
	string result;
	int h=N/3600;
	int m=(N%3600)/60;
	int s=(N%60);

	result=to_string(h)+":"+to_string(m)+":"+to_string(s);
	cout << result << endl;
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3296
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef vector<string>VS;
struct S{string p;VS v;};
map<string,S>m;
int A(string a,string n)
{
	if(m[n].p.empty())return 0;
	if(m[n].p==a)return 1;
	return A(a,m[n].p);
}
int main()
{
	int N,M,i,c,f;
	string s,t,x,y;
	while(cin>>N>>M,N)
	{
		VS v;
		m.clear();
		getline(cin,s);
		getline(cin,s);
		m[s].p="";
		v.push_back(s);
		for(i=1;i<N;++i)
		{
			getline(cin,s);
			c=count(s.begin(),s.end(),' ');
			s=s.substr(c);
			while(v.size()>c)v.pop_back();
			m[s].p=v.back();
			m[v.back()].v.push_back(s);
			v.push_back(s);
		}
		for(i=0;i<M;++i)
		{
			getline(cin,s);
			v.clear();
			for(;;)
			{
				c=s.find(' ');
				if(c==string::npos)break;
				v.push_back(s.substr(0,c));
				s=s.substr(c+1);
			}
			x=v[0];
			y=s;
			y.erase(y.size()-1);
			t=v[3];
			if(t=="child")f=(m[x].p==y);
			if(t=="parent")f=(m[y].p==x);
			if(t=="sibling")f=(m[x].p==m[y].p);
			if(t=="descendant")f=A(y,x);
			if(t=="ancestor")f=A(x,y);
			cout<<(f?"True\n":"False\n");
		}cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1008
#include<stdio.h>
int main(void) {
	int a, b, c, x, y, ab = 0,h,t,i,d;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	h = (x > y) ? y:x;
	t = (x > y) ? x - y : y - x;
	if (a + b < c * 2) {
		ab += ((a + b) * h);
	}
	else {
		ab += ((c * 2)* h);
	}
	if (x > y) {
		d = (a > c * 2) ? c * 2 : a;
		ab += (d * t);
	}
	else {
		d = (b > c * 2) ? c * 2 : b;
		ab += (d * t);
	}
	printf("%d\n", ab);
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const int inf = 1e9 + 7;
const int maxN = 5e6 + 5;

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


Measured memory_bytes: 256
import java.util.*;

class Main{
 	public static void main(String[] args){
     Scanner sc = new Scanner(System.in);
      int num1 = sc.nextInt();
      int num2 = sc.nextInt();
      if ( num1 == num2){
       System.out.println("Yes");
      } else{
       System.out.println("No");
      }
    }
}

Measured memory_bytes: 24148
#include <stdio.h>
#include <math.h>

int isPrime(int n){
    int i;
    for(i=2;i<=(int)sqrt(n);i++){
        if(n%i==0) return 0;
    }
    return 1;
}

int main(){
    int q;
    scanf("%d", &q);
    int l[q+1], r[q+1];
    int i;
    for(i=1;i<=q;i++) scanf("%d %d", &l[i], &r[i]);
    int sosu_num[100002];
    for(i=0;i<=100001;i++) sosu_num[i] = 0;
    for(i=3;i<=100000;i++){
        sosu_num[i] = sosu_num[i-1];
        if(i%2==1&&isPrime(i)==1&&isPrime((i+1)/2)) sosu_num[i] += 1;
    }
    for(i=1;i<=q;i++) printf("%d\n", sosu_num[r[i]] - sosu_num[l[i]-1]);
    
    return 0;
}

Measured memory_bytes: 1792
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printyn(a) printf(a ? "Yes\n" : "No\n");
#define printYN(a) printf(a ? "YES\n" : "NO\n");
#define all(x) (x).begin(), (x).end()

using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
//#include <vector>

using namespace std;

int main() {

	int w, h, n, x, y, a, x0, y0, x1, y1;
	scanf("%d%d%d", &w, &h, &n);
	x0 = y0 = 0;
	x1 = w;
	y1 = h;
	rep(i, n) {
		scanf("%d%d%d", &x, &y, &a);
		if (a == 1) {
			x0 = max(x0, x);
		}
		else if (a == 2) {
			x1 = min(x1, x);
		}
		else if (a == 3) {
			y0 = max(y0, y);
		}
		else {
			y1 = min(y1, y);
		}
	}
	printf("%d\n" , y1 > y0 && x1 > x0 ? (x1 - x0) * (y1 - y0) : 0);
	return 0;
}


Measured memory_bytes: 128
//Pck2018 BozoSort
//20181019
//F_Naru
#include<iostream>
using namespace std;
//正しい順序になったかをメモする配列と
//順序が正しい個数をメモする変数をつくる
//n番目のメモする配列が0かつ順序が正しかったら
//個数をメモする変数を１つ増やしn番目Nのメモする配列を1にする
int N;
int Sorted_num=0;

bool judge(int *, int*, int);
void output(int *);//debug
int main(){
  cin >> N;
  int* bozo = new int[N+2];
  int* sorted = new int[N+2];//bozo[i-1] <= bozo[i] なら 1 以外は 0
  int before = 0;//min
  bozo[0] = 0;//min
  bozo[N+1] = 1000000001;//Max
  sorted[0] = 1;
  sorted[N+1] = 1;

  for(int i=1; i<=N; i++){
    cin >> bozo[i];
    if(before <= bozo[i]){//正しい並び
      sorted[i] = 1;
      Sorted_num++;
    }
    before=bozo[i];
  }
  if(Sorted_num == N){//はじめからソートされている
    cout << 0 << endl;
    delete[] bozo;
    delete[] sorted;
    return 0;
  }
  //命令読み込み
  int Q,x,y,temp;
  cin >> Q;
  for(int i=1; i<=Q; i++){
    cin >> x >> y;
    //swap
    temp=bozo[y];
    bozo[y]=bozo[x];
    bozo[x]=temp;
    //判定
    judge(bozo, sorted, x);
    judge(bozo, sorted, y);
    if(Sorted_num >= N){
      cout << i << endl;
      delete[] bozo;
      delete[] sorted;
      return 0;
    }
  }
  cout << -1 << endl;
  delete[] bozo;
  delete[] sorted;
  return 0;
}

bool judge(int* a, int* b,  int x){//判定
  for(int i=0; i<2; i++){
    if(a[x-1+i] <= a[x+i]  && b[x+i] == 0){//swapにより正順になった
      b[x+i]=1;
      Sorted_num++;
    } else if(a[(x-1)+i] > a[x+i] && b[x+i] == 1){//swapによりダメな順になった
      b[x+i] = 0;
      Sorted_num--;
    }
  }
}

void output(int* p){//debug
  for(int i=0; i<=N+1; i++){
    cout << p[i] << " ";
  }
  cout << endl;
}



Measured memory_bytes: 5224
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int main()
{
int A,B;
cin>>A>>B;
A=(A+11)%13;
B=(B+11)%13;
if(A>B)cout<<"Alice"<<endl;
if(A==B)cout<<"Draw"<<endl;
if(A<B)cout<<"Bob"<<endl;
system ("pause");
return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vd vector<double>
#define f(i,l,r) for(ll i=l;i<r;i++)
#define d(i,n,m) for(ll i=n;i>=m;i--)
#define P (ll)1e9+7
#define pb push_back
#define F first
#define S second
#define IP ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int offset[]={1,0,-1,0,1};
int main()
{
    IP
    ll n;
    cin>>n;
    vl height;
    f(i,0,n)
    {
        ll temp;
        cin>>temp;
        height.pb(temp);
    }
    ll ans=0;
    unordered_map<ll,ll> check;
    f(i,0,n)
    {
        if(i+1>height[i])
         ans+=check[i+1-height[i]];
         check[i+1+height[i]]++;
    }
    
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 13684
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,ans=0,x=0;
    cin>>n>>m;
    pair<ll,ll>arr[n];
    for(ll i=0;i<n;i++)cin>>arr[i].first>>arr[i].second;
    sort(arr,arr+n);
    while(m>0)ans+=min(m,arr[x].second)*arr[x].first,m-=arr[x].second,x++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define H 5000000

int A[H],n;

void maxHeapify( int *A ,int  i ){

  int r,l,largest,a;
  
  l = 2 * i;
  r = (2 * i) + 1;
  
  if ( l <= n && A[l] > A[i])
    largest = l;
  else
    largest = i;
      
  if (r <= n && A[r] > A[largest])
    largest = r;
  
  if (largest != i){

    a = A[i];
    A[i] = A[largest];
    A[largest] = a;
    maxHeapify( A , largest );
  
  }	 
}


void buildMaxHeap( int *A ){
  
  int i;
 
  for(i = n / 2; i > 0 ; i--) 
    maxHeapify( A , i );
    }


      
main(){
  
  int i;
 
  scanf("%d", &n);
 
  for(i = 1; i <= n; i++)
    scanf("%d", &A[i]);
  
   buildMaxHeap(A);
 
  for(i = 1 ; i <= n ; i++) 
    printf(" %d", A[i]);
  
  printf("\n");
  
  return 0;
  
}

Measured memory_bytes: 2552
#include<cstdio>
#include<complex>
#include<cmath>
using namespace std;
typedef complex<int> xy;


int main() {
	xy p[110];
	int n;
	scanf("%d", &n);
	int x, y;

	for (int i = 0; i < n; i++) {
		scanf("%d %d", &x, &y);
		p[i] = xy(x,y);
	}

	double sum = 0.0;
	for (int i = 1; i <= n - 2; i++) {
		xy a = p[0], b = p[i], c = p[i + 1];
		sum += (conj(b - a)*(c - a)).imag() / 2.0;
	}
	printf("%.1f\n", abs(sum));

	return 0;
}

Measured memory_bytes: 1064
function Main(arg) 
{
  var sa = arg.split("\n")[0].split("");
  var sb = arg.split("\n")[1].split("");
  var sc = arg.split("\n")[2].split("");

  var next = 'a';
  while (1) {
    if (next === 'a') {
      if (sa.length===0) {
        console.log("A");
        return;
      }
      next = sa.shift();
    }
    else if (next === 'b') {
      if (sb.length===0) {
        console.log("B");
        return;
      }
      next = sb.shift();
    }
    else if (next === 'c') {
      if (sc.length===0) {
        console.log("C");
        return;
      }
      next = sc.shift();
    }
  }

  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
    
    int R[200000], n;
    
    cin >> n;
    
    for(int i = 0; i < n; i ++) {
        
        cin >> R[i];
        
    }
    
    int maxv = -20000000000000000000000;
    int minv = R[0];
    
    for(int i = 1; i < n; i ++) {
        
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
        
    }
    
    cout << maxv << endl;
    
    return 0;
    
}


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

int main(void){
  int H, A, _A;
  int cnt = 0;
  cin >> H >> A;
  while(1){
    cnt++;
    _A = A * cnt;
    if(_A >= H){
      cout << cnt << "\n";
      break;
    }
  }
  return 0;
}


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

int main(){
  long N, M, A;
  cin >> N >> M;
  long day=0;
  for(int i=0; i<M; i++){
    cin >> A;
    day+=A;
  }
  if(N<day){
    cout << "-1" << endl;
    return 0;
  }
  cout << N-day << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];

    ll cnt1 = 0;
    ll cnt2 = 0;
    rep(i, N) {
        if (a[i] < b[i]) {
            cnt2 += (b[i] - a[i]) / 2;
        } else {
            cnt1 += a[i] - b[i];
        }
    }

    if (cnt1 <= cnt2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

long long n, a[100009], ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		ans += 2LL * min(1LL * i + 1LL, n - 1LL - i)*(a[i + 1] - a[i]);
	}
	if (n % 2 == 0) ans -= (a[n / 2] - a[n / 2 - 1]);
	else {
		ans -= min(a[n / 2] - a[n / 2 - 1], a[n / 2 + 1] - a[n / 2]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

  int n, i, j;
  int a[11000];

  while(cin >> n, n){
    for(i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a, a+n);
    int ans = 1000000;
    for(i = 0; i < n-1; i++){
      for(j = i+1; j < n; j++){
        ans = min(ans, a[j]-a[i]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3112