akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//アルメリアさんの写経
signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W; cin >> H >> W;
    string S[400];
    REP(i,H) cin >> S[i];

    bool visited[405][405] = {};
    int dx[] = {-1,1,0,0};
    int dy[] = {0,0,-1,1};

    LL ans = 0;

    REP(i,H) REP(j,W){
        if(visited[i][j]) continue;
        visited[i][j] = true;
        VL num(2,0);
        queue<PII> que;
        que.push({i,j});

        while(que.size()){
            auto p = que.front(); que.pop();
            int x = p.first, y = p.second;
            num[S[x][y] == '#']++;

            REP(k,4){
                int x2 = x + dx[k];
                int y2 = y + dy[k];
                if(0 <= x2 && x2 < H && 0 <= y2 && y2 < W && !visited[x2][y2] && S[x][y] != S[x2][y2]){
                    que.push({x2,y2});
                    visited[x2][y2] = true;
                }
            }
            dump(i)
            dump(j)
            dump(num[0])
            dump(num[1])
        }

        ans += num[0] * num[1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size))
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
 
int inner_rating(int n, int r)
{
	 int x;
	 if(n>=10)
	 {
		 return r;
	 }
	 else
	 {
		 x = 100*(10-n);
		 return r+x;
	 }
 }
int32_t main()
{
	int n,r;
	cin>>n>>r;
	int result;
	result = inner_rating(n,r);
	cout<<result;
	IOS;
	return 0;
}


Measured memory_bytes: 256
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 1e6;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}



void solve()
{
	int n;
	cin>>n;
	
	if(n>=30){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
	
    return;
}
// how r u bro

Measured memory_bytes: 3644
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
s = 0
n = len(bin(max(A))[2:])
for i in range(n):
  b = 1<<i
  N_t = sum([1 for Ai in A if (b&Ai)>0])
  N_f = N-N_t
  s += (1<<i) * N_t * N_f
print(s%MOD)


Measured memory_bytes: 42156
N = int(input())
top_bottom_array = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, N + 1):
    bottom = i % 10
    if bottom == 0:
        continue
    while i >= 10:
        i //= 10
    top = i
    top_bottom_array[top][bottom] += 1

ans = 0

for i in range(1,10):
    for j in range(1,10):
        ans += top_bottom_array[i][j] * top_bottom_array[j][i]

print(ans)

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

int g(int a, int b){
    if(a%b==0)return b;
    else return g(b, a%b);
}

int main(void){
    int n,b;
    cin>>n>>b;
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        b=min(b, g(a, b));
    }
    cout<<b<<endl;
}


Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    int[] a = new int[n];

    double ans = 0;
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      ans += 1 / (double)a[i];
    }
    
    System.out.println(1 / ans);
  }
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll d;
    string s;
    cin>>s>>d;
    ll n=s.length();
    ll dp[n+1][2][d+1];
    ll num;
    
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            num=j?9:(s[i]-'0');
            for(int k=0;k<=num;k++){
                for(int x=0;x<d;x++){
                    dp[i+1][j|(k<num)][(k+x)%d]+=dp[i][j][x]%=mod;
                }
            }
        }
    }
    cout << (dp[n][0][0]+dp[n][1][0]+mod-1)%mod <<endl;
    return 0;

}


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

