akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    bool ok = false;
    int cnt = 0;
    for (int i = 0;i < n;i++){
        int a, b;
        cin >> a >> b;
        if (a == b){
            cnt++;
            if (cnt == 3){
                ok = true;
            }
        }
        else {
            cnt  = 0;
        }
    }

    if (ok ){
        cout << "Yes" << endl;
    }
    else {
        cout <<"No" << endl;
    }

}

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

int main()
{
    int input_01[255];
    int input_02[255];
    int input_id = 0;
    while(1) {
        cin >> input_01[input_id] >> input_02[input_id];
        if(input_01[input_id] == 0 && input_02[input_id] == 0) break;
        input_id++;
    }

    int draw_id = 0;
    while(draw_id < input_id) {
        for(int i = 0; i < input_01[draw_id]; i++) {
            for(int j = 0; j < input_02[draw_id]; j++) {
                if(i == 0 || i == input_01[draw_id]-1) cout << "#";
                else if(j == 0 || j == input_02[draw_id]-1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        draw_id++;
    }

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    char c1 = s.at(0);
    if(s.at(0)==s.at(1)&&s.at(0)==s.at(2)&&s.at(0)==s.at(3)){
        cout << "No" << endl; return 0;
    }
    if(c1==s.at(1)){
        if(s.at(2)==s.at(3)){
            cout << "Yes" << endl; return 0;
        }else{
            cout << "No" << endl; return 0;            
        }
    }else{
        if(c1==s.at(2)){
            if(s.at(1)==s.at(3)){
            cout << "Yes" << endl; return 0;
            }else{
            cout << "No" << endl; return 0;
            }
        }else if(c1==s.at(3)){
            if(s.at(1)==s.at(2)){
            cout << "Yes" << endl; return 0;
            }else{
            cout << "No" << endl; return 0;
            }
        }
    }

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

}


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

using namespace std;


void solve() {
    int m,n;
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        m-=x;
    }
    cout << (m<0?-1:m);
}

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


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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	bool cup[3]={};
	cup[0]=true;
	char a,b;char ch;
	while(cin>>a>>ch>>b){
		swap(cup[a-'A'],cup[b-'A']);
	}
	rep(i,3){
		if(cup[i]){
			cout<<(char)('A'+i)<<endl;
			break;
		}
	}
}

Measured memory_bytes: 1132
$cnt = 0
$g = []
 
def i_sort(ca, n)
  c = ca.dup
  n.upto(c.size - 1) do |i|
    v = c[i]
    j = i - n
    while j >= 0 && c[j] > v
      c[j+n] = c[j]
      j -= n
      $cnt += 1
    end
    c[j+n] = v
  end
  c
end
 
def shell_sort(ca)
  m = 1
  n = ca.size / 9
  while m <= n
    m = m * 3 + 1
  end
  while m > 0
    ca = i_sort(ca, m)
    $g << m
    m /= 3
  end
  ca
end
 
gets
arr = shell_sort($<.read.split("\n").map &:to_i)
puts format("%d\n%s\n", $g.size, $g.join(' '))
puts $cnt
puts arr

Measured memory_bytes: 147232
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    char pos = 'A';
    string s;
    while(cin >> s) {
        if(pos == s[0])
            pos = s[2];
        else if (pos == s[2])
            pos = s[0];
    }

    cout << pos << endl;

    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

char s[105];

int main()
{
    int i,n,k;
    ///freopen(".in","r",stdin);
    ///freopen(".out","w",stdout);
    scanf("%d\n%s\n%d",&n,s+1,&k);
    for(i=1; i<=n; i++)
        if(s[i]!=s[k])
            printf("*");
        else
            putchar(s[k]);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q), B(N,0);
  for (int i = 0; i < Q; ++i) {
    cin >> A.at(i);
    --A.at(i);
    B.at(A.at(i))++; 
  }

  for (int i = 0; i < N; ++i) {
    B.at(i) += K - Q;
    if (B.at(i) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
// 愚直DFSでいけんの？ -> どう考えても駄目です
// 解説観て実装しただけなので理解がカスです あとでやれたらやります

package main

import "fmt"

func main() {
	var N, X, Y int
	fmt.Scan(&N, &X, &Y)
	ANS := make(map[int]int)
	for i := 1; i <= N; i++ {
		for j := i; j <= N; j++ {
			tmp := min(abs(i-j), min(abs(X-i)+abs(Y-j)+1, abs(X-j)+abs(Y-i)+1))
			ANS[tmp]++
		}
	}
	for i := 1; i < N; i++ {
		fmt.Println(ANS[i])
	}
}

func abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

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


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 6000;
const ll mod = 1e9 + 7;
ll dp[maxn][maxn];

ll qpow(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1; 
    }
    return res;
}

ll inv(ll a) {
    return qpow(a, mod - 2);
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int len = s.length();
    dp[0][0] = 1;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] = ((2 * dp[i][j]) % mod + dp[i + 1][j + 1]) % mod;
            dp[i + 1][max(j - 1, 0)] = (dp[i][j] + dp[i + 1][max(j - 1, 0)]) % mod; 
        }
    }
    ll ans = (dp[n][len] * qpow( qpow(2, len), mod - 2) ) % mod;
    cout << ans;
}


