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

int main()
{
    /* ここから */
    int N;
    char S[4];
    int AC=0,WA=0,TLE=0,RE=0;
    int i;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%s",S);
        if(strcmp(S,"AC")==0)
        {
            AC++;
        }
        else if(strcmp(S,"WA")==0)
        {
            WA++;
        }
        else if(strcmp(S,"TLE")==0)
        {
            TLE++;
        }
        else if(strcmp(S,"RE")==0)
        {
            RE++;
        }
    }
    printf("AC x %d\n",AC);
    printf("WA x %d\n",WA);
    printf("TLE x %d\n",TLE);
    printf("RE x %d\n",RE);
    /* ここまで */
    return 0;
}

Measured memory_bytes: 1732
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    if (H == 1 || W == 1)
    {
        writeln(1);
        return;
    }
    long a = (W + 1) / 2;
    long b = W / 2;
    long c = (H + 1) / 2;
    long d = H / 2;
    writeln(a * c + b * d);
}


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

int main(){
	int n;
	cin>>n;
	std::vector<int> v(2*n,0);
	for(int i=0;i<2*n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	int ret=0;
	for(int i=0;i<n;i++){
		ret+=v[2*i];
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main() {  
  int i,j,a,min,temp,count;
  int data[N];

  scanf("%d",&a);
  for(i = 0; i < a; i++) {
    scanf("%d",&data[i]);
  }

  for(i = 0; i < a; i++) {
    min = i;
    for(j = i; j < a; j++) {
      if(data[j] < data[min]) {
	min = j;
      }
    }
    temp = data[i];
    data[i] = data[min];
    data[min] = temp;
    if(i != min) {
      count++;
    }
  }

  for(i = 0; i < a; i++) {
    printf("%d",data[i]);
    if(i != a - 1) {
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}
      
      
	
	
  

  
  



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

int main() {
  int a;
  cin >> a;
  int b;
  cin >> b;
  int c;
  cin >> c;
  if (c - (a - b) < 0) {
    cout << 0 << endl;
  } else {
    cout << c - (a - b) << endl;
  }
}

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

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int M = scan.nextInt();
			 Integer[]A = new Integer[N];
			
			double goukei = 0;
			
			for(int i = 0;i<N;i++) {
				A[i] = scan.nextInt();
				goukei+=A[i];
			}
			
			double koremimanhadame = goukei/(4.0*M);
			int count = 0;
			
			Arrays.sort(A,Collections.reverseOrder());
			
			for(int i = 0;i<N;i++) {
				if(koremimanhadame<=(double)A[i]) {
					count++;
					if(count ==M)break;
				}
			}
			
			System.out.println(count==M?"Yes":"No");
			
			
			
		}
		
		
	}
		

}

Measured memory_bytes: 21588
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

bool test = true;
#define log(x) cout << "#x" << " : " << x << "\n";

int main()
{
    int a;
    cin >> a;
    cout << (a + (a*a) + (a*a*a)) << "\n";
    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define fastio std::ios_base::sync_with_stdio(false), std::cout.tie(0), std::cin.tie(0);
#define N 100007
#define mxx INT_MAX

typedef long long ll;



int arr[107];
int main() {
	int num, k;
	std::cin >> num >> k;
	while (k--) {
		int d, l;
		std::cin >> d;
		for (int x = 0; x < d; x++) {
			std::cin >> l;
			arr[l]++;
		}
		
	}int count = 0;
	for (int x = 1; x <= num; x++) {
		if (arr[x] == 0)count++;
	}
	std::cout << count;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
int main(){
	int c = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size()/2;i++)
		if (s.at(i) != s.at(s.size() - i - 1)){
			c++;
		}
	cout << c << endl;
}

Measured memory_bytes: 256
s = input()
flag = True
while(flag):
    if(len(s)==0):
        flag = False
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:]== 'eraser':
        s = s[:-6]
    elif s[-7:]=='dreamer':
        s = s[:-7]
    else:
        break
if(flag):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 133880
import numpy as np
W, H, N = map(int, input().split())
g = np.zeros((H, W))

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        g[:, :x] = 1
    elif a == 2:
        g[:, x:] = 1
    elif a == 3:
        g[abs(H-y):, :] = 1
    else:
        g[:abs(H-y), :] = 1

print(np.count_nonzero(g == 0))


Measured memory_bytes: 20892
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        if (x1 == 0) System.out.println(1);
        int x2 = sc.nextInt();
        if (x2 == 0) System.out.println(2);
        int x3 = sc.nextInt();
        if (x3 == 0) System.out.println(3);
        int x4 = sc.nextInt();
        if (x4 == 0) System.out.println(4);
        int x5 = sc.nextInt();
        if (x5 == 0) System.out.println(5);

    }
}

