akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define MAXN 10000
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;

ll num[10005]={0};
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int x;
    cin>>x;
    for(int i=0;i<=MAXN;i++){
        int tp=1;
        for(int j=0;j<5;j++){
            tp*=i;
        }
        num[i]=tp;
       // cout<<tp<<' ';
    }
 //   cout<<num[MAXN]<<endl;
    for(int i=0;i<=MAXN;i++){
        for(int j=0;j<=MAXN;j++){
            if(num[i]+num[j]==x){
                    j*=-1;
                cout<<i<<' '<<j<<endl;return 0;
            }
            else if(num[i]-num[j]==x){

                cout<<i<<' '<<j<<endl;return 0;
            }
        }
    }

    return 0;
}


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

bool isLeap(int y){
    if (y % 4 == 0){
	if (y % 400 == 0) return true;
	if (y % 100 == 0) return false;
	return true;
    }
    return false;
}

int main(){
    int a, b, c = 0;
    while (1){
	cin >> a >> b;
	if (a == 0 && b == 0) break;
	if (c != 0) cout << endl;
	c = 1;
	vector<int> y;
	for (int i = a; i <= b; i++){
	    if (isLeap(i)) y.push_back(i);
	}
	if (y.empty()) cout << "NA" << endl;
	else for (int i = 0; i < y.size(); i++)
		 cout << y[i] << endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

//Card Game
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			boolean[] u = new boolean[11];
			int c1 = sc.nextInt();
			int c2 = sc.nextInt();
			int c3 = sc.nextInt();
			u[c1]=u[c2]=u[c3]=true;
			int x = c1+c2;
			int c = 0;
			for(int i=1;i<=10;i++){
				if(!u[i]&&x+i<=20)c++;
			}
			System.out.println(c*100/7>=50?"YES":"NO");
		}
	}
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}
char pic[55][55];
char temp[55][55];
int n, m;

int find_pic(int x, int y){
    int flag = 1;
    for (int i = 0; i < m; i++){
        for (int j = 0; j < m; j++){
            if ((x+i > n && y+j > n) || (pic[x+i][y+j] != temp[i][j])) flag = 0;
        }
    }
    return flag;
}



int main(void){
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            scanf(" %c", &pic[i][j]);
        }
    }
    for (int i = 0; i < m; i++){
        for (int j = 0; j < m; j++){
            scanf(" %c", &temp[i][j]);
        }
    }

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (find_pic(i, j)){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;

}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(void) {
  char s[100] = {0};
  int i = 0;
  gets(s);
  i = strlen(s)-1;
  while(i >= 0)
  putchar(s[i--]);
  
  putchar('\n');
  return 0;
}

Measured memory_bytes: 908
# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def xor_sum(n):
    if n == 0: return 0
    if n % 2 != 0:
        return int((n + 1) % 4 != 0)
    return xor_sum(n-1) ^ n

def main():
    A, B = MI()
    if A == 0:
        return xor_sum(B)
    return xor_sum(A-1) ^ xor_sum(B)

if __name__ == "__main__":
    print(main())


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

int sum (int a)
{
 int sum = 0;
 while( 0 < a ) {
 sum += a % 10;
 a /= 10;
}

return sum;
}
int main()
{
 int n, a, b, min;
 cin >> n;
min = 999999;
for( a = 1; a <= n/2; a++ ) {
  b = n-a;
 int t = sum(a) + sum(b);
 if( t < min ) min = t;  
}
 cout << min << endl;
}



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

#define INF 1e9
using namespace std;