Measured memory_bytes: 233984
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int d[N];
  for(int i = 0; i < N; i++) cin >> d[i];
  int M;
  cin >> M;
  int t[M];
  for(int i = 0; i < M; i++) cin >> t[i];

  sort(d, d + N);
  sort(t, t + M);
  int id = 0;
  int it = 0;

  while(true){
    if(d[id] == t[it]){
      id++;
      it++;
    }
    else if(d[id] > t[it]){
      cout << "NO" << endl;
      return 0;
    }
    else{
      id++;
    }

    if(it == M){
      cout << "YES" << endl;
      return 0;
    }
    if(id == N){
      cout << "NO" << endl;
      return 0;
    }
  }

}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

lli n;

vector< lli > d;

void divisors(lli k)
{
	d.clear();

	for(lli i = 1 ; i*i <= k ; i++)
	{
		if( k%i == 0 )
		{
			if( i != 1 ) d.push_back( i );
			if( i*i != k ) d.push_back( k/i );
		}
	}
}

int main()
{
	scanf("%lld",&n);

	divisors( n - 1 );
	lli ans = d.size();

	divisors( n );

	for(int j = 0 ; j < d.size() ; j++)
	{
		lli curD = d[j];

		lli aux = n;

		while( aux%curD == 0 )
			aux /= curD;

		if( aux%curD == 1 ) ans++;
	}

	printf("%lld\n",ans);
}

Measured memory_bytes: 384
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int H = Integer.parseInt(scanner.next());
        int A = Integer.parseInt(scanner.next());
        int ans = H / A + (H % A == 0 ? 0 : 1);
        System.out.println(ans);
    }

}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  priority_queue<int> A;
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    
    A.push(a);
  }
  
  for (int i = 0; i < M; i++){
    int tar = A.top();
    tar /= 2;
    A.pop();
    A.push(tar);
  }
  
  long long int ans = 0;
  while (!A.empty()){
    ans += A.top();
    A.pop();
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3880
#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;
  vector<int>a(n);
  int ad=1;
  rep(i,n){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0)
         ad=0;
    }
   }
  if(ad==0)
    cout<<"DENIED"<<endl;
  else
    cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
string s;
llint sum[3][4005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	s = "#" + s;
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'R') s[i] = '0';
		if(s[i] == 'G') s[i] = '1';
		if(s[i] == 'B') s[i] = '2';
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 3; j++) sum[j][i] = sum[j][i-1];
		sum[s[i]-'0'][i]++;
	}
	
	for(int i = 1; i <= n; i++){
		llint c = s[i]-'0';
		ans += sum[(c+1)%3][i-1] * (sum[(c+2)%3][n] - sum[(c+2)%3][i]);
		ans += sum[(c+2)%3][i-1] * (sum[(c+1)%3][n] - sum[(c+1)%3][i]);
		for(int j = 1; j <= n; j++){
			if(i-j <= 0 || i+j > n) break;
			if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) ans--;
		}
	}
	cout << ans << endl;
	
	
	return 0;
}

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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;


int main() {
  int1(n);
  str(s);
  int mk=0;
  repi(n){
    int left[27];
    int right[27];
    for(int m=0;m<27;m++){
      left[m]=0;
      right[m]=0;
    }
    int kaburi=0;
    for (int j=0; j < i; ++j) {
      left[ s[j] - 'a']++;
    }
    for (int k=i; k < n; ++k) {
      right[ s[k] - 'a']++;
    }

    for(int l=0;l<27;l++){
      
      
      if(left[l]>0 && right[l]>0){
        kaburi++;
      }
    }
    
    mk=max(mk,kaburi);
  }
  prln(mk);
}