Measured memory_bytes: 35748
#include <iostream>
#include<algorithm>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main() {

  ll n,q;
  ll sum = 0;
  cin >> n;
  int a[n];
  REP(i,n){
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a+n);
  ll count = 1;
  ll cons = a[0];
  map<int, int> mp;
  for(ll i=1;i<(ll)(n);i++) {
    if( a[i] == a[i-1]){
      count++;
    } else {
      mp[cons] = count;
      count = 1;
      cons = a[i];
    }
  }
  mp[cons] = count;
  cin >> q;
  ll b,c;
  //記憶用
  REP(i,q){
    cin >> b >> c;
    auto itr = mp.find(b);
    if( itr != mp.end() ) {//検索あるなら
      count = mp[b];
      mp[b] = 0;
      auto itr = mp.find(c);
      if( itr != mp.end() ) {//検索あるなら
        mp[c] += count;
      } else {
        mp[c] = count;
      }
      sum += (c-b) * count;
    } 
    //和を出す
    cout << (ll)sum << endl;
  }

  return 0;
}


Measured memory_bytes: 7876
#include <stdio.h>
int main(void)
{
	char A,B,C,D,E,F,G;
	scanf("%c%c%c%c",&A,&B,&C,&D);
	int a,b,c,d,e,f,g;
	a=A-'0'; b=B-'0'; c=C-'0'; d=D-'0';
	int z=a;
	for(e=1; e<=2; e++){
		for(f=1; f<=2; f++){
			for(g=1; g<=2; g++){
				if(e==1){
					z=z+b; E='+';
				}else{
					z=z-b; E='-';
				}
				if(f==1){
					z=z+c; F='+';
				}else{
					z=z-c; F='-';
				}
				if(g==1){
					z=z+d; G='+';
				}else{
					z=z-d; G='-';
				}
				if(z==7){
					printf("%d%c%d%c%d%c%d=7\n",a,E,b,F,c,G,d);
					return 0;
				}
				z=a;
			}
		}
	}
	return 0;
}

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

int main() {
  int N, n1, n2, n3, n4;
  cin >> N;
  n1 = N /1000;
  n2 = (N - n1 * 1000) / 100;
  n3 = (N - n1 * 1000 - n2 * 100) / 10;
  n4 = (N - n1 * 1000 - n2 * 100 - n3 * 10) / 1;
  if (n1 == n2) {
    if (n1 == n3)
      cout << "Yes" << endl;
    else 
      cout << "No" << endl;
  }
  else if (n2 == n3) {
    if (n2 == n4) 
      cout << "Yes" << endl;
    else 
      cout << "No" << endl;
  }
  else 
    cout << "No" << endl;
}


Measured memory_bytes: 256
ABs = []

N = int(input())
for i in range(N):
    ABs.append(tuple(map(int,input().split())))

ABs = sorted(ABs, key=lambda x: x[1])

sum = 0
for A, B in ABs:
    sum += A
    if sum > B:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 38948
//Created Time:2019年12月19日 星期四 14时49分01秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define N 200005
#define ll long long
#define pb push_back
#define vec vector < state >

using namespace std;

int n, cnt;
int fir[N]; 
struct edge{
	int to, nxt, w;
}e[N << 1];

struct state{
	ll x, y;

	state() {};

	state(ll X, ll Y){x = X, y = Y;}
};

vec s[N];

void add(int ,int, int);
bool check(ll);
void dfs(int ,int ,ll);
void merge(int ,int ,int ,ll);
vec get(int ,int ,ll);

int main(){
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) {
		int v, w; scanf("%d%d", &v, &w);
		add(v, i, w); add(i, v, w);
	}
	ll res = 0, l = 0, r = 2e10;
	while (l <= r) {
		ll mid = (l + r) >> 1;
		if(check(mid)) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << res << endl;
	return 0;
}

void add(int u, int v, int w){
	e[++cnt] = (edge){v, fir[u], w}; fir[u] = cnt;
	return ;
}

bool check(ll mid){
	dfs(1, 0, mid); return s[1].size() > 0;
}

void dfs(int u, int fa, ll mid){
	s[u].clear(); int ch[2], tmp = 0;
	for (int i = fir[u]; i; i = e[i].nxt) {
		int v = e[i].to, w = e[i].w; if(v == fa) continue;
		dfs(v, u, mid); ch[tmp++] = v;
		int sz = s[v].size(); if(!sz) return ;
		for(int j = 0; j < sz; ++j) s[v][j].x += w, s[v][j].y += w;
	}
	if(!tmp) s[u].push_back(state(0, 0));
	else merge(u, ch[0], ch[1], mid);
	return ;
}

void merge(int u, int ls, int rs, ll mid){
	vector < state > s1 = get(ls, rs, mid), s2 = get(rs, ls, mid);
	int sz1 = s1.size(), sz2 = s2.size(), i = 0, j = 0;
	while (i < sz1 && j < sz2) 
		if(s1[i].x < s2[j].x) s[u].pb(s1[i++]);
		else s[u].pb(s2[j++]);
	while (i < sz1) s[u].pb(s1[i++]);
	while (j < sz2) s[u].pb(s2[j++]);
	int sz = s[u].size(); if(!sz) return ;
	for (i = 1, j = 0; i < sz; ++i) {
		if(s[u][i].y >= s[u][j].y) continue;
		else s[u][++j] = s[u][i];
	}
	s[u].resize(j + 1); return ;
}