int main() {

    int N, X; cin >> N >> X;

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

        d[i] = abs(x[i] - X);
    }

    int ans = INF;
    ans = __gcd(d[0], d[1]);

    for (int i = 2; i < N; ++i) {
        ans = __gcd(ans, d[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int H, W, N;
        cin >> H >> W >> N;

        int ans = INF;
        for (int h = 0; h <= H; ++h) {
            for (int w = 0; w <= W; ++w) {
                Int val = H * W - (H - h) * (W - w);
                if (val >= N) {
                    chmin(ans, h + w);
                }
            }
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

max_val = max(dic.values())
k = [key for key in dic if dic[key] == max_val]
for i in sorted(k):
    print(i)

Measured memory_bytes: 32984
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    x = int(input())
    for i in range(-500,501):
        for j in range(-500, 501):
            if i ** 5 - j ** 5 == x:
                print(i, j)
                exit()
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 9816
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long p = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        Map<Integer, Integer> primeFactorizationMap = primeFactorizationMap(p);
        long result = 1;
        if (n == 1) {
            result = p;
        } else {
            for (int key : primeFactorizationMap.keySet()) {
                if (n <= primeFactorizationMap.get(key)) {
                    result *= Math.pow(key, primeFactorizationMap.get(key) / n);
                }
            }
        }

        // 出力
        System.out.println(result);
    }

    public static Map<Integer, Integer> primeFactorizationMap(long num) {
        Map<Integer, Integer> map = new HashMap<>();
        int max = (int) Math.sqrt(num);
        int div = 2;
        while (div <= max) {
            if (num % div == 0) {
                num /= div;
                if (map.containsKey(div)) {
                    map.put(div, map.get(div) + 1);
                } else {
                    map.put(div, 1);
                }
            } else {
                div++;
            }
        }
        if (num != 1) {
            map.put((int) num, 1);
        }
        return map;
    }
}


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

int main() {
    char ch[101] = "";
    while (cin >> ch) {
        char output[101];
        int index = 0;
        for (int i = 0; i < (int)(sizeof ch / sizeof ch[0]); i++) {
            if (ch[i] == '@') {
                int n = ch[i + 1] - '0';
                char c = ch[i + 2];
                for (int j = 0; j < n; j++) {
                    output[index++] = c;
                }
                i += 2;
            } else {
                output[index++] = ch[i];
            }
        }
        cout << output << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	double n;
	while(1){
		cin>>n;
		if(n<0)break;
		string ans="";
		bool check=true;
		int size;
		for(int i=7;i>=-4;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				ans+='1';
			}else{
				ans+='0';
			}
			if(n<1e-6){
				check=false;
				break;
			}
			if(i==0)ans+='.';
		}
		size=ans.size();
		if(ans.size()<=8){
			rep(i,8-size)ans+='0';
			ans+=".0000";
		}else if(ans.size()<13)rep(i,13-size)ans+='0';
		if(!check)cout<<ans<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  string answer = "Good";
  char temp = s.at(0);
  for (int i = 1; i < s.size(); i++) {
    if (s.at(i) == temp) {
      answer = "Bad";
      break;
    }
    temp = s.at(i);
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = 0
    y = 0
    while len(a) > 0:
        m += max(a)
        a.remove(max(a))
        if len(a) == 0:
            break
        y += max(a)
        a.remove(max(a))
    ans = 0
    ans = m - y
    print(ans)
main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fe(i,a,b) for(int i=(a);i<=(b);i++)
#define fne(i,a,b) for(int i=(a);i<(b);i++)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%lld",&x)
#define mst(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls lc,l,m
#define rs rc,m+1,r
#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl;
#define dbg3(x,y,z) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl;
const int INF =0x3f3f3f3f;
const int mod = 1e9+7;
const double eps=1e-8;
const int N = 2e5+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int c[N],w[N];
ll dp[N];
int main(){
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	int n,W;
	read2(n,W);
    fe(i,1,n){read2(c[i],w[i]);}
    fe(i,1,n){
    	for(int j=W;j>=c[i];j--){
			dp[j] = max(dp[j],dp[j-c[i]]+w[i]);
    	}
    }
    cout<<dp[W]<<endl;




	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define Max 1000000000

int main()
{
    int i,j,N,K,S,m;
    scanf("%d %d %d",&N,&K,&S);
    j=0;
    if(S==Max)
        m=Max-1;
    else
        m=Max;
    for(i=0; i<N; i++)
    {
        if(j<K)
        {
            printf("%d ",S);
            j++;
        }
        else
        {
            printf("%d ",m);
        }
    }
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_MSOL2020
{
    class MainClass
    {

        static int[] s, k;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            k = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);

            int a = s[0];
            int b = s[1];
            int c = s[2];
            for (int i = 0; i < k[0]; i++)
            {
                if (a >= b)
                {
                    b *= 2;
                    if (a < b && b < c)
                    {
                        WriteLine("Yes");
                        return;
                    }
                }
                else if (b >= c)
                {
                    c *= 2;
                    if (a < b && b < c)
                    {
                        WriteLine("Yes");
                        return;
                    }
                }
                else if (a < b && b < c)
                {
                    WriteLine("Yes");
                    return;
                }
            }
            WriteLine("No");
            return;
        }

        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
        public static int UpperBound<T>(T[] a, T v)
        {
            return UpperBound(a, v, Comparer<T>.Default);
        }

        public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res <= 0) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
    }
}


Measured memory_bytes: 28020
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
using namespace std;
const int maxn = 10001;
int a[maxn];
int vis[maxn];
void dfs(int pre , int cur)
{
    if(cur < 10 && a[pre] < a[cur])
    {
        vis[cur] = 1;
        dfs(cur , cur + 1);
    }
    else if(cur < 10 && a[pre] > a[cur]){
        dfs(pre , cur + 1);
    }
}

int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ
    int n;
    cin >> n;
    while(n --){
        for(int i = 0 ; i < 10 ; i ++){
            cin >> a[i];
        }
        bool flag = false;
        for(int i = 0 ; i < 10 ; i ++){
            memset(vis , 0 , sizeof(vis));
            vis[i] = 1;
            dfs(i , i + 1);
            int pre = 0;
            for(int j = 0 ; j < 10 ; j ++){
                if(vis[j] == 0){
                    if(pre > a[j]){
                        flag = true;
                        break;
                    }
                    else pre = a[j];
                }
            }
            if(!flag){
                cout << "YES" << endl;
                break;
            }
        }
        if(flag) cout << "NO" << endl;

    }
}

Measured memory_bytes: 3088
a,b,x,y=map(int,input().split())
xl=list(map(int,input().split()))
yl=list(map(int,input().split()))
xl.append(x)
xl.sort()
yl.append(y)
yl.sort()
xm=xl[a]
ym=yl[0]
if xm<ym:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
#create date: 2020-07-01 09:01

import sys
stdin = sys.stdin
from functools import lru_cache

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

@lru_cache(maxsize=2**52-3)
def f(n, x):
    if n == 0:
        return 1

    if x == 1:
        return 0
    elif x <= 2**(n+1)-2:
        #print("f({}, {})".format(n-1, x-1))
        return f(n-1, x-1)
    elif x == 2**(n+1)-1:
        return f(n-1, 2**(n+1)-3) + 1
    elif x < 2**(n+2)-2:
        return f(n-1, 2**(n+1)-3) + 1 + f(n-1, x-(2**(n+1)-1))
    else:
        return 2 * f(n-1, 2**(n+1)-3) + 1

def main():
    n, x = na()
    print(f(n, x))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9564
n = int(input())
d = {0:n}
for i in range(n):
    p = int(input())
    d[p] = i

dp = [1]*(n+1)
for i in range(n):
    if d[i+1] > d[i]:
        dp[i+1] = dp[i] + 1
print(n - max(dp))

Measured memory_bytes: 35832
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int main() {
	int n;
	bool flag = false;
	cin >> n;
	for (int i = 0; i <= n / 4; i++) {
		for (int j = 0; j <= n / 7; j++) {
			if (i * 4 + j * 7 == n) {
				flag = true;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a = N / 100000000;
  int b = N % 100000000 / 10000000;
  int c = N % 100000000 % 10000000 / 1000000;
  int d = N % 100000000 % 10000000 % 1000000 / 100000;
  int e = N % 100000000 % 10000000 % 1000000 % 100000 / 10000;
  int f = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 / 1000;
  int g = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 % 1000 / 100;
  int h = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 % 1000 % 100 / 10;
  int i = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 % 1000 % 100 % 10;
  int sum = a + b + c + d + e + f + g + h + i;
  
  if(N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#ifdef XS
	#include</home/xs/acm/modules/mylib/De>
	#include<cassert>
	#define NDEBUG
	const int Te=1;
#else 
	const int Te=0;
#endif
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define IF if(Te)
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	try{
		inp();
	}
	catch(... ){
		IF cout<<"exception";
	}//for compatibility with cygwin c++ runtime
	return 0;
}
const int N = 3e5;
int a[N];
void inp(){
	int n;
	cin>>n;
	for(int i =1;i<=n;i++){
		cin>>a[i];
	}
	if(n%2){//odd
		for(int i =n;i>=1;i-=2){
			cout<<a[i]<<' ';
		}
		for(int i=2;i<=n;i+=2){
			cout<<a[i]<<' ';
		}
	}
	else {
		//even
		for(int i=n;i>=2;i-=2){
			cout<<a[i]<<' ';
		}
		for(int i=1;i<=n;i+=2){
			cout<<a[i]<<' ';
		}
	}
}
//C.cc by xsthunder at Sat Jul  1 23:26:43 2017


Measured memory_bytes: 2944
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}

Measured memory_bytes: 3556
import numpy as np
from itertools import combinations
N, M, X = map(int, input().split())
T = []
cost = 0
is_update = False
for _ in range(N):
    t = list(map(int, input().split()))
    cost += t[0]
    T.append(t)

for i in range(1, N+1):
    for c in combinations(T, i):
        c = np.array(c)
        _cost = c[:, 0].sum()
        if (c[:, 1:].sum(axis=0) >= X).all() and _cost <= cost:
            cost = _cost
            is_update = True
print(cost if is_update else -1)

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

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long p1 = a*c, p2 = a*d, p3 = b*c, p4 = b*d;

    cout << max(p4, max(p3, max(p1, p2))) <<  endl;
    return 0;
}


Measured memory_bytes: 3552
#include <stdio.h>
int main(){
    int A;
    int B;
    int C;
    int D;
    scanf("%d %d",&C,&D);
    if(-100<=C){
        A=C;
    }
    if(D<=100){
        B=D;
    }
    int E;
    int F;
    int G;
    E=A+B;
    F=A-B;
    G=A*B;
    if(E<=F){
        if(F<=G){printf("%d",G);}
        else{printf("%d",F);}
    }
    else{
        if(E<=G){printf("%d",G);}
        else{printf("%d",E);}
        }
        return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;


int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)
    {
        if(b==c)
        {
            cout<<"1"<<endl;
        }
        else
        {
            cout<<"2"<<endl;
        }
    }
    else
    {
        if(a==c||b==c)
        {
            cout<<"2"<<endl;
        }
        else
        {
            cout<<"3"<<endl;
        }

    }
	return 0;
}


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

int n,m;
int p[110];
int ans;

int main()
{
	cin >> n >> m;
	for (int i = 1;i <= m;i ++)
	{
		int x;
		cin >> x;
		for (int j = 1;j <= x;j ++)
		{
			int y;
			cin >> y;
			p[y] = true;
		}
	}
	for (int i = 1;i <= n;i ++)
		if (!p[i]) ans ++;
	cout << ans << endl;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

char S[155];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  cin >> S;
  S[1] = 'B' + 'R' - S[1];
  puts(S);

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* ミラー-ラビン素数判定法 */

namespace MillerRabin {
  typedef __int128_t Int;
  Int power(Int k, Int n, ll M) {
    if(n == 0) return 1;
    if(n == 1) return k % M;

    Int res = power(k, n/2, M);
    res = res * res % M;
    return n%2 ? res % M * k % M : res;
  }

  bool isPrime(ll x) {
    int a[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, -1}; // x < 2^64
    //int a[] = {2, 7, 61, -1}; // x < 2^32
    if(x == 2) return true;
    if(x <= 1 || x % 2 == 0) return false;
    Int d = x - 1;
    int s = 0;
    for(; d%2 == 0; s++) d >>= 1;
    for(int i=0; a[i] != -1 && a[i] < x; i++){
      Int y = power(a[i], d, x);
      if(y == 1) continue;
      for(int j=0; j<s-1 && y != x-1; j++) y = (y * y) % x;
      if(y != x-1) return false;
    }
    return true;
  }
};


int main() {
  ll X;

  cin >> X;

  while(!MillerRabin::isPrime(X)) X++;

  cout << X << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n);
  rep(i, n) rep3(j, i + 1, n) {
    int k;
    if (i == x && j == y) {
      k = 1;
    } else if (j <= x || i >= y) {
      k = j - i;
    } else if (x <= i && j <= y) {
      k = j - i;
      chmin(k, i - x + 1 + y - j);
    } else if (i <= x && j >= y) {
      k = j - y + 1 + x - i;
    } else if (i <= x && j <= y) {
      k = x - i + min(j - x, 1 + y - j);
    } else {
      k = j - y + min(y - i, 1 + i - x);
    }
    // cout << k << " " << i << " " << j << endl;
    ans[k]++;
  }
  rep3(i, 1, n) cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,num) for(ll i=0;i<num;i++)
const ll mod=1000000007;

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

    rep(i,s.size()){
        int a=(s.at(i)-'A'+n)%26+'A';
        cout<<(char)(a);
    }
    return 0;
}




































































































































































































































































































































































































































































































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[301];
LL B[60];
LL C[62];
LL D[62];

LL solve(LL bb,LL xx){
	LL now=0;
	if(bb<xx)return -1;
	if(bb==0)return 0;
	//bbの最高桁
	LL temp=1;
	LL cc=bb;
	while(cc!=0){
		cc/=2;
		temp*=2;
	}
	temp/=2;
	//cout<<temp<<endl;
	if(bb-temp>=xx){
		return solve(bb-temp,xx);
	}
	if(temp>=xx){
		return temp;
	}
	return temp+solve(bb-temp,xx-temp);
}


LL E[62];
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	if(N==2){
		if((A[0]+A[1])%2==0&&A[0]>=A[1]){
			cout<<(A[0]-A[1])/2<<endl;
		}else{
			cout<<-1<<endl;
		}
		return 0;
	}
	
	LL ans=0;
	REP(i,N){
		if(i==0)continue;
		if(i==1)continue;
		ans=ans^A[i];
	}
	LL now=A[0]+A[1];
	now-=ans;
	if(now%2!=0){
		cout<<-1<<endl;
		return 0;
	}
	now/=2;
	//cout<<ans<<" "<<now<<endl;
	int up=0;
	bool check=false;
	REP(i,60){
		if(now%2==1){
			//C[i+1]++;
		}
		B[i]=ans%2+(now%2*2);
		ans/=2;
		now/=2;
	}
	REP(i,60){
		D[i]=B[i]-C[i];
		if(D[i]>2)check=true;
		if(D[i]<0)check=true;
	}
	/*REP(i,5){
		cout<<B[i]<<" "<<C[i]<<" "<<D[i]<<endl;
	}*/
	if(check==true){
		cout<<-1<<endl;
		return 0;
	}
	LL aa=0;
	LL bb=0;
	LL nn=1;
	REP(i,60){
		if(D[i]==0){
		}
		if(D[i]==1){
			bb+=nn;
			E[i]=1;
		}
		if(D[i]==2){
			aa+=nn;
		}
		nn*=2;
	}

	LL temp=A[1]-aa;
	LL aaaaa=solve(bb,temp);
	if(aaaaa==-1){
		cout<<-1<<endl;
		return 0;
	}	
	LL o=aaaaa+aa;
	//cout<<o<<" "<<A[0]+A[1]-o<<endl;
	LL ans2=o-A[1];
	if(ans2>=A[0]){
		cout<<-1<<endl;
	}else{
		cout<<ans2<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
a = [int(input()) for _ in range(n)]
# print(a)
a.sort()
n2 = n//2
if n % 2 == 0:
    print(sum(a[n2:])*2 - sum(a[:n2])*2 - a[n2]+a[n2-1])
else:
    
    ans1 = sum(a[n2+1:])*2 - sum(a[:n2+1])*2 + a[n2-1]+a[n2]
    
    ans2 = sum(a[n2:])*2 - sum(a[:n2])*2 - a[n2]-a[n2+1]
    print(max(ans1, ans2))


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

using namespace std;

#define MAX 234567

int main()
{
    vector<bool> prime(MAX, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i < MAX; i++) {
        if (prime[i]) {
            for (int j = 2 * i; j < MAX; j += i) {
                prime[j] = 0;
            }
        }
    }

    int N;
    while (cin >> N, N) {
        int res = 0;
        for (int i = 2; i <= N/2; i++) {
            if (prime[i] && prime[N-i]) ++res;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    long long  n ;
    cin >> n ;
   using pis = pair<int, string>;
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
  }
 
  int val_max = 0;
  for (auto i: m) {
    val_max = max(val_max, i.second);
  }
 
  for (auto it = m.begin(); it != m.end(); it++) {
    if ((it->second) == val_max) {
      cout << it->first << endl;
    }
  }

}

Measured memory_bytes: 26368
n = int(input())
s = input()

wh = 0
bl = 0
a = []
for i in range(n):
    if s[i] == ".":
        wh += 1
    else:
        bl += 1
    a.append([wh,bl])
#print(a)

ans = a[n-1][0]-a[0][0]
for i in range(n):
    k = (a[i][1]) + (a[n-1][0]-a[i][0])
    #print(i,k,(a[i][1]),(a[n-1][0]-a[i][0]))
    ans = min(ans,  k)

print(ans)


Measured memory_bytes: 66212
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {

    int A,P;
    cin >> A >> P;

    int ap=0;

    ap = (A*3+P)/2;

    cout << ap << endl;

}

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

namespace ABC129
{
    class C
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            long[] a = new long[M];
            for (int i = 0; i < M; i++)
            {
                a[i] = long.Parse(Console.ReadLine());
            }

            long[] dp = new long[N + 10];
            dp[N] = 1;

            int index = M - 1;
            for (int i = N - 1; 0 <= i; i--)
            {
                if (0 <= index && a[index] == i) { dp[index] = 0; index--; continue; }
                dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;
            }
            Console.WriteLine(dp[0]);
        }
    }
}

Measured memory_bytes: 14560
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  sort(ALL(a));
  
  int maxx = a[n-1];
  int med1=maxx/2,med2=maxx/2+1;
  int minn=INF,samin=INF,qw,er;
  
  if(maxx%2==0){
    
    rep(i,0,n-1){
      qw = abs(med1-a[i]);
      if(qw <= samin){
        samin = qw;
        minn = a[i];
      }
    }
    
  }
  
  else {
    
    rep(i,0,n-1){
      qw = abs(med1-a[i]);
      er = abs(med2-a[i]);
      
      if(min(qw,er) <= samin){
        samin = min(qw,er);
        minn = a[i];
      }
      
    }
    
  }
  
  cout << maxx << ' ' << minn << endl;
  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int HMAX=50;
const int WMAX=50;

// Problem Specific Parameter:

int main() {
  int h, w; cin >> h >> w;
  char s[WMAX][HMAX];
  for(int y = 0; y < h; ++y) {
    for(int x = 0; x < w; ++x) {
      cin >> s[x][y];
    }
  }
  for(int y = 0; y < h; ++y) {
    for(int x = 0; x < w; ++x) {
      if(s[x][y] == '#') {
        int cnt = 0;
        for(int i = 0; i < 4; ++i) {
          if(s[x+dx[i]][y+dy[i]] == '#') cnt++;
        }
        if(cnt == 0) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int A = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		System.out.print("#");
		for(int j=0;j<W;j++){
			System.out.print("#");
		}
		System.out.println("#");
		
		
		for(int i=0;i<H;i++){
			System.out.print("#");
			System.out.print(sc.next());
			System.out.println("#");
		}
		
		
		System.out.print("#");
		for(int j=0;j<W;j++){
			System.out.print("#");
		}
		System.out.println("#");
		
	}

}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

// 隣接リストで使う辺を表す型
struct Edge {
  long long to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(long long to, long long cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge

const long long INF = 100000000000000;

vector<long long> dist; // 最短距離

// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(long long n, long long s) { // nは頂点数、sは開始頂点
  dist = vector<long long>(n, INF);
  dist[s] = 0; // 開始点の距離は0
  for (long long i = 0; i < n+5002; i++) {
    for (long long v = 0; v < n; v++) {
      for (long long k = 0; k < graph[v].size(); k++) {
        Edge e = graph[v][k];
        if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (i >= n - 1) 
	  {
		  if(e.to==n-1)return true; // n回目にも更新があるなら負の閉路が存在
	  }
        }
      }
    }
  }
  return false;
}

int main() {
  long long n, m,p;
  cin >> n >> m >> p;

  graph = AdjList(n);
  
  for (long long i = 0; i < m; i++) {
    long long from, to, cost;
    cin >> from >> to >> cost;
    from--;to--;cost*=(-1);cost+=p;
    graph[from].push_back(Edge(to, cost));
  }
  
  if(bellman_ford(n, 0))
  {
	  cout << -1 << endl;
  }
  else
  {
	  cout << (dist[n-1]*(-1)>0 ? dist[n-1]*(-1) : 0) << endl;

  }
   return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int d[100000];
int check(int x,int y){
	if(x<y) return (d[y]-d[x]+100000)%100000;
	return (d[x]-d[y]+100000)%100000;
}
int main(){
	int n,m,s[100000],a[100000];
	scanf("%d%d",&n,&m);
	for(int i=0;i<n-1;i++) scanf("%d",&s[i]);
	for(int i=0;i<m;i++) scanf("%d",&a[i]);
	int c=0; d[0]=0; 
	for(int i=1;i<n;i++){ c+=s[i-1]; c%=100000; d[i]=c;}
	int res=0,now=0;
	for(int i=0;i<m;i++){ res=(res+check(a[i]+now,now))%100000; now+=a[i];}
	printf("%d\n",res);
}

Measured memory_bytes: 2356
#include"bits/stdc++.h"
using namespace std;

void Main() {
		int h, w;
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h - 1) {
					cout << "#";
					continue;
				}
				if (j == 0 || j == w - 1) {
					cout << "#";
					continue;
				}
				cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3072
import sys
while True:
	n,x = map(int,input().split())
	if n==0 and x==0: sys.exit()
	counter=0
	for a in range(1,n+1):
		for b in range(a+1,n+1):
			for c in range(b+1,n+1):
				if a+b+c==x:
					counter+=1
					break
					
	print(counter)


Measured memory_bytes: 5600
#include<stdio.h>

int main(){

  int n,m,s[100000],t[50000],i,j,count = 0,left,right,mid;

  scanf("%d",&n);

  for(i = 0; i < n ;i++){

    scanf("%d",&s[i]);
  }

  scanf("%d",&m);

  for(i = 0; i < m ; i++){

    scanf("%d",&t[i]);
  }


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

    while(left < right){
    	mid = (left+right)/2;
      
      if(s[mid] == t[i]){

	count++;
	break;
      }

      else if(s[mid] > t[i]){
	right = mid;
	
      }

      else{
	left = mid+1;
	
      }
    }

  

  }

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

  return 0;
}
	



Measured memory_bytes: 2280
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define pb push_back
typedef long long ll;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T&a,Args&...b){ read(a); read(b...); }

struct t {
	ll val;
	int l, r;
	bool operator<(const t& oth) const {
		return l < oth.l;
	}
};

set<t> s;
int l;

vector<int> ans;

void add(t x){
	auto it = s.insert(x).first;
	if(it != s.begin()){
		auto il = it;
		--il;
		if(il->val + it->val >= l){
			ans.pb(il->r);
			t n = {il->val+it->val, il->l, it->r};
			s.erase(il); s.erase(it);
			add(n);
			return;
		}
	}
	auto ir = it; ++ir;
	if(ir != s.end()){
		if(it->val + ir->val >= l){
			ans.pb(it->r);
			t n = {it->val+ir->val, it->l, ir->r};
			s.erase(it); s.erase(ir);
			add(n);
			return;
		}
	}
}

int main(){
	int n;
	read(n, l);
	for(int i=1; i<=n; ++i){
		int a; read(a);
		add({a, i, i});
	}
	if(s.size() >= 2u){
		puts("Impossible");
	} else {
		puts("Possible");
		reverse(all(ans));
		for(int A:ans) printf("%d\n",A);
	}
	return 0;
}


Measured memory_bytes: 13312
N=int(input())
a=[int(i) for i in input().split()]
argM=0
argm=0
for i in range(N):
    if a[argM]<a[i]:
        argM=i
    if a[argm]>a[i]:
        argm=i
if a[argM]<=0:
    print(N-1)
    for i in list(range(N-1))[::-1]:
        a[i]+=a[i+1]
        print(i+2,i+1)
elif a[argm]>=0:
    print(N-1)
    for i in range(N-1):
        a[i+1]+=a[i]
        print(i+1,i+2)
else:
    L=[]
    if a[argM]+a[argm]>=0:
        for i in range(N):
            if i==argM:
                continue
            L.append([argM+1,i+1])
            a[i]+=a[argM]
        for i in range(N-1):
            a[i+1]+=a[i]
            L.append([i+1,i+2])
        print(len(L))
        for p in L:
            print(p[0],p[1])
    else:
        for i in range(N):
            if i==argm:
                continue
            L.append([argm+1,i+1])
            a[i]+=a[argm]
        for i in list(range(N-1))[::-1]:
            a[i]+=a[i+1]
            L.append([i+2,i+1])
        print(len(L))
        for p in L:
            print(p[0],p[1])
#print(a)


Measured memory_bytes: 3188
import math

n, d = list(map(int, input().split()))
x = [[0] * d] * n

for i in range(n):
    x[i] = list(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range((i + 1), n, 1):
        diffs = 0

        for k in range(d):
            diffs += (x[i][k] - x[j][k]) ** 2

        dist = math.sqrt(diffs)
        if (math.floor(dist) == math.ceil(dist)):
            ans += 1

print(ans)


Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader fr = new FastReader();

		int N = fr.nextInt();
		int W = fr.nextInt(); // upto 10^5
		int[] w = new int[N+1];
		int[] v = new int[N+1]; 
		int sumVals = 0;
		
		for(int i = 1; i <= N; i++) {
			w[i] = fr.nextInt();
			v[i] = fr.nextInt();
			sumVals += v[i];
		}
		
		long[][] dp = new long[N+1][sumVals+1];
		
		for (long[] arr : dp) Arrays.fill(arr, Integer.MAX_VALUE);
		
//		long[] dp = new long[W+1]; // only 1 array. 
//		
//		for (int i = 0; i < N; i++) {
//			for (int j = W; j >= w[i]; j--) {
//				dp[j] = Math.max(dp[j], dp[j-w[i]] + v[i]);
//			}
//		}
		
		
		dp[0][0] = 0;
		
		for(int i = 1; i <= N; i++) {
			for (int j = 0; j <= sumVals; j++) {
				if (v[i] <= j) dp[i][j] = Math.min(dp[i-1][j], w[i]+dp[i-1][j-v[i]]);
				else dp[i][j] = dp[i-1][j];
			}
		}
		for(int i = sumVals; i >= 0; i--) {
			if (dp[N][i] <= W) {
				System.out.println(i);
				break;
			}
		}
	}

}


Measured memory_bytes: 137476
fun main(args: Array<String>) {
    while (true){
        val (l, op, r) = readLine()?.split(" ") ?: return
        val answer = when {
            op.equals("+") -> l.toInt() + r.toInt()
            op.equals("-") -> l.toInt() - r.toInt()
            op.equals("*") -> l.toInt() * r.toInt()
            op.equals("/") -> l.toInt() / r.toInt()
            else -> return
        }
        println("$answer")
    }
}



Measured memory_bytes: 31992
c, z = map(int, input().split())
if(c >= z):
    print('No')
    exit()
x = (4 * c - z) / 2
yojo = (4 * c - z) % 2
y = c - x

if(x >= 0 and yojo == 0 and y >= 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inpl(): return list(map(int, sys.stdin.readline().split()))


def inpl_str(): return list(sys.stdin.readline().split())


N = inp()
aa = inpl()

cnts = [0]*(N+10)

for a in aa:
    cnts[a] += 1

S = 0
for a in aa:
    S += cnts[a]-1

S //= 2

for a in aa:
    print(S - cnts[a] + 1)


Measured memory_bytes: 26984