akhauriyash/Code-Regression huggingface dataset:
import { Hash } from "crypto";

class Input {
    private lines: string[];
    constructor(lines: string[]) {
        this.lines = lines;
    }

    public readLine(): string { return this.lines.shift() as string; }
    public readLineInt(): number { return parseInt(this.readLine()); }
    public readLineIntArray(): number[] { return this.readLine().split(" ").map(n => parseInt(n)); }
    public readLineStringArray(): string[] { return this.readLine().split(" "); }

    public readAllLines(): string[] { return this.lines; }
    public readAllLinesInt(): number[] { return this.lines.map(s => parseInt(s)); }
    public readAllLinesIntArray(): number[][] { return this.lines.map(s => s.split(" ").map(n => parseInt(n))); }
    public readAllLinesStringArray(): string[][] { return this.lines.map(s => s.split(" ")); }
}

function calc(stdin: Input) {
    const first = stdin.readLineIntArray();
    const N = first[0];
    const Y = first[1] / 1000;

    for (let hideyo = 0; hideyo <= N; hideyo++) {
        for (let ichiyo = 0; ichiyo <= N - hideyo; ichiyo++) {
            const yukichi = N - hideyo - ichiyo;
            if (hideyo + ichiyo * 5 + yukichi * 10 == Y) {
                return `${yukichi} ${ichiyo} ${hideyo}`;
            }
        }
    }

    return "-1 -1 -1";
}

function main(stdin: string) {
    console.log(calc(new Input(stdin.split("\n"))));
}

if (require.main && require.main.filename.indexOf("Main") >= 0) {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
} else {
    main(`
2000 20000000
`.trim());
}

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

enum An {
  T,
  F
};

An M(An a, An b){
  if(a == T && b == T){
    return T;
  }
  if(a == T && b == F){
    return F;
  }
  if(a == F && b == T){
    return T;
  }
  if(a == F && b == F){
    return T;
  }
}