Measured memory_bytes: 256
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
args = sys.argv


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if len(args) == 2 and args[1] == "DEBUG" else dump_dummy
N = int(input())
S = [input() for i in range(N)]

D = {'M': [], 'A': [], 'R': [], 'C': [], 'H': []}
for Si in S:
    if Si[0] in D:
        D[Si[0]].append(Si)

dump(D)

ans = 0
for x in it.combinations("MARCH", 3):
    x0, x1, x2 = x
    dump(x0, x1, x2)
    ans += len(D[x0])*len(D[x1])*len(D[x2])
print(ans)


Measured memory_bytes: 11276
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C, K] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2]), long(input_raw[3])]
    print ((-1) ** (K%2)) *  (A - B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

int r,d,x;

int main(){ 
  cin>>r>>d>>x;
  int xi2=0,xi=x;
  rep(i,10){
    xi2=r*xi-d;
    xi=xi2;
    cout<<xi2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, x;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> x;
  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  } 
  if (N == 2) {
    cout << "Yes" << endl;
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
    return 0;
  }
  cout << "Yes" << endl;
  vector<int> a;
  if (x == 2) {
    for (int i = 1; i < 2 * N; i++) {
      if (i >= 1 && i <= 4) continue;
      a.emplace_back(i);
    }
    for (int i = 0; i < N - 3; i++) {
      cout << a[i] << endl;
    }
    cout << 4 << endl;
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
    for (int i = N - 3; i < a.size(); i++) {
      cout << a[i] << endl;
    }
  } else {
    for (int i = 1; i < 2 * N; i++) {
      if (i >= x - 2 && i <= x + 1) continue;
      a.emplace_back(i);
    }
    for (int i = 0; i < N - 2; i++) {
      cout << a[i] << endl;
    }
    cout << x - 1 << endl;
    cout << x << endl;
    cout << x + 1 << endl;
    cout << x - 2 << endl;
    for (int i = N - 2; i < a.size(); i++) {
      cout << a[i] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2420
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int m = sc.nextInt();
        int d = sc.nextInt();
        int ans=0;
        
        for(int i=4; i<=m; i++) {
			for(int j=2; j <= d/10; j++) {
				for(int k=2; k<=9; k++) {
					if(j==d/10 && k>d%10) {
						break;
					}
					if(i==j*k) {
						ans++;
					}
				}
			}
		}
			
        System.out.println(ans);
	}
}


Measured memory_bytes: 35720
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto c:v) cout<<" "<<c; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	cout<<(n^1)<<endl;
}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 100005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    int i,j,k,n,wei;
    cin>>n>>wei;
    vector<ll> w(n+5), profit(n+5);
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>profit[i];
    }
    vector<vector<ll>> dp(n+5,vector<ll>(wei+5));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=wei;j++)
        {
            if(j >= w[i])
            {
                dp[i][j] = max(dp[i-1][j], profit[i]+ dp[i-1][j-w[i]]);
            }   
            else
            {
                dp[i][j] = dp[i-1][j];   
            }
        }
    }
    cout<<dp[n][wei];
    return 0;           
}

Measured memory_bytes: 86192
blue=int(input())
b=[]
r=[]
for i in range(blue):
  b.append(input())
red=int(input())
for i in range(red):
  r.append(input())
count=[]
for i in range(len(b)):
  counter=0
  for j in range(len(b)):
    if b[i]==b[j]:
      counter+=1
  for j in range(len(r)):
    if b[i]==r[j]:
      counter-=1
  count.append(counter)
if max(count)<0:
  print(0)
else:
  print(max(count))

Measured memory_bytes: 9052
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	while(true){
	    if(a==0 && b==0) break;
	    if(a<b) System.out.println(a+" "+b);
	    else System.out.println(b+" "+a);
	    a=sc.nextInt();
	    b=sc.nextInt();
	}
    }
}

Measured memory_bytes: 27128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