vec get(int x, int y, ll mid){
	vector < state > tmp;
	int sz1 = s[x].size(), sz2 = s[y].size(); ll mn = 999999999999;
	for (int i = 0, j = 0; i < sz1; ++i) {
		while (j < sz2 && s[x][i].y + s[y][j].x <= mid) mn = min(mn, s[y][j++].y); 
		if(mn == 999999999999 || (tmp.size() && mn == tmp.back().y)) continue;
		tmp.pb(state(s[x][i].x, mn));
	}
	return tmp;
}


Measured memory_bytes: 32504
//incompleter....
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    int a,b,sum,cal;
    while(scanf("%d %c %d",&a,&ch,&b)!=EOF)
    {
        if(ch=='+')
        {
            sum=a+b;
            cout<<sum<<endl;
        }
        else if(ch=='?')
        {
            break;
        }
        else if(ch=='-')
        {
            sum=a-b;
            cout<<sum<<endl;
        }
        else if(ch=='*')
        {
            sum=a*b;
            cout<<sum<<endl;
        }
        else if(ch=='/')
        {
            sum=a/b;
            cout<<sum<<endl;
        }

    }
}



Measured memory_bytes: 3120
def BellmanFord(edges,num_vertex,start):
    inf=float("inf")
    dist=[inf for i in range(num_vertex)]
    dist[start]=0
    for i in range(num_vertex):
        for edge in edges:
            if dist[edge[0]]!=inf and dist[edge[1]]>dist[edge[0]]+edge[2]:
                dist[edge[1]]=dist[edge[0]]+edge[2]
                if i==num_vertex-1 and edge[1]==num_vertex-1:
                    return -1
    return dist

n,m=map(int,input().split())
edges=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    edges.append((a,b,-c))
dist=BellmanFord(edges,n,0)
if dist==-1:
    print("inf")
