akhauriyash/Code-Regression huggingface dataset:
#include <limits>
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
  long L, R;
  cin >> L >> R;
  size_t size = R - L + 1;
  if (size >= 2019) { cout << 0 << endl; return 0; }
  vector<long> nums(size);
  
  long res = numeric_limits<long>::max();
  for (long i = 0; i < size -1; ++i) {
    for (long j = i + 1; j < size; ++j) {
      res = min(res, ((L + i) * (L + j)) % 2019);
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        double n = scanner.nextInt(), m = scanner.nextInt() - 1, d = n - scanner.nextInt();
        System.out.println(m / n * (d == n ? 1 : 2 * d / n));
    }
}

Measured memory_bytes: 22100
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
struct point
{
    int a,b;
};
const int N=105;
int ab[N][N],u[N],nx[N],n;
bool f(int q)
{
    for(int i=1;i<=n;i++)
    {
        if(ab[q][i]&&u[i]==0)
        {
            u[i]=1;
            if(nx[i]==0||f(nx[i]))
            {
                nx[i]=q;
                return true;
            }
        }
    }
    return false;
}
int main()
{
    cin>>n;
    point a[n+2],b[n+2];
    for(int i=1;i<=n;i++)
        cin>>a[i].a>>a[i].b;
    for(int i=1;i<=n;i++)
        cin>>b[i].a>>b[i].b;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        if(a[i].a<b[j].a&&a[i].b<b[j].b)ab[i][j]=1;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        memset(u,0,sizeof(u));
        if(f(i))sum++;
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
arr = list(map(int,input().split()))

arr.sort(reverse=True)
count = 0
for i in range(n-2):
    j = i+1
    k = n-1
    while j < k:
        if arr[i] < arr[j] + arr[k]:
            count += k-j
            j += 1
        else:
            k -= 1
print(count)

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

using namespace std;

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

    int m = n / 2 + (n % 2);
    if (k <= m) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,y = map(int,input().split())

for i in range(y//10000+1):
    if i > n:
        break
    for j in range((y-i*10000)//5000+1):
        if i + j > n:
            break
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(i,j,n-i-j)
            exit()

print(-1,-1,-1)


Measured memory_bytes: 40812
import math
n = int(input())
a_tmp = input().split()
a = [[] for i in range(n)]
for i in range(n):
    a[i] = int(a_tmp[i])
a2 = [[] for i in range(n)]
for i in range(n):
    tmp = a[i]
    coun = 0
    while 1:
        if tmp % 2 == 0:
            tmp = tmp/2
            coun += 1
        else:
            break
    a2[i] = coun

print(sum(a2))


Measured memory_bytes: 4916
#include<bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int d[100009];
main(){
	r(i,100009)d[i]=1e17;
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	s--;t--;
	vector<P>v[100009];
	r(i,m){
		int a,b,c,w;
		cin>>a>>b>>c>>w;a--;b--;c--;
		v[a].push_back(P(b,w));
		v[b].push_back(P(a,w));
		v[c].push_back(P(b,w));
		v[b].push_back(P(c,w));
		v[a].push_back(P(c,w));
		v[c].push_back(P(a,w));
	}
	priority_queue<P,vector<P>,greater<P> >q;
	q.push(P(0,s));
	d[s]=0;
	while(!q.empty()){
		P p=q.top();q.pop();
		int now=p.second;
		int cost=p.first;
		if(d[now]<cost)continue;
		r(i,v[now].size()){
			int nex=v[now][i].first;
			int ncos=v[now][i].second+cost;
			if(d[nex]>ncos){
				d[nex]=ncos;
				q.push(P(ncos,nex));
			}
		}
	}
	cout<<d[t]<<endl;
}


Measured memory_bytes: 23728
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;


const int MAX_S = 1<<16;
int C[128];

bool isExist[9][MAX_S];

int convert(string s) {
  int j = 0;
  for(int i = 0; i < s.size(); ++i) {
    j |= C[s[i]]<<(i*2);
  }
  return j;
}

int main() {
  int n;
  char s[100];
  C['A'] = 0;
  C['C'] = 1;
  C['G'] = 2;
  C['T'] = 3;
  fill(isExist[0],isExist[9], false);
  scanf("%d", &n);
  while(n--) {
    scanf("%s", s);
    if(s[0] == 'f') {
      scanf("%s", s);
      if(isExist[strlen(s)][convert(string(s))])
        printf("yes\n");
      else
        printf("no\n");
    } else {
      scanf("%s", s);
      isExist[strlen(s)][convert(string(s))] = true;
    }
  }
  return 0;
}

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


typedef long long ll;

int main() {
  int k; cin >> k;
  int cnt = 0;
  vector<ll> nums = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  while (cnt+nums.size() < k) {
    vector<ll> nnums;
    for (ll x: nums) {
      int d0 = x%10;
      for (int d = max(0,d0-1); d <= min(d0+1,9); ++d) {
        ll x2 = x*10+d;
        // cerr << x << " " << x2 << endl;
        nnums.push_back(x2);
      }
    }
    cnt += nums.size();
    swap(nums, nnums);
  }
  sort(nums.begin(), nums.end());
  cout << nums[k-cnt-1] << endl;
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
#include<string>
using namespace std;
string s;
int x,y,z;
int main()
{
	cin>>s;
	x=(int(s[0])-48)*1000+(int(s[1])-48)*100+(int(s[2])-48)*10+int(s[3])-48;
	y=(int(s[5])-48)*10+int(s[6])-48;
	z=(int(s[8])-48)*10+int(s[9])-48;
	if(x>2019)
	{
		cout<<"TBD";
		return 0;
	}
	else if(y>4)
	{
		cout<<"TBD";
		return 0;
	}
	else if(z>30)
	{
		cout<<"TBD";
		return 0;		
	}
	else
	{
		cout<<"Heisei";
	}
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m;
vector<array<int, 4>> in;
vector<pair<int, int>> e[500000];
int dist[500000];

template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };
template<typename Cost> void dijkstra(int start, vector<pair<int, Cost>> g[], Cost dist[]) {
	RPQ<pair<Cost, int>> q;
	dist[start] = 0;
	q.emplace(dist[start], start);
	while(! q.empty()) {
		auto cp = q.top(); q.pop();
		int  p = cp.SE;
		Cost c = cp.FI;
		if(dist[p] != c) { continue; }
		for(auto && e : g[p]) {
			int ep = e.FI;
			int ec = e.SE;
			if(setmin(dist[ep], dist[p] + ec)) { q.emplace(dist[ep], ep); }
		}
	}
	return;
}

int main() {
	cin >> n >> m;
	inc(i, m) {
		int p, q, c;
		cin >> p >> q >> c;
		p--; q--;
		
		int ep = n + 2 * i + 0;
		int eq = n + 2 * i + 1;
		in.PB({ p, c, ep, eq });
		in.PB({ q, c, eq, ep });
	}
	sort(ALL(in));
	
	inc(i, in.size()) {
		int  p = in[i][0];
		int ep = in[i][2];
		int eq = in[i][3];
		e[ep].PB({ eq, 0 });
		e[ep].PB({  p, 1 });
		e[ p].PB({ ep, 1 });
	}
	
	int k = in.size() - 1;
	inc(i, k) {
		if(in[i][0] == in[i + 1][0] && in[i][1] == in[i + 1][1]) {
			int ep0 = in[i + 0][2];
			int ep1 = in[i + 1][2];
			e[ep0].PB({ ep1, 0 });
			e[ep1].PB({ ep0, 0 });
		}
	}
	
	int INF = n + 2 * m + 1;
	inc(i, n + m * 2) { dist[i] = INF; }
	dijkstra<int>(0, e, dist);
	
	cout << (dist[n - 1] == INF ? -1 : dist[n - 1] / 2) << endl;
	
	return 0;
}


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


typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	int n, m;
	cin >> n >> m;
	int ans;
	ans = (n * (n - 1)) / 2 + (m * (m - 1) / 2);
	cout << ans;
	return 0;
}









Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;


public class Main {
	Scanner sc = new Scanner(System.in);
	void a() {
		while(true) {
			int n = sc.nextInt();
			if(n == 0) return;
			int[] a = new int[n];
			double sum = 0.0;
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
				sum += a[i];
			}
			sum /= (double)(n);
			int cnt = 0;
			for(int i = 0; i < n; i++) {
				if(a[i] <= sum) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}

	}

	void b() {
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int t = sc.nextInt();
			int p = sc.nextInt();
			if(n == 0 && m == 0 && t == 0 && p == 0) return;
			final int LEN = 1000;
			int[][] pe = new int[LEN][LEN];
			for(int i = 0; i < LEN; i++) {
				Arrays.fill(pe[i], 0);
			}
			for(int i = 0; i < m; i++) {
				for(int j = 0; j < n; j++) {
					pe[i][j] = 1;
				}
			}
			/*for(int i = 0; i < m * 2; i++) {
				System.out.println(Arrays.toString(pe[i]));
			}*/
			int x = 0;
			int y = 0;
			for(int k = 0; k < t; k++) {
				int d = sc.nextInt();
				int c = sc.nextInt();
				//System.out.println(d);
				if(d == 1) {	
					for(int i = x; i < c + x; i++) {
						for(int j = 0; j < LEN; j++) {
							int num = pe[j][i]; 
							pe[j][i] = 0;
							//System.out.println(i + (c - i) * 2 + " " + j);
							pe[j][i + (c - i + x) * 2 - 1] += num;
						}
					}
					x += c;
					//System.out.println(x);
				}
				if(d == 2) {
					for(int i = y; i < c + y; i++) {
						for(int j = 0; j < LEN; j++) {
							int num = pe[i][j]; 
							pe[i][j] = 0;
							pe[i + (c - i + y) * 2 - 1][j] += num;
						}
					}
					y += c;
				}
			}
			/*
			for(int i = 0; i < m * 2; i++) {
				System.out.println(Arrays.toString(pe[i]));
			}
			 */

			for(int i = 0; i < p; i++) {
				int X = sc.nextInt();
				int Y = sc.nextInt();
				int ans = pe[y + Y][x + X];
				//System.out.println(x + X + " " + (y + Y) + " " + x + " "  + y);
				System.out.println(ans);
			}
		}

	}


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

}



Measured memory_bytes: 695564
#include <bits/stdc++.h>
using namespace std;
template<class T>inline bool chMax(T& a,T b){if(a<b){a=b;return true;}else{return false;}}
template<class T>inline bool chMin(T& a,T b){if(a>b){a=b;return true;}else{return false;}}
const int inf=1e9;
vector<int> mem(100000);    
 
int main(){
    int N;
    cin >>N;
    vector<int> h(N);
    for (int i=0;i<N;i++)cin >>h[i];
    for(int i=0;i<N;i++)mem[i]=inf; 
    mem[0]=0;
    for (int i=1;i<N;i++){
    chMin(mem[i],mem[i-1]+abs(h[i]-h[i-1]));
    if(i>1)chMin(mem[i],mem[i-2]+abs(h[i]-h[i-2]));
    }

    cout <<mem[N-1] <<endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
  int a[10000],n,min,max,i;
  long long sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }

  min=max=a[0];
  for(i=0;i<n;i++){
    if(a[i]<min)min=a[i];
    if(a[i]>max)max=a[i];
  }

  printf("%d %d %lld\n",min,max,sum);

  return 0;
}

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

Measured memory_bytes: 3644
#include"stdio.h"

int main(void)
{
  unsigned int x1,x2,x3,x4,x5,ans;
  
  //input
  scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
  
  //check
  if(x1+1 == 1)
  {
    ans=1;
  }else if(x2+2 == 2){
    ans=2;
  }else if(x3+3 == 3){
    ans=3;
  }else if(x4+4 == 4){
    ans=4;
  }else{
  	ans=5;
  }
  //output
  printf("%d",ans);

  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}    


signed main()
{
    showoff;
    int a,b;
    cin >> a >> b;
    if(min(a,b) == 1 && max(a,b) == 2)cout << 3;
    else if(min(a,b) == 1 && max(a,b) == 3)cout << 2;
    else cout << 1;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

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

int a[222222], b[222222], c[666666], d[666666];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        scanf("%d", a + i);
    for(int i = 0; i < n; i++)
        scanf("%d", b + i);
    for(int i = 0; i < n; i++)
        c[i] = a[i] ^ a[(i + 1) % n], c[i + n] = b[i] ^ b[(i + 1) % n];
    for(int i = 0; i < n; i++)
        c[i + n + n] = c[i + n];
    c[n] = -1;
    int j;
    d[0] = j = -1;
    for(int i = 0; i < n * 3; d[++i] = ++j)
        while(j >= 0 && c[i] != c[j])
            j = d[j];
    for(int i = 0; i < n; i++)
        if(d[n * 3 - i] >= n)
            cout << i << ' ' << (a[i] ^ b[0]) << '\n';
    cout << flush;
    return 0;
}


Measured memory_bytes: 10368
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = []
    if n%2 == 0:
        for i in range(n//2):
            ans.append(a[(-i*2)-1])
        for j in range(n//2):
            ans.append(a[(j*2)])
    else:
        for i in range(n//2+1):
            ans.append(a[(-i*2)-1])
        for j in range(n//2):
            ans.append(a[(j*2)+1])
    print(*ans)
resolve()

Measured memory_bytes: 30904
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    int64_t n;
    cin >> n;
    auto x = (n * 100) / 108;

    auto cur = x + ((x*8)/100);
    if (cur == n) {
        cout << x << endl;
        return 0;
    }
    else if (cur < n) {
        while (cur < n) {
            x ++;
            cur = x + ((x*8)/100);
            //cerr << cur << endl;
        }
        if (cur == n) {
            cout << x << endl;
            return 0;
        }
    }
    else if (cur > n) {
        while (cur > n) {
            x --;
            cur = x + ((x*8)/100);
        }
        if (cur == n) {
            cout << x << endl;
            return 0;
        }
    }
    cout << ":("<< endl;
}


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

int n, m;
vector<vector<int>> e(101010, vector<int>(0));
int per[101010];

void dfs(int a, int d)
{
  if(per[a] != 0) return;
  per[a] = d;
  
  for(auto x : e[a])
  {
    dfs(x, d);
  }
  return;
}

int main()
{
  cin >> n >> m;
  
  rep(i, m)
  {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    e[y].emplace_back(x);
    e[x].emplace_back(y);
  }
  
  //rep(i, n) { for(auto x : e[i]) cout << x << " "; cout << endl;}
  
  int c = 0;
  rep(i, n)
  {
    if(per[i]== 0)
    {
      c++;
      dfs(i, c);
    }
    //rep(j, n) cout << per[j] << " "; cout << endl;
  }
  
  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,C,K; cin>>N>>C>>K;
    vector<ll> T(N);
    rep(i,N) cin>>T[i];
    sort(all(T));
    
    ll ans=1;
    ll now=0; //乗ってた人
    ll time=T[0]; //出発時刻
    rep(i,N){
        if(now==C){
            now=1;
            time=T[i];
            ans++;
        }
        else if(T[i]>time+K){
            now=1;
            time=T[i];
            ans++;
        }
        else now++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4004
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d,train,bus int
	fmt.Scan(&a, &b, &c, &d)
	if a >= b{
		train = b
	} else {
		train = a
	}
	if c >= d {
		bus = d
	} else {
		bus = c
	}
	fmt.Println(train + bus)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <ext/numeric>
#define oo 0x3f3f3f3f
#define long long long

using namespace std;
//using namespace __gnu_cxx;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> arr(n);
    set<pair<int, int>> isBlack;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second;
        isBlack.insert({arr[i].first, arr[i].second});
    }

    map<int, long> ans;
    ans[0] = 1ll * (h - 2) * (w - 2);
    set<pair<int, int>> vis;
    for (int i = 0; i < n; ++i) {
        for (int x = max(1, arr[i].first - 2); x <= arr[i].first; ++x) {
            for (int y = max(1, arr[i].second - 2); y <= arr[i].second; ++y) {
                if (x + 2 > h || y + 2 > w)
                    continue;
                if (!vis.insert({x, y}).second)
                    continue;
                int cnt = 0;
                for (int a = x; a <= x + 2; ++a) {
                    for (int b = y; b <= y + 2; ++b) {
                        if (isBlack.count({a, b})) {
                            ++cnt;
                        }
                    }
                }
//                cout << x << ' ' << y << ' ' << cnt << '\n';
                ++ans[cnt];
                --ans[0];
            }
        }
    }

    for (int i = 0; i < 10; ++i) {
        cout << ans[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 50912
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  char s[3];
  int count = 700;
  scanf("%s",s);
  for(int i=0;i<3;i++){
    if(s[i]=='o')count += 100;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,d,l;
    cin >> n >> k;
    int count[n] = {};
    for (int i = 0; i < k; i++){
        cin >> d;
        for (int j = 0; j < d; j++){
            cin >> l;
            count[l-1] = 1;
        }
    }
    int c = 0;
    for (int i = 0; i < n; i++){
        if (count[i] == 0){
            c++;
        }
    }
    cout << c << endl;
    //cout << 1.0 * clock() / CLOCKS_PER_SEC;
    return 0;
}

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

int main() {
  vector<int> A;
  int q; cin >> q;
  for(int i=0; i<q; i++) {
    int que, val;
    cin >> que;

    if(que == 0) {
      //pushBack
      cin >> val;
      A.push_back(val);
    } else if(que == 1) {
      //randomAccess
      cin >> val;
      cout << A[val] << endl;
    } else if(que == 2) {
      //popBack
      A.pop_back();
    }
  }
}



Measured memory_bytes: 3852
#include <iostream>
#include <string>
#include <sstream>


using namespace std;

int main(){
  string s;
  string ans;

  cin >> s;

  ans.push_back(s.at(0));

  int count = 0;
  for(int i=1; i<s.size(); i++){
    count++;
  }

  count--;

  string a = to_string( count );

  ans = ans + a;
  ans.push_back( s.at( s.size()-1 ) );

  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
int main(){
	int n,a,b,c;
	std::cin>>n;
	while(n>0){
		std::cin>>a>>b>>c;
		if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b){
			std::cout<<"YES"<<std::endl;
		}
		else std::cout<<"NO"<<std::endl;
		n--;
	}
	return 0;
}

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

public class Main {

	static void solve (Scanner in, PrintWriter out, Methods ms) {

		while (true) {
			
			int n = in.nextInt();
			if (n == 0) return;
			
			double minDif = Double.MAX_VALUE;
			int minId = -1;
			
			for (int i = 0; i < n; i++) {
				int id = in.nextInt();
				double height = in.nextDouble() / 100;
				double weight = in.nextDouble();
				double bmi = weight / (height * height);
				double dif = Math.abs(bmi - 22);
				if (dif < minDif) {
					minDif = dif;
					minId = id;
				}
			}
			
			out.println(minId);
			
		}

	}



	public static void main (String[] args) {

		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Methods ms = new Methods();
		solve(in, out, ms);
		in.close();
		out.close();

	}

	static class Methods {

		public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}

		public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}

		public int min (int... ar) {Arrays.sort(ar); return ar[0];}

		public long gcd (long a, long b) {return b > 0 ? gcd(b,a%b) : a;}

		public long lcm (long a, long b) {return a / gcd(a,b) * b;}

		public long factorial (int i) {
			if (i == 1) return 1;
			else return i * factorial(i-1);
		}

		public int manhat (int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) + Math.abs(y1 - y2);
		}

		public double euclid (double x1, double y1, double x2, double y2) {
			return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
		}

		public boolean isPrime (int n) {
			if (n == 2) return true;
			if (n < 2 || n % 2 == 0) return false;
			for (int i = 3; i <= Math.sqrt(n); i += 2) if(n % i == 0) return false;
			return true;
		}

	}

}


Measured memory_bytes: 48344
#include<cstdio>
#include<iostream>
using namespace std;
int s,n,a,b;
int f(int x){
	int y=0,z=x;
	while(x){
		y+=x%10;
		x/=10;
	}
	if(y>=a&&y<=b)return z;
	else return 0;
}
int main(){
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)s+=f(i);
	cout<<s<<endl;
}

Measured memory_bytes: 256
import heapq

Q = []
while True:
    lis = input().split()
    if lis[0] == "insert":
        heapq.heappush(Q, (-1) * int(lis[1]))
    if lis[0] == "extract":
        n = heapq.heappop(Q)
        print(-n)
    if lis[0] == "end":
        break


Measured memory_bytes: 45312
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{

    class ProgramD
    {
        static void Main(string[] args)
        {
            //入力
            long x = long.Parse(Console.ReadLine());

            for (long i = 0; i < 1000; i++)
                for (long j = -1000; j < 1000; j++)
                {
                    if(i*i*i*i*i - j * j* j* j* j == x)
                    {
                        Console.WriteLine(i + " " + j);
                        return;
                    }

                }

        }
    }
}


Measured memory_bytes: 27544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
char str[10][10];
char str2[10][10];
bool vis[20];
int m,n,k,ans,l;
void dfs(int u){
    if(u > m+n){
    int t = 0;
    for(int p = 1; p <=m; p++ ){
        for(int q = 1; q <= n; q++){
            if(str[p][q] == '#') t++;
        }
    }
    if(t == k) ans++;
    return;
    }

    // 不变成red
    dfs(u + 1);
    //变red
    if(vis[u] == 0){
        vis[u] = 1;
        if(u <= m){
            for(int i = 1; i <= n; i++) str[u][i] = '0';
            dfs(u+1);
            vis[u] = 0;
            for(int i = 1; i <= n; i++) if(vis[i+m] == 0)str[u][i] = str2[u][i];
        }
        if(u > m) {
            int s = u - m;
            for(int i = 1; i <= m; i++) str[i][s] = '0';
            dfs(u+1); 
            vis[u] = 0;
            for(int i = 1; i <= m; i++) if(vis[i] == 0)str[i][s] = str2[i][s];
        }
    }
}
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    m = read<int>(), n = read<int>(), k = read<int>();
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++) {
            cin>>str[i][j];
            str2[i][j] = str[i][j];
    }
    }

    dfs(1);
    cout<<ans;

}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i ++) cin >> a[i];
    sort(a.begin(), a.end());
    int cost = 0;
    for(int i = 0; i < n-1; i ++) cost += a[i+1]-a[i];
    cout << cost << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long n,k,ans;