int main(){
  int N; cin >> N;
  vector<int> b(N), ans;
  for (int i=0; i<N; i++) cin >> b[i];
  while(N>0){
    int befN = N;
    for (int i=N-1; i>=0; i--){
      if (b[i]==i+1){
        ans.push_back(i+1);
        b.erase(b.begin()+i);
        N--;
        break;
      }
    }
    if (N==befN){
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i=ans.size()-1; i>=0; i--){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

#define MAX_N 55556
int prime[MAX_N];

void eras(){
    for(int i=0;i<MAX_N;i++)
        prime[i]=1;
    prime[0]=prime[1]=0;
    for(int i=0;i<MAX_N;i++)
        if(prime[i])
            for(int j=i+i;j<MAX_N;j+=i)
                prime[j]=0;
}

int main(void){
    int N;
    GI(N);
    eras();
    REP(i,MAX_N)
        if(N>0 && prime[i] && i%5==1){
            printf("%d ",i);
            N--;
        }
    printf("\n");
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
using namespace std;
int n;
int e = 1000000;
int u[100000];
int v[100000];
int w[100000];
int s[100000];
vector<int> g[100000];
void dfs(int a, int b) {
	for (int i = 0; i < g[a].size(); i++) {
		if (g[a][i] != b && g[a][i] - e != b) {
			if (g[a][i] < e) {
				s[g[a][i]] = 1 - s[a];
				dfs(g[a][i], a);
			}
			else {
				s[g[a][i] - e] = s[a];
				dfs(g[a][i] - e, a);
			}
		}
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		scanf("%d%d%d", u + i, v + i, w + i);
		u[i]--; v[i]--;
	}
	for (int i = 0; i < n - 1; i++) {
		if (w[i] % 2) {
			g[u[i]].push_back(v[i]);
			g[v[i]].push_back(u[i]);
		}
		else {
			g[u[i]].push_back(v[i] + e);
			g[v[i]].push_back(u[i] + e);
		}
	}
	dfs(0, 0);
	for (int i = 0; i < n; i++) {
		printf("%d\n", s[i]);
	}
}

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

using namespace std;

int main()
{
    int n,a[1005],p,i=0,q=0;
    cin>>n;
    while(n--){
        cin>>p;
       if(p%2==0){
            a[i]=p;
            i++;
       }
    }
    for(int j=0;j<i;j++){
        if(a[j]%3==0 || a[j]%5==0){
            q++;
        }
    }
    if(q==i) cout<<"APPROVED";
    else cout<<"DENIED";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a[3],b;
    for(int i=0;i<3;i++){
    cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]!=a[1]){
    if(a[1]==a[2]) cout<<a[0];
    else cout<<a[1]<<"\n";
    }
    else cout<<a[2];
    cout<<"\n";
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	n++;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<int> mn(n);
	mn.back() = a.back();
	for (int i = n - 2; i >= 0; i--) {
		mn[i] = a[i] + (mn[i + 1]);
	}
	if (n == 1) {
		if (a[0] != 1) {
			cout << -1 << endl;
		} else {
			cout << 1 << endl;
		}
		exit(0);
	}
	if (a[0] != 0) {
		cout << "-1" << endl;
		exit(0);
	}
	int c = 1;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		// if (2 * c < mn[i]) {
		// 	cout << "-1" << endl;
		// 	exit(0);
		// }
		if (min(2 * c, mn[i]) < 0 || min(2 * c, mn[i]) - a[i] < 0) {
			cout << "-1" << endl;
			exit(0);
		}
		ans += min(2 * c, mn[i]);
		c = min(2 * c, mn[i]) - a[i];
		// cerr << c << ' ';
	}
	// cerr << endl;
	cout << ans << endl;
	// int ans = 1;
	// int c = 1;
	// for (int i = 1; i < n; i++) {
	// 	if (2 * c)
	// }
}

Measured memory_bytes: 4576
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  ll a[n+1];rep(i,1,n+1)cin>>a[i];

  bool num[n+1];CLR(num,0);
  ll c=0;
  vector<ll>ans;
  for(ll i=n;i>=1;i--){
    ll count=0;
    for(ll j=2*i;j<=n;j+=i){
      if(num[j])count++;
    }
    if(count%2!=a[i]){
      num[i]=1;
      ans.push_back(i);
      c++;
    }
  }
  if(c==0)out(c);
  else{
    out(c);
    rep(i,0,c){
      cout<<ans[i]<<" ";
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 3828
N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
start = 0
queue = [start]
pre = [None]*N
pre[0] = 0
while queue:
    v = queue.pop(0)
    for i in adj[v]:
        if pre[i] is None:
            pre[i] = v
            queue.append(i)
if None in pre:
    print("No")
else:
    print("Yes")
    for p in pre[1:]:
        print(p+1)

Measured memory_bytes: 34460
#include <bits/stdc++.h>
using namespace std;
int main() {  
  int N , A , B , C , D , E , F , G , H , J , K , L ;
  cin >> N ;

  A = N / 100000000 ;
  B = ( N - A * 100000000  ) / 10000000 ;
  C = ( N - A * 100000000 - B * 10000000 ) / 1000000 ;
  D = ( N - A * 100000000 - B * 10000000 - C * 1000000 ) / 100000 ;
  E = ( N - A * 100000000 - B * 10000000 - C * 1000000 - D * 100000 ) / 10000 ;
  F = ( N - A * 100000000 - B * 10000000 - C * 1000000 - D * 100000 - E * 10000 ) / 1000 ;
  G = ( N - A * 100000000 - B * 10000000 - C * 1000000 - D * 100000 - E * 10000 - F * 1000 ) / 100 ;
  H = ( N - A * 100000000 - B * 10000000 - C * 1000000 - D * 100000 - E * 10000 - F * 1000 - G * 100) / 10 ;
  J = N - A * 100000000 - B * 10000000 - C * 1000000 - D * 100000 - E * 10000 - F * 1000 - G * 100 - H * 10 ;
  K = A + B + C + D + E + F + G + H + J ;


    if ( N % K == 0 ){
      cout << "Yes" << endl;
    }   
    else {
      cout << "No" << endl;
    }  
}

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

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

    auto odds = 0;
    for (auto i = 0; i < N; i++)
    {
        int x; cin >> x;
        odds += x % 2 == 1;
    }

    cout << (odds % 2 == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import itertools
import math

N = int(input())

iter = []
for i in range(N):
    iter.append(i)
    
city = list(itertools.permutations(iter))

x=[0]*N
y =[0]*N

for i in range(N):
    x[i],y[i] = map(int,input().split())
    
sum =0 

for i in (city):
    road = 0
    
    for j in range(N-1):
        road += math.sqrt((x[i[j]] -x[i[j+1]])**2 + (y[i[j]]-y[i[j+1]])**2)

    
    sum += road
    
    
print(sum/len(city))

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

using namespace std;

int main(){
	int N, B[100];
	cin >> N;
	for (int i = 0; i < N-1; i++){
		cin >> B[i];
	}

	int ans = B[0] + B[N - 2];
	for (int i = 1; i < N - 1; i++){
		ans += min(B[i - 1], B[i]);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Accepted return 0;
int A[100010],B[100010];
int two[33];
int shu[100010][33],p[33],q[33];
int main()
{
    int N,K,i,j,k;
    long long ans,res;
    bool flag;
    cin>>N>>K;
    for(i=1;i<=N;i++)
        scanf("%d%d",&A[i],&B[i]);
    two[0]=1;
    for(i=1;i<=30;i++)
        two[i]=two[i-1]*2;
    for(i=1;i<=N;i++)
    {
        for(j=29;j>=0;j--)
        {
            shu[i][j]=A[i]/two[j];
            A[i]%=two[j];
        }
    }
    for(i=29;i>=0;i--)
    {
        p[i]=K/two[i];
        K%=two[i];
    }
    ans=0;
    for(i=1;i<=N;i++)
    {
        flag=true;
        for(j=29;j>=0;j--)
            if (shu[i][j]>p[j]) flag=false;
        if (flag) ans+=B[i];
    }
    for(i=29;i>=0;i--)
    {
        if (p[i]==1)
        {
            for(j=29;j>i;j--)
                q[j]=p[j];
            q[i]=0;
            for(j=i-1;j>=0;j--)
                q[j]=1;
            res=0;
            for(j=1;j<=N;j++)
            {
                flag=true;
                for(k=29;k>=0;k--)
                    if (shu[j][k]>q[k]) flag=false;
                if (flag) res+=B[j];
            }
            ans=max(ans,res);
        }
    }
    cout<<ans<<endl;
    Accepted
}


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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

int get(int x) {
	int ret = 0;
	while (x) {
		ret += (x%10);
		x = x / 10;
	}
	return ret;
}

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

	int n;
	cin >> n;
	int ans = MOD;
	for (int i = 1; i < n; ++i) {
		int a = i;
		int b = n-i;
		ans = min(ans, get(a) + get(b));
	}	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
C = [int(z) for z in input().split()]
centertoover = [0] * N  # それを中段に置くと上段の組み合わせはいくつある？
undertocenter = [0] * N  # それを下段に置くと中段の組み合わせはいくつある？
sort_A = sorted(A)
sort_B = sorted(B)
sum = 0
sum_B = [0]*N
for i in range(N):
    sum += bisect.bisect_left(sort_A, sort_B[i])
    sum_B[i] += sum
ans = 0

for j in range(N):
    index = bisect.bisect_left(sort_B, C[j])
    if index != 0:
        ans += sum_B[index-1]

print(ans)
# print(sum_B)


Measured memory_bytes: 23292
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func strToInts(str string) []int {
	var res []int
	for _, s := range strings.Split(str, " ") {
		n, _ := strconv.Atoi(s)
		res = append(res, n)
	}
	return res
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	line1 := strToInts(readLine(sc))
	a, b := line1[0], line1[1]

	cnt := 0
	for i := 0; i < 2; i++ {
		if a >= b {
			cnt += a
			a--
		} else {
			cnt += b
			b--
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

string ans;
void out(int num){
    if(!num){
        // putchar('0');
        ans += '0';
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        // putchar(buf[i]);
        ans += buf[i];
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        // putchar('\n');
        ans += '\n';
    }
    // cout << ss.str();
    // cout << ans;
    write(1, ans.data(), ans.size());
}


Measured memory_bytes: 1668
#include <stdio.h>
int w,h;//tate yoko
int mem[60][3] = {0};//w b r
int mi = 2501;
char c;
int main()
{
    scanf("%d%d",&w,&h);
    for(int i = 0; i < w; i++)
    {
        for(int j = 0; j < h + 1; j++)
        {
            scanf("%c",&c);
            if(c == 'W')mem[i][0]++;
            else if(c == 'B')mem[i][1]++;
            else if(c == 'R')mem[i][2]++;
        }
    }
    for(int i = 0; i < w; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            mem[i][j] = h - mem[i][j];
        }
    }
    for(int i = 1; i < w - 1; i++)
    {
        for(int j = i + 1; j < w; j++)
        {
            int sum = 0;
            for(int k = 0; k < i; k++)
            {
                sum += mem[k][0];
            }
            for(int l = i; l < j; l++)
            {
                sum += mem[l][1];
            }
            for(int m = j; m < w; m++)
            {
                sum += mem[m][2];
            }
            if(mi > sum)mi = sum;
        }
    }
    printf("%d\n",mi);
}

Measured memory_bytes: 1028
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

#[fastout]
fn main() {
    input! {
    n: usize,
    m: usize,
    h: [usize; n],
    abs: [[usize; 2]; m],
    }
    let mut isgood = vec![true; n];
    for ab in abs{
        let a = ab[0] - 1;
        let b = ab[1] - 1;
        if h[a] > h[b] {
            isgood[b] = false;
        } else if h[a] == h[b] {
            isgood[a] = false;
            isgood[b] = false;
        } else {
            isgood[a] = false;
        }
    }
    let ans = isgood.iter().filter(|&&x| x).count();
    println!("{}", ans);
}


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

int main(){
    double a, b;
    cin >> a >> b;
    int h, m;
    cin >> h >> m;

    int time = h*60+m;
    double a_k = time%60*6;
    double b_k = ((double)time)*(0.5);

    double ans = sqrt(a*a + b*b - 2*a*b*cos((a_k-b_k)/360.0*2.0*3.14159265358979));
    printf("%.10f", ans);
}

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

int main() {
    long long n,d;
    cin>>n>>d;
    long long x,y;
    double z;
    int count=0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        x = pow(x,2);
        y = pow(y,2);
        z = sqrt(x+y);
        if(z<=d){
            count+=1;
        }
        x=0;
        y=0;
        z=0;
        
    }
    cout<<count<<endl;
        

    
    
        
        
    return 0;
    
    
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll n, m;
    cin >> n >> m;
    vector<pll> v(n);
    ll a, b;
    for (int i = 0; i < n; i++) {cin >> a >> b; v[i] = pll(a, b);}
    sort(v.begin(), v.end());
    ll total = 0;
    for (int i = 0; i < n; i++) {
        int cnt = min(m, v[i].second);
        m = max(0LL, m - v[i].second);
        total += cnt * v[i].first;
    }
    cout << total << '\n';
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int x, y;
    ll a, b, c;
    cin >> a >> b >> c >> x >> y;
    c *= 2;
    c = min(c, a+b);
    ll ans;
    if(x > y) {
        ans = y * c;
        x -= y;
    } else {
        ans = x * c;
        x = y-x;
        a = b;
    }


    ans += x * min(a, c);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    cin>>a>>b>>c;

    r = (b/c)-((a)/c);

    if(a%c == 0){
        r++;

        cout<<r<<endl;

    }else{
        cout<<r<<endl;
    }




    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
      	boolean d;
      
      	if((a+b) == c || (b+c) == a || (c+a) == b) d = true;
		else d = false;

		if(d) System.out.println("Yes");
      	else System.out.println("No");
	}
}

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

int main()
{
    int x, y;
    cin >> x >> y;

    rep(i, x+1) {
        int tatol = i;
        int toki = x - i;

        if ((tatol * 4) + (toki * 2) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
set <string> ans;
string Str,str;
bool cal(string a){
  bool alph[300]={};
  alph['a']=1;
  for(int i=0;i<a.size();i++){
    if(!alph[a[i]])alph[a[i]]=1,a[i]--;
    if(a[i]!=Str[i])return 0;
  }
  return 1;
}

bool used[300];
void saiki(int idx){
  while(used[str[idx]]||str[idx]=='z')idx++;
  if(idx==(int)str.size()&&cal(str))ans.insert(str);
  if(idx==str.size())return;
  saiki(idx+1);

  str[idx]++;
  used[str[idx]-1]=1;
  saiki(idx+1);
  used[str[idx]-1]=0;
  str[idx]--;
}

int main(){
  while(1){
  cin>>Str;
  str=Str;
  if(Str=="#")break;
  ans.clear();
  saiki(0);
  cout <<ans.size()<<endl;
  set <string>:: iterator it=ans.begin();

  int cnt=0;
  if(ans.size()<=10){
    while(it!=ans.end())cout <<*it<<endl,it++,cnt++;
  }
  else {
    while(cnt!=5) cout << *it<<endl,it++,cnt++;
    it=ans.end();
    while(cnt--)it--;
    while(it!=ans.end())cout << *it<<endl,it++;
  }
 

  
  }
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define INF 1e+9
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int N;
    cin >> N;
    bool p[N];
    int temp;
    for(int i = 0; i < N; i++){
        cin >>  temp;
        if(--temp == i) p[i] = true;
        else p[i] = false;
    }

    int res = 0;
    for(int i = 0; i < N - 1; i++){
        if(p[i] == true and p[i+1] == true){
            res++;
            p[i] = p[i+1] = false;
        }
    }

    for(int i = 0; i < N; i++){
        if(p[i] == true) res++;
    }

    cout << res << '\n';
    return 0;
}

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

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
typedef pair<int,int> pii;
int h,w;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp[55][55][4];
vector<string> v;
bool check(int a,int b){
    if(0<=a&&a<h&&0<=b&&b<w) return true;
    return false;
}
int foo(int a,int b,int c){
    if(!check(a,b)) return 0;
    if(dp[a][b][c]>=0) return dp[a][b][c];
    dp[a][b][c]=0;
    int ret=0;
    if(v[a][b]=='G'){
        return dp[a][b][c]=1;
    }
    rep(k,4){
        int cc=(c-1+k+4)%4;
        if(v[a+dy[cc]][b+dx[cc]]!='#'){
            ret=foo(a+dy[cc],b+dx[cc],cc);
            break;
        }    
    }
    return dp[a][b][c]=ret;
}   

int main(){
    cin>>h>>w;
    v=vector<string>(h+2);
    rep(i,h) cin>>v[i+1];
    v[0]=v[h+1]=string(w+2,'#');
    reep(i,1,h+1){
        v[i]="#"+v[i]+"#";
    }
    h+=2;
    w+=2;
    char y[]="<^>v";
    pii pos;
    int vec;
    rep(i,h){
        rep(j,w){
            rep(k,4) if(v[i][j]==y[k]) pos=pii(i,j),vec=3-k,v[i][j]='.';
        }
    }
    rep(i,55) rep(j,55) rep(k,4) dp[i][j][k]=-1;
    foo(pos.first,pos.second,vec);
    set<pii> se;
    pii gg;
    rep(i,55){
        rep(j,55){
            if(check(i,j)&&v[i][j]=='G') gg=pii(i,j);
            rep(k,4){
                if(dp[i][j][k]==1) se.insert(pii(i,j));
            }
        }
    }
    if(se.find(gg)==se.end()) cout<<-1<<endl;
    else cout<<se.size()<<endl;
}

Measured memory_bytes: 1616
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const long double EPS = 1e-9;
static const long double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

#include <complex>

typedef complex<long double> Point;
typedef vector<Point> Polygon;

static const long double INF = 1e+10;

#define CURR(P, i) (P[i])
#define NEXT(P, i) (P[(i + 1) % P.size()])

struct Line : public vector<Point> {
  Line() {;}
  Line(Point a, Point b) { push_back(a); push_back(b); }
};

namespace std {
  bool operator<(const Point &lhs, const Point &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
  }
}

inline long double cross(const Point &a, const Point &b) {
  return imag(conj(a) * b);
}

inline long double dot(const Point &a, const Point &b) {
  return real(conj(a) * b);
}

inline int ccw(Point a, Point b, Point c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) { return 1; }
  if (cross(b, c) < 0) { return -1; }
  if (dot(b, c) < 0) { return 2; }
  if (norm(b) < norm(c)) { return -2; }
  return 0;
}


Point crosspointSS(const Line &l, const Line &m) {
  long double A = cross(l[1] - l[0], m[1] - m[0]);
  long double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) {
    assert(false);
    return m[0];
  }
  if (abs(A) < EPS) { assert(false); }
  return m[0] + B / A * (m[1] - m[0]);
}

Polygon ConvexCut(const Polygon &P, const Line &l) {
  Polygon Q;
  for (int i = 0; i < (int)P.size(); i++) {
    Point A = CURR(P, i), B = NEXT(P, i);
    if (ccw(l[0], l[1], A) != -1) { Q.push_back(A); }
    if (ccw(l[0], l[1], A) * ccw(l[0], l[1], B) < 0) {
      Q.push_back(crosspointSS(Line(A, B), l));
    }
  }
  return Q;
}

long double Area(const Polygon &p) {
  long double ret = 0.0;
  REP(i, p.size()) {
    ret += cross(CURR(p, i), NEXT(p, i));
  }
  return ret / 2.0;
}

int n;
Polygon poly;

long double CutArea(long double theta) {
  Point vect = Point(cos(theta), sin(theta));
  Line l = Line(vect * -1000.0L, vect * 1000.0L);
  Polygon ps = ConvexCut(poly, l);
  return Area(ps);
}

int main() {
  while (scanf("%d", &n), n) {
    poly.clear();
    REP(i, n) {
      long double x, y;
      scanf("%Lf %Lf", &x, &y);
      poly.push_back(Point(x, y));
    }
    long double all = Area(poly);
    long double left = 0.0;
    long double right = PI;
    bool s = (CutArea(left) < all / 2.0);
    REP(iter, 200) {
      long double mid = (left + right) / 2.0;
      if ((CutArea(mid) < all / 2.0) == s) {
        left = mid;
      } else {
        right = mid;
      }
    }
    printf("%.16Lf %.16Lf\n", 10 * cos(left) + 1e-17, 10 * sin(left) + 1e-17);
  }
}

Measured memory_bytes: 1004
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d%d",&a,&b);
  int i;
  for(i=0;i<=a;i++){
    if((i*2+(a-i)*4)==b){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

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

pair<bool, int> square(string s, int i);

pair<bool, int> rounded(string s, int i){
    pair<bool, int> ret;
    for(;i<s.length();++i){
        if(s[i] == '['){
            ret = square(s, i+1);
            i = ret.second;
            if(ret.first == false)return ret;
        }else if(s[i] == ']'){
            return (pair<bool, int>){false, i};
        }else if(s[i] == ')'){
            return (pair<bool, int>){true, i};
        }else if(s[i] == '('){
            ret = rounded(s, i+1);
            i = ret.second;
            if(ret.first == false)return ret;
        }
    }
    return (pair<bool, int>){false, i};
}

pair<bool, int> square(string s, int i){
    pair<bool, int> ret;
    for(;i<s.length();++i){
        if(s[i] == '('){
            ret = rounded(s, i+1);
            i = ret.second;
            if(ret.first == false)return ret;
        }
        else if(s[i] == ')'){
            return (pair<bool, int>){false, i};
        }else if(s[i] == ']'){
            return (pair<bool, int>){true, i};
        }else if(s[i] == '['){
            ret = square(s, i+1);
            i = ret.second;
            if(ret.first == false)return ret;
        }
    }
    return (pair<bool, int>){false, i};
}

int main(){
    string s;
    while(getline(cin,s), s[0] != '.'){
        bool flag = false;
        pair<bool, int> ret = pair<bool, int>{true, 0};
        for(int i=0;i<s.length();++i){
            if(s[i] == '('){
                ret = rounded(s, i+1);
                if(ret.first == false){
                    flag = true;
                    printf("no\n");
                    break;
                }
                i = ret.second;
            }else if(s[i] == '['){
                ret = square(s, i+1);
                if(ret.first == false){
                    flag = true;
                    printf("no\n");
                    break;
                }
                i = ret.second;
            }else if(s[i] == ')' || s[i] == ']'){
                printf("no\n");
                flag = true;
                break;
            }
        }
        if(flag == false && ret.first == true)printf("yes\n");
        else if(flag == false)printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 3220
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var res = "";
        while (num != 0)
            if (num % 2 != 0)
            {
                res = "1" + res;
                num = (num - 1) / -2;
            }
            else
            {
                res = "0" + res;
                num /= -2;
            }
        WriteLine(res==""?"0":res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Info{
	Info(int arg_node_id,int arg_step,int arg_sum_dist){
		node_id = arg_node_id;
		step = arg_step;
		sum_dist = arg_sum_dist;
	}
	bool operator<(const struct Info &arg) const{

		return sum_dist > arg.sum_dist; //総距離の降順(PQ)
	}

	int node_id,step,sum_dist;
};


int N,M;
int min_dist[SIZE][4];
int start,goal;
vector<int> G[SIZE];


int main(){

	scanf("%d %d",&N,&M);

	int from,to;

	for(int i = 0; i < M; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		G[from].push_back(to);
	}

	scanf("%d %d",&start,&goal);
	start--;
	goal--;

	for(int i = 0; i < N; i++){
		for(int k = 1; k <= 3; k++){

			min_dist[i][k] = BIG_NUM;
		}
	}

	priority_queue<Info> Q;
	min_dist[start][3] = 0;

	Q.push(Info(start,3,0));

	while(!Q.empty()){

		if(Q.top().sum_dist > min_dist[Q.top().node_id][Q.top().step]){

			Q.pop();

		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next = G[Q.top().node_id][i];
				int next_step = Q.top().step+1;
				int next_dist = Q.top().sum_dist;

				if(next_step == 4){

					next_step = 1;
					next_dist++;
				}

				if(min_dist[next][next_step] > next_dist){

					min_dist[next][next_step] = next_dist;
					Q.push(Info(next,next_step,next_dist));
				}
			}

			Q.pop();
		}
	}

	if(min_dist[goal][3] == BIG_NUM){

		printf("-1\n");

	}else{

		printf("%d\n",min_dist[goal][3]);
	}

	return 0;
}


Measured memory_bytes: 7296
#include<stdio.h>
#include<algorithm>
using namespace std;

typedef long long lld;

struct edg {
	int s, e; lld v;
	bool operator< (const edg& c) const {
		return v<c.v;
	}
} edgs[303030];

int N, xs[101010], ys[101010], ecn;
int xix[101010], yix[101010];
int par[101010]; lld sum;

bool cmp1(const int &x, const int &y){ return xs[x] < xs[y]; }
bool cmp2(const int &x, const int &y){ return ys[x] < ys[y]; }

int root(int ix){
	if(par[ix]<0) return ix;
	return par[ix]=root(par[ix]);
}

int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++) scanf("%d%d", &xs[i], &ys[i]), xix[i]=yix[i]=i;
	sort(xix, xix+N, cmp1);
	sort(yix, yix+N, cmp2);
	for(int i=1; i<N; i++){
		edgs[ecn].s = xix[i-1], edgs[ecn].e = xix[i];
		edgs[ecn++].v = xs[xix[i]]-xs[xix[i-1]];
	}
	for(int i=1; i<N; i++){
		edgs[ecn].s = yix[i-1], edgs[ecn].e = yix[i];
		edgs[ecn++].v = ys[yix[i]]-ys[yix[i-1]];
	}
	sort(edgs, edgs+ecn);

	for(int i=0; i<N; i++)par[i]=-1;
	for(int i=0; i<ecn; i++){
		int s=edgs[i].s, e=edgs[i].e;
		s=root(s), e=root(e);
		if(s==e)continue;
		sum += edgs[i].v;
		par[s]=e;
	}
	printf("%lld", sum);
	return 0;
}


Measured memory_bytes: 6400
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define MAXN 205
struct node{
	int a,b;
}c[MAXN];
int Abs(int x)
{
	if(x>0) return x;
	return -x;
}
bool cmp(node p,node q)
{
	return p.a<q.a;
}
int main()
{
	int n,l,ans=0;
    scanf("%d %d",&n,&l);
	for(int i=1;i<=n;i++)
	{
		c[i].a=Abs(l+i-1);
		c[i].b=l+i-1;
		ans+=l+i-1;
	}
	sort(c+1,c+n+1,cmp);
	ans-=c[1].b;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int i, j, max, min, sum = 0, n = 1, test[1000][5] = {0};
	while (1) {
		max = -10000;
		min = 10000;
		scanf("%d", &n);
		if (n == 0)break;
		sum = 0;
		for (i = 0; i < n; i++) {
			sum = 0;
			for (j = 0; j < 5; j++) { scanf("%d", &test[i][j]); sum += test[i][j]; }
			if (min >= sum)min = sum;
			if (max <= sum)max = sum;
		}
		printf("%d %d\n", max, min);
		for (i = 0; i < n; i++) {
			for (j = 0; j < 5; j++) { test[i][j] = 0; }
		}
	}
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  while(getline(cin,s)){
    double w;
    vector<double> v;
    stringstream ss(s);
    ss>>w;
    double t;
    while(ss>>t) v.push_back(t);
    int n=v.size();
    double dp[1<<n][n],inf=1<<25;
    for(int i=0;i<(1<<n);i++)
      for(int j=0;j<n;j++)
	dp[i][j]=inf;
    for(int i=0;i<n;i++) dp[1<<i][i]=v[i];
    for(int i=1;i<(1<<n);i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)
	  if(((i>>j)&1)&&!((i>>k)&1)) 
	    dp[i+(1<<k)][k]=min(dp[i+(1<<k)][k],
				dp[i][j]+sqrt((v[j]+v[k])*(v[j]+v[k])-(v[j]-v[k])*(v[j]-v[k])));
    bool f=v.size()==0;
    for(int i=0;i<n;i++) f|=dp[(1<<n)-1][i]+v[i]<=w+1e-7;
    cout<<(f?"OK":"NA")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3584
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int numbers[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        System.out.println(numbers[num-1]);
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using IVN=System.Int64;
class abc167_b{
  public static void Main(){
    String[] s = Console.ReadLine().Split(' ');
    IVN a = IVN.Parse(s[0]);
    IVN b = IVN.Parse(s[1]);
    IVN c = IVN.Parse(s[2]);
    IVN k = IVN.Parse(s[3]);
    IVN ans = 0;
    if(a > k){
      ans += k;
    }
    else{
      ans += a;
      k -= a;
      if(k > 0){
        k -= b;
        if(k > 0){
          ans -= k;
        }
      }
    }
    Console.WriteLine(ans);
  }
}


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

const int MAX_NUM = 1000000;

int main(){
	bool list[MAX_NUM + 1] = {0};
	
	for(int two = 0;two <= 20;two++){
		for(int three = 0;three <= 13;three++){
			for(int five = 0;five <= 9;five++){
				int num = pow(2, two) * pow(3, three) * pow(5, five);
				if(1 <= num && num <= MAX_NUM) list[num] = true;
			}
		}
	}
	int m, n;
	while(1){
		cin >> m;
		if(m == 0) break;
		cin >> n;
		int ans = 0;
		for(int i = m;i <= n;i++){
			if(list[i]) ans++;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll x=a[0];
    for(int i=1;i<n;i++)x^=a[i];
    for(int i=0;i<n;i++){
        cout<<(x^a[i])<<"\n";
    }
}


Measured memory_bytes: 5144
#include<iostream>

using namespace std;

int main()
{
  int x,y;
  while(1){
  cin>>x>>y;
  if(x==0 && y==0)
    break;
  else if(x>y)
    cout<<y<<" "<<x<<endl;
  else
    cout<<x<<" "<<y<<endl;
  }
  return 0;
}


Measured memory_bytes: 3004
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=100005;
struct node{int x,y,next;}a[MAXN];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
int ru[MAXN],n,m,fa[MAXN];
queue<int> li;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n-1+m;i++)
	{
		int x=read(),y=read();
		ins(x,y);ru[y]++;
	}
	for(int i=1;i<=n;i++)if(!ru[i])li.push(i);
	while(!li.empty())
	{
		int x=li.front();li.pop();
		for(int k=last[x];k;k=a[k].next)
		{
			int y=a[k].y;
			ru[y]--;if(!ru[y]){fa[y]=x;li.push(y);}
		}
	}
	for(int i=1;i<=n;i++)pr2(fa[i]);
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

class UnionFind{
    vector<ll> par; vector<ll> r_size;
    public:
        UnionFind(ll N) : par(N),r_size(N){
            for(int i=0; i<N; ++i){ par[i] = i; r_size[i] = 1;}
        }

        //Nの大きさで初期化
        void init(ll N){
            par.resize(N); r_size.resize(N);
            for(int i=0; i<N; ++i){ par[i] = i; r_size[i] = 1;}
        }

        ll find(ll x){
            if(par[x] == x)return x;
            return par[x]=find(par[x]);
        }

        //xとyとが所属する集合を併呑する
        void unite(ll x,ll y){
            ll rx = find(x); ll ry = find(y);
            if(rx == ry) return;
            if(r_size[rx]<r_size[ry]) swap(rx,ry);
            r_size[rx] += r_size[ry];
            par[ry] = rx;
        }

        bool same(ll x, ll y){
            ll ry = find(x); ll rx = find(y);
            return rx == ry;
        }

        //素集合の大きさを返す
        ll el_size(ll x){
            return r_size[find(x)];
        }
};

bool compare_second(const ip& ip1, const ip& ip2){
    return ip1.second <ip2.second;
}

int main(){
    int n,m,x,y,t; cin>>n>>m;
    vector<ip> p(n); rep(i,n){cin>>t; p[i].first = i; p[i].second = --t;}
    vector<ip> pairs(m); rep(i,m){ cin>>x>>y; pairs[i].first = --x; pairs[i].second = --y;}

    vector<ip> ele(n); ele = p;
    sort(ele.begin(),ele.end(),compare_second);

    UnionFind uf(n);
    rep(i,m)uf.unite(pairs[i].first,pairs[i].second);
    int ans = 0;
    rep(i,n){
        if(p[i].second == i)++ans;
        else if(uf.same(p[i].first, p[ele[i].first].first))++ans;
    }
    cout<<ans <<endl; return 0;
}


Measured memory_bytes: 4224
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ni() (val int) {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return val
}

var root []int

func find(i int) int {
	if root[i] != i {
		root[i] = find(root[i])
	}
	return root[i]
}

func unite(i, j int) {
	i = find(i)
	j = find(j)
	if i == j {
		return
	}
	root[j] = i
}

func same(i, j int) bool {
	return find(i) == find(j)
}

func main() {
	sc.Split(bufio.ScanWords)

	n := ni()
	m := ni()

	root = make([]int, n+m)
	for i := 0; i < n+m; i++ {
		root[i] = i
	}
	for i := 0; i < n; i++ {
		k := ni()
		for j := 0; j < k; j++ {
			l := ni()
			unite(i, n+l-1)
		}
	}
	ok := true
	for i := 0; i < n; i++ {
		if same(0, i) == false {
			ok = false
		}
	}
	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 9984