int main(void) {

  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  map<int, int> m;
  for(int i=0; i<n; i++){
    m[a[i]]++;
  }
  int cnt = 0;
  for(int i=0; i<n; i++){
    if( m[a[i]] == 0 ) continue;
    if( m[a[i]] > a[i] ){
      cnt += (m[a[i]]-a[i]);
      m[a[i]] = a[i];
    }else if( m[a[i]] < a[i] ){
      cnt += m[a[i]];
      m[a[i]] = 0;
    }
  }
  cout << cnt << endl;

  return 0;
}

// EOF


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

int main()
{
	int n, cnt = 0, nb;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> nb;
		if (i % 2 != 0 && nb % 2 != 0)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();
	return 0;
}

Measured memory_bytes: 3664
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, K, Q;
    cin >> N >> K >> Q;
    vec<ll> score(N, -Q);
    REP(i, Q){
        ll A;
        cin >> A;
        A--;
        score[A]++;
    }
    REP(i, N){
        if(score[i] <= -K){
            cout << "No" << el;
        }else{
            cout << "Yes" << el;
        }
    }
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

string ws;
	while(cin >> ws){
		if( cin.eof()) break;
		int c[10][10]={0};
		rep(i,10) c[0][i] = ws[i] - '0';
		rep2(i,1,10){
			rep(j,10){
				c[i][j] = (c[i-1][j] + c[i-1][j+1])%10;
			}
//			rep(j,10) cout << c[i][j] << " "; cout <<":q"<< endl;
		}
		cout << c[9][0]  <<endl;
	}
	return 0;
	
	
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;
const int maxn=1e6+10;
vector<int>vec[maxn];
int main()
{
  int n;cin>>n;
  for(int i=2;i<=n;i++)
  {
  	int x;cin>>x;
  	vec[x].push_back(i);
  }
  for(int i=1;i<=n;i++)
  cout<<vec[i].size()<<endl;
  
	return 0;
}

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

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

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

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

	int kc; cin >> kc;
	int tc[101];

	for (int i = 0;i < n;i++){
		cin >> tc[i];
	}

	sort(tc,tc+n);
	reverse(tc,tc+n);

	double p,nex;
	int cnt = 1;
	p = (double)kc/a;
	nex = (double)(kc+tc[0])/(a+b);
	while(nex>p){
		p = nex;
		cnt++;
		int sum = kc;
		for (int i = 0;i < cnt;i++){
			sum += tc[i];
		}
		nex = (double)sum/(a+b*cnt);
	}

	cout << (int)p << endl;

	return 0;

}



Measured memory_bytes: 3152
#include <cstring>
#include <iostream>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		int nx[n][n],ny[n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				cin>>nx[i][j]>>ny[i][j];
		
		int vis[n][n];
		memset(vis,0,sizeof(vis));
		
		int cur=0,res=0;
		for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(!vis[i][j]){
			cur++;
			for(int x=j,y=i;;){
				if(vis[y][x]){
					if(vis[y][x]==cur)
						res++;
					break;
				}
				vis[y][x]=cur;
				int tx=nx[y][x],ty=ny[y][x];
				x=tx,y=ty;
			}
		}
		
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
n = int(input())
a = list(map(int, input().split()))
x = 0
tmp = 0
mount = []

for i in range(n):
    if i%2 == 0:
        x += a[i]
    else:
        x -= a[i]
x = x//2

for i in range(n):
    mount.append(x)
    x = a[i] - x
mount = list(map(lambda x: str(x*2), mount))

print(" ".join(mount))

Measured memory_bytes: 18504
#include <iostream>
using namespace std;
int main()
{
	int h[5], i, t[3];
	while (cin >> h[0] && h[0])
	{
		t[0] = t[1] = t[2] = 0;
		t[h[0]-1]++;
		for (i = 1; i < 5; i++)
		{
			cin >> h[i];
			t[h[i]-1]++;
		}
		if ((h[0] == h[1] && h[1] == h[2] && h[2] == h[3] && h[3] == h[4]) || (t[0] > 0 && t[1] > 0 && t[2] > 0))
			for (i = 0; i < 5; i++)
				cout << 3 << endl;
		else
		{
			if (t[0] > 0 && t[1] > 0)
			{
				for (i = 0; i < 5; i++)
				{
					if (h[i] == 1)
						cout << 1 << endl;
					else
						cout << 2 << endl;
				}
			}
			else if (t[1] > 0 && t[2] > 0)
			{
				for (i = 0; i < 5; i++)
				{
					if (h[i] == 2)
						cout << 1 << endl;
					else
						cout << 2 << endl;
				}
			}
			else
			{
				for (i = 0; i < 5; i++)
				{
					if (h[i] == 3)
						cout << 1 << endl;
					else
						cout << 2 << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
double r,s,l;
cin>>r;
s=M_PI*pow(r,2);
l=M_PI*2.0*r;
cout<<fixed<<setprecision(6)<<s<<" "<<fixed<<setprecision(6)<<l<<endl;
}

   

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <cmath>
#include <string>
#include <limits>

using namespace std;

int main() {
    int N, K;
    vector<int> x;
    cin >> N >> K;
    for (size_t i = 0; i < N; i++) {
        int xi;
        cin >> xi;
        x.push_back(xi);
    }

    //int tmin = numeric_limits<int>::infinity();
    int tmin = abs(x[0]) + abs(x[x.size()-1]-x[0]);
    for(int i=0; i<N-K+1; i++) {
        int l = x[i];
        int r = x[i+K-1];
        int t;
        if(l <= 0 && r >= 0) {
            t = min(-l, r) * 2 + max(-l, r);
        } else {
            t = max(abs(l), abs(r));
        }
        tmin = min(tmin, t);
    }

    cout << tmin << endl;
}


Measured memory_bytes: 892
#include <stdio.h>
int main(){
  int k,a,b;
  scanf("%d",&k);
  scanf("%d %d",&a,&b);
  int i;
  for (i=a;i<=b;i++){
    if(i%k==0){
      printf("OK\n");
      break;
    }
    if(i==b){
      printf("NG\n");
    }
  }
  return 0;
}

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

int main()
{
    int n; cin>>n;
    vector<long> s(n+1);
    for(int i=0; i<n; ++i) {
        cin>>s[i+1];
        s[i+1]+=s[i];
    }

    long res=LONG_MAX;
    for(int i=1; i<n; ++i)
        res=min(res, abs(s[n]-2*s[i]));
    cout<<res<<endl;
}




Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  REP(i,n){
    ll a;
    cin >> a;
    if(a%2==1){
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
typedef long long ll;
const int tt=1e9+7;
int N,cnt[256],Ans;
char s[100005];
int main(){
	scanf("%d%s",&N,s+1);
	for (int i=1;i<=N;++i){
		int gg=1;
		for (char j='a';j<='z';++j) if (j^s[i])
			gg=(ll)gg*(cnt[j]+1)%tt;
		(Ans+=gg)%=tt,++cnt[s[i]];
	}
	return printf("%d",Ans),0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    for(int i=0; i<M; i++){
        cin >> p[i] >> S[i];
    }

    int cnt_AC = 0;
    int cnt_PN = 0;
    vector<int> p_AC(N, 0);
    vector<int> p_WA(N, 0);


    for(int i=0; i<M; i++){
        if(S[i] == "AC"){
            if(p_AC[p[i]-1] == 0){
                cnt_AC++;
                cnt_PN += p_WA[p[i]-1];
            }
            p_AC[p[i]-1]++;
        }

        if(S[i] == "WA"){
            p_WA[p[i]-1]++;
        }
    }

    cout << cnt_AC << " " << cnt_PN << endl;

    return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<cstdio>
#include<cstring>

namespace momomo
{
	const int N=201000;

	int begin[N],next[N*2],to[N*2];
	int n,e;

	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}

	int dep[N];
	int fa[N][20],f[N][20];
	int getmax(int p,int d)
	{
		int ret=0;
		for(int k=19;~k;k--)
			if(d&(1<<k))ret=std::max(ret,f[p][k]),p=fa[p][k];
		return ret;
	}
	void predfs(int p=1,int h=0)
	{
		fa[p][0]=h,dep[p]=dep[h]+1,f[p][0]=p;
		for(int k=1;k<20;k++)
			fa[p][k]=fa[fa[p][k-1]][k-1],f[p][k]=std::max(f[p][k-1],f[fa[p][k-1]][k-1]);

		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)predfs(q,p);
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
		predfs();
	}
	int ans[N];
	void dfs(int p=1,int h=0)
	{
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)ans[q]+=ans[p],dfs(q,p);
	}
	void solve()
	{
		initialize();

		for(int p=2;p<=n;p++)
		{
			int q=p;
			for(int k=19;~k;k--)
			{
				int u=fa[q][k];
				if(!u)continue;
				if(getmax(p,dep[p]-dep[u])<getmax(fa[u][0],dep[u]-1))q=u;
			}
			ans[q]++;
		}
		dfs();
		for(int i=2;i<=n;i++)
			printf("%d ",ans[i]);
		printf("\n");
	}
}

int main()
{
	momomo::solve();
	return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
	#endif
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	ll ans = 0;
	sort(a.begin(),a.end());
	for(int i=0;i<n-k;i++)ans += a[i];
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a=0,b=0;
  int arr[4]={0,0,0,0};
  
  cin>>a>>b;
  arr[a]=arr[b]=1;
  if(arr[1]==0){
    cout<<1<<endl;
  }else if(arr[2]==0){
    cout<<2<<endl;
  }else{
    cout<<3<<endl;
  }
}
  


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

class D
{
	static void Main()
	{
		double m = 1000000000000000, v;
		var q = new int[13].SelectMany((y, d) => new int[1000].Select((z, i) => i + new string('9', d)))
			.Select(long.Parse)
			.Distinct()
			.OrderBy(x => -x)
			.Where(x =>
			{
				var r = (v = (double)x / $"{x}".Sum(c => c - '0')) <= m;
				if (r) m = v;
				return r;
			})
			.Reverse()
			.Take(int.Parse(Console.ReadLine()));
		Console.WriteLine(string.Join("\n", q));
	}
}


Measured memory_bytes: 16992
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  long double A, B, N, x;
  long long int ans;
  cin >> A >> B >> N;
  if(B-N > 1){
    x = N;
    ans = (long long int)floor(A*x/B) - (long long int)A*(long long int)floor(x/B);
  }else{
    x = B-1;
    ans = (long long int)floor(A*x/B) - (long long int)A*(long long int)floor(x/B);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll x;cin >> x;
    vl f;
    rep(i,500){
        ll t=i*i;
        f.pb(t*t*i);
    }
    rep(i,500){
        rep(j,500){
            if(f[i]+f[j]==x){
                cout << i <<" " << -j <<endl;
                return 0;
            }
        }
    }
    rep(i,500){
        rep(j,500){
            if(f[i]-f[j]==x){
                cout << i <<" " << j <<endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

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

  int a[n], b[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> b[i];
  }

  // aの方が大きい
  long int plus = 0;
  // bの方が大きい
  long int minus = 0;
  // 変える必要がある要素
  int m_change[n];
  int m_num = 0;
  vector <int> p_change;
  int p_num = 0;
  for(int i = 0; i < n; i++) {
    // 合格してる
    if(a[i] > b[i]) {
      plus += (a[i] - b[i]);
      p_change.push_back(a[i] - b[i]);
      p_num++;
    }
    // 不合格
    if(a[i] < b[i]) {
      minus += (b[i] - a[i]);
      m_change[m_num] = i;
      m_num++;
    }
  }
  // cout << "plus: " << plus << endl;
  // cout << "p_num: " << p_num << endl;
  for(int i = 0; i < m_num; i++) {
    // cout << "m_change: " << m_change[i] << endl;
    int x = m_change[i];
    plus -= (b[x] - a[x]);
    if(plus < 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  int use_plus_num = 0;
  if(m_num != 0) {
    sort(p_change.begin(), p_change.end(),greater<int>());
    for(int i = 0; i < p_num; i++) {
      // int x = p_change[i];
      // minus -= (a[x] - b[x]);
      // cout << "p_change " << p_change[i] << endl;
      // cout << "minus " << minus << endl;
      minus -= p_change[i];
      use_plus_num++;
      if(minus < 0) break;
      // cout << "log" << endl;

    }
  }

  cout << m_num + use_plus_num << endl;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main() {
	int n; cin >> n; ll a[114514];
	for (int i = 1; i <= n; i++)cin >> a[i];
	sort(a + 1, a + n + 1);
	ll ans1 = 0;
	bool b = false;
	int m = n;
	while (m) {
		if (a[m] == a[m - 1]) { if (b) { cout << ans1*a[m] << endl; return 0; } else { ans1 = a[m]; b = true; m -= 2; } }
		else m--;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n, x, m = map(int, input().split())
    d1 = defaultdict(int)
    r = 0
    while n:
        if d1[x]:
            cycle = d1[x] - n
            t0 = 0
            cycle2 = cycle
            while cycle2:
                t0 += x
                x = x**2 % m
                cycle2 -= 1
            c, rem = divmod(n,  cycle)
            r += c * t0
            while rem:
                r += x
                x = x**2 % m
                rem -= 1
            print(r)
            sys.exit()
        else:
            d1[x] = n
            r += x
            x = x**2 % m
        n -= 1
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 77860
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    double r;cin>>r;
    double res=r*2*3.141592;
    cout<<res<<endl;
}


Measured memory_bytes: 3788
import sys
 
if __name__ == '__main__':
    val = int(input().strip())

    arr = []
    i = 2
    while i < int(val ** 0.5 + 1):
        if val % i == 0:
            arr.append(i)
            val //= i
            continue
        i += 1
    if val != 1:
        arr.append(val)
    
    
    count = 0
    cur_val = 0

    for e in arr:
        if cur_val != e:
            cur_val = e
            times = 1
            n = 1
        if times == n * (n + 1) // 2:
            count += 1
            n += 1
        times += 1
    
    print(count)    
        


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

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

int main(void){
    int n,x[100001]={0};
    cin>>n>>x[0];
    
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    sort(x,x+n+1);
    for(int i=0;i<n;i++){
        x[i]=x[i+1]-x[i];
    }
    int ans=x[0];
    for(int i=1;i<=n-1;i++){
        ans = g(ans,x[i]);
    }
    cout<<ans<<endl;
    
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	long long n, sum = 0;
	cin >> n;

	for (long long i = 1; i <= n; i++) {

		if (((i % 3) != 0) && ((i % 5) != 0)) {
			sum += i;
		}
	}
	cout << sum << endl;

}



Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if(a*n>b)cout<<b<<endl;
	else cout<<a*n<<endl; 

 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	int k,a,b;
	cin>>k;
	cin>>a>>b;
	if(a%k==0 || b%k==0)cout<<"OK";
	else if(a/k != b/k)cout<<"OK";
	else
	cout<<"NG";
}




Measured memory_bytes: 3636
#include <cstdio>

using namespace std;

int main()
{
    double mean = 0;
    int n; double a;
    scanf( "%d\n", &n );
    double times = n;
    while( n > 0 )
    {
        scanf( "%lf\n", &a );
        mean += a;
        n--;
    }
    mean /= times;
    printf( "%.0lf\n", mean );
    return 0;
}


Measured memory_bytes: 2592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  intl A,B,K;
  cin >>A>>B>>K;
  intl resultA = max(A-K,(intl)(0));
  intl resultB =max((intl)(0), (K-A > 0)? B-(K-A) : B );
  cout <<resultA<<" "<<resultB;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  mat a(n,vec(n));
  for(ll i=0;i<n;i++) for(ll j=0;j<n;j++) cin >> a[i][j];
  vec dp((1<<n));
  dp[0]=1;
  for(ll s=1;s<(1<<n);s++) {
    for(ll i=0;i<n;i++) {
      for(ll j=i+1;j<n;j++) {
        if(s>>i&s>>j&1) dp[s]+=a[i][j];
      }
    }
    for(ll t=s;t>0;t=t-1&s) {
      if(t==s) continue;
      dp[s]=max(dp[s],dp[t]+dp[s^t]);
    }
  }
  cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (long int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  long int A, B, C, D;
  cin >> A >> B >> C >> D;

  long int c, d, cd, all;

  long int mcd = (C * D) / __gcd(C, D);

  c = B / C - (A - 1) / C;
  d = B / D - (A - 1) / D;
  cd = B / mcd - (A - 1) / mcd;
  all = B - A + 1;

  cout << all - (c + d - cd);

  return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int left = Math.max(a, c);
        int right = Math.min(b, d);
        int ans = right - left;

        if(ans <0){
            System.out.println(0);
        } else {
            System.out.println(right - left);
        }
    }

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
string s;
int nums,numt;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='S') 
		  nums++;
        if((nums)&&(s[i]=='T'))
        {
            nums--;
            numt+=2;
        }
    }
    cout<<s.size()-numt<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] l = new int[n];
        for(int i=0;i<n;i++)
        {
            l[i] = scan.nextInt();
        }
        int ans = 0;
        
        Arrays.sort(l);
        while(k>0)
        {
            ans+=l[n-k];
            k--;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto ai = readln.split;

  ai.reverse();

  writeln(ai.join(" "));
}

Measured memory_bytes: 2468
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N;
	scanf("%d", &N);
	int P[10];
	int maxi = 0;
	int maxp = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &P[i]);
		if (P[i] > maxp) {
			maxp = P[i];
			maxi = i;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i == maxi) {
			ans += P[i] / 2;
		}
		else {
			ans += P[i];
		}
	}

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




#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
N=int(input())

def call(n):
	lstAns=list()
	for x in range(1,n+1):
		if x % 3 == 0:
			lstAns.append(x)
			continue
		y = x
		while 0 < y:
			if y % 10 == 3:
				lstAns.append(x)
				break
			else:
				y //= 10

	return lstAns

ans = call(N)

ans = " ".join(map(str,ans))
if 0 < len(ans):
	ans = " " + ans

print(ans)



Measured memory_bytes: 6108
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    rep(i,0,n)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    int dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    rep(i,1,n)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]+n>'Z') s[i]-=26;
    s[i]+=n;
  }
  cout<<s<<"\n";
}


Measured memory_bytes: 256
package main

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

func main() {
	var t string
	var s = bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if s.Scan() {
		t = s.Text()
	}
	a, err := strconv.Atoi(t)
	if err != nil {
		fmt.Println(-1)
		return
	}

	if s.Scan() {
		t = s.Text()
	}
	b, err := strconv.Atoi(t)
	if err != nil {
		fmt.Println(-1)
		return
	}

	if a > b {
		fmt.Println(-1)
	}

	if a > 100 {
		fmt.Println(-1)
	}

	if b > 100 {
		fmt.Println(-1)
	}

	for i := 0; i < 2000; i++ {
		if (int(float64(i)*0.08) == a) && (int(float64(i)*0.10) == b) {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)

	// // O(1)
	// var x = int(float64(a) / 0.08)
	// if int(float64(x)*0.10) == b {
	// 	fmt.Println(x)
	// 	return
	// }
	// fmt.Println(-1)

	// // O(1)
	// var x = int(float64(b) / 0.10)
	// if int(float64(x)*0.08) == a {
	// 	fmt.Println(x)
	// 	return
	// }
	// fmt.Println(-1)

}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll n,a[200005],f[200005][3];
int main()
{
	scanf("%lld",&n);
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		f[i][0]=min(f[i-1][0],sum)+(a[i]&1?1:(a[i]?0:2));
		f[i][1]=min(f[i-1][1],f[i-1][2])+(a[i]&1?1:(a[i]?0:2));
		f[i][2]=min(f[i-1][0],min(f[i-1][2],sum))+(a[i]&1?0:1);
//		printf("%lld %lld %lld\n",f[i][0],f[i][1],f[i][2]);
		sum+=a[i];
	}
	sum=0;
	ll ans=1000000000000000000ll;
	for(int i=n;i>=0;i--)
	{
		ans=min(ans,min(min(f[i][0],f[i][1]),f[i][2])+sum);
		sum+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
/* ex3_3 
　　　　　sachiyan*/

#include <stdio.h>
#include<math.h> //math.h の標準ライブラリを使用
int main(void){
    int INT, ARY, ans; //入力値N,Kと答えansを定義
    scanf("%d %d", &INT, &ARY); //入力値N,Kを読み取る
    ans = 0; //ansに初期値0を代入
    while(pow(ARY, ans) <= INT){ //powはmath.hによる累乗を計算する関数
        ans++;  //K進数の最高位を探す　Kのans乗がN以下の時はそれ以上の桁が存在するので繰り返す
    }
    printf("%d\n", ans); //答えansを出力
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int gcb(int x, int y) {
    if (0 == (x % y))
        return y;
    else
        return gcb(y, x%y);
}

int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", x > y ? gcb(x, y) : gcb(y, x));
    return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int main(void){

	int i, j;
	int height[10];
	int temp;
	
	for(i = 0; i < 10; i++){
		scanf("%d", &height[i]);
	}
	
	for(i = 0; i < 9; i++){
		for(j = 9; j > i; j--){
			if(height[j - 1] > height[j]){
				temp			= height[j];
				height[j]		= height[j - 1];
				height[j - 1]	= temp;
			}
		}
	}
	
	printf("%d\n%d\n%d\n", height[9], height[8], height[7]);
	
	return 0;
}

Measured memory_bytes: 600