else:
    print(-dist[-1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back

using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n=s.size();
    reverse(s.begin(), s.end());
    int x=1;
    int tot=0;
    int m=2019;
    vector<int> dp(m);
    ll ans=0;
    for (int i = 0; i < n; ++i)
    {
        dp[tot]++;
        tot+=(s[i]-'0')*x;
        x=(x*10)%m;
        tot%=m;
        ans+=dp[tot];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int n;

void make_irre (vector <ll> & a )
{
	ll g;			// Ååöñ
	vector <ll> pre;
	do{
		pre = a;
		g = a[0];
		for (int i = 1; i < n; i++ )
			g = __gcd (g, a[i] );
		rep (i, n )
			a[i] /= g;
	}while (pre != a );
}

int main()
{
	while (cin >> n && n ){
		vector <ll> d (n, 0LL ), v(n, 0LL );

		rep (i, n )
			cin >> d[i] >> v[i];
		// ùñªÌ
		rep (i, n ){
			ll g = __gcd(d[i], v[i] );	
			v[i] /= g;
			d[i] /= g;
		} // end rep
		// ¬x¯mÌùñ»(?)
		make_irre (v );
		// £¯mÌùñ»(?)
		make_irre (d );
		// ®ä»
		rep (i, n ){
			if (v[i] % d[i] == 0 ){
				v[i] /= d[i];
			}else{
				ll m = d[i];
				rep (j, n )
					if (i != j )
						v[j] *= m;
			} // end if
		} // end rep
		make_irre (v );

		rep (i, n )
			cout << v[i] << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int a = 0;
		int b = 0;
		int ttl = 0;
		
		for (int i=0; i<N; i++){
			a = sc.nextInt();
			b = sc.nextInt();
			ttl = ttl + ((b+1) - a);
		}
		System.out.println(ttl);
		
		
	}
}

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

int main(){
	int h, w, ans = -2000000000; cin>>h>>w;
	vector<string> grid(h);
	vector<vector<int>>  r(h, vector<int>(w, 1)), c(h, vector<int>(w, 1));
	for(int i=0;i<h;++i){
		cin>>grid[i];
		if (grid[i][0]=='#') r[i][0]=0;;
		for (int j=1; j<w; ++j){
			if (grid[i][j]=='.') r[i][j]+=r[i][j-1];
			else r[i][j]=0;
	}	}
	for(int i=0; i<w; ++i) {
		if (grid[0][i]=='#') c[0][i]=0;
		for (int j=1; j<h; ++j){
			if (grid[j][i]=='.') c[j][i]+=c[j-1][i];
			else c[j][i]=0;
	}	}
	for(int i=0;i<h;++i) for (int j=w-2; j>=0; --j) if (r[i][j]){
			if (r[i][j+1]) r[i][j]=r[i][j+1];
	}	
	for(int i=0;i<w;++i) for (int j=h-2; j>=0; --j) if (c[j][i]){
			if (c[j+1][i]) c[j][i]=c[j+1][i];
	}
	
	for(int i=0; i<h; ++i) for (int j=0; j<w; ++j) if (grid[i][j] == '.'){
		ans=max(ans, r[i][j] + c[i][j] -1);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 35712
N = int(input())
s = list(map(int,input().split()))
M = max(s)
count = [0] * (M+1)
for i in range(1,N):
    count[s[i]] += 1
ans = 0

for j in count:
    if j == 0:
        continue
    ans += int(j*(j-1)/2)
print(ans)
for i in range(1,N):
    ans += count[s[i-1]]
    count[s[i-1]] += 1
    count[s[i]] -= 1
    ans -= count[s[i]]
    print(ans)




Measured memory_bytes: 26140
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    string str;
    
    cin>>str;
    for(int i=0;i<str.size();i++){
        if(str[i]!=',')cout<<str[i];
        else cout<<" ";
    }
    cout<<endl;
     
    return 0;
}
 

Measured memory_bytes: 256
#組み合わせ個数
def choose(n, r, mod)
  return 0 if not (0 <= r and r <= n)
  return 1 if r == 0 or r == n
  fact(n, mod) * inverse(fact(r, mod) * fact(n-r, mod) % mod, mod) % mod
end
#階乗(MODあり)
@fact = [1]
def fact(n, mod)
  if n > @fact.size then
    f = @fact[-1]
    (@fact.size+1..n).each{|i|
      f = (f * i) % mod
      @fact << f
    }
  end
  @fact[n-1]
end
#逆元(MODあり)
def inverse(x, mod)
  pow(x, mod-2, mod)
end
#べき乗(MODあり)(繰り返し２乗法)
def pow(x, n, mod)
  ans = 1
  while n > 0
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  ans
end

N, K = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

r = N - K
b = K
imax = [b, r + 1].min
(1..imax).each{|i|
  puts (choose(r + 1, i, MOD) * choose(b - 1, i - 1, MOD) % MOD)
}
(imax + 1..K).each{puts 0} if imax < K


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n , m , c;
    cin>>n>>m>>c;
    int b[m];
    for (int i = 0; i < m; ++i) {
        cin>>b[i];
    }
    int ans = 0;
    for(int i = 0; i < n ; i++){
        int sum = 0;
        for(int j = 0 ; j <m ;j++){
            int k ; cin>>k;
            sum += k * b[j];
        }
        if(sum + c > 0)
            ans++;
    }
    cout<<ans<<endl;
}


int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    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++)

int main() {
  int N;
  cin >> N;
  string x;
  rep(i, N) {
    
    cin >> x;
   
     
    if (x == "Y"){
    cout << "Four" << endl;
    break;
    }
    
    else if (x != "Y"){
    continue;
    
    }
    
  }
  if (x != "Y"){
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B,X;
  cin >> A >> B >>X;
  bool flag =false;
  if(A<=X && A+B >=X) flag =true;
  if(flag)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

fn gcd(a: i64, b: i64) -> i64 {
    let mut x = a;
    let mut y = b;

    if y > x {
        std::mem::swap(&mut x, &mut y);
    }

    loop {
        x = x % y;

        if x == 0 {
            return y;
        }

        std::mem::swap(&mut x, &mut y);
    }
}

#[fastout]
fn main() {
    input! {in_k: i64};
    let mut count: i64 = 0;

    for a in 1..=in_k {
        for b in 1..=in_k {
            let g = gcd(a, b);

            for c in 1..=in_k {
                count += gcd(g, c);
            }
        }
    }

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


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

pair<int, int> points[52][11];
int pointsCount[52];
int n, m;

int r90[] = {
	0, -1,
	1, 0,
};

int lineCheck1(int num)
{
	for (int j = 0; j < pointsCount[0]; j++)
	{
		if (points[0][j].first != points[num][j].first
			|| points[0][j].second != points[num][j].second) return 0;
	}
	return 1;
}

int lineCheck2(int num)
{
	int ofX = points[num][pointsCount[0] - 1].first;
	int ofY = points[num][pointsCount[0] - 1].second;
	for (int j = 0; j < pointsCount[0]; j++)
	{
		if (points[0][j].first != points[num][pointsCount[0] - j - 1].first - ofX
			|| points[0][j].second != points[num][pointsCount[0] - j - 1].second - ofY) return 0;
	}
	return 1;
}

int solve()
{
	int firstNum = 1;
	for (int i = 1; i < n + 1; i++)
	{
		int output = 0;
		if (pointsCount[0] != pointsCount[i]) continue;
		for (int k = 0; k < 4; k++)
		{
			for (int j = 0; j < pointsCount[0]; j++)
			{
				int newX = (-1) * points[i][j].second;
				int newY = points[i][j].first;
				points[i][j].first = newX;
				points[i][j].second = newY;
			}
			if (output) continue;
			if (lineCheck1(i) || lineCheck2(i))
			{
//				if (firstNum) firstNum = 0;
//				else cout << '\n';
				cout << i << endl;;
				output = 1;
				break;
			}
		}
	}
}

int main()
{
	int firstFlg = 1;
	while(1)
	{
		if (firstFlg) firstFlg = 0;
		else cout << "+++++" << endl;
		cin >> n;
		if (n == 0) break;
		
		for (int i = 0; i < n + 1; i++)
		{
			cin >> pointsCount[i];
			pair<int, int> first;
			cin >> first.first >> first.second;
			points[i][0].first = points[i][0].second = 0;
			for (int j = 1; j < pointsCount[i]; j++)
			{
				cin >> points[i][j].first >> points[i][j].second;
				points[i][j].first -= first.first;
				points[i][j].second -= first.second;
			}
		}
		solve();
	}
	return 0;
}

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

int N, A[200005];
map<int,int> cnt;
vector<int> B;

void init(){
  
  int x = 2;
  
  while(1){

    B.push_back( x );
    x *= 2;
    
    if( x > 3e9  ) break;
    
  }
  
}

signed main(){
  
  init();
  
  cin>>N;
  
  for(int i=0;i<N;i++){
    cin>>A[i];
    cnt[A[i]]++;
  }
  
  sort( A, A + N, greater<int>() );
  
  int ans = 0;
  
  for(int i=0;i<N;i++){
    
    if( cnt[A[i]] ){
      
      cnt[A[i]]--;
      
      int k = *upper_bound( B.begin(), B.end(), A[i] ) - A[i];
      
      if( cnt[k] ){
	
	cnt[k]--;
	
	ans++;
	
      }
      
    }
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


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

int main(){
  	int H,W;
	cin >>H>>W;
    
  	vector<vector<int>> dp(1100, vector<int>(1100, 0));
  	vector<vector<char>> a(H, vector<char>(W));
  	for(int i=0;i<H;i++){
     	for(int j=0;j<W;j++){
     	cin>>a[i][j];
        }  
    }
       dp[0][0]=1;
    for(int i=0;i<H;i++){
     	for(int j=0;j<W;j++){
     	   if (i+1 < H && a[i+1][j] == '.') {
             dp[i+1][j]+=dp[i][j];
           	 dp[i+1][j]=dp[i+1][j]%1000000007;
           }
            if (j+1 < W && a[i][j+1] == '.') {
              dp[i][j+1]+= dp[i][j];
              dp[i][j+1]=dp[i][j+1]%1000000007;
            }
        }
    } 
      cout << dp[H-1][W-1] << endl;
      
} 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc148_a() {
	ll A, B;
	cin >> A >> B;

	vector<ll> t(3, 0);
	t[A - 1] = 1;
	t[B - 1] = 1;

	ll ans = 0;
	rep(i, 3) {
		if (t[i] == 0) {
			ans = i + 1;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc148_a();

	return 0;
}

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

const int N = 111;

int a[N];

int sq(int x) {
	return x * x;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str; cin >> str;
	int l = -1, r = -1;
	for(int i = 0; i < str.size() - 1; ++i) {
		if(str[i] == str[i + 1]) {
			l = i + 1;
			r = i + 2;
		}
	}

	for(int i = 0; i + 2 < str.size(); i++) {
		if(str[i] == str[i + 2]) {
			l = i + 1;
			r = i + 3;
		}
	}

	cout << l << " " << r << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
map<ll,ll> ma;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n;  cin >> n;
  vector<double> v(n);
  rep(i,0,n){
    cin >> v[i];
  }
  sort(all(v));
  double ans = v[0];
  rep(i,1,n){
    ans = (ans+v[i])/2;
  }
  printf("%.6f", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

vector<int> G[101010];

 void dfs(int s, vector<int>& dist, int p = -1) {
     for (auto v : G[s]) {
         if (v == p) continue;
         dist[v] = dist[s] + 1;
         dfs(v, dist, s);
     }
}

void solve() {
    int n, v, u;
    cin >> n >> u >> v;
    u--; v--;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dt(n, 0), da(n, 0);
    dfs(u, dt);
    dfs(v, da);
    int ans = 0;
    rep(i, n) {
        if (dt[i] >= da[i]) continue;
        else chmax(ans, da[i] - 1);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 14472
#include <iostream>

int main()
{
    using namespace std;

    int n;
    cin >> n;

    int i = 1;
    while (1)
    {
        int x = i;

        if (x % 3 == 0)
        {
            cout << " " << i;
        }
        else
        {
            while (x)
            {
                if (x % 10 == 3)
                {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }

        if (i++ >= n)
        {
            cout << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3096
def solve():
    n = input()
    ans = 0
    for i in range(2 ** (len(n) - 1)):
        insertcount = 0
        count = 0
        line = list(n)
        j = i
        while j > 0:
            if j & 1 == 1:
                line.insert(1 + count + insertcount, "+")
                insertcount += 1
            count += 1
            j >>= 1
        ans += eval("".join(line))
    print(ans)

if __name__=="__main__":
    solve()


Measured memory_bytes: 3064
// ref. http://tsutaj.hatenablog.com/entry/2017/03/07/173127

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll n;
vector<ll> a;

void solve() {
  // dp[l][r] = dp[l+1][r-1] + 2 if dp[l+1][r-1] == d-2 && abs(a[l]-a[r]) <= 1
  vector<vector<ll>> dp(n, vector<ll>(n));
  vector<vector<ll>> take(n, vector<ll>(n));

  for (ll d = 2; d <= n; ++d) { // dist
    rep(l,n) {
      ll r = l+d-1; // we consider [l,r]
      if (r >= n) { continue; }
      if (dp[l+1][r-1] == d-2 && abs(a[l]-a[r]) <= 1) {
        chmax(dp[l][r], d);
      }
      for (ll k = l; k < r; ++k) {
        chmax(dp[l][r], dp[l][k] + dp[k+1][r]);
      }
    }
  }
  cout << dp[0][n-1] << endl;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  while (true) {
    cin >> n;
    if (n == 0) { break; } // exit
    a.resize(n);
    rep(i,n) {
      cin >> a[i];
    }
    solve();
  }
}



Measured memory_bytes: 4460
s=[]
n=int(input())
for _ in range(n):
    a=input()
    s.append(a)

b=s.count('AC')
c=s.count('WA')
d=s.count('TLE')
e=s.count('RE')

print('AC x '+str(b))
print('WA x '+str(c))
print('TLE x '+str(d))
print('RE x '+str(e))

Measured memory_bytes: 16296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		if(n == 26) {
			for(int i = n - 1 ; i >= 0 ; i--) {
				if(i == 0) {
					System.out.println(-1);
					return;
				}
				if(s.charAt(i - 1) < s.charAt(i)) {
					String temp = s.substring(i);
					char base = s.charAt(i - 1);
					char min = 'z';
					for(int j = 0 ; j < temp.length() ; j++) {
						if(base < temp.charAt(j) && min > temp.charAt(j)) min = temp.charAt(j);
					}
					System.out.println(s.substring(0, i - 1) + min);
					return;
				}
			}
		} else {
			char min = 'z';
			int[] cnt = new int[26];
			for(int i = 0 ; i < s.length() ; i++) {
				cnt[(int)(s.charAt(i) - 'a')]++;
			}
			for(int i = 0 ; i < 26 ; i++) {
				if(cnt[i] == 0) {
					min = (char)(i + 'a');
					break;
				}
			}
			System.out.println(s + min);
		}
	}
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  int c = 0;
  rep(i,0,n) {
    int x; cin>>x;
    if(x%2) c++;
  }
  if(c%2) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

struct Solver {
    memo: std::collections::BTreeMap<u64, u64>,
    abc: [u64; 3],
    d: u64,
}
impl Solver {
    fn new(a: u64, b: u64, c: u64, d: u64) -> Self {
        Self {
            memo: std::collections::BTreeMap::new(),
            abc: [a, b, c],
            d: d,
        }
    }
    fn solve(&mut self, x: u64) -> u64 {
        if x == 0 {
            0
        } else if x == 1 {
            self.d
        } else if let Some(y) = self.memo.get(&x) {
            *y
        } else {
            let mut res = x.saturating_mul(self.d);
            use std::cmp::min;
            let z = [2, 3, 5];
            for i in 0..3 {
                if x % z[i] == 0 {
                    res = min(res, self.solve(x / z[i]) + self.abc[i]);
                } else {
                    let y = (x / z[i]) * z[i];
                    res = min(res, self.solve(y / z[i]) + self.abc[i] + (x - y) * self.d);
                    res = min(
                        res,
                        self.solve(y / z[i] + 1) + self.abc[i] + (y + z[i] - x) * self.d,
                    );
                }
            }
            self.memo.insert(x, res);
            res
        }
    }
}

fn main() {
    input! {
        t: usize,
    }
    for _ in 0..t {
        input! { n: u64, a: u64, b :u64, c: u64, d: u64 }
        let mut solver = Solver::new(a, b, c, d);
        println!("{}", solver.solve(n));
    }
}


Measured memory_bytes: 2504
def makemap(x,y):
    multilist = [[0 for col in range(y)] for row in range(x)]
    return multilist

def drow(X,Y,x,y,a,multilist):
    if a ==1 :
        for i in range(0,x):
            for j in range(0,Y):
                multilist[i][j]=1
    elif a ==2 :
        for i in range(x,X):
            for j in range(0,Y):
                multilist[i][j]=1
         
    elif a ==3 :
        for i in range(0,X):
            for j in range(0,y):
                multilist[i][j]=1
         
    elif a ==4 :
        for i in range(0,X):
            for j in range(y,Y):
                multilist[i][j]=1
    
    return multilist
    

def main():
    X,Y,N = map(int,input().split())
    mapx=makemap(X,Y)
    count = 0
    for k in range(0,N):
        x,y,a = map(int,input().split())
        mapx = drow(X,Y,x,y,a,mapx)
    for i in range(0,X):
        for j in range(0,Y):
            if mapx[i][j]==0:
                count+=1
    print(count)
    
main()


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

long long Ans;
int N, M, i, j, sub, judg[100000],A[100000],B[100000],C[100000];
int main()
{
	cin >> N >> M;
	Ans = (N * 3 + M) / 2;

	cout << Ans;

}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	int s, t, d;
	cin >> s >> t >> d;
	int req_loss = s - t;

	vector<int> inputs;
	int summing = 0;
	int going = 0;
	REP(i, d) {
		int a;
		cin >> a;
		a *= -1LL;
		summing += a;
		going = min(going, summing);
		inputs.push_back(a);
	}
	int ans = 0;
	REP(i, 30LL * d) {
		ans++;
		req_loss -= inputs[i % d];
		if (req_loss <= 0) {
			cout << ans << endl;
			return;
		}
	}
	ll bot = 1e5;
	ll top = -1;
	while (bot - top > 1) {
		ll mid = (top + bot) / 2LL;
		int now_val = req_loss - mid * summing;
		REP(j, d) {
			now_val -= inputs[j];
			if (now_val <= 0) break;
		}
		if (now_val <= 0) {
			bot = mid;
		}
		else {
			top = mid;
		}
	}
	ans += bot * d;
	req_loss -= bot * summing;
	REP(i, 30LL * d) {
		ans++;
		req_loss -= inputs[i % d];
		if (req_loss <= 0) {
			cout << ans << endl;
			return;
		}
	}
	cout << -1 << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <set>
#include <stack>
#include <string>
using namespace std;
typedef long long ll;

void solve() {
    int sum = 0;
    string N;
    cin >> N;
    for (char c : N) {
        sum += (c-'0');
    }
    if (sum % 9 == 0)
        cout << "Yes";
    else 
        cout << "No";
}

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

Measured memory_bytes: 3488
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long n=1,k,num = 7;
	cin>>k;
	while(num%k!=0)
	{
		num=num%k;		
		num = num*10+7;
		n++;				
		if(n>10000000)
		{
			n=-1;
			break;
		}
	}		
	cout<<n;
}

Measured memory_bytes: 3576
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
gap=[h[i]-h[i-1] for i in range(1,n)]
tmp=0
lst=[gap[0]]
for i in range(1,len(gap)):
    lst.append(gap[i]+lst[i-1])
#print(gap,lst)
ans=[lst[k-2]]
for i in range(k,n):
    ans.append(lst[i-1]-lst[i-k])
#print(ans)
print(min(ans))

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

/*n以下の素数の個数を返す*/
void sieve(int n){
    vector<int> prime(n+1);
    rep(i, n+1) is_prime[i]=1;
    int p=0;
    is_prime[0]=0;
    is_prime[1]=0;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++]=i; 
            for(int j=2*i;j<=n;j+=i) is_prime[j]=0;
        }
    }
}

int main(void){
    int q;
    cin>>q;
    is_prime.resize(100004);
    sieve(100005);
    vector<pair<int, int> > v(q);
    rep(i, q){
        int l, r;
        cin>>l>>r;
        v[i]=make_pair(l, r);
    }

    vector<int> is_two_prime(100005);
    int now=0;
    for(int i=0;i<=100003;i++){
        if(i%2!=0){
            if(is_prime[i]&&is_prime[(i+1)/2]) {
                now++;
            }   
        }   
        is_two_prime[i]=now;
    }
    /*rep(i, 20) cout<<is_two_prime[i]<<" ";
    cout<<endl;*/
    rep(i, q){
        int l=v[i].first;
        int r=v[i].second;
        int ans=is_two_prime[r]-is_two_prime[l-1];
        cout<<ans<<endl;
    }
    return 0;
}

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

#define SIZE 200000

void CountingSort(int* A, int* B, int k, int n) {
    int C[10001] = {};
    
    for(int i = 0; i < n; ++i) {
        ++C[A[i]];
    }
    
    for(int i = 1; i <= k; ++i) {
        C[i] += C[i - 1];
    }

    for(int i = 0; i < n; ++i) {
        B[C[A[i]]] = A[i];
        --C[A[i]];
    }
}

int main(void) {
    int n;
    int k = 0;
    
    cin >> n;
    
    int* A = new int [n];
    int* B = new int [n + 1];
    
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
        if(k < A[i]) {
            k = A[i];
        }
    }
    
    CountingSort(A, B, k, n);
    
    cout << B[1];
    for(int i = 2; i <= n; ++i) {
        cout << ' ' << B[i];
    }
    cout << endl;
    
    delete[] A;
    delete[] B;
    
    return 0;
}


Measured memory_bytes: 18364
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0]
for i in range(1, n):
    dp += [min([dp[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)])]
print(dp[-1])

Measured memory_bytes: 20420
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]
sortA = sorted(A, reverse=True)

for i in range(N):
    if A[i] == sortA[0]:
        print(sortA[1])
    else:
        print(sortA[0])

Measured memory_bytes: 96084
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if(a+k-1<b-k+1){
        for(int i=a; i<a+k;i++){
            cout<<i<<endl;
        }
        for(int i=b-k+1;i<b+1;i++){
            cout<<i<<endl;
        }
    }
    else{
        for(int i=a;i<b+1;i++)cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int mmax=0,gcd=0;
	int n,k;
	scanf("%d%d",&n,&k);
	while(n--){
		int x;
		scanf("%d",&x);
		mmax=max(mmax,x);
		gcd=__gcd(gcd,x);
	}
	puts(k<=mmax && k%gcd==0?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;



int main(){
    int N;
    cin >> N;
    if(N <= 999){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl; 
    }
    
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toInt)
    val aMap = mutableMapOf<Int?,Int?>()

    aList.forEach{
        if(aMap.containsKey(it)){
            aMap[it] = aMap[it]?.plus(1)
        }else{
            aMap[it] = 1
        }
    }

    for(i in 1 .. n){
        if(aMap.containsKey(i)){
            println(aMap[i])
        }else{
            println(0)
        }
    }
}

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

int main() {
    int N;
  	cin >> N;
  	int A[N],num[N];
  	for(int i=0;i<N;i++){
    cin >> A[i];
    }
    for(int i=0;i<N;i++){
    num[A[i]-1] = i+1;
    }
  	for(int i=0;i<N;i++){
 	cout << num[i] << ' ';
    }
  	cout << endl;
  	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int T,a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void myout(Object text){//standard output
		System.out.println(text);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      Long a = sc.nextLong();
      Long b = sc.nextLong();
      Long x = sc.nextLong();
      Long output = new Long(0);
      if(a > 0){
        output = ((a - 1) / x + 1);
      }
      
      if(b > 0){
        output = (b / x + 1) - output;
      }else{
        output = new Long(1);
      }
      myout(output);
	}
}


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

#define TRACE(x)
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MOD = 998244353;
int sum(int a, int b) { return (a + b) % MOD; }
int prod(int a, int b) { return a * 1ll * b % MOD; }

int pow2[5000];
int ncr[5000][5001];

// number of combinations if D dice are thrown,
// there are V distinct allowed values, and P
// disjoint pairs of values that cannot both appear
int solve(int D, int V, int P) {
    WATCH(D);
    WATCH(V);
    WATCH(P);

    int ans = 0;
    for (int p = 0; p <= min(P, D); p++) {
        int res = pow2[p];
        res = prod(res, ncr[P][p]);

        int dividers = V - 2 * P + p - 1;
        if (dividers < 0) continue;
        int balls = D - p;
        res = prod(res, ncr[dividers + balls][balls]);
        ans = sum(ans, res);
    }
    return ans;
}

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

    pow2[0] = 1;
    for (int i = 1; i < 5000; i++)
        pow2[i] = prod(2, pow2[i-1]);

    ncr[0][0] = 1;
    for (int n = 1; n < 5000; n++) {
        for (int r = 0; r <= n; r++) {
            ncr[n][r] = ncr[n-1][r];
            if (r) ncr[n][r] = sum(ncr[n][r], ncr[n-1][r-1]);
        }
    }

    int K, N;
    cin >> K >> N;
    for (int i = 2; i <= 2 * K; i++) {
        WATCH(i);

        bool half = false;
        int pairs = 0;
        for (int a = 1; a <= K; a++) {
            int b = i - a;
            if (b < 1 || b > K || b < a) continue;
            if (a == b) half = true;
            else pairs++;
        }

        WATCH(half);
        WATCH(pairs);

        if (half) {
            cout << sum(solve(N, K - 1, pairs),
                        solve(N-1, K - 1, pairs)) << "\n";
        } else cout << solve(N, K, pairs) << "\n";
    }

    return 0;
}



Measured memory_bytes: 96384
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

list = [b-a, c-a, d-a, e-a, c-b, d-b, e-b,
        d-c, e-c, e-d]

if max(list) > k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3060
'''
参考
https://qiita.com/DaikiSuyama/items/ddb4544ee5df2f8d45c7
1～Nをある数で割った余りの合計を最大値にするためには、
2～Nで1～N-1を割ればよい（最後のNは1で割る）
以下の通り、余りは1～Nとなる
1 mod 2 = 1
2 mod 3 = 2
3 mod 4 = 3
…
（N-1) mod N = N-1
N mod 1 = N
https://mathwords.net/1karannowa
1～Nまでの和を求める公式
'''

N = int(input())
ans = N * (N-1) // 2
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;


int main(){
	int	flag=0;
	int c[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c[i][j];
		}
	}
	if(c[0][0]-c[1][0]==c[0][1]-c[1][1]&&c[0][1]-c[1][1]==c[0][2]-c[1][2]){
		flag++;
	}
	if(c[1][0]-c[2][0]==c[1][1]-c[2][1]&&c[1][1]-c[2][1]==c[1][2]-c[2][2]){
		flag++;
	}
	if(c[0][0]-c[0][1]==c[1][0]-c[1][1]&&c[1][0]-c[1][1]==c[2][0]-c[2][1]){
		flag++;
	}
	if(c[0][1]-c[0][2]==c[1][1]-c[1][2]&&c[1][1]-c[1][2]==c[2][1]-c[2][2]){
		flag++;
	}
	if(flag==4){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256