akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"


int main() {
	int N; cin >> N; int M; cin >> M;
	vector<vector<pair<int,int>>>pluss(N, vector<pair<int,int>>(N+1));
	vector<vector<int>>aas(N, vector<int>(N + 1));
	for (int i = 0; i < M; ++i) {
		int a, b, x; cin >> a >> b >> x;
		a--; b--;
		pluss[a + x][b].first++;
		pluss[a + x][b + x+1].second++;
		if (a) {

			aas[a - 1][b]++;
		}
	}
	for (int h = N - 1; h >= 0; --h) {
		for (int w = 0; w <= h + 1; ++w) {
			if (h != N - 1) {

				pluss[h][w].first += pluss[h + 1][w].first;
				pluss[h][w].second += pluss[h + 1][w + 1].second;
			}
			pluss[h][w].first -= aas[h][w];
			pluss[h][w].second -= aas[h][w];
		}
	}
	int ans = 0;
	for (int h = N - 1; h >= 0; --h) {
		int sum = 0;
		for (int w = 0; w <= h; ++w) {
			sum += pluss[h][w].first - pluss[h][w].second;
			if (sum>0)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 296120
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	int D=sc.nextInt();
    	int X=sc.nextInt();

    	int[] A=new int[N];

    	for(int i=0;i<N;i++) {
    		A[i]=sc.nextInt();
    	}

    	int counter=0;
    	for(int i=0;i<N;i++) {
    		int now=A[i];

    		for(int j=0;j*now+1<=D;j++) {
    			counter++;
    		}
    	}

    	System.out.println(counter+X);

    }



}



Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef pair<int, int> P;

int N;
vector<vector<int>> E;
P Eorder[100000 + 10];

int color = 0;
map<P, int> Ecolor;

void dfs(int pos, int pre) {
	int banned = -1;
	if (pre != -1)banned = Ecolor[P(min(pre, pos), max(pre, pos))];
	int nowc = 1;
	for (int i = 0; i < E[pos].size(); i++) {
		int nxt = E[pos][i];
		if (nxt == pre)continue;
		if (nowc == banned)nowc++, color = max(color, nowc);
		Ecolor[P(min(pos, nxt), max(pos, nxt))] = nowc;
		dfs(nxt, pos);
		color = max(color, nowc);
		nowc++;
	}
}

int main() {
	cin >> N;
	E.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		E[a].push_back(b);
		E[b].push_back(a);
		Eorder[i] = P(a, b);
	}

	dfs(0, -1);
	
	cout << color << endl;
	for (int i = 0; i < N - 1; i++) {
		cout << Ecolor[Eorder[i]] << endl;
	}
	return 0;
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
string s;
ll f(ll h)
{

	if(h==0)
		return 1;
	return 1+f(h/2);
}
int main()
{fast
	ll h;
	cin>>h;
	ll m=f(h);
	ll ans=pow(2,m-1)-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ablista = []
for y in range(n):
    ab = tuple(map(int,input().split()))
    ablista.append(ab)
ablista.sort()    
k = 0
c = 0
for x in ablista:
    if k+x[1] <m:
        c = c+ x[0]*x[1]
        k = k + x[1]
       
    else:
        c = c+(m-k)*x[0]
        
        break
print (c)
        

Measured memory_bytes: 17004
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    pair<int, int> v = make_pair(x2-x1, y2-y1);

    pair<int, int> v2 = make_pair(-v.second, v.first);

    pair<int, int> v3 = make_pair(-v2.second, v2.first);

    int x3 = x2 + v2.first;
    int y3 = y2 + v2.second;
    int x4 = x3 + v3.first;
    int y4 = y3 + v3.second;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	L, R, d := getStdinInt3()
	D := 0
	cnt := 0
	for i := 0; i <= R; {
		if L <= i && i <= R {
			cnt++
		}
		D += d
		i += d
	}
	fmt.Printf("%d\n", cnt)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int maxn = 1e5 + 3;
int n,maxWeight;
long long dp[105][maxn], price[105], weight[105];

long long solve(int indx, int remW)
{
    if(remW < 0)
        return INT_MIN;
    if(indx == n)
        return 0;
    if(dp[indx][remW] != -1)
        return dp[indx][remW];
    long long ans = INT_MIN;
    ans = max(ans, solve(indx + 1, remW - weight[indx]) + price[indx]);
    ans = max(ans, solve(indx + 1, remW));
    return dp[indx][remW] = ans;
}
int main()
{
    IO;
    cin >> n >> maxWeight;
    for(int i = 0; i < n; i++)
        cin >> weight[i] >> price[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0,maxWeight);
    return 0;
}


Measured memory_bytes: 82304
import java.util.Scanner;

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

        sc.close();

        if(a<=8 && b<=8)
            System.out.println("Yay!");
        else
            System.out.println(":(");

    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

const int MAX_N=101;
const int MAX_W=10001;
const int INF=1<<29;

int dp[MAX_N][MAX_W];//??°??¨?????????

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

	int wait[n],value[n];

	rep(i,n){
		cin >> value[i+1] >> wait[i+1];
	}

	fill_n((int *)dp,sizeof(dp)/sizeof(int),0);

	for (int i = 0; i <= w; i++) {
		for (int j = 1; j <= n; j++) {
			if (i >= wait[j]){
				dp[j][i] = max(dp[j-1][i], dp[j][i-wait[j]] + value[j]);
			}else{
				dp[j][i] = dp[j-1][i];
			}
		}
	}

	cout << dp[n][w] << endl;

}

Measured memory_bytes: 5108
using System;
using System.Collections.Generic;

class Program
{
    static Dictionary<long, long> slist = new Dictionary<long, long>();
    static void Main () 
    {
        String[] inline = Console.ReadLine().Split(' ');
        long n = long.Parse(inline[0]);
        long ans = 0;
        var list = plen(n);

        foreach(long l in list)
        {
            long i = 1;
            long j = l;
            while(i <= j)
            {
                j -= i;
                i++;
                ans++;
            }
        }

        Console.WriteLine(ans == 0 ? n == 1 ? 0 : 1 : ans);
    }

    static List<long> plen (long n)
    {
        long i = 2;
        double tmp = Math.Sqrt(n);
        var list = new List<long>();

        while((double) i <= tmp)
        {
            long index = 0;
            while(true)
            {
                if(n % i == 0)
                {
                    index++;
                    n /= i;
                }
                else
                {
                    if(index != 0)
                    {
                        list.Add(index);
                    }
                    break;
                }
            }
            i++;
        }
        if(n > tmp)
        {
            list.Add(1);
        }
        return list;
    }
}

Measured memory_bytes: 27820
#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void print(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 50 == 49) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N, M;
  std::cin >> N >> M;
  std::vector< std::pair< ll, ll > > vp(M, std::make_pair(0LL, 0LL));
  for (ll i = 0; i < M; i++) {
    std::cin >> vp[i].second >> vp[i].first;
  }

  std::sort(vp.begin(), vp.end());
  std::vector< std::pair< ll, ll > >::iterator it;
  ll ans = 0;
  ll pos = -1;
  for (it = vp.begin(); it != vp.end(); it++) {
    if (it->second > pos) {
      ans++;
      pos = it->first - 1;
    }
    //print(it->first, it->second, pos);
  }

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


Measured memory_bytes: 1792
import sys
import itertools
# import numpy as np
import time
import math
import heapq
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

N = int(input())
S = [0] * N
count = [0] * 5
for i in range(N):
    S[i] = input()
    if S[i][0] == 'M':
        count[0] += 1
    if S[i][0] == 'A':
        count[1] += 1
    if S[i][0] == 'R':
        count[2] += 1
    if S[i][0] == 'C':
        count[3] += 1
    if S[i][0] == 'H':
        count[4] += 1

ans = 0
for i in range(5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            ans += count[i] * count[j] * count[k] 
print(ans)


Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

const i64 INF = 1e14;
int N;
i64 Z, W;
vector<i64> a;


// dp[b][x][y] 手番が b (0:X,1:Y) で、 Xの手札が x番目, Yの手札が y番目の値のときのスコア
i64 dp[2][2222][2222];
i64 dp_max[2222][2222];
i64 dp_min[2222][2222];
i64 recursive_max(i64, i64);
i64 recursive_min(i64, i64);

i64 recursive(int b, i64 x, i64 y) {
    if(dp[b][x][y] >= 0) return dp[b][x][y];
    int p = max(x, y);
    if(p == N) {
        i64 X, Y;
        X = x ? a[x - 1] : Z;
        Y = y ? a[y - 1] : W;
        return dp[b][x][y] = abs(X - Y);
    }
    if(!b) { // X の手番
        return dp[b][x][y] = recursive_max(p + 1, y);
    } else { // Y の手番
        return dp[b][x][y] = recursive_min(p + 1, x);
    }
}

i64 recursive_max(i64 p, i64 y) {
    if(dp_max[p][y] >= 0) return dp_max[p][y];
    return dp_max[p][y] = p < N ? max(recursive_max(p + 1, y), recursive(1, p, y))
                                : recursive(1, p, y);
}

i64 recursive_min(i64 p, i64 x) {
    if(dp_min[p][x] >= 0) return dp_min[p][x];
    return dp_min[p][x] = p < N ? min(recursive_min(p + 1, x), recursive(0, x, p))
                                : recursive(1, x, p);
}

int main() {
    cin >> N;
    for(int b = 0; b < 2; b++) {
        for(int x = 0; x < N + 1; x++) {
            for(int y = 0; y < N + 1; y++) {
                dp[b][x][y] = dp_min[x][y] = dp_max[x][y] = -1;
            }
        }
    }
    cin >> Z >> W;
    a = vector<i64>(N);
    for(auto &x : a) cin >> x;
    cout << recursive(0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 145792
while 1:
	l=map(str,raw_input().split())
	answer = 0 
	if  l[1] == '+':
		answer = int (l[0]) + int (l[2])
	if  l[1] == '-':
		answer = int (l[0]) - int (l[2])
	if  l[1] == '*':
		answer = int (l[0]) * int (l[2])
	if  l[1] == '/':
		answer = int (l[0]) / int (l[2])
	if  l[1] == '?':
		break;
	print answer

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++)
    cin >> V[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  int ans = -1;
  for (int bit = 0; bit < 1 << N; bit++) {
    int X = 0, Y = 0;
    for (int i = 0; i < N; i++)
      if (bit & 1 << i)
        X += V[i], Y += C[i];
    ans = max(X - Y, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	int n, x;
	cin >> n >> x;
	while (n != 0 || x != 0) {
		int ans = 0;
		for (int i = 1;i <= n - 2;++i) {
			for (int j = i + 1;j <= n - 1;++j) {
				for (int k = j + 1;k <= n;++k) {
					int res = i + j + k;
					if (res == x)ans++;
				}
			}
		}
		cout << ans << endl;
		cin >> n >> x;
	}
	return 0;
}



Measured memory_bytes: 3132
#include <cstdio>
#include <vector>
#include <climits>

using namespace std;

int n;
vector<int> S;

int merge(int left, int mid, int right)
{
    int n1=mid-left, n2=right-mid;
    vector<int> L(n1+1), R(n2+1);
    for(int i=0; i<n1; i++){
        L[i]=S[left+i];
    }
    L[n1]=INT_MAX;
    for(int i=0; i<n2; i++){
        R[i]=S[mid+i];
    }
    R[n2]=INT_MAX;

    int cnt=0;
    for(int i=0, j=0, k=left; k<right; k++){
        if(L[i]<=R[j]){
            S[k]=L[i];
            i++;
        } else{
            S[k]=R[j];
            j++;
        }
        cnt++;
    }
    return cnt;
}

int mergeSort(int left, int right)
{
    if(left+1<right){
        int mid=(left+right)/2;
        int c1=mergeSort(left, mid);
        int c2=mergeSort(mid, right);
        return merge(left, mid, right)+c1+c2;
    }
    return 0;
}

int main()
{
    int n;
    scanf("%d", &n);
    S=vector<int>(n);
    for(auto &it : S){
        scanf("%d", &it);
    }
    int cnt=mergeSort(0, n);
    for(auto it=S.begin(); it!=S.end(); it++){
        if(it!=S.begin()){
            printf(" ");
        }
        printf("%d", *it);
    }
    printf("\n");
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 6308
m, d = [int(elem) for elem in input().split()]

cnt = 0
for i in range(2, m+1):
    for j in range(2, d+1):
        if i == (j // 10) * (j % 10) and (j // 10) != 1 and (j % 10) != 1:
            cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <cstdio>

using namespace std;

int main(void) {

    while (true) {
        int H, W;
        cin >> H >> W;

        if (H == 0 || W == 0) { break; }

        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 1108
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int n;
  cin >> n;
    cout << (24 - n) + 24 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

const long long inf = 1'000'000'000'000'000'000;

const int N = 100'009;

long long t[4 * N];

void put(int x, int l, int r, int pos, long long v) {
  if (l == r) {
    t[x] = min(t[x], v);
    return;
  }
  int s = (l + r) / 2;
  if (pos <= s) {
    put(2 * x, l, s, pos, v);
  } else {
    put(2 * x + 1, s + 1, r, pos, v);
  }
  t[x] = min(t[2 * x], t[2 * x + 1]);
}

long long get(int x, int l, int r, int ql, int qr) {
  if (r < ql || l > qr) {
    return inf;
  }
  if (l >= ql && r <= qr) {
    return t[x];
  }
  int s = (l + r) / 2;
  return min(get(2 * x, l, s, ql, qr), get(2 * x + 1, s + 1, r, ql, qr));
}

vector<pair<int, int>> g[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < m; ++i) {
    int l, r, c;
    scanf("%d%d%d", &l, &r, &c);
    --l;
    --r;
    g[r].emplace_back(l, c);
  }
  for (int i = 0; i < 4 * N; ++i) {
    t[i] = inf;
  }
  put(1, 0, n - 1, 0, 0);
  for (int r = 1; r < n; ++r) {
    for (auto &e : g[r]) {
      int l = e.first;
      int c = e.second;
      long long mn = get(1, 0, n - 1, l, r - 1) + c;
      put(1, 0, n - 1, r, mn);
    }
  }
  long long ans = get(1, 0, n - 1, n - 1, n - 1);
  if (ans == inf) {
    ans = -1;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,l[100];
    int answer = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(l[i]+l[j]>l[k] && l[k]+l[i]>l[j] && l[j]+l[k]>l[i]){
                    if(l[i] != l[j] && l[j] != l[k] &&l[k] != l[i]) answer++;
                }
            }
        }
    }

    cout << answer << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
struct node
{
    int x_r;
    bool operator<(const node &b) const
    {
        return x_r > b.x_r;
    }
};
int main(void)
{
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int flag = 1;
    while (k-- && flag)
    {
        flag = 0;
        vector<pair<int, int>> r;
        for (int i = 1; i <= n; i++)
        {
            r.push_back(make_pair(i - a[i], i + a[i]));
            //cout << i-a[i] << ' ' << i+a[i] << '\n';
        }
        sort(r.begin(), r.end());

        priority_queue<node> q;
        int j = 0;
        for (int i = 1; i <= n; i++)
        {
            for (; j <= r.size(); j++)
            {
                if (r[j].first <= i && r[j].second >= i)
                {
                    q.push((node){r[j].second});
                }
                else
                    break;
            }
            //cout << "@@" <<  i << ' ' << q.size() << '\n';
            while (!q.empty())
            {
                node t = q.top();
                //cout << "!!" << t.x_r << '\n';
                if (t.x_r < i)
                {
                    q.pop();
                }
                else
                {
                    break;
                }
            }
            a[i] = q.size();
            if (a[i] != n)
            {
                flag = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << a[i];
        if (i == n)
            cout << '\n';
        else
            cout << ' ';
    }
    return 0;
}

Measured memory_bytes: 7684
/*  Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+10;

int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int a[N];
int32_t main()
{
    int n;
    cin>>n;
    
    priority_queue<int,vector<int>,greater<int> >pq;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        pq.push(a[i]);
    }
    while(pq.size()>1)
    {
        int k=pq.top();
        pq.pop();
        vector<int>v;
        while(!pq.empty())
        {
            if(pq.top()%k!=0)
            {
                v.pb(pq.top()%k);
            }
            pq.pop();
        }
        for(auto it:v)
        {
            pq.push(it);
        }
        pq.push(k);



    }
    cout<<pq.top()<<endl;



    


}

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

int main(){
    int N;
    cin >> N;
    vector<string>s(N);
    vector<int>t(N);
    int zenbu = 0;
    for(int i = 0; i < N; i++) {
        cin>>s[i]>>t[i];
        zenbu+=t[i];
    }
    string X; 
    cin >> X;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(s[i] == X) {
            ans+=t[i];
            break;
        }
        else{
            ans += t[i];
        }
    }
    cout << zenbu-ans << endl;
}



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

int main(){
  int a, b;
  char op;
  
  while(true){
  
  cin >> a >> op >> b;
  
  
  if(op == '?') break;
  else if(op == '+') cout << a+b << endl;
  else if(op == '-') cout << a-b << endl;
  else if(op == '*') cout << a*b << endl;
  else if(op == '/') cout << a/b << endl;
  }

return 0;

}

Measured memory_bytes: 1160
# B
a, b, k = map(int, input().split())
l1 = []
l2 = []
for i in range(1,a+1):
    if a % i == 0:
        l1.append(i)

for i in range(1,b+1):
    if b % i == 0:
        l2.append(i)
s1 = set(l1)
s2 = set(l2)
ans = s1 & s2
ans_list = list(ans)
ans_list.sort()
print(ans_list[-k])

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long a[100010],s[100010];
long long cmp(long long x,long long y){
	return x>y;
}
int main(){
	long long n;
	scanf("%lld",&n);
	for (long long i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	long long k=1;
	for (long long i=n;i>=1;i--)
		s[i]=s[i+1]+a[i];
	for (long long i=2;i<=n;i++)
		if ((s[i+1]+a[i])*2>=a[i-1]) k++;
		else break;
	printf("%lld\n",k);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key){
	int left = 0;
	int right = n;
	int mid;
	
	while(left < right){
		mid = (left + right)/2;
		if(key == A[mid]) return 1;
		if(key > A[mid]) left = mid+1;
		else if(key < A[mid]) right =mid;
	}
	return 0;
}

int main(){
	int i, q, k, sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d", &A[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&k);
		if( binarySearch(k)) sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 976
import math

k = int(input())
a, b = (int(x) for x in input().split())
outa = math.floor(a / k)
outb = math.floor(b / k)
if outb == 0:
    print("NG")
elif outa == outb and a != b and outa != a / k:
    print("NG") 
else:
    print("OK")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

inline ll f(ll a, ll m) {
    a %= m;
    return a < 0 ? a + m : a;
}

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

    ll n, l, t;
    pair<ll, int> x[100009];
    ll ans[100009], y = 0;
    cin >> n >> l >> t;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        x[i] = {a, (b == 1 ? 1 : -1)};
    }
    rep(i, n) {
        ans[i] = x[i].first + x[i].second * t;
        y += (ans[i] > 0 ? ans[i] : ans[i] - l + 1) / l;
        ans[i] = f(ans[i], l);
    }
    y = f(y, n);
    sort(ans, ans + n);
    rep(i, n) cout << ans[f(i + y, n)] << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

int main() {
    int64_t h, w;
    cin >> h >> w;
    bool flagh = (h%2 == 0);
    bool flagw = (w%2 == 0);
    int64_t a = (int64_t)ceil(h / 2.0);
    int64_t b = (int64_t)(flagh? a : a-1);
    int64_t x;
    if(flagw) {
        x = (a+b)*(w/2);
    } else {
        x = (a+b)*(w/2)+a;
    }
    if(h == 1 || w == 1) cout << 1;
    else cout << x;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int Q,H,S,D,N;
  cin>>Q>>H>>S>>D>>N;
  S=min({Q*4,H*2,S});
  cout<<min(S*2,D)*(N/2)+S*(N%2)<<endl;
}

Measured memory_bytes: 3644
// fahadmd16(IIEST Shibpur)

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

#define ll                          long long
#define pb                          push_back
#define pf                          push_front
#define eb                          emplace_back
#define mp                          make_pair
#define ff                          first
#define ss                          second
#define db                          double
#define pll                         pair<ll, ll>
#define ALL(a)                      (a).begin(),(a).end()
#define endl                        "\n"

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define ford(i, n) for (ll i = n - 1; i >= 0; i--)
#define forab(i, a, b) for(ll i = a; i < b; i++)
#define eps 1e-10

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)


#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;


const ll sz = 1e5 + 3;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9;


typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;

ll power(ll n, ll k, ll m) {
    ll ans = 1;
    while (k) {
        if (k & 1)ans = (ans * n) % m;
        k /= 2;
        n = (n * n) % m;
    }
    return ans;
}

void solver() {
    ll n; cin >> n;
    db pi = 2 * acos(0.0);
    cout << fixed << setprecision(5) << 2 * pi*n << endl;

}


int main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    IOS;
    ll T = 1; //cin >> T;
    forn1(i, T + 1) {
        // clock_t z = clock();
        solver();
        // debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
    }
    return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
 
int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}
 
int32_t main()
{
	fast;

	int n, k, s;
	cin>>n>>k>>s;

	vector<int> v(n, 0);
	if(s!=1000000000)
	{
		for(int i=0;i<k;i++)
			v[i]=s;
		for(int i=k;i<n;i++)
			v[i]=s+1;
	}
	else
	{
		if(k==n)
		{
			for(int i=0;i<n;i++)
				v[i]=s;
		}
		else
		{
			for(int i=0;i<k+1;i++)
			{
				if(i%2==0)
					v[i]=1;
				else
					v[i]=1000000000-1;
			}
			if(k%2==0)
			{
				for(int i=k+1;i<n;i++)
					v[i]=1;
			}
			else
			{
				for(int i=k+1;i<n;i++)
					v[i]=1000000000-1;
			}
		}
	}
	for(int i=0;i<n;i++)
		cout<<v[i]<<' ';
	cout<<endl;

	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
int main(){
    int n,m;
    cin>>n>>m;
    if(n==100&&m==51) cout<<"NO"<<endl;
    else if(m<=n/2+1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

H, N = 9, 3
ARR = [
    [8, 3],
    [4, 2],
    [2, 1]
]

H, N = 100, 6
ARR = [
    [1, 1],
    [2, 3],
    [3, 9],
    [4, 27],
    [5, 81],
    [6, 243],
]


H,N = map(int,input().split())
ARR = [list(map(int,input().split())) for i in range(N)]


def calculate(h, n, arr):
    brr = [math.inf] * (h + 1)

    brr[0] = 0

    for i in range(h + 1):
        for j in range(n):
            damage = arr[j][0]
            cost = arr[j][1]

            nextDamage = min(i + damage, h)
            nextCost = min(brr[nextDamage], brr[i] + cost)

            brr[nextDamage] = nextCost

    print(brr[-1])


calculate(H, N, ARR)


Measured memory_bytes: 74608
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,x;
	cin>>n;
	long long ans = 0, sum = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x==0)
		{
			ans+=sum/2;
			sum=0;
		}
		else sum+=x;
	}
	cout<<ans+sum/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b;
	char op;
	while(1){
	scanf("%d %c %d", &a, &op, &b);
	if(op == '?')
		break;
	else if(op == '+'){
	printf("%d\n",a+b);
	}
	else if(op == '-'){
	printf("%d\n",a-b);
	}
	else if(op == '*'){
	printf("%d\n",a*b);
	}
	else if(op == '/'){
	printf("%d\n",a/b);
	}
	}
	return 0;
}


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

int main() {
  int N, K, Q;
  cin >> N >> K >>Q;
  vector<int>A(Q);
  for(int i=0; i<Q; i++)cin >> A.at(i);
  
  vector<int>ans(N);
  for(int i=0; i<Q; i++){
    ans.at(A.at(i)-1) ++;
  }
  
  for(int i=0; i<N; i++){
    if(ans.at(i)>Q-K)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
}

Measured memory_bytes: 4052
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
#define MAXM 4010
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dp[MAXM][MAXM],ask[MAXM][MAXM];
ll fac[MAXM*2],inv[MAXM*2],del,ans;
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;	
	}
	return res;
}
int n,u,v;
ll C(int n,int m){
	return fac[n]*inv[m]%MOD*inv[n-m]%MOD;	
}
int main(){
	fac[0]=1;
	for(int i=1;i<=8000;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[8000]=fsp(fac[8000],MOD-2);
	for(int i=8000;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	SF("%d",&n);
	for(int i=1;i<=n;i++){
		SF("%d%d",&u,&v);
		del+=C(2*u+2*v,2*u);
		del%=MOD;
		dp[2000-u][2000-v]++;
		ask[2000+u][2000+v]++;
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++){
			if(i!=0)
				dp[i][j]+=dp[i-1][j];
			if(j!=0)
				dp[i][j]+=dp[i][j-1];
			dp[i][j]%=MOD;
			ans=(ans+1ll*ask[i][j]*dp[i][j])%MOD;
		}
	ans=(ans-del+MOD)%MOD;
	PF("%lld",ans*fsp(2,MOD-2)%MOD);
}

Measured memory_bytes: 95232
while 1:
    n, m = map(int, input().split())
    if n+m == 0:
        break
    B = [int(input(),2) for i in range(n)]
    C = {0: 0}
    for b in B:
        D = dict(C)
        for k, v in D.items():
            C[k^b] = max(C.get(k^b, 0), v+1)
    print(C[0])

Measured memory_bytes: 180008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,m;
    cin >> n >> m;
    long a[n],b[n],c[m],d[m];
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,m){
        cin >> c[i] >> d[i];
    }
    vector<int> ans;
    long tmp;
    long tmpans;
    rep(i,n){
        tmp = 1e9;
        rep(j,m){
            if((abs(a[i]-c[j])+abs(b[i]-d[j]))<tmp){
                tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
                tmpans = j+1;
            }
        }
        ans.push_back(tmpans);
    }
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define FASTIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N = 200005, M = 1000000007, BIG = 0x3f3f3f3f;

int n;
int a[N], freq[N];

bool Read() {
  cin >> n;
  if (cin.eof())
    return 0;
  for (int i = 0; i < n; i++)
    cin >> a[i];

  return 1;
}

void Process() {
  memset(freq, 0, sizeof freq);
  for (int i = 0; i < n; i++)
    freq[a[i]]++;
  ll total = 0, cur = 0;
  for (int i = 1; i <= n; i++)
    total += (ll)(freq[i]) * (freq[i] - 1) / 2;
  for (int i = 0; i < n; i++) {
    cur = total - (ll)(freq[a[i]]) * (freq[a[i]] - 1) / 2;
    if (freq[a[i]] - 2 > 0)
      cur += (ll)(freq[a[i]] - 1) * (freq[a[i]] - 2) / 2;
    cout << cur << "\n";
  }
}

int main() {
  FASTIO();

  while (Read())
    Process();

  return 0;
}

Measured memory_bytes: 4224
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	sort.Ints(a)

	for i := 0; i < n-1; i++ {
		if a[i] == a[i+1] {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

Measured memory_bytes: 5120
from math import atan2, degrees

a, b, x = map(int, input().split())

vol = a * a * b

if x * 2 <= vol:
    ans = atan2(a * b * b, 2 * x)

else:
    ans = atan2(2 * (vol - x), a ** 3)

ans = degrees(ans)
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],max1,max2;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>=max1)max2=max1,max1=a[i];
        else if(a[i]>max2)max2=a[i];
    }
    for(int i=1;i<=n;i++)
        if(a[i]==max1)cout<<max2<<endl;else cout<<max1<<endl;
    return 0;
}

Measured memory_bytes: 2432
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n, m;
int a[200000];

vector<int> v[200000];

int main()
{
	int i, j, k, l;
	cin>>n>>m;
	for(i=0;i<n;i++) scanf("%d", &a[i]), v[a[i]%m].push_back(a[i]);
	int ans=0;
	for(i=0;i<=m/2;i++)
	{
		int u=(m-i)%m;
		if(i == u)
		{
			ans+=v[i].size()/2;
		}
		else
		{
			vector<int> x, y;
			x=v[i], y=v[m-i];
			if(x.size() > y.size()) swap(x, y);
			ans+=x.size();
			sort(all(y));
			int cnt=0;
			for(j=0;j<y.size();j++)
			{
				if(j != y.size()-1 && y[j] == y[j+1]) cnt+=2, j++;
			}
			ans+=min((int)(y.size()-x.size())/2, cnt/2);
		}
	}
	cout<<ans<<endl;
	return 0;
}
//*/

Measured memory_bytes: 8448
// vim: foldmethod=marker
#include <iostream> // cout, endl, cin{{{
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
typedef long long ll;/*}}}*/

int main(int argc, char *argv[])
{
  ll a, b;
  cin >> a >> b;
  ll tmp, r, x;
  lldiv_t ans;

  x = a * b;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while(r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  ans = lldiv(x, b);

  cout << ans.quot << endl;
}


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

typedef long long LL;

typedef vector<int> VI;
typedef vector<VI> VVI;

typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

typedef vector<double> VD;
typedef vector<VD> VDD;

typedef vector<string> VS;
typedef vector<VS> VVS;

typedef vector<bool> VB;
typedef vector<VB> VVB;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define fst first;
#define snd second;
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define RANGE(x, y, maxX, maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && y < (maxY))
#define REP(i, init, N) for (int i = (init); i < (int)(N); i++)

const int INF = 0x3f3f3f3f;
const int DX[] = {1,0,-1,0};
const int DY[] = {0,-1,0,1};

int N;
VI IS;
VI RS;
VI OS;

const int M = 256;

void generate_rs(int s, int a, int c) {
    RS = VI(N);
    RS[0] = s;

    REP(i, 0, N) {
        RS[i] = (a * (i == 0 ? s : RS[i - 1]) + c) % M;
    }
}

void generate_os() {
    OS = VI(N);

    REP(i, 0, N) {
        OS[i] = (IS[i] + RS[i]) % M;
    }
}

double calc_h() {
    double ans = 0;
    VI cnts(M);

    for (auto o : OS) {
        cnts[o]++;
    }

    REP(i, 0, M) {
        if (cnts[i] == 0) continue;
        double a = (1. * cnts[i] / N);
        double t = 1. * a * log2(a);

        ans += t;
    }

    return -ans;
}

VI solve() {
    double min_h = 1e+12;
    VI ans = {-1, -1, -1};

    REP(s, 0, 16) REP(a, 0, 16) REP(c, 0, 16) {
        generate_rs(s, a, c);
        generate_os();
        double h = calc_h();

        VI t({s, a, c});

        if (abs(min_h - h) <= 1e-9) {
        } else if (min_h + 1e-9 > h) {
            min_h = h;
            ans = t;
        }
    }

    return ans;
}

int main(void) {
    while (cin >> N, N) {
        IS = VI(N);
        for (auto &i : IS) {
            cin >> i;
        }

        VI ans = solve();
        REP(i, 0, 3) {
            cout << ans[i] << (i == 2 ? '\n' : ' ');
        }
    }

    return 0;
}

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

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

int main()
{
	// fast
	ll h,w;
	cin>>h>>w;
	ll p,q;
	if(h==1 || w==1)
	{
		cout<<1;
		return 0;
	}
	if(w%2)
	{
		q=(w/2)+1;
		p=q*(h/2);
		p+=(q-1)*(h/2);
		if(h%2 != 0)
			p+=q;
		cout<<p;
	}
	else
	{
		q=w/2;
		p=q*(h);
		
		cout<<p;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

  public static int x   = 0;
  public static int max = 0;

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    int N    = scan.nextInt();
    String S = scan.next();

    for (int i = 0; i < N; i++){
      if (S.charAt(i) == 'I'){
        x++;
      }
      else if(S.charAt(i) == 'D'){
        x--;
      }

      if (x > max){
        max = x;
      }
    }

    System.out.println(max);
  }
}


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

std::vector<int> h(100000);
std::vector<int> memo(100000);
int cal(int i){
	if(memo[i]!=-1){
		return memo[i];
	}
	else{
		int way1=99999;
		int way2=99999;
		way1=cal(i-1)+abs(h[i]-h[i-1]);
		if(i-1>=0){
			way2=cal(i-2)+abs(h[i]-h[i-2]);
		}
		if(way1<way2){
			memo[i]=way1;
		}
		else{
			memo[i]=way2;
		}
		return memo[i];
	}
}
int main(){
	int n;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>h[i];
		memo[i]=-1;
	}
	memo[0]=0;
	memo[1]=abs(h[0]-h[1]);
	printf("%d\n",cal(n-1));
	return 0;
}

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

map<long, long> prime_factor(long long n) {
  map <long, long> res;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

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

int main() {
  long long N, P;
  cin >> N >> P;
  map<long, long> mp = prime_factor(P);
  long long ans = 1;
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    if (it->second >= N) ans *= mod_pow(it->first, it->second / N);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007
typedef long long ll;

int sort(const void *a, const void *b){
  return *(int *)b - *(int *)a;
}

int
main(int argc, char *argv[])
{
  int n;
  int a[200000]; int b[200000];
  int max = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  
  qsort(b, n, sizeof(int), sort);

  for(int i = 0; i < n; i++){
    if(a[i] == b[0]) printf("%d\n", b[1]);
    else printf("%d\n", b[0]);
  }
  return 0;
}

  


Measured memory_bytes: 3120
X, Y, A, B, C = [int(n) for n in input().split(" ")]

p = [int(n) for n in input().split(" ")]
q = [int(n) for n in input().split(" ")]
r = [int(n) for n in input().split(" ")]

R = sorted(p)
G = sorted(q)
T = sorted(r)

W = 0
GetR = 0
GetG = 0
GetS = 0

while GetS < X + Y:
    a = -1
    b = -1
    c = -1
    if len(R) > 0 and GetR < X:
        a = R[-1]
    if len(G) > 0 and GetG < Y:
        b = G[-1]
    if len(T) > 0:
        c = T[-1]

    t = max([a, b, c])
    index = [a, b, c].index(t)
    W += t
    #print(R, G, T)
    GetS += 1
    if index == 0:
        del(R[-1])
        GetR += 1
    if index == 1:
        del(G[-1])
        GetG += 1
    if index == 2:
        del(T[-1])

print(W)

Measured memory_bytes: 29040
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  if ((s.size() % 2 == 0 && s.front() != s.back()) || (s.size() % 2 == 1 && s.front() == s.back())) {
    std::cout << "Second";
  } else {
    std::cout << "First";
  }
  return 0;
}

Measured memory_bytes: 640
n = int(input())
otoshi = [input().split() for i in range(n)]

sumyen = 0
for i in range(n):
    if otoshi[i][1] == 'JPY':
        sumyen += float(otoshi[i][0])
    else:
        sumyen += float(otoshi[i][0])*380000

print(sumyen)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include <sstream>
#include <cstring>
using namespace std;
vector<vector<int> > list;
int dp[100][50];
int chack(int i,int j){
  //  cout<<i<<" "<<j<<endl;
  if(dp[i][j]!=-1)
    return dp[i][j];
  if(i==list.size()-1)
    return list[i][j];
  int max=list[i][j];
  int tmp1=-1,tmp2=-1;
  if(i<list.size()/2)
    {
      tmp1=chack(i+1,j);
      tmp2=chack(i+1,j+1);
      if(tmp1>tmp2)
	max+=tmp1;
      else
	max+=tmp2;
    }
  else
    {
      if(j<list[i+1].size())
	tmp1=chack(i+1,j);
      if(j>0)
	tmp2=chack(i+1,j-1);
      if(tmp1>tmp2)
	max+=tmp1;
      else
	max+=tmp2;
    }
  dp[i][j]=max;
  return max;
}

int main()
{
  memset(dp,-1,sizeof(dp));
  string str;

  while(getline(cin,str))
    {
      stringstream ss(str);
      int tmp;
      char a;
      vector<int> v;
      while(!ss.eof()){
	ss>>tmp>>a;
	v.push_back(tmp);
      }
      list.push_back(v);
    }
  cout<<chack(0,0)<<endl;
  /*
  for(int i=0;i<list.size();i++,cout<<endl)
    for(int j=0;j<list[i].size();j++)
      {
	cout<<list[i][j]<<" ";
      }
  for(int i=0;i<list.size();i++,cout<<endl)
    for(int j=0;j<list[i].size();j++)
      {
	cout<<dp[i][j]<<" ";
      }
  */
}

Measured memory_bytes: 1296
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

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

    cout << z << " " << x << " " << y << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,h[100001];
bool vis[100001];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	for(int i=1;i<n;i++)
	{
		if(h[i-1]<h[i]&&h[i]>=h[i+1]) h[i]--;
		if(h[i]>h[i+1])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 512