akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define t int
long long knapSack(int W, int wt[], int val[], int n) 
{ 
    int i, w; 
    long long K[n + 1][W + 1]; 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 
int main(){
    int n,k; 
    cin>>n>>k;
    int wt[n+1],val[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
   cout<<knapSack(k,wt,val,n)<<"\n";
   return 0;
}

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




int main() {
    ios::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m);
    for (auto &el: b) cin >> el;

    int cnt = 0;
    vector<int> a(m);
    for (int i = 0; i < n; ++i) {
        for (auto &el: a) cin >> el;
        int res = c;
        for (int i = 0; i < m; ++i) res += a[i] * b[i];
        if (res > 0) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


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

using namespace std;

#ifdef ACMTUYO
struct RTC{~RTC(){cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC <<" seconds\n";}} runtimecount;
#define DBG(X) cerr << #X << " = " << X << '\n';
#else
struct RTC{};
#define DBG(X)
#endif

#define fast_io() ios_base::sync_with_stdio(false)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(c) (c).begin(),(c).end()
#define forn(i, n) for (int i = 0; i < (n); i++)
typedef long long int ll;

int main() {
  ll D, T, S;
  scanf("%lld %lld %lld", &D, &T, &S);
  puts(T * S >= D? "Yes": "No");
  return 0;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const int Max=2e5+5;
ll a[3005][3005]; 
int main()
{
	ll r,c,k;
	scl(r);scl(c);scl(k);
	for(ll i=1;i<=k;i++){
		ll u,v,co;scl(u);scl(v);scl(co);
		a[u][v]=co;
	}ll maxx=0;
	for(int i=1;i<=r;i++){
		ll max1=0,max2=0,max3=0;
		for(int j=1;j<=c;j++){
			max3=max(max3,max2+a[i][j]);max2=max(max2,max1+a[i][j]);max1=max(max1,a[i-1][j]+a[i][j]);
			a[i][j]=max(max1,max(max2,max3));maxx=max(maxx,a[i][j]);
		}
	}pf("%lld\n",maxx);
}


Measured memory_bytes: 74076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int x; cin >> x;
    int ans = 0;
    for(int b=1; b<=33; b++){
        for(int p=2; p<=10; p++){
            if(pow(b, p) <= x && pow(b, p) > ans) ans = pow(b, p);
        }
    }

    cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vvi g(n);
	REP(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vi d(n, INF);
	{
		d[0] = 0;
		queue<int> q;
		q.push(0);
		while (!q.empty()) {
			int p = q.front(); q.pop();
			REP(i, g[p].size()) {
				if (d[g[p][i]] == INF) {
					d[g[p][i]] = d[p] + 1;
					q.push(g[p][i]);
				}
			}
		}
	}
	int t = max_element(ALL(d)) - d.begin();
	d = vi(n, INF);
	{
		d[t] = 0;
		queue<int> q;
		q.push(t);
		while (!q.empty()) {
			int p = q.front(); q.pop();
			REP(i, g[p].size()) {
				if (d[g[p][i]] == INF) {
					d[g[p][i]] = d[p] + 1;
					q.push(g[p][i]);
				}
			}
		}
	}
	int s = *max_element(ALL(d));
	if (s % 3 == 1)cout << "Second" << endl;
	else cout << "First" << endl;
}

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

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  ll a[n], b[m], A[n+1], B[m+1];
  ll sum_a = 0, sum_b = 0;
  A[0] = 0; B[0] = 0;
  for(ll i=0;i<n;i++){
    cin >> a[i];
    sum_a += a[i];
    A[i+1] = sum_a;
  }
  for(ll i=0;i<m;i++){
    cin >> b[i];
    sum_b += b[i];
    B[i+1] = sum_b;
  }

  ll ans = 0;
  ll b_tmp = m;
  for(ll i=0;i<n+1;i++){
    if(A[i]>k) break;
    while(A[i]+B[b_tmp]>k) b_tmp--;
    ans = max(ans,i+b_tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9808
def f(n):
  return (n**2-n)//2
N=int(input())
A=[]
for i in range(N):
  S=sorted(input())
  A.append("".join(S))
A=sorted(A)
A.append("")
ans=0
n=1
for i in range(N):
  if A[i]==A[i+1]:
    n+=1
  else:
    ans+=f(n)
    n=1
print(ans)

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int K;

signed main() {
    cin >> K;
    if(K%2==0)cout<<(K/2)*(K/2)<<endl;
    else cout<<(K/2+1)*(K/2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#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(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    int maxcnt = 0;
    int cnt = 0;
    REP(i, n - 1)
    {
        if(h[i] - h[i+1] >= 0)
        {
            cnt++;
            maxcnt = max(cnt, maxcnt);
        }
        else
        {
            cnt = 0;
        }
    }



    cout << maxcnt << endl;
    
}

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

int main() {
int k,n;
cin >> k >> n;
vector<int> a(n);
rep(i,n) cin>>a[i];

a[0]=a[0]+k;

int ans=0;
rep(i,n-1)
{int l=i+1;
  ans=max(ans,a[l+1]-a[l]);
}
ans=max(ans,a[0]-a[n-1]);
ans=k-ans;
cout << ans <<endl;
return 0;
}


Measured memory_bytes: 1152
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int a;
		boolean existRyokin[] = new boolean[n];
		for (int i=0; i<m; i++){
			a = sc.nextInt();
			existRyokin[a] = true;
		}
		int leftCost = 0;
		int rightCost = 0;
		for (int i=x; i>0; i--){
			if (existRyokin[i]){
				leftCost ++;
			}
		}
		for (int i=x; i<n; i++){
			if (existRyokin[i]){
				rightCost ++;
			}
		}
		System.out.println(Math.min(leftCost, rightCost));
	}
}


Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println((a + b) % 24);

        
    }
}



Measured memory_bytes: 22228
#include<bits/stdc++.h>
#include<stdio.h>
#include<vector>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define vll vector<long long int>
#define endl "\n"
#define FOR(x) for(int i=0; i<x; i++)
#define sortV(x) sort(x.begin(), x.end())
#define sortA(x) sort(x, x+(sizeof(x)/sizeof(x[0])))
#define arrsige(x) (sizeof(x)/sizeof(x[0]))
#define vsige(x) x.size()
#define pb push_back
#define ll long long int
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yess cout << "Yes" << endl
#define noo cout << "No" << endl


using namespace std;


void prnt(vector<long long int> v)
{
    cout << endl << endl << "vector size: " << v.size() << "  \nthe vector: " ;

    for(int i=0; i<v.size(); i++)
    {
        cout << v[i] << " ";
    }


    cout << endl << endl;
}


void solve()
{
    int n, x;
    char c;
    cin >> c;
    if(c>=65 && c<=90) cout << "A";
    else if(c>=97 && c<=122) cout << "a";
    else cout << "not matched!";
    return;
}




int main()
{
    IOS;
    int tc=1;
    //cin >> tc;
    while(tc--)
    {
        solve();
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;


int main() {
    fast
	int t=1;
// 	cin>>t;
	while(t--){
    long long X;
     cin >> X;
     long long P = 100, step = 0;
     while(P < X){
     P += P / 100;
     step++;
     }
 cout << step << endl;
	}
	return 0;
}


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

int main()
{
	int x, i,flag = 0, limit = 0, answer = 0;
	scanf("%d", &x);
	while (flag == 0)
	{
		limit =(int)sqrt((double)x);
		for (i = limit; i > 1; i--) {
			if (x%i == 0)
				break;
		}
		if (i == 1) {
			answer = x;
			flag = 1;
			break;
		}
		x++;
	}
	printf("%d", answer);
	return 0;
}

Measured memory_bytes: 128
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


def get_digit_order(digit, found_list):
    count = 0
    select = 1
    while select != digit:
        if select not in found_list:
            count += 1
        select += 1
    return count


def get_order(num_list):
    found = []
    order = 0
    for i in range(N - 1):
        digit_count = get_digit_order(num_list[i], found)
        found.append(num_list[i])
        order += math.factorial(N - i - 1) * digit_count
    return order


a = get_order(A)
b = get_order(B)

print(abs(a - b))



Measured memory_bytes: 3064
/* https://atcoder.jp/contests/abc082/tasks/arc087_a */

#include <iostream>
#include <map>
#include <set>

/* {{{ Variables */
int N;
std::map<int, int> cnt;
std::set<int> keys;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    int k;
    std::cin >> k;

    if (cnt.find(k) == cnt.end()) {
      cnt.insert(std::make_pair(k, 1));
      keys.insert(k);
    } else {
      int c = cnt.at(k);
      cnt.at(k) = c+1;
    }
  }
  /* }}} */

  /* {{{ Output */
  int rest = 0;

  for (int k: keys) {
    int c = cnt.at(k);

    if (k > c) {
      rest += c;
    } else if (k < c) {
      rest += c - k;
    }
  }

  std::cout << rest << std::endl;
  /* }}} */

  return 0;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int d[10001];
int main() {
	int N, M, p;
	scanf("%d %d %d", &N, &M, &p);
	for (int i = 0; i < M; i++) {
		scanf("%d", &d[i]);
		d[i] -= p;
		if (d[i] < 0) d[i] += N;
	}
	sort(d, d + M);
	d[M] = N;
	int ans = N - d[0];
	for (int i = 0; i < M; i++) {
		ans = min(ans, d[i] + (N - d[i + 1]) + min(d[i], N - d[i+1]));
	}
	printf("%d\n", ans*100);
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define x first
#define y second

pii a[51];
pii b[51];

int dist(pii a, pii b) {
    return abs(a.x - b.x) + abs(a.y - b.y);
}

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

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

    int res[51];
    for (int i = 0; i < n; i++) {
        int mn = 987654321, idx;
        for (int j = 0; j < m; j++) {
            if (mn > dist(a[i], b[j])) {
                mn = dist(a[i], b[j]);
                idx = j;
            }
        }
        res[i] = idx;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>


using namespace std;
int count_black(int h , int w, vector<vector<char>> hw , vector<bool> ignore_h , vector<bool> ignore_w){
    int ret_ans = 0;
    for(int i = 0 ;i < h ;i++){
        for(int j = 0;j < w ;j++){
            if (ignore_h[i]) continue;
            if (ignore_w[j]) continue;
            if (hw[i][j] == '#') ++ret_ans;
        }
    }
    return ret_ans;
}


int main(){
int h,w,k;
cin >> h >> w >>k;
vector<vector<char>> vec(h ,vector<char>(w));
for (int i = 0;i < h;i++){
    for (int j = 0;j < w;j++){
        cin >> vec.at(i).at(j);
    }
}
int ans = 0;

//(h+w)^2の回数計算するために、左ビットシフトを(h+w)回している、ビット全探索をしている
for(int i = 0; i < (1<<(h+w)); i++){
    vector<bool> ignore_h(h, false);
    vector<bool> ignore_w(w, false);
    for(int j = 0; j < (h + w) ; j++){
    //j個シフトしながら各ビットが1か0か判定
        if ((i>>j) & 1) {
            if (j < w) {
                ignore_w[j] = true;
            }
            else {
                ignore_h[j-w] = true;
            }
        }
    }

    
    if (count_black(h, w, vec, ignore_h, ignore_w) == k) {
        ++ans;
    }
}
cout << ans << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;



char str[100];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			scanf("%s", str);
			if (string(str) == "snuke")
			{
				printf("%c%d\n", 'A' + j, i + 1);
				return 0;
			}
		}




	return 0;
}



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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

ll gdb(ll A,ll B)
{
    if(A==0 && B==0)
    {
        // 存在しない
    }
    else if(A==0 && B>0)
    {
        return B;
    }
    else if(A>0 && B==0)
    {
        return A;
    }
    else
    {
        if(A>B)
        {
            return gdb(A % B,B);
        }
        else if(A==B)
        {
            return A;
        }
        else
        {
            return gdb(A,B%A);
        }
    }
}

ll tgdb(ll A,ll B, ll C)
{
    return gdb(A,gdb(B,C));
}

int main()
{
    ll K;
    cin >> K;

    ll answer = 0;

    for(ll a = 1; a <= K; a++)
    {
        for(ll b = 1; b <= K; b++)
        {
            for(ll c = 1; c <= K; c++)
            {
                answer += tgdb(a,b,c);
            }   
        }
    }

    cout << answer << endl;

    return 0;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,m;
long long t=0;
priority_queue<int> h;

void nhap()
{
    scanf("%d %d",&n,&m);
    for (int i=1;i<=n;++i)
    {
        int x;
        scanf("%d",&x);
        h.push(x);
    }
}

void process()
{
    while (!h.empty() && m>0)
    {
        int x=h.top();
        h.pop();
        x/=2;
        if (x>0) h.push(x);
        m--;
    }
    while (!h.empty())
    {
        t+=h.top();
        h.pop();
    }
    cout<<t;
}

int main()
{
    nhap();
    process();
    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include<stdlib.h>
int main(){
    int flag=0;
    long long int a[4]={0},product[4]={0};
    scanf("%lld%lld%lld%lld",&a[0],&a[1],&a[2],&a[3]);
   product[0]=a[0]*a[2];
  product[1]=a[0]*a[3];
  product[2]=a[1]*a[2];
  product[3]=a[1]*a[3];
  do{
        flag=0;
        for(int i=1;i<4;i++){
            long long int temp=0;
            if(product[i-1]<product[i]){
                temp=product[i-1];
                product[i-1]=product[i];
                product[i]=product[i-1];
                flag++;
            }
        }
    }while(flag);
  printf("%lld",product[0]);
}

Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	ll n;
	cin >> n;
	ll n_copy;
	n_copy = n;
	ll d[10] = {};
	ll w = 1000000000;
	for (int i = 9; i >= 0; i--) {
		if (n / w >= 0) {
			d[i] = n / w;
			n %= w;
		}
		w /= 10;
	}
	int sum = 0;
	for (int i = 0; i < 10; i++) {
		sum += d[i];
	}
	if (n_copy % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

def height(ans, loop):
  if loop > max(h):
    print(ans)
    return
  
  i = 0
  for i in range(n):
    if i == 0 and h[i] >= loop:
      ans += 1
    elif h[i] >= loop and h[i-1] < loop:
      ans += 1
      
  height(ans, loop+1)
  
height(0, 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head


struct BIT{
  vl bit;
  int size;
  void init( int n ){
    size = 1;
    while( size < n ) size *= 2;
    bit = vl( size , 0 );
  }
  void add( int k , ll v ){
    for( int i = k+1; i <= size; i += i & -i ) bit[i-1] += v;
  }
  ll sum( int k ){ // [0,k)
    ll res = 0;
    for( int i = k; i > 0; i -= i & -i ) res += bit[i-1];
    return res;
  }
  ll sum( int l , int r ){ // [l,r)
    return sum( r ) - sum( l );
  }
  ll get( int k ){
    return sum( k+1 ) - sum( k );
  }
  ll update( int k , ll x ){
    add( k , x - get(k) );
  }
};

typedef tuple<int,int,int> Q;

BIT bit;

int n, m;

vector<Q> v;

int ans[300010];

int main(){

  n = in();
  m = in();
  REP( i , n ){
    int l = in();
    int r = in();
    v.pb( r , 2 , l );
  }
  FOR( d , 1 , m+1 ){
    for( int i = d; i <= m; i += d ){
      v.pb( i , 1 , d );
    }
  }

  SORT( v );
  REVERSE( v );

  bit.init( m+10 );
  YYS( w , v ){
    int r = get<0>( w );
    int t = get<1>( w );
    int s = get<2>( w );
    if( t == 2 ){
      bit.add( s , 1 );
    } else if( t == 1 ){
      int l = r - s;
      if( l < 0 ){
        l = -1;
      }
      ans[s] += bit.sum( l+1 , r+1 );
    }
  }

  FOR( i , 1 , m+1 ){
    printf( "%d\n" , ans[i] );
  }
  
  return 0;
}


Measured memory_bytes: 26984
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
using P = pair <int, int>;
 
 
int main() {
    int h,w;
    cin >> h >> w;
    rep(i,h){
        vector<char>c(w);
        rep(j,w){
            cin >> c[j];
        }
        rep(k,w){
            cout << c[k];        
        }
        cout << endl;
        rep(k,w){
            cout << c[k];
        }
        cout << endl;

    }
}


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

using namespace std;

const int ComputeGCM(const int A, const int B)
{
    if (B == 0)
    {
        return A;
    }
    return ComputeGCM(B, A % B);
}

int main()
{
    int N;
    cin >> N;
    vector<int> lives(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> lives[i];
    }
    int gcm = ComputeGCM(lives[0], lives[1]);
    for (int i = 2; i < N; ++i)
    {
        gcm = ComputeGCM(gcm, lives[i]);
    }
    cout << gcm << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  char a;
  cin >> a;

  if (isupper(a)) cout << 'A' << endl;
  else cout << 'a' << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
int x,y,a,b,c;
int cnt[3];
vector<pair<int,int>> v;
void MAIN() {
	cin>>x>>y>>a>>b>>c;
	for(int i=0;i<a;i++){
		int t;cin>>t;
		v.pb({t,0});
	}
	for(int i=0;i<b;i++){
		int t;cin>>t;
		v.pb({t,1});
	}
	for(int i=0;i<c;i++){
		int t;cin>>t;
		v.pb({t,2});
	}
	sort(all(v));reverse(all(v));
	for(int i=0;i<x+y;i++) {
		cnt[v[i].se]++;
	}
	ll sum=0;
	if(cnt[0]<=x&&cnt[1]<=y) {
		for(int i=0;i<x+y;i++)sum+=v[i].fi;
	} else if(cnt[0]<=x) {
		for(int i=0;i<a+b+c;i++) {
			if(x&&(v[i].se==0||v[i].se==2))x--,sum+=v[i].fi;
			if(y&&v[i].se==1)y--,sum+=v[i].fi;
		}
	} else if(cnt[1]<=y) {
		for(int i=0;i<a+b+c;i++) {
			if(x&&v[i].se==0)x--,sum+=v[i].fi;
			if(y&&(v[i].se==1||v[i].se==2))y--,sum+=v[i].fi;
		}
	}
	cout<<sum;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 6512
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
string s, t;
int n, m;
void solve(){
    int n, m;
    cin >> n >> m;
    cin >> s >> t;
    int l = (n * m) / (__gcd(n, m));
    int d1 = l / n, d2 = l / m;
    bool yes = 1;
    for(int i = 0; i < n; i++){
        if((i * d1) % d2 == 0){
            int p = (i * d1) / d2;
            if(p < m && s[i] != t[p])
                yes = 0;
        }
    }
    if(yes)
        cout << l << endl;
    else
        cout << -1 << endl;
}
signed main()
{
    IO;
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    fr(i, 1, t){
        solve();
    }
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
};

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

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

    int A[4][3][10] = {};

    for(int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        b--; f--; r--;
        A[b][f][r] += v;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << A[i][j][k];
            }
            cout << endl;
        }
        if(i < 3){
            for(int j = 0; j < 20; j++){
                cout << '#';
            }
            cout << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 3076
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    string s;cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}



    return 0;
}


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

int main()
{
  int a,b;
  cin >> a >> b;
  if((a+b)%2 == 0) cout << (a+b)/2 << endl;
  if((a+b)%2 == 1) cout << ((a+b)/2 + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>        //sort(v.begin(), v.end(), [std::greater()]);  第3引数をなしにすると昇順。
#include <utility>  
#include <vector>           
#include <iterator>         //vector入力で使う istream_iterator(cin)
#include <iomanip>          //doubleやfloatなどの少数の桁数を指定する setprecision(桁数) 

/*----------- 定義 -----------*/
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef long long int lli;
/*----------------------------*/


/*----------- 入力 -----------*/
lli A,B,N;
vector<int> vec;
/*----------------------------*/
 
 
 
int main(void){
    cin >> A >> B;
    
    if(A < 2*B)
        N = 0;
    else if(A == 2*B)
        N = 0;
    else{
        N = A - 2*B;
    }
        
    cout << N;
    

    return 0;
}


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

int main() {
  int a, b, c, k, m = 1, x;
  scanf("%d %d %d\n%d", &a, &b, &c, &k);
  m <<= k;
  x = max(a, max(b, c));
  printf("%d\n", a + b + c + x * (m - 1));
}

Measured memory_bytes: 256
// ARC_061_C

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

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

	int n = s.size();
	vector<int> v(n);
	for(int i = 0; i < n; ++i) v[i] = s[i];

	ll sum = 0;
	
	for(int tmp = 0; tmp < (1 << (n-1)); ++tmp) {
		ll pos = 0;
		for(int i = 0; i < n-1; ++i) {
			if(tmp & (1 << i)) {
				string sub = s.substr(pos, i-pos+1);
				sum += stoll(sub);
				pos = i + 1;
			}
		}
		string sub = s.substr(pos, n);
		sum += stoll(sub);                 
	} 

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>


int main(void) {
    int N;
    std::vector<int> nest,primes;
    std::vector<int> mod;

    std::cin >> N;

    nest.resize(55556);

    int idx = 2;
    while(idx < 55556) {
        if(nest[idx] == 0) {
            int i = 1;
            while(true) {
                if(i * idx + idx > 55555)
                    break;
                nest[i * idx + idx] = 1;
                i++;
            }
        }
        idx++;
    }

    for(int i = 2; i < nest.size(); i++) {
        if(nest[i] == 0 && i%5==1)
            mod.push_back(i);
    }


    for(int i = 0; i < N; i++) {
        std::cout << mod[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		long[] H = new long[N];
		boolean[] isGood = new boolean[N];
		int answer = 0;

		for (int i = 0; i < N; i++) {
			H[i] = scan.nextLong();
			isGood[i] = true;
		}

		for (int i = 0; i < M; i++) {
			int A = scan.nextInt();
			int B = scan.nextInt();

			if (H[A - 1] > H[B - 1]) isGood[B - 1] = false;
			else if (H[A - 1] == H[B - 1]) {
				isGood[A - 1] = false;
				isGood[B - 1] = false;
			}
			else isGood[A - 1] = false;
		}

		for (int i = 0; i < N; i++) {
			if (isGood[i]) answer++;
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 60660
fun main() {
    a()
}

fun a() {
    val s = readLine()!!
    fun aa(): Int {
        if (s == "RRR") return 3
        if (s.take(2) == "RR" || s.takeLast(2) == "RR") return 2
        if (s.any { it == 'R' }) return 1
        return 0
    }
    aa().toLong().print()
}

fun readLong() = readLine()!!.toLong()
fun readLongList() = readLine()!!.split(" ").map { it.toLong() }

fun Long.bitEach(action: (Int) -> Unit) {
    (0 until Long.SIZE_BITS).forEach { action(((this shr it) and 1).toInt()) }
}

fun Long.bitFilter(bit: Int) = (0 until Long.SIZE_BITS).filter { ((this shr it) and 1) == 1L }

fun <T1, T2> pairs(first: Iterable<T1>, second: Iterable<T2>) = first.flatMap { t1 -> second.map { t2 -> t1 to t2 } }

fun Long.primeSequence() = sequence<Long> {
    var n = this@primeSequence
    if (n % 2L == 0L) {
        yield(2L)
        n /= 2L
    }
    var i = 3L
    while (n > 0) {
        if (n % i == 0L) {
            yield(i)
            n /= i
        }
        i += 2L
    }
}

fun Long.print() {
    println(this)
}

Measured memory_bytes: 35860
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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


	cin >> N >> M >> K;
	cout << min(N*M, K) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		int count =0;
		for (int i=0;i<s.length()-2;i++) {
			if (s.substring(i, i+3).equals("ABC")) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define pb push_back
#define x first
#define y second
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

const string FILENAME = "input";
const int MAXN = 4e3 + 5, H = 2e3 + 1, p = 1e9 + 7;

typedef pair <int, int> point;

int sum(int a, int b) {
	a += b;
	if (a >= p)
		return a - p;
	return a;
}

int mul(long long a, int b) {
	return a * b % p;
}

int powx(int a, int b) {
	int ans = 1;
	while (b) {
		if (b & 1) ans = mul(ans, a);
		a = mul(a, a);
		b >>= 1;
	}
	return ans;
}

const int p2 = powx(2, p - 2);

int n;
int f[2][MAXN * 2];
vector <point> arr;
int dp[MAXN][MAXN];
int ans = 0;

int cnk(int n, int k) {
	return mul(f[0][n], mul(f[1][n - k], f[1][k]));
}

int main() {
	ios::sync_with_stdio(false);
	srand(time(0));
	//read(FILENAME); 
	f[0][0] = 1;
	f[1][0] = 1;
	for (int i = 1; i < MAXN * 2; ++i) {
		f[0][i] = mul(f[0][i - 1], i);
		f[1][i] = powx(f[0][i], p - 2);
	}
	cin >> n;
	arr.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> arr[i].x >> arr[i].y;
		++dp[H - arr[i].x][H - arr[i].y];
	}
	for (int i = 0; i + 1 < MAXN; ++i) {
		for (int j = 0; j + 1 < MAXN; ++j) {
			dp[i][j + 1] = sum(dp[i][j], dp[i][j + 1]);
			dp[i + 1][j] = sum(dp[i][j], dp[i + 1][j]);
		}
	}
	for (auto i : arr) {
		ans = sum(ans, dp[H + i.x][H + i.y]);
		ans = sum(ans, p - cnk((i.x + i.y) * 2, i.x * 2));
	}
	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < n; ++j) {
	// 		if (i == j) continue;
	// 		ans = sum(ans, cnk(arr[i].x + arr[i].y + arr[j].x + arr[j].y, arr[i].x + arr[j].x));
	// 	}
	// }
	cout << mul(ans, p2) << endl;
}

Measured memory_bytes: 64512
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def size(self, x):
        return -self.parents[self.root(x)]


if __name__ == '__main__':
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(lambda x: int(x)-1, input().split())
        uf.unite(a, b)

    cnt = 0
    for i in range(n):
        if uf.root(i) == i:
            cnt += 1
    print(cnt-1)


Measured memory_bytes: 10972
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii < (ll)(ee); ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
ll a,b,c;
int main(){
	FAST
	cin>>a>>b>>c;
	cout<<max(0ll,c - (a-b));
}


Measured memory_bytes: 256
s = input()
ans = "Yes"
for i in range(len(s)):
    if (i+1) % 2 == 0:
        if s[i] not in ['L', 'U', 'D']:
            ans = "No"
            break
    else:
        if s[i] not in ['R', 'U', 'D']:
            ans = "No"
            break

print(ans)


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int n,q,S[100000],T[50000],i,left,right,mid,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    left=0;
    right=n;

    while(left<right){
      mid=(left+right)/2;

      if(T[i]==S[mid]){
	count++;
	break;
      }
      if(T[i]>S[mid]) left=mid+1;
      else if(T[i]<S[mid]) right=mid;
    }
  }

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

  return 0;
}
      

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;
    cin>>s;
    int a[4];
    a[0]=s%10;
    a[1]=s/10%10;
    a[2]=s/100%10;
    a[3]=s/1000;
    for(int i=0;i<=3;i++){
    	for(int j=0;j<=3;j++){
    		if(a[i]==a[j]&&(i-j==1||j-i==1)){
    			cout<<"Bad"<<endl;
				return 0; 
    		}
    	}
    }
    cout<<"Good";
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
ll modExp(ll a, ll b, ll c) {
	a %= c;
	ll ans = 1;
	for(; b; b >>= 1) {
		if(b & 1){
			ans *= a;
			ans %= c;
		}
		a *= a;
		a %= c;
	}
	return ans;
}
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n,i,j;
	cin >> n;
	cout << fixed << setprecision(8);
	pair<ll,ll>pt[n];
	for(i = 0; i < n; i++) {
		cin >> pt[i].fst >> pt[i].scd;
	}
	ld sum = 0;
	for(i = 0; i < n; i++) {
		for(j = i + 1; j < n; j++) {
			sum += 2 * sqrtl(
			(pt[i].fst - pt[j].fst) * (pt[i].fst - pt[j].fst) + 
			(pt[i].scd - pt[j].scd) * (pt[i].scd - pt[j].scd)
			) / n;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int i,n,a[51],p=0;
  scanf("%d",&n );
  for(i=0;i<n;i++){
    scanf("%d",&a[i] );
  }
  for(i=0;i<n;i++){
    if(a[i]!=i+1) p++;
  }
 
  if(p==0 || p==2){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, C, K;
	cin >> A >> B >> C >>K;

	if(B<C) swap(B, C);
	if(A<B) swap(A, B);
	REP(i, K) A *= 2;
	cout << A + B + C << endl;
    return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]) {

    val source = scala.io.Source.stdin.getLines.toSeq

    var index: Int = 0

    while(true) {

      val nm = source(index).split(" ").map(_.toInt)

      if (nm.forall(_ == 0))
        return

      println(calc(nm(0), nm(1), source.drop(index + 1).take(nm.sum)))

      index += nm.sum + 1

    }
  }

  def calc(n: Int, m: Int, inputs: Seq[String]) = {
    val taro = inputs.take(n).map(_.toInt).sorted
    val hana = inputs.drop(n).take(m).map(_.toInt).sorted

    val diff = taro.sum - hana.sum

    if (diff == 0) {
      taro.find(v => hana.contains(v)).map(v => s"${v} ${v}").getOrElse("-1")
    } else if (Math.abs(diff) % 2 == 1) {
      "-1"
    } else {
      (for (
        v1 <- taro;
        v2 <- hana;
        if v1 - v2 == diff / 2
      ) yield s"${v1} ${v2}").headOption.getOrElse("-1")
    }
  }

}

Measured memory_bytes: 45388
export class Main {
  private n: number;
  private k: number;
  private r: number;
  private s: number;
  private p: number;
  private t: string;
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    [this.n, this.k] = tmp[0].split(" ").map(int => parseInt(int));
    [this.r, this.s, this.p] = tmp[1].split(" ").map(int => parseInt(int));
    this.t = tmp[2].split(" ")[0];
    let result: number = 0;
    const tList: string[] = this.t.split("");
    const winMap = {
      r: "p",
      s: "r",
      p: "s"
    };
    const pointMap = {
      p: this.p,
      s: this.s,
      r: this.r
    };
    const pointList = [[this.p, "p"], [this.s, "s"], [this.r, "r"]];
    pointList.sort(([_1, a1], [_2, a2]) => a2 - a1);

    let teList = [];
    for (let i = 0; i < this.n; i++) {
      const prev: string = i - this.k < 0 ? "" : teList[i - this.k];
      const vs: string = tList[i];
      const win = winMap[vs];
      if (win != prev) {
        result += pointMap[win];
        teList.push(win);
        continue;
      }
      if (i + this.k >= this.n) {
        teList.push(win);
        continue;
      }
      const nextWin = winMap[tList[i + this.k]];
      const other = ["p", "s", "r"].filter(a => a != win && a != nextWin)[0];
      teList.push(other);
    }

    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 998244353;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool A[n + 1]; for (int i = 0; i < n + 1; i++) { A[i] = 1; }for (int i = 2; i < n + 1; i++) { if (A[i]) { prime.pb(i); ll b = i; while (b <= n) { A[b] = 0; b += i; } } } }

vector<vector<pair<int,int>>> Edge;
vector<int> node;

bool bellman_ford(int n,int s) {
	node = vector<int>(n,INF);
	node[s] = 0;
	REP (i,n) {
		REP (j,Edge.size()) {
			REP (k,Edge[j].size()) {
				int from = j,to = Edge[j][k].F;
				int cost = Edge[j][k].S;
				if (node[from] != INF && node[to] > node[from] + cost) {
					node[to] = node[from] + cost;
					if (i == n - 1 && to == n - 1) return true;
				}
			}
		}
	}
	return false;
}

int dp[100000];
int dp2[100000];

signed main() {
	int n;
	cin >> n;
	vector<int> a(n+100,INF);
	a[0] = 0;
	REP (i,n) {
		int x;cin >> x;
		a[i+1] = a[i] + x;
	}

	int ans = INF;
	FOR (i,1,n-1) {
		auto it = upper_bound(ALL(a),a[i+1] / 2);
		int Ldif = abs((int)*it - (a[i+1] - (int)*it));
		int Lmax,Lmin;
		if (abs((int)*(--it) - (a[i+1] - (int)*it)) < Ldif) {
			Lmax = max(a[i+1] - (int)*it,(int)*it);
			Lmin = min(a[i+1] - (int)*it,(int)*it);
		} else {
			it++;
			Lmax = max(a[i+1] - (int)*it,(int)*it);
			Lmin = min(a[i+1] - (int)*it,(int)*it);
		}

		it = upper_bound(ALL(a),(a[i+1] + a[n]) / 2);
		int Rdif = abs((int)*it - a[i+1] - (a[n] - (int)*it));
		int Rmax,Rmin;
		if (abs((int)*(--it) - a[i+1] - (a[n] - (int)*it)) < Rdif) {
			Rmax = max((int)*it - a[i+1],a[n] - (int)*it);
			Rmin = min((int)*it - a[i+1],a[n] - (int)*it);
		} else {
			it++;
			Rmax = max((int)*it - a[i+1],a[n] - (int)*it);
			Rmin = min((int)*it - a[i+1],a[n] - (int)*it);
		}

		ans = min({ans,max(Lmax,Rmax) - min(Lmin,Rmin)});
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
function Main(input){
  var N = input.split('\n')[0].trim();
  var A = input.split('\n')[1].split(' ');
  N = parseInt(N,10);
  var a = [];

  

  
  for(i=0;i<N;i++){
    A[i] = parseInt(A[i],10);
    a[(A[i]-1)] = i+1;
  }
/*
  for(i=0;i<N;i++){
    Nn[i] = (i+1);
    a[i] = A.indexOf(Nn[i]);
    a[i] = parseInt(a[i],10) + 1;
  }
  */
  console.log(a.join(' '));


}

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

Measured memory_bytes: 41160
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

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

    double ans = 0;

    for (int i = 1; i <= N; i++)
    {
        if(i%2 == 1) ans++;
    }

    printf("%.7lf",ans/N);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(s) for s in input().split()]
A.sort()
vA = 0;
vB = 0;
for i in range(N):
    if (len(A) == 0):
        break
    vA += A.pop()
    if (len(A) == 0):
        break
    vB += A.pop()
print(vA - vB)


Measured memory_bytes: 3060