int main(void){
  int N; cin >> N;
  vector<An> P(N);
  for(int i = 0; i < N; i++){
    char c; cin >> c;
    if(c == 'F'){
      P[i] = F;
    }else{
      P[i] = T;
    }
  }
  An current = M(P[0], P[1]);
  for(int i = 2; i < N; i++){
    current = M(current, P[i]);
  }
  if(current == T){
    cout << 'T' << endl;
  }else{
    cout << 'F' << endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>

using namespace std;

int main() {

    int R, G, B, N;
    int count = 0;
    cin >> R >> G >> B >> N;

    for(int i = 0; i <= N; i++) {
        if(R * i <= N){
            for(int j = 0; j <= N - i; j++){
                if(R * i  + G * j <= N){
                    if((N - (R*i + G*j)) % B == 0){
                        count++;
                    }
                }
            }
        }
    }

    cout << count << endl;

}

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

using namespace std;

int main(){
  long long int n,i,ans=0,a;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    if(a%2==0){
      while(a%2==0){
        a/=2;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

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

	sort(d.begin(), d.end());

	int ans = 0;
	for (int k = 0; k <= 100000; k++) {
		auto i = lower_bound(ALL(d), k);
		int a = i - d.begin();
		int b = N - a;

		if (a == b) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int i = 1;
    for(; i <= n; i++){
        int x = i;
        if(x % 3 == 0) {
            printf(" %d",i);
        }else{
            do {
                if (x % 10 == 3) {
                    printf(" %d",i);
                    break;
                }
                x /= 10;
            }while(x);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2100
N,M = map(int,input().split())

A = list(map(int,input().split()))
su = sum(A)
A.sort(reverse=True)

cnt = 0
for i in A:
  if (i >= su / 4 / M):
    cnt += 1
if (cnt >= M):
  print('Yes')
else:
  print('No')


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

void swap(int &a, int &b){
  int tmp = a;
  a = b;
  b = tmp;
}

void print_vect(vector<int> v){
  vector<int>::iterator i = v.begin();
  cout << *i++;
  while (i != v.end())
  {
    cout << " " << *i++;
  }
  cout << endl;
}

int main(){
  ios::sync_with_stdio(false);
  int N, count = 0;
  cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }
  int mini;
  for(int i = 0; i < N; i++){
    mini = i;
    for(int j = i; j < N; j++){
      if(v[j] < v[mini])
        mini = j;
    }
    if(i!=mini){
      swap(v[i], v[mini]);
      count++;
    }
  }
  print_vect(v);
  cout << count << endl;
  return 0;
}

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

#define rep(i, n) for(int i=0; i<n; i++)

int main(){
	int n;
	while(cin>>n){
		int ans = 0;
		rep(i, 10){
			rep(j, 10){
				rep(k, 10){
					rep(l, 10){
						if(i+j+k+l==n){
							ans++;
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int W, H, N;
    cin >> W >> H >> N;
    int ans = 0, w = 0, h = 0;
    rep(i, N) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) w = max(w, x);
        if (a == 2) W = min(W, x);
        if (a == 3) h = max(h, y);
        if (a == 4) H = min(H, y);
    }

    if (w >= W || h >= H) ans = 0;
    else ans = (W - w) * (H - h);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)

Measured memory_bytes: 8988
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

int data_[210][2] = {-2};

void input() {
	CI N;

	

	return;
}


int main(void) {
	input();
	
	int a = 0;
	int b = 0;
	int c = 0;
	int max = 0;
	int other1 = 0;
	int other2 = 0;

	for (int i = 0; i < N; i++) {
		CI a >> b >> c;
		if (a > max) {
			max = a;
			other1 = b;
			other2 = c;
		}
		if (b > max) {
				max = b;
				other1 = a;
				other2 = c;
		}
		
		if (c > max) {
			max = c;
			other1 = a;
			other2 = b;
		}
			
		

		if (other1 * other1 + other2 * other2 == max * max) {
			CO "YES" E
		}
		else {
			CO "NO" E
		}

		max = 0;


	}


	return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#define MAX_N 2000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

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

  int K;
  cin>>K;
  string S;
  cin>>S;
  int N=S.size();

  setComb();

  ll ans=0;
  ll L=N+K;
  for(ll i=L-1;i>=0;i--){
      if(i<N-1) break;
      ll res=comb(i,N-1);
      mul(res,mod_pow(26,L-1-i));
      mul(res,mod_pow(25,i-(N-1)));

      add(ans,res);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 51256
#include<stdio.h>
#include<string.h>
int main(){
int n,m,c[20],s[60001]={0},i,j;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++)
scanf("%d",&c[i]);
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if((s[i]+1<s[i+c[j]]||s[i+c[j]]==0)&&i+c[j]<=n)
s[i+c[j]]=s[i]+1;
}
}
printf("%d\n",s[n]);
return 0;
}



Measured memory_bytes: 2136
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include<list>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
llong L, R;
int ans;
int main() {
	cin >> L >> R;
	ans = 20000;
	for (int i = L; i < R; i++) {
		if (ans == 0) break;
		for (int j = i + 1; j <= R; j++) {
			ans = min(ans, ((i%2019)*(j%2019)) % 2019);
			if (ans == 0) break;
		}
		if (ans == 0) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int n, x;
int ans[1000000];
int main() {
    memset(ans, 0, sizeof ans);
    cin >> n >> x;
    if (n == 1 && x != 1) puts("No");
    else if (n == 1 && x == 1) puts("Yes\n1");
    else if (n == 2) {
        if (x != 2) puts("No");
        else puts("Yes\n1 2 3");
    } else if (x == 1 || x == 2 * n - 1) puts("No");
    else {
        puts("Yes");
        if (x == 2 || x == 2 * n - 2) {
            ans[n] = x;
            ans[n - 1] = 1;
            ans[n + 1] = 2 * n - 1;
            int t = 1;
            for (int i = 1; i < 2 * n; ++ i) {
                if (i == n || i == n - 1 || i == n + 1) continue ;
                while (t == 1 || t == 2 * n - 1 || t == x) ++ t;
                ans[i] = t;
                ++ t;
            }
            for (int i = 1; i < 2 * n; ++ i) printf("%d\n", ans[i]);
        }
        else {
            ans[n] = x;
            ans[n - 1] = x + 1;
            ans[n + 1] = x - 1;
            ans[n - 2] = x - 2;
            ans[n + 2] = x + 2;
            int t = 1;
            for (int i = 1; i < 2 * n; ++ i) {
                if (i == n || i == n - 1 || i == n + 1 || i == n - 2 || i == n + 2) continue ;
                while (t == x - 1 || t == x + 1 || t == x || t == x - 2 || t == x + 2) ++ t;
                ans[i] = t;
                ++ t;
            }
            for (int i = 1; i < 2 * n; ++ i) printf("%d\n", ans[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 5376
/**
 *    author:  FromDihPout
 *    created: 2020-08-01
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    
    vector<bool> seen(n);
    int curr = 0, cnt = 0;
    while (curr != 1 && !seen[curr]) {
        seen[curr] = true;
        curr = a[curr];
        cnt++;
    }
    
    if (curr == 1) {
        cout << cnt << '\n';
    }
    else {
        cout << -1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner

object Main {

  def initialize(): Map[(Char, Char), Char] = {
    Map(
      ('A', '0') -> 'X',
      ('A', '1') -> 'Y',
      ('X', '0') -> 'E',
      ('X', '1') -> 'Z',
      ('Z', '0') -> 'W',
      ('Z', '1') -> 'B',
      ('B', '0') -> 'Y',
      ('B', '1') -> 'X',
      ('Y', '0') -> 'X',
      ('Y', '1') -> 'E',
      ('W', '0') -> 'B',
      ('W', '1') -> 'Y',
      ('E', '0') -> 'E',
      ('E', '1') -> 'E'
    )
  }

  def check(S: String, now: Char, M: Map[(Char, Char), Char]): Char = {
    if (S.size == 0) (now) else (check(S.drop(1), M((now, S.charAt(0))), M))
  }

  def solve(sc: => Scanner, M: Map[(Char, Char), Char]): Unit = {
    val S = sc.next
    if (S != "#") {
      println(if (check(S, 'A', M) == 'B') ("Yes") else ("No"))
      solve(sc, M)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc, initialize())
  }
}

Measured memory_bytes: 45328
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int[] lefts = new int[n];
		int[] rights = new int[n];
		lefts[1] = arr[0];
		rights[n - 2] = arr[n - 1];
		for (int i = 2; i < n; i++) {
		    lefts[i] = gcd(lefts[i - 1], arr[i - 1]);
		    rights[n - i - 1] = gcd(rights[n - i], arr[n - i]);
		}
		int max = 1;
		for (int i = 1; i < n - 1; i++) {
		    max = Math.max(max, gcd(lefts[i], rights[i]));
		}
		max = Math.max(max, lefts[n - 1]);
		max = Math.max(max, rights[0]);
		System.out.println(max);
   }
   
   static int gcd(int x, int y) {
       if (x % y == 0) {
           return y;
       } else {
           return gcd(y, x % y);
       }
   }
}


Measured memory_bytes: 50520
#include<bits/stdc++.h>
using namespace std;vector<string> n;
int N,L;
int main(){
  cin>>N>>L;string l;
  for(int i=0;i<N;++i){
    cin>>l;n.push_back(l);}
  sort(n.begin(),n.end());
  for(int i=0;i<N;++i)cout<<n[i];
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val N = scala.io.StdIn.readInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toInt - 1)
	val ans = new Array[Int](N)

	for(x <- a){
		ans(x) += 1
	}
	ans.foreach(println(_))
}


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

void BS(int a[], int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j] > a[j - 1]) {
				swap(a[j], a[j - 1]);
			}
		}
	}
}
int solve(int a[], int n)
{
	if (n == 1)  return 1;
	BS(a, n);
	int cnt = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1])  cnt++;
	}

	return cnt + 1;
}

int main()
{
	int n;
	int a[100];

	cin >> n;
	for (int i = 0; i < n; i++)  cin >> a[i];
	
	cout << solve(a, n) << endl;
}

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

using namespace std;

using ll = long long;

int main()
{
  int n, l;
  cin >> n >> l;
  vector<ll> a(n);
  pair<int, int> p{-1, -1};
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    if (i)
    {
      if (a[i] + a[i - 1] >= l)
      {
        p = make_pair(i - 1, i);
      }
    }
  }
  if (p.first == p.second && p.second == -1)
  {
    cout << "Impossible" << endl;
  }
  else
  {
    cout << "Possible" << endl;
    for (int i = 0; i < p.first; ++i)
    {
      cout << i + 1 << endl;
    }
    for (int i = n - 1; i > p.second; --i)
    {
      cout << i << endl;
    }
    cout << p.second << endl;
  }
}

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

int main() {
  int N, A[200];
  
  int dmin = 100;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int A;
    scanf("%d", &A);
    int d = 0;
    while (A % 2 == 0) {
      A /= 2;
      ++d;
    }
    dmin = min(dmin, d);
  }
  printf("%d\n", dmin);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100001

typedef struct{
  int parent;
  int left;
  int right;
} Node;

void getDepth(int,int);

int depth[N];
Node T[N];

int main()
{
    int i,j,u,n,deg,id,k,sibling ,left,x,right,r;

    scanf("%d",&n);
    for(i = 0; i < n; i++) {
      T[i].parent = -1;
      T[i].left = -1;
      T[i].right = -1;
    }

    for(i = 0; i < n; i++) {
      scanf("%d %d",&id,&k);

      if (k != 0){
        scanf("%d",&sibling);
        T[sibling].parent = id;
        T[id].left = sibling;
        right = sibling;
        
        for(j = 1; j < k ; j++) {
          scanf("%d",&sibling);
          T[sibling].parent = id;
          T[right].right = sibling;
          right = sibling;
        }
      }
    }
    
    for(i = 0; i < n; i++){
      if(T[i].parent == -1) r = i;
    }

    getDepth(r,0);

    for(i = 0; i < n; i++) {
      printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth[i]);
      
      if(T[i].parent == -1) printf("root, [");
      else if(T[i].left == -1) printf("leaf, [");
      else printf("internal node, [");

      x = T[i].left;
      if(x != -1) {
        while(1) {
          if(T[x].right == -1) {
            printf("%d",x);
            break;
          }
          else {
            printf("%d, ",x);
            x = T[x].right;
          }
        }
      }
      printf("]\n");
    }
    return 0;
  }
  
void getDepth(int n ,int p) {
  depth[n]=p;

  if(T[n].right != -1) getDepth(T[n].right,p);
  if(T[n].left != -1) getDepth(T[n].left, p+1);
  return;
}
 

Measured memory_bytes: 5292
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int NN = 1e7;
const int M = 1e9+7;
int main(){
    int x,y;cin>>x>>y;
    ll N = (x+y)/3;
    ll K = (2*x-y)/3;
    vector<ll> fact(NN),ifact(NN),inv(NN);
   
    fact[0] = ifact[0] = inv[1] = fact[1] = ifact[1] = 1;
	for(int i = 2; i < NN; i++){
		fact[i] = fact[i-1]*i%M;
		inv[i] = (M-M/i*inv[M%i]%M)%M;
		ifact[i] = inv[i]*ifact[i-1]%M;
	}

    if((x+y)%3!=0) {
        cout<<0;
        return 0;
    }
    if(x < N || y < N){
        cout<<0;
        return 0;
    }
   
    x-=N;
    y-=N;
    cout<<fact[x+y]%M*ifact[x]%M*ifact[y]%M;

}


Measured memory_bytes: 234752
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


N = 10 ** 5
primes = prime_numbers(N)
a = [1 if n in primes and (n + 1) // 2 in primes else 0 for n in range(N + 1)]
a = list(accumulate(a))

ans = []
Q, *LR = map(int, open(0).read().split())
for l, r in zip(*[iter(LR)] * 2):
    ans.append(a[r] - a[l - 1])

print('\n'.join(map(str, ans)))


Measured memory_bytes: 29012
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
int cmp(pair<int,int> a,pair<int,int> b){
	return (a.x>b.x);
}
int main(){
	int a;
	scanf("%d",&a);
	pair<int,int> b[a];
	for(int i=0;i<a;i++){
		scanf("%d",&b[i].x);
		b[i].y=i;
	}
	sort(b,b+a,cmp);
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(b[j].y!=i){
				printf("%d\n",b[j].x);
				break;
			}
		}
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int N; cin>>N;
    vector<ll> a(N,0);
    ll X=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        X+=a[i];
    }
    vector<ll> x(N,0);
    x[0]=a[0];
    for(int i=1;i<N;i++){
        x[i]=x[i-1]+a[i];
    }

    ll mini=2000000009;
    for(int i=0;i<N-1;i++){
        mini=min(mini,abs(2*x[i]-X));
    }
    cout<<mini;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll A, B;
  cin >> A >> B;
  if (A == B) {
    cout << "0\n";
  } else {
    if ((A + B) % 2 == 0) {
      cout << (A + B) / 2 << "\n";
    } else {
      cout << "IMPOSSIBLE\n";
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int power(int a, int b)
{
    int j,f=1;
    for(j=1; j<=b; j++)
    {
        f=f*a;
    }
    return f;
}
int main()
{
    int n,i,sum,s;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        sum=power(2,i);
        if(sum>n)
            break;
    }
    s=power(2,i-1);
    printf("%d\n",s);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))
;
void prac(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
   #endif 
}
ll n;
ll arr[21];
ll dp[1<<21];
ll solve(ll mask)
{
	if(mask==(1<<n)-1){
		return 1;
	}
	if(mask>=(1<<n) )return 0;
	if(dp[mask]!=-1)return dp[mask];
	
	ll index=__builtin_popcount (mask);
	// cout<<index;
	ll ans=0;
	for(ll i=0;i<n;i++){
		// cout<<mask<<(1<<i)<<endl;
		// cout<<i<<(arr[index]&(1<<i)) <<((mask&(1<<i))==0LL)<<endl;
		if(arr[index]&(1<<i) && ((mask&(1<<i))==0LL)){
			
			ans+=solve(mask|(1<<i));
			ans%=mod;
		}
	}
	dp[mask]=ans;
	return ans;
}

int main() 
{
  	// prac();
  
    in(n)
    // for(ll i=0;i<(1<<n);i++)dp[i]=-1;
    for(ll i=0;i<n;i++){
    	for(ll j=0;j<n;j++){
    		ll x;
    		in(x)
    		if(x){
    			arr[i]|=(1<<j);
    		}
    	}
    }

  	dp[0]=1;
  	for(ll i=0;i<n;i++){
  		for(ll j=0;j<(1<<n);j++){
  			if(__builtin_popcount (j)!=i)continue;
  			for(ll m=0;m<n;m++){
  				if(arr[i]&(1<<m) && (j&(1<<m))==0LL){
  					// cout<<i<<" "<<m<<" "<<j<<endl;
  					dp[j|(1<<m)]+=dp[j];
  					dp[j|(1<<m)]%=mod;
  				}
  			}
  		}
  	}

    //prllarr(arr,7)
    out(dp[(1<<n)-1])
    // ll ans=solve(0);
    // out(ans)



}
/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/






Measured memory_bytes: 16640
import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 90760
#include<iostream>
#include<vector>
#include<climits>
#include<stdlib.h>
#include<stack>
using namespace std;
class Point{
public:
    int x, y;
    Point(int xx, int yy): x(xx), y(yy){}
};

int orientation(Point A, Point B, Point C){
    int o = (B.y-A.y)*(C.x-B.x)-(B.x-A.x)*(C.y-B.y);
    if(o == 0) return 0;
    if(o < 0) return -1;
    return 1;
}

int distSq(Point A, Point B){
    return (A.y-B.y)*(A.y-B.y)+(A.x-B.x)*(A.x-B.x);
}

bool compare(Point& O, Point& A, Point& B){
    int o = orientation(O, A, B);
    if(o == 0) return distSq(O, A) > distSq(O, B);
    return o < 0;
}

int partition(vector<Point>& points, const int& l, const int& r){
    int p =  l+rand()%(r-l);
    swap(points[r-1], points[p]);
    p = l;
    for(int i = l; i < r-1; i++){
        if(compare(points[0], points[i], points[r-1])){
            swap(points[i], points[p]);
            p++;
        }
    }
    swap(points[r-1], points[p]);
    return p;
}

void quickSort(vector<Point>& points, const int& l, const int& r){
    if(l >= r-1) return;
    int p = partition(points, l, r);
    quickSort(points, l, p);
    quickSort(points, p+1, r);
}

Point nextToTop(stack<Point>& S){
    Point t = S.top();
    S.pop();
    Point r = S.top();
    S.push(t);
    return r;
}

void convexHull(vector<Point>& points){
    int ymin = 0, m = points.size();
    for(int i = 1; i < m; i++){
        if(points[i].y < points[ymin].y) ymin = i;
        else if(points[i].y == points[ymin].y && points[i].x < points[ymin].x) ymin = i;
    }
    swap(points[0], points[ymin]);
    quickSort(points, 1, m);
    int offset = 2;
    while(orientation(points[0], points[1], points[offset]) == 0) offset++;
    stack<Point> S;
    S.push(points[0]);
    for(int i = offset-1; i >= 1; i--) S.push(points[i]);
    for(int i = offset; i < m; i++){
        while(orientation(nextToTop(S), S.top(), points[i]) > 0){
            S.pop();
        }
        S.push(points[i]);
    }
    stack<Point> ans;
    while(!S.empty()){
        ans.push(S.top());
        S.pop();
    }
    cout << ans.size() << endl;
    while(!ans.empty()){
        cout << ans.top().x << " " << ans.top().y << endl;
        ans.pop();
    }
}

int main(){
    vector<Point> points;
    int n, x, y;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        points.push_back(Point(x, y));
    }
    convexHull(points);
}



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

int main(){
  int N, M, A, B;
  cin >> N >> M >> A >> B;
  if(N*M < 2*(A+B)){
    cout << "NO" << endl;
    return 0;
  }
  vector<string> ans(N,string(M,'.'));
  if(M%2){
    for(int i = 0; i < N; i += 2){
      if(i+1 >= N) break;
      if(!B) break;
      ans[i][M-1] = '^';
      ans[i+1][M-1] = 'v';
      --B;
    }
  }
  if(N%2){
    for(int j = 0; j < M; j += 2){
      if(!A) break;
      if(j+1 >= M) break;
      ans[N-1][M%2+j] = '<';
      ans[N-1][M%2+j+1] = '>';
      --A;
    }
  }
  for(int i = 0; i < N/2; ++i){
    for(int j = M/2-1; j >= 0; --j){
      if(A > 1){
        A -= 2;
        ans[2*i][2*j] = '<';
        ans[2*i][2*j+1] = '>';
        ans[2*i+1][2*j] = '<';
        ans[2*i+1][2*j+1] = '>';
      }else if(B > 1){
        B -= 2;
        ans[2*i][2*j] = '^';
        ans[2*i][2*j+1] = '^';
        ans[2*i+1][2*j] = 'v';
        ans[2*i+1][2*j+1] = 'v';
      }else if(A > 0){
        --A;
        ans[2*i][2*j] = '<';
        ans[2*i][2*j+1] = '>';
      }else if(B > 0){
        --B;
        ans[2*i][2*j+1] = '^';
        ans[2*i+1][2*j+1] = 'v';
      }
    }
  }
  if(B > 0 && N > 1 && ans[N-1][0] == '.' && ans[N-2][0] == '.'){
    ans[N-1][0] = 'v';
    ans[N-2][0] = '^';
    --B;
  }
  if(A || B){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for(int i = 0; i < N; ++i) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <ctime>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<ll> vl;
typedef vector< vector<ll> > vvl;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forv(i, v) forn(i, v.size())
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back

int main() {
#ifdef NEREVAR_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n; cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    ll ans = 0;
    forn(i, n) {
        ans += a[i] / 2;
        a[i] &= 1;
        if (a[i] == 1 && (i < n - 1 && a[i + 1])) {
            ans++;
            a[i] = 0;
            a[i + 1]--;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int mp[2][31][31]={};
int sai[7][4]= {{0,0,0,0},{3,5,4,2},{1,4,6,3},{1,2,6,5},{5,6,2,1},{3,6,4,1},{2,4,5,3}};
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

void die(int t,int f,int x,int y){
  int i,j,x2,y2,mx=3,f2,t2;
  mp[1][y][x]++;
  for(i=0;i<4;i++){
    if(sai[t][i]==f){
      for(j=i;j<i+4;j++){
	int m=j%4,x1=x+dx[j-i],y1=y+dy[j-i];
	if(mp[1][y][x]-1>mp[1][y1][x1]&&sai[t][m]>mx){
	  mx=sai[t][m],x2=x1,y2=y1,t2=7-mx;
	  if(j-i==2)f2=7-t;
	  else if(j-i==0)f2=t;
	  else f2=f;
	}
      }
      break;
    }
  }
  if(mx!=3)mp[1][y][x]--,die(t2,f2,x2,y2);
  else mp[0][y][x]=t;
}

int main(){
  while(1){
    int n;cin>>n;if(n==0)break;
    int i,j,t,f,c[7]={};
    for(i=0;i<n;i++){
      cin>>t>>f;
      die(t,f,15,15);
    }
    for(i=0;i<31;i++)
      for(j=0;j<31;j++){
	c[mp[0][i][j]]++;
	mp[0][i][j]=mp[1][i][j]=0;
      }
    for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,k,b,ans=0;
    int a[40]={};
    
    cin>>n>>m;
    
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>b;
            a[b]++;
        }
    }
    
    for(int i=0;i<=m;i++){
        if(a[i]==n) ans++;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	string s,t;
	cin>>s>>t;
	int count = 0;
	for(int i=0;i<3;i++)
		count+=(s[i]==t[i]);
	cout<<count;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << setw(4); cout << endl;}
#define shop(n,x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define ff first
#define ss second
#define sq(x) (x*x)
#define endl '\n'
#define en " "
#define pb push_back
#define mpair make_pair
ll mod=1000000007;
double pi=3.1415926536;
ll n, m;
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// go fast 		check		//		CHECK -> if()   else if()
		
		ll x=0, y=0, d=1, k=mod;
		cin >> n >> m;
		ll a[n + 1], v[n + 1];
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i] >> v[i];
			x += v[i];
		}
		ll dp[n + 1][x + 1];

		for(int i = 0; i <= n; i++)
			for(int j = 0; j <= x; j++)
				dp[i][j] = -1,dp[i][0] = 0;
	//	shop(x, i);
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= x; j++)
			{
				if(j >= v[i])
				{
					if(dp[i - 1][j - v[i]] == -1 || dp[i - 1][j] == -1)
					{
						if(dp[i - 1][j - v[i]] == -1)
							dp[i][j] = dp[i - 1][j];
						else
							dp[i][j] = a[i] + dp[i - 1][j - v[i]];
					}					
					else
						dp[i][j] = min(a[i] + dp[i - 1][j - v[i]], dp[i - 1][j]);
				}
				else
					dp[i][j] = dp[i - 1][j];
			}
		}
		for(int i = 0; i <= x; i++)
			if(dp[n][i] > 0 && dp[n][i] <= m)
				y = i;

		cout << y << endl;
	//	for(int i = 0; i <= n; i++)
	//		show(dp[i]);
	}
}	

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

ll p(ll a , ll b)
{
    ll ans = 1 ;
    while(b)
    {
        if(b%2)
        {
            ans *= a ;
        }
        a *= a ;
        b /= 2 ;
    }
    return ans ;
}

int main()
{
    ll n , a[200010] , ans = 0 ;
    cin >> n ;
    for(int i = 0 ; i < n ; i++)
    {
         cin >> a[i] ;
         if(i > 0)
         {
              if(a[i] < a[i-1])
              {
                   ans += (a[i-1]-a[i]) ;
                   a[i] = a[i-1] ;
              }
         }
    }
    cout << ans << endl ;
}


Measured memory_bytes: 5192
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int p = 0;
        int a;
        int b;
        int z;
        int m;
        a = x;
        b = y;
        while (x % y != 0) {
            z = x;
            x = y;
            y = z % y;
        }
        m = a + b - y;

        if (a % 2 == 0 || b % 2 == 0 || a == b || a % 2 > 0 && b % 2 > 0) {
            System.out.println(m + 1);
        } else {
            System.out.println(m);
        }

    }
}



Measured memory_bytes: 26312
p = input()
a = map(int, raw_input().strip().split())
b = [0] * p

p2 = p * p

s = []
for i in xrange(p):
    if a[i]: s.append(i)

ncr = [[0 for i in xrange(p)] for j in xrange(p)]

for i in xrange(p):
    ncr[i][0] = ncr[i][i] = 1
    ncr[i][1] = i

for n in xrange(2, p):
    for r in xrange(2, n):
        ncr[n][r] = ncr[n - 1][r] + ncr[n - 1][r - 1]
        if (ncr[n][r] >= p): ncr[n][r] -= p

jpow = [[0 for i in xrange(p)] for j in xrange(p)]
jpow[0][0] = 1

for i in xrange(1, p):
    val = 1
    for j in xrange(p):
        jpow[i][j] = val
        val *= i
        if (val >= p2): val %= p

for r in xrange(1, p):
    for j in s:
        x = ncr[p - 1][r]
        x *= jpow[j][p - 1 - r]
        if (x >= p2): x %= p

        if (p - r) & 1: b[r] -= x
        else: b[r] += x

    if b[r] >= p or b[r] < 0: b[r] %= p

if a[0]: b[0] = 1

print ' '.join(map(str, b))

Measured memory_bytes: 175004
#include<bits/stdc++.h>
using namespace std;
int roundof(float a)
{
    return a;
}
int main()
{
    int a,b;
    cin>>a>>b;
    int n=0;
    for(int i=1; i<=1009; i++)
    {
        if(roundof(i*0.08)==a && roundof(i*0.1)==b)
        {
            cout<<i<<endl;
            n++;
            break;
        }
    }
    if(n==0)
        cout<<"-1"<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String S = scan.next();

		int total = 0;

		String S1 = S.substring(0,1);
		String S2 = S.substring(1,2);
		String S3 = S.substring(2,3);

		int count = 0;
		while(count < 1)
		{
			if((S1 + S2 + S3).equals("RRR"))
			{
				total += 3;
				break;
			}

			if((S1 + S2).equals("RR") || (S2 + S3).equals("RR"))
			{
				total += 2;
				break;
			}

			if(S1.equals("R") || S2.equals("R") || S3.equals("R"))
			{
				total += 1;
				break;
			}
			count++;
		}

		System.out.println(total);

		scan.close();
	}
}


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

const int INF = 1001001001;

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  long long ans = 0;
  int neg = 0;
  rep(i,n) {
    ans += abs(a[i]);
    if (a[i] < 0) neg++;
  }
  if (neg%2 == 1) {
    int minA = INF;
    rep(i,n) minA = min(minA, abs(a[i]));
    ans -= minA*2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
    int N; cin >> N;
    cout << ((N + 999) / 1000) * 1000 - N << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    
	 long long n,i,j,k,sum=0,count=0,ans=0,x,y,l,r,m;
     cin>>n;
     for(i=-600;i<=600;i++)
     {
         count=(i*i*i*i*i);
         for(j=-600;j<=600;j++)
         {
             sum=(j*j*j*j*j);
             if((count-sum)==n)
             {
                 cout<<i<<" "<<j; return 0;
             }
         }
     }
    
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 100100; 

int n,cnt,ans;
int a[maxn],col[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	memset(col,0,sizeof(col));
	cnt=0,ans=0;
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read(); 
		if(a[i]<3200) col[a[i]/400]++;
		else col[8]++;
	}
	
//	for(int i=0;i<=8;i++) printf("%d ",col[i]); printf("\n"); 
	
	for(int i=0;i<=7;i++){
		if(col[i]) cnt++;
	}
	
	if(cnt!=0){
		printf("%d %d\n",cnt,cnt+col[8]);
	}else{
		printf("%d %d\n",1,col[8]);
	}

	return 0;
}

Measured memory_bytes: 4088
#include <stdio.h>
typedef unsigned long long ull;

int
main(void)
{
	ull A, B, C, D;
	scanf("%llu %llu %llu %llu", &A, &B, &C, &D);
	ull c = C, d = D;
	ull x = C * D;

	if (C < D) {
		ull tmp = C;
		C = D;
		D = tmp;
	}

	ull r = C % D;
	while (r != 0) {
		C = D;
		D = r;
		r = C % D;
	}

	ull lcm = x / D;
	A--;
	ull res = (B / c + B / d - B / lcm) -
	    (A / c + A / d - A / lcm);
	printf("%llu\n", (B - A) - res);
	return (0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a[100010],b[100010],sum=0;
    scanf("%lld",&n);
    for(int i=0;i<n+1;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&b[i]);
    }
    for(int i=0;i<n;i++)
    {
        long long p=a[i]+a[i+1];
        if(p>=b[i])
        {
            sum+=b[i];
            if(b[i]>a[i])
            {
                a[i+1]-=b[i]-a[i];
            }

        }
        else
        {
            sum+=p;
            a[i+1]=0;
        }
    }
    printf("%lld\n",sum);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n,m,x;
  cin >> n>>m>>x;
  vi c(n);
  vii a(n, vi(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }
  ll ans = INF;
  for (int tmp = 0; tmp < (1 << 12); tmp++){
    vi t(m,0);
    ll money = 0;
    bitset<12> s(tmp);
    // ビット列を出力
    rep(i,n){
      if(s[i]){
        money += c[i];
        rep(j,m){
          t[j] += a[i][j];
        }
      }
    }
    bool z = true;
    rep(i,m){
      if(t[i]<x){
        z = false;
      }
    }
    if(z){
      chmin(ans, money);
    }
  }
  if(ans==INF){
    print(-1);
  }
  else{
    print(ans);
  }
}

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

ll dp[110][100105];
int w[110], v[110];
int main(){
    int n, W;
    cin >> n >> W;
    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= W; j++){
            if(j >= w[i]) dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    } 
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 79360
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
while m>0:
  a[0]//=2
  for i in range(1, m):
    if i<n and a[i] >= a[0]:
      a[i]//=2
    else:
      a.sort(reverse=True)
      m-=i
      break
  else:
    break
print(sum(a))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    vector<pair<double, string>> d(N);
    REP(i, N) cin >> d[i].first >> d[i].second;

    double BTC = 380000.0;
    double ans = 0.0;
    REP(i, N) {
        if (d[i].second == "JPY") {
            ans += d[i].first;
        } else {
            ans += BTC * d[i].first;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d %d",$n,$m);
  $count = 0;
  for($i=1; $i<$n; $i++){
    $count += $i;
  }
  for($i=1; $i<$m; $i++){
    $count += $i;
  }
  echo $count."\n";

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

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
//const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int digitlen(long long i){
    long long t = i;
    int count = 0;
    while(t){
        count += 1;
        t /= 10;
    }
    return count;
}

vector<int> cumsum(vector<int> arr){
    vector<int> ret;
    int l = arr.size();
    ret.push_back(arr[0]);
    for(int i = 1; i < l; i++){
        ret.push_back(ret[i-1] + arr[i]);
    }
    return ret;
}

vector<int> eratosthenes(int n){
    int arr[n+1];
    rep(i,0,n+1){
        arr[i] = 1;
    }
    arr[0] = 0; arr[1] = 0;
    for(int i = 2; i < n; i++){
        if(arr[i]==1){
            for(int j = 2*i; j < n+1; j+=i){
                arr[j] = 0;
            }
        }
    }
    
    vector<int> ret;
    for(int i = 2; i<n+1; i++){
        if(arr[i] == 1){
            ret.push_back(i);
        }
    }
    return ret;

}


int main(){
    while(true){
        int n,m;
        cin >> n >> m;
        if(n == 0 && m == 0) return 0;
        int r;
        cin >> r;

        int arr[m][720];

        rep(i,0,m){
            rep(j,0,720){
                arr[i][j] = 0;
            }
        }

        rep(i,0,r){
            int t,n,m,s;
            cin >> t >> n >> m >> s;
            if(s == 1){
                arr[m-1][t-540] += 1;
            }else{
                arr[m-1][t-540] -= 1;
            }
        }

        rep(i,0,m){
            rep(j,1,720){
                arr[i][j] = arr[i][j-1] + arr[i][j]; 
            }
        }

        int q;
        cin >> q;

        rep(i,0,q){
            int ans = 0;
            int ts,te,m;
            cin >> ts >> te >> m;
            rep(j,ts-540,te-540){
                if(arr[m-1][j] > 0) ans++;
            }
            cout << ans << endl;
        }

    }

}




Measured memory_bytes: 30192
# coding: utf-8
while True:
    n,x = map(int, input().split())
    
    if n == x == 0:
        break
    
    list = [i for i in range(1,n+1)]
    count = 0
    
    for i in list:
        for j in list[i:]:
            k = x - (i + j)
            if list[j:].count(k) == 1:
                count += 1
                
    print(count)

Measured memory_bytes: 7668
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

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

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}

int main() {

	int n;
	cin >> n;
	vector<ll> a(n);

	ll t = 1LL;

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

	t--;

	ll ans = 0;

	for (int i = 0; i < n; i++)
	{
		ans += a[i] - 1;
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    int N = sc.nextInt();
    int L = sc.nextInt();
    String[] S = new String[N];
    
    for(int i = 0; i < N; i++) {
        String token = sc.next();
        if(token.length() == L) S[i] =  token;
    }
    Arrays.sort(S);
    System.out.println(String.join("",S));
  }
}


Measured memory_bytes: 24148
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>
#include<limits>
typedef long long ll;
using namespace std;
#define mp(a,b) make_pair(a,b)
#define rep(i,n) for (size_t i = 0; i < (n); ++i)
/*
  m = y+z + (e- y^2 - z^3)
  = e + y -y^2 + z- z^3;
*/



int main(){
  int e;
  while(  cin >> e and e != 0){
    int ans = e;
    for(int z = 0;z < 101;z++){
      int m = e;
      m -= z*z*z;
      if(m < 0)break;
      for(int y = 0;y < 1000;y++){
	int m2 = m;
	m2 -= y*y;
	if(m2 < 0)break;
	ans = min(m2+y+z,ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160