int main(){
	scanf("%d%d",&n,&k);
	for(int b=k+1;b<=n;b++){
		ans+=n/b*(b-k);
		int remain=n%b;
		if(remain>=k){
			if(k)ans+=remain-k+1;
			else ans+=remain-k;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
# dt:=ti+1 - ti, d:=abs(xi - xi+1) + abs(yi - yi+1)とおくと
# dt<=t and t%2 =d%2で判定できる

n = int(input())
t, x, y = zip(*((map(int, input().split()) for _ in range(n))))
t = [z for z in t]
x = [z for z in x]
y = [z for z in y]
t.insert(0, 0)  # 1-indexedにするため先頭に0を追加
x.insert(0, 0)
y.insert(0, 0)
# print(t, x, y)
can = True
for i in range(n):
    dt = t[i + 1] - t[i]
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if (dt < dist):
        can = False
    if ((dist % 2) != (dt % 2)):
        can = False

if can:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 58232
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;
typedef long long ll;

struct Node{
    ll a;
    ll b;
} node[100007];

bool cmp(Node a,Node b){
    return a.a < b.a;
}

int main(){
    int N,M;
    while(cin >> N >> M){
        for(int i = 0; i < N; i++){
            cin >> node[i].a >> node[i].b;
        }
        sort(node,node+N,cmp);
        int idx = 0;
        ll sum = 0;
        priority_queue<ll> q;
        for(int i = 1; i <= M; i++){
            while(node[idx].a <= i && idx < N){
                q.push(node[idx].b);
                idx++;
            }
            if(!q.empty()){
                sum+=q.top();
                q.pop();
            }
        }
        cout << sum << endl;
    }
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    printf("%d %d %f", a/b, a%b, (double)a/b);
    // cout << a/b <<" "<< a%b <<" "<< (double)a/(double)b << endl;
    return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

bool is_prime[1001];
int prime[1001];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i <= 1000; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j <= 1000; j += i)is_prime[j] = false;
		}
	}
	ll n; scanf("%lld", &n);
	ll res = 1;
	rep(i, p) {
		ll t = n;
		int cnt = 0;
		while (t) {
			cnt += t / prime[i];
			t /= prime[i];
		}
		(res *= cnt + 1) %= MOD;
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    String S = sc.next();
    String ans = S.equals("ABC") ? "ARC" : "ABC";
    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 25348
h,w = map(int,input().split())
ans = []
flag = True

for i in range(h):
    ans.append(list(input()))

for i in range(h):
    for j in range(w):
        if flag == False:
            break
        if ans[i][j] == '#':
            if j-1 >= 0:
                if ans[i][j-1] == '#':
                    continue
            if i-1 >= 0:
                if ans[i-1][j] == '#':
                    continue
            if j+1 < w:
                if ans[i][j+1] == '#':
                    continue
            if i+1 < h:
                if ans[i+1][j] == '#':
                    continue
            flag = False

if flag:
    print('Yes')
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
ll n,w,wi[105],vi[105],dp[100005][105];
int main(){
   cin>>n>>w;
   for(ll i=1;i<=n;i++) cin>>wi[i]>>vi[i];
   for(ll i=1;i<=w;i++){
      for(ll j=1;j<=n;j++){
         if(wi[j]<=i) dp[i][j]=max(dp[i][j-1],dp[i-wi[j]][j-1]+vi[j]);
         else dp[i][j]=dp[i][j-1];
      }
   }
   cout<<dp[w][n];
   return 0;
}

Measured memory_bytes: 85644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    bool can = false;
    int cnt = 0;
    int a[n+1];rep1(i,n){cin>>a[i];if(a[i]==2)can = true;}
    if(!can){co(-1);return 0;}
    int index = 1;
    bool flag[n+1]={false};
    while(1){
        if(flag[a[index]]){co(-1);return 0;}
        if(a[index]==2){cnt++;break;}
        else{flag[a[index]]=true;cnt++;index = a[index];}
    }
    co(cnt);
}

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

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> b(n,-1);
    b[0]=0;//a+1にはb[a]回後に着く

    int rs,rn;
    int nexttown=a[0];
    for(int i = 0; i < n; i++) {
        if(b[nexttown-1]==-1){
            b[nexttown-1]=i+1;
            int x=a[nexttown-1];
            nexttown=x;
        }

        else{
            rs=nexttown;
            rn=i+1-b[nexttown-1];
            break;
        }
    }
    int fr=b[rs-1];

    vector<int> c(rn);
    c[0]=rs;
    for(int i = 1; i < rn; i++) {
        c[i]=a[c[i-1]-1];
    }

    if(k<fr){
        for(int i = 0; i < n; i++) {
            if(b[i]==k) {
                cout << i+1 << endl;
                break;
            }
        }
    }
    else{
        k -= fr;
        k %= rn;
        cout << c[k] << endl;
    }

    return 0;
}

Measured memory_bytes: 5468
sx,sy,tx,ty = map(int,input().split())
ans = []
dx = tx-sx
dy = ty-sy
if dy>0:
    if dx>0:
        a = ['U','R','D','L']
    else:
        a = ['U','L','D','R']
else:
    if dx>0:
        a = ['D','R','U','L']
    else:
        a = ['D','L','U','R']
dx,dy = abs(dx),abs(dy)
ans.append(a[0]*dy)
ans.append(a[1]*dx)
ans.append(a[2]*dy)
ans.append(a[3]*(dx+1))
ans.append(a[0]*(dy+1))
ans.append(a[1]*(dx+1))
ans.append(a[2])
ans.append(a[1])
ans.append(a[2]*(dy+1))
ans.append(a[3]*(dx+1))
ans.append(a[0])
print(''.join(ans))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
string s[105];
int main()
{
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<h;i++)
    {
        cout<<s[i]<<endl;
        cout<<s[i]<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> x(N), y(N), num(N);
    rep (i, 0, N) cin >> x[i] >> y[i];
    iota(num.begin(), num.end(), 0);

    int cnt = 0;
    double ans = 0;
    do {
        ++cnt;
        rep (i, 1, num.size()) {
            ans += sqrt(pow(x[num[i-1]] - x[num[i]], 2) + pow(y[num[i-1]] - y[num[i]], 2));
        }
    } while (next_permutation(num.begin(), num.end()));

    printf("%.10f", ans/cnt);
}

Measured memory_bytes: 256
#include<iostream>
int main(){
  int n,i,in,min,max;
  long long sum;
  std::cin >> n;
  for(i=sum=0; i<n; i++){
    std::cin >> in;
    if(i == 0) min = max = in;
    if(min > in) min = in;
    if(max < in) max = in;
    sum += in;
  }
  std::cout << min << " " << max << " " << sum << std::endl;
  return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  bool b = false;
  for(int i =0; i < 26; i++){
    for(int j = 0; j < 15; j++){
      if(4*i+7*j == N){
        b = true;
      }
      if(b)break;
    }
    if(b)break;
  }
  if(b){
  cout << "Yes" << endl;
}
else{
  cout << "No" << endl;
}
}

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

bool isPrime(int x){
    for(int i = 2; i < x; i++){
        if(x % i == 0){ return false;}
    }
    return true;
}

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

    for(int i = x;; i++){
        if(isPrime(i)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char s[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	char m[26]={'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C'};
	char bm[1024],bs[1024];
	int i,j;
	scanf("%s",bm);
	strcpy(bs,bm);
	for(i=0;i<strlen(bm);i++){
		for(j=0;j<26;j++){
			if(m[j]==bm[i]){
				bs[i]=s[j];
				break;
			}
		}
	}
	printf("%s\n",bs);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    string S;
    cin >> S;

    int N = S.size();
    vector<vector<int>> dp(N + 1, vector<int>(2));
    dp[0][0] = 0;
    dp[0][1] = -INF;
    rep(i, N) {
        int n = S[i] - '0';
        rep(j, 2) {
            rep(k, 10) {
                if (j == 0 && n < k) break;
                int ni = i+1, nj = j;
                if (k < n) nj = 1;
                dp[ni][nj] = max(dp[ni][nj], dp[i][j] + k);
            }
        }
    }

    int ans = 0;
    rep(i, N+1) {
        ans = max(ans, dp[i][0]);
        ans = max(ans, dp[i][1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void branch(int a, int b, int c) {
    if (a <= b) {
	if (b <= c) {
	    printf("%d %d %d\n", a, b, c);
	} else if (c <= a) {
	    printf("%d %d %d\n", c, a, b);
	} else {
	    printf("%d %d %d\n", a, c, b);
	}
    } else if (b <= a) {
        if (a <= c) {
	    printf("%d %d %d\n", b, a, c);
	} else if (c <= b) {
	    printf("%d %d %d\n", c, b, a);
	} else {
	    printf("%d %d %d\n", b, c, a);
	}
    }
}

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

    scanf("%d %d %d", &a, &b, &c);
    branch(a, b, c);
    
    return 0;
}


Measured memory_bytes: 2036
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;

    vector<vector<int>> E(N);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;

        E[a].pb(b);
        E[b].pb(a);
    }

    mint ans = K;

    queue<int> q;
    q.push(0);

    vector<bool> used(N, false);
    used[0] = true;

    debug(N, K)

    while(!q.empty()) {
        int node = q.front(); q.pop();

        int s = E[node].size();

        if (s > K) {
            print(0);
            return 0;
        }

        int cnt = 0;
        for(auto& to: E[node]) if(used[to]) cnt++;

        int k = K - cnt - 1;
        cnt = 0;
        for(auto &to: E[node]) {
            if (used[to]) continue;
            used[to] = true;
            q.push(to);
            ans *= k - cnt;
            cnt++;
        }
    }

    print(ans);

}


Measured memory_bytes: 9524
class Queue:
    def __init__(self, size=1e6):
        self.max_size = size
        self.data = []
    
    def enqueue(self, x):
        self.data.append(x)
    
    def dequeue(self):
        return self.data.pop(0)
    
    def isEmpty(self):
        return len(self.data) == 0 
    
    def isFull(self):
        return len(self.data) == self.max_size



N, Q = tuple(map(int, input().split()))
queue = Queue()
processes = [(p[0], int(p[1])) for p in [ input().split() for _ in range(N)]]
[queue.enqueue(p) for p in processes]
current_q = 0

while True:
    current_q += Q
    name, time = queue.dequeue()
    time -= Q
    if (time > 0):
        queue.enqueue((name, time))
        continue
    else:
        current_q += time
        print('{} {}'.format(name, current_q))
    if queue.isEmpty(): 
        break




Measured memory_bytes: 20784
import java.util.Scanner;
import java.lang.Math;
import java.lang.System;
import java.io.*;
class Process{
  String n;
  int t;
}
class Main{
  private static int max = 100005;
  private static int head, tail;
  private static Process[] q=new Process[max];

  public static void initialize(){
    head = 0;
    tail = 0;
    return;
  }

  public static boolean isEmpty(){
    return head==tail;
  }

  public static boolean isFull(){
    return ((tail+1)%max==head);
  }

  public static void enqueue(String n, int t){
    if(isFull()) System.out.println("Error");
    q[tail]=new Process();
    q[tail].n=n;
    q[tail].t=t;
    //System.out.println(tail);
    tail=(tail+1)%max;
    //System.out.println(tail);
  }

  public static Process dequeue(){
    if(isEmpty()) System.out.println("Error");
    int x=head;
    head=(head+1)%max;
    return q[x];
  }

  public static void main(String args[]) throws Exception{
    Scanner stdIn=new Scanner(System.in);
    int namecnt=stdIn.nextInt();
    int quantum=stdIn.nextInt();
    int total=0;

    // InputStreamReader isr=new InputStreamReader(System.in);
    // BufferedReader br=new BufferedReader(isr);
    String line;
    for(int i=0;i<namecnt;i++){
      String n=stdIn.next();
      int t=stdIn.nextInt();
      enqueue(n,t);
      //String[] str=line.split(" ");
      // enqueue(str[0],Integer.parseInt(str[1]));

      //System.out.println(line);
  }

    while(!isEmpty()){
      Process temp=new Process();
      temp=dequeue();
      //System.out.println(temp.n+temp.t);
      if(temp.t>quantum){
        temp.t-=quantum;
        enqueue(temp.n,temp.t);
        total+=quantum;
      }
      else{
        total+=temp.t;
        System.out.println(temp.n+" "+total);
      }
    }
  }
}




Measured memory_bytes: 75980