akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import defaultdict, deque
from functools import reduce
import math

input = sys.stdin.readline

def chmax(a, b):
    if a > b:
        return a
    else:
        return b
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    T = [int(input()) for _ in range(N)]
    print(lcm(*T))


if __name__ == '__main__':
    main()


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b, res = 0;
    scanf("%d%d", &a, &b);
    if (a == b) res = a + b;
    else res = max(a, b) * 2 - 1;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  n%=10;
  if(n==2||n==4||n==5||n==7||n==9) cout<<"hon"<<endl;
  else if(n==0||n==1||n==6||n==8) cout<<"pon"<<endl;
  else if(n==3) cout<<"bon"<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    int sum = 0;
    int min = 10000;
    for (int i = 1; i <= n; i++)
    {
        int t = l + i - 1;
        if (abs(min) > abs(t))
        {
            min = t;
        }
        sum += t;
    }

    sum -= min;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int n;

void solve(int *min,int flag,int c){
	int i;
	static int sum = 0, count = 0;
	if(count + 1 < *min && sum < n){
		for(i = 0;((i + 1) * (i + 2) * (i + 3)) / 6 + sum <= n && i < c;i++);
		while(i > 0){
			if(flag == 1 && i * (i + 1) * (i + 2) / 6 % 2 == 0){
				i--;
				continue;
			}
			sum += i * (i + 1) * (i + 2) / 6;
			count++;
			solve(min,flag,i);
			sum -= i * (i + 1) * (i + 2) / 6;
			count--;
			i--;
		}
	}
	else if(sum == n){
		if(count < *min)
			*min = count;
	}
	return;
}

int main(void){
	int min;
	scanf("%d",&n);
	while(n != 0){
		min = n;
		solve(&min,0,0x7FFFFFFF);
		printf("%d ",min);
		min = n;
		solve(&min,1,0x7FFFFFFF);
		printf("%d\n",min);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0526-input.txt"));

		while (scan.hasNext()) {
			int n = scan.nextInt();
			if (n == 0)
				break;
			Table t = new Table(n);
			for (int i = 0; i < n; i++)
				t.add(scan.nextInt());
			System.out.println(t.count());
		}
		scan.close();
		System.exit(0);
	}
}

class Table {
	public Table(int n) {
		s = new int[n];
	}

	public int count() {
		int t = 0;
		for (int i = 0; i < p; i++)
			if (s[i] == 0)
				t++;
		return t;
	}

	public void add(int nx) {
		if (p % 2 == 1)
			for (int i = p - 1; i >= 0; i--)
				if (s[i] != nx)
					s[i] = nx;
				else
					break;
		s[p++] = nx;
	}

	int[] s;
	int p = 0;
}

Measured memory_bytes: 67200
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n;
	cin >> n;
	set<string> s;
	string str;
	cin >> str;
	s.insert(str);
	char prev = str.back();
	n--;
	while(n--)
	{
		cin >> str;
		if(s.count(str) == 1 || str[0] != prev)
		{
			cout << "No";
			return 0;
		}
		s.insert(str);
		prev = str.back();
	}
	cout << "Yes";
	return 0;
}

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

int main() {
  int n, m, a = 9999;
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    int c, t;
    cin >> c >> t;
    if(t <= m)
      a = min(a, c);
  }
  if(a == 9999)
    cout << "TLE" << endl;
  else
    cout << a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


int main(){
    string S;
    cin >> S;
    ll sum=0;
    rep(i, S.length()){
        if(S.at(i)=='1')
            sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    string s;
    cin>>s;
    bool ans=false;
    for(int i=0;i<s.length();i+=2)
       {

          if(s[i]=='L')
           {
              ans=true;
              break;

           }

       }
       for(int i=1;i<s.length();i+=2)
       {

          if(s[i]=='R')
           {
              ans=true;
              break;

           }

       }
       if(ans)
           cout<<"No"<<endl;
           else
              cout<<"Yes"<<endl;




return 0;}


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

int main(void)
{
	double v, y, t;

	while (scanf("%lf", &v) != EOF) {
		t = v / 9.8;
		y = 4.9 * pow(t, 2);
		printf("%d\n", (int)y / 5 + 2);
	}

	return (0);
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

struct Maxflow {
	struct edge { int to, cap, rev; edge(int t, int c, int r) { to = t; cap = c; rev = r; } };
	int V;
	vector<vector<edge>> G;
	vector<int> itr, level;

	Maxflow(int V) : V(V) { G.assign(V, vector<edge>()); }

	void add_edge(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, (int)G[to].size()));
		G[to].push_back(edge(from, 0, (int)G[from].size() - 1));
	}

	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		level[s] = 0; q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			for (auto &e : G[v]) {
				if (e.cap > 0 and level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int& i = itr[v]; i < (int)G[v].size(); ++i) {
			edge& e = G[v][i];
			if (e.cap > 0 and level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int run(int s, int t) {
		int ret = 0, f;
		while (bfs(s), level[t] >= 0) {
			itr.assign(V, 0);
			while ((f = dfs(s, t, INF)) > 0) ret += f;
		}
		return ret;
	}
};

int M, N;
int B[500], R[500];

int gcd(int a, int b) { return a ? gcd(b%a, a) : b; }

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (cin >> M >> N)
	{
		if (M == 0) return 0;
		rep(i, 0, M) cin >> B[i];
		rep(i, 0, N) cin >> R[i];

		Maxflow mf(1 + M + N + 1);
		rep(i, 0, M) mf.add_edge(0, i + 1, 1);
		rep(i, 0, M) rep(j, 0, N)
		{
			if (gcd(B[i], R[j]) != 1) mf.add_edge(1 + i, 1 + M + j, 1);
		}
		rep(i, 0, N) mf.add_edge(1 + M + i, 1 + N + M, 1);

		cout << mf.run(0, 1 + N + M) << endl;
	}
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d)
    cout << "Left" << endl;
  else if (a + b < c + d)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    char a;
    cin >> a;
    if(int(a)>='a'&&int(a)<='z'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  std::cin>>s;
  if(s=="Sunny")
    std::cout<<"Cloudy";
  else if(s=="Cloudy")
    std::cout<<"Rainy";
  else if(s=="Rainy")
    std::cout<<"Sunny";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
const intt MOD = 2038077799;
const intt INF = 1e18;
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt modExp(intt base, intt power) {
    if (power == 0) {
        return 1;
    } else {
        intt cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("ouut.txt","w",stdout);
  #endif
}

int main()
{
  fast_io
  go();
  int N; cin >> N;
  vector<intt> A(N), B(N);
  for0(i, N) cin >> A[i];
  for0(i, N) cin >> B[i];
  vector<intt> dA(N), dB(N);
    for0(i, N) 
    {
        dA[i] = A[(i+1)%N] ^ A[i];
        dB[i] = B[(i+1)%N] ^ B[i];
    }
 
    intt hashB = 0;
    intt base = 1400312813; 
    for0(i, N) {
        hashB *= base;
        hashB %= MOD;
        hashB += dB[i];
        hashB %= MOD;
    }
 
    intt hashA = 0;
    for0(i, N) {
        hashA *= base; hashA %= MOD; hashA += dA[i]; hashA %= MOD;
    }
    vi ans;
    intt exp = modExp(base, N-1);
    for0(i, N) {
        if (hashA == hashB) {
            ans.pb(i);
        }
        intt val = exp * dA[i]; val %= MOD;
        hashA += MOD - val; hashA %= MOD;
        hashA *= base; hashA %= MOD;
        hashA += dA[i]; hashA %= MOD;
    }
 
    for0(i, sz(ans)) {
        cout << ans[i] << " " << (A[0] ^ B[(N-ans[i])%N]) << endl;
    }
  
  return 0;

}



Measured memory_bytes: 10892
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  string S; cin>>S;
  ll MOD = 2019;
  vector<ll> pre(200010, 0);
  pre[0] = 0;
  pre[1] = 1;
  map<ll,ll> M;
  M[0]++;
  ll ssz = S.size();
  for(ll i=2; i<=ssz; i++){
    pre[i] = pre[i-1] * 10;
    pre[i] %= MOD;
  }
  
  ll tmp = 0, ans = 0;
  for(ll i=ssz-1; i>=0; i--){
    tmp += (S[i]-'0') * pre[ssz-i];
    tmp %= MOD;
    ans += M[tmp];
    M[tmp]++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5188
#include <iostream>;
#include <queue>;
#include <string>;
#include <vector>;
using namespace std;



int main() {
	string c;
	string ans;
	cin >> c;
	for (int i = 0; i < c.size(); i++)
	{
		if (c[i] == 'A') ans += 'T';
		if (c[i] == 'T') ans += 'A';
		if (c[i] == 'G') ans += 'C';
		if (c[i] == 'C') ans += 'G';
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
from collections import Counter
n = int(input())

def factorization(n):
    c = Counter()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            c[i]=cnt
    if temp!=1:
        c[temp]=1
    if len(c)==0:
        c[n]=1
    c[1] = 0
    return c

def isOk(c):
    ret = 1
    for _,v in c.items():
        ret*=(v+1)
    return ret

c = Counter([])
for i in range(1, n+1):
    c += factorization(i)

# cから適当に約数を選んで約数の個数が75となるように選ぶ
# factorization(75): [5,2][3,1]
lc = [[k, v] for k, v in c.items()]

ans=0
# 一つの素因数が75個
f75 = sum([1 for v in c.values() if v >= 74])
ans+=f75
# 3, 3, 5のパターン
f3 = sum([1 for v in c.values() if v >= 2])
f5 = sum([1 for v in c.values() if v >= 4])
f15 = sum([1 for v in c.values() if v >= 14])
f25 = sum([1 for v in c.values() if v >= 24])
ans+=f15*(f5-1)
ans+=f25*(f3 - 1)
if f5 >= 2:
    ans+=(f5*(f5-1)//2)*(f3-2)
print(ans)

Measured memory_bytes: 3316
N,M = map(int,input().split())
drink = [list(map(int,input().split())) for n in range(N)]
drink.sort(key=lambda x: x[0])
m = 0
ans = 0
while M != 0:
    if M >= drink[m][1]:
        ans += drink[m][0]*drink[m][1]
        M -= drink[m][1]
    else:
        ans += drink[m][0]*M
        M = 0
    m += 1
print(ans)


Measured memory_bytes: 29020
#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
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll N, A, B;
  ll ans = 0;
  cin >> N >> A >> B;
  ans += A * (N / (A + B));
  if (N % (A + B) > A)
  {
    ans += A;
  }
  else
  {
    ans += N % (A + B);
  }

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		String			getData;
		BufferedReader 	reader = new BufferedReader(new InputStreamReader(System.in));


		while((getData = reader.readLine()) != null){
			String[]	dataList =getData.split(" ");
			double[]		valueList= new double[dataList.length];

			for(int i = 0; i < dataList.length; i++){
				valueList[i] = Double.parseDouble(dataList[i]);
			}

			double x = (valueList[2] * valueList[4] - valueList[1] * valueList[5]) / (valueList[0] * valueList[4] - valueList[1] * valueList[3]);
			double y = (valueList[5] * valueList[0] - valueList[2] * valueList[3]) / (valueList[0] * valueList[4] - valueList[3] * valueList[1]);

			if(-0.0005 < x && x < 0.0005)	x = 0;
			if(-0.0005 < y && y < 0.0005)	y = 0;

			System.out.printf("%.3f %.3f\n", x, y);

		}

	}
}

Measured memory_bytes: 11000
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1)

    def search(self, k):
        if k > self.total:
            return -1
        if k == 0:
            return 0
        step = 1 << (self.size.bit_length() - 1)
        now_index = 0
        ret = 0
        while step:
            if now_index + step < self.size and ret + self.bit[now_index + step - 1] < k:
                ret += self.bit[now_index + step - 1]
                now_index += step
            step >>= 1
        # now_indexを伸ばしいって、sumがk以上に達する直前まで伸ばし続けるならreturnのところでnow_index - 1。
        # その場合、bit.sum(now_index - 1) <= k < bit.sum(now_index)
        # 達してすぐのindexであれば-1しない
        return now_index

n = I()
A = LI()
val_idx = {A[j]:j+1 for j in range(n)}
bit = BIT(n + 2)
bit.add(n + 1, 1)
bit.add(0, 1)
ans = 0
for k in range(1, n + 1):
    idx = val_idx[k]
    bit.add(idx, 1)
    m = bit.sum(idx)
    r = bit.search(m + 1)
    l = bit.search(m - 1)
    ans += (r - idx) * (idx - l) * k

print(ans)

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

int main() {
	int A , B ;
    cin >> A >> B ;
    int kaibunsu = 0;
	for(int i = A; i <= B; i++){
        if((i / 10000 == i % 10) && (i % 10000 / 1000 == i % 100 / 10)){
        	kaibunsu ++;
        }
    }
    cout << kaibunsu << endl;
}


Measured memory_bytes: 3592
N, M, X, Y = [int(nmxy) for nmxy in input().split()]
x = [int(xx) for xx in input().split()]
y = [int(yy) for yy in input().split()]
x_Z = max(x)
Z_y = min(y)
for Z in range(X+1, Y):
  if x_Z < Z <= Z_y:
    print("No War")
    break
else:
  print("War")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        v[i] = a;
    }

    for (int i = 0; i < n; i++)
    {
        while(v[i]%2== 0){
            v[i] /= 2;
            cnt ++;
        }
    }
    
    cout << cnt << endl;

}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
  x=0; int ch=getchar(),f=0;
  while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
  while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
  if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=200050;
ll n,a[maxn];
map<ll,ll> mp;
int main()
{
  cin>>n;
  rep(i,1,n) rd(a[i]),mp[a[i]]++;
  ll ans=0;
  for(auto x:mp)
  {
    ans+=x.second*(x.second-1)/2;
  }
  rep(i,1,n)
  {
    ll temp=0;
    temp=mp[a[i]]-1;
    cout<<ans-temp<<endl;
  }
  return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h; cin >> h;
    if(h == 0){
        OUT(1);
        return 0;
    }
    int a = h,b = 1;
    int ans = 1;
    while(a > b){
        b *= 2;
        if(a < b) break;
        ans += b;
    }
    ANS;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=105;
const int maxw=1e5+5;
const int inf=0x3f3f3f3f;
int w[maxn],v[maxn];
long long dp[maxw][maxn];
int main()
{
	int n,tw;
	while(~scanf("%d%d",&n,&tw))
	{
		for(int i=1;i<=n;i++)
		  scanf("%d%d",&w[i],&v[i]);
		for(int i=1;i<=n;i++)//n件物品 
		{
			for(int j=0;j<=tw;j++)//背包容量 
			{
				if(j-w[i]>=0)
				  dp[j][i]=max(dp[j][i-1],dp[j-w[i]][i-1]+v[i]);
				else
				  dp[j][i]=dp[j][i-1];
				//cout<<dp[j][i]<<" ";
			}
			//cout<<endl;
		}
		cout<<dp[tw][n];
	}
}

Measured memory_bytes: 85672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
string S;
int dp[1000010][3];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> S;
    N = S.size();
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = inf;
        }
    }
    reverse(S.begin(), S.end());    
    for(int i = 0; i < N; i++){
        dp[i][0] += S[i] - '0';
        chmin(dp[i + 1][0], dp[i][0]);
        chmin(dp[i + 1][1], dp[i][0]);
        chmin(dp[i + 1][2], dp[i][0]);

        dp[i][1] += (S[i] - '0') + 2;
        chmin(dp[i + 1][0], dp[i][1]);
        chmin(dp[i + 1][1], dp[i][1]);
        chmin(dp[i + 1][2], dp[i][1]);

        dp[i][2] += ('9' - S[i]);
        chmin(dp[i + 1][1], dp[i][2]);
        chmin(dp[i + 1][2], dp[i][2]);
    }
    cout << min({dp[N - 1][0], dp[N- 1][1], dp[N][1] + 2}) << endl;
    return 0;
}

Measured memory_bytes: 13084
Imports System.Text
Imports System.String
Imports System.Core
Imports System

Module Module1

    Sub Main()
        Dim ans As String = ""

        Dim getvaluelength As Integer


        Dim mojiretu As String = Console.ReadLine()

        Dim flg As Boolean = True

        If mojiretu <> StrReverse(mojiretu) Then
            flg = False
        End If

        If mojiretu.Substring(0, CInt((mojiretu.Length - 1) / 2)) <> StrReverse(mojiretu.Substring(0, CInt((mojiretu.Length - 1) / 2))) Then
            flg = False
        End If

        If mojiretu.Substring(CInt((mojiretu.Length + 3) / 2) - 1) <> StrReverse(mojiretu.Substring(CInt((mojiretu.Length + 3) / 2) - 1)) Then
            flg = False
        End If

        If flg Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If
        Console.ReadKey()




    End Sub




End Module


Measured memory_bytes: 21840
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	s, t := "", ""
	fmt.Scan(&s, &t)

	memo := make([][]int, len(s)+1)
	for i := 0; i <= len(s); i++ {
		memo[i] = make([]int, len(t)+1)
	}
	for i := 1; i <= len(s); i++ {
		for j := 1; j <= len(t); j++ {
			if s[i-1] == t[j-1] {
				memo[i][j] = memo[i-1][j-1] + 1
				continue
			}
			memo[i][j] = max(memo[i-1][j], memo[i][j-1])
		}
	}

	bestLen := memo[len(s)][len(t)]
	// Go backward to construct the solution
	solution := ""
	for i, j := len(s)-1, len(t)-1; len(solution) != bestLen; {

		if s[i] == t[j] {
			solution, i, j = s[i:i+1]+solution, i-1, j-1
			continue
		}
		if memo[i][j+1] > memo[i+1][j] {
			i--
		} else {
			j--
		}
	}
	fmt.Println(solution)
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    double a, b;
    cin >> a >> b;

    for (int i = 0; i <= 100000; i++) {
        double id = i;
        double p8 = 0.08 * id;
        double p10 = 0.1 * id;

        int pi8 = p8;
        int pi10 = p10;

        if (pi8 == a && pi10 == b) {
            cout << i << endl;
            ret();
        }
    }

    cout << -1 << endl;
}


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

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans=0;
	if(a%2==0&&b%2==0&&c%2==0){
		while(a%2==0&&b%2==0&&c%2==0){
			ll A,B,C,num1,num2,num3;
			num1=a,num2=b,num3=c;
			A=a/2,B=b/2,C=c/2;
			a=B+C,b=A+C,c=A+B;
			if(a==num1&&b==num2&&c==num3){
				cout<<-1<<endl;
				return 0;
			}
			ans++;
		}
	}else{
		cout<<0<<endl;
		return 0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
int go(int a, int b, string s) {
  int k = a;
  for (int i = a + 1; i <= b; ++i) {
    if (s[i] == '.' && i - k <= 2) k = i;
  }
  return k;
}
int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s; cin >> s;
  --a; --b; --c; --d;
  if (c != go(a, c, s)) kek("No");
  if (d != go(b, d, s)) kek("No");
  if (d > c) kek("Yes");
  for (int i = b + 1; i <= d + 1; ++i) {
    if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.')
      kek("Yes");
  }
  kek("No");
  
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    cout.precision(15);
    double a, b;
    cin >> a >> b;
    double c, d;
    cin >> c >> d;
    int m = c * 60 + d;
    double da = m / 2.0;
    double db = (m * 6) % 360;
    if(da == db){
        cout << abs(a - b) << endl;
        return 0;
    }

    double di = db - da;

    if(abs(di) == 180){
        cout << a + b << endl;
        return 0;
    }

    double ans = 0;

    if(di > 0){
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    else {
        di = da - db;
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4156
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define INF 10000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, M;
int S, T;

int dist[MAX_N][3];
int sv, tv;

int main(void)
{
  scanf("%d%d", &N, &M);
  int u, v;
  vector<vector<int>> G(N);
  REP(i, M)
  {
    scanf("%d%d", &u, &v);
    // 0-indexed
    G[u - 1].push_back(v - 1);
  }
  scanf("%d%d", &sv, &tv);
  // 0-indexed
  sv = sv - 1, tv = tv - 1;

  REP(i, N) REP(j, 3) dist[i][j] = INF;

  queue<P> que;
  que.push(P(sv, 0));
  dist[sv][0] = 0;
  while (!que.empty()) {
    int v = que.front().first;
    int l = que.front().second;
    que.pop();
    for (int u : G[v]) {
      int nl = (l + 1) % 3;
      if (dist[u][nl] != INF) continue;
      dist[u][nl] = dist[v][l] + 1;
      que.push(P(u, nl));
    }
  }
  int res = dist[tv][0];
  if (res == INF)
    res = -1;
  else
    res /= 3;
  printf("%d\n", res);
  return 0;
}


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

using namespace std;
#define int long long

const int N = 1005, oo = 1e9 + 5;
int n, a[N], ans1, ans2;
vector <int> odd, even;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (a[i] > 0 && i & 1) {
			ans1 += a[i];
			odd.push_back(i);
		}
		if (a[i] > 0 && !(i & 1)) {
			ans2 += a[i];
			even.push_back(i);
		}
	}
	if (max(ans1, ans2) == 0) {
		int mx = -oo, id = -1;
		for (int i = 1; i <= n; ++i) {
			if (a[i] > mx) {
				mx = a[i];
				id = i;
			}
		}
		cout << mx << endl << n - 1 << endl;
		for (int i = 1; i < id; ++i) cout << 1 << endl;
		for (int i = n - id + 1; i > 1; --i) cout << i << endl;
		return 0;
	}
	cout << max(ans1, ans2) << endl;
	if (ans1 < ans2) {
		swap(even, odd);
	}
	vector <int> res; res.clear();
	for (int i = 1; i < odd[0]; ++i) {
		res.push_back(1);
	}
	for (int i = 0; i < odd.size() - 1; ++i) {
		int f1 = odd[i], f2 = odd[i + 1];
		int cen = (f1 + f2) >> 1;
		cen -= f1 - 1;
		for (int j = cen; j > 1; --j)
			res.push_back(j);
	}
	int rem = n - odd.back() + 1;
	for (int i = rem; i > 1; --i) res.push_back(i);
	cout << res.size() << endl;
	for (int v : res) cout << v << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
long h[100005]= { 0 };
long f[30] = { 0 };
int main()
{	
	int n;
	string a, b;
	cin >> n>>a>>b;
	f[a[0]-'a'] = 1;
	for (int i = 1; i < n-1; i++) {	
		f[a[i] - 'a'] += f[b[i] - 'a'];
		f[a[i] - 'a'] = f[a[i] - 'a'] % 1000000007;
	}
	cout << f[b[n-1] - 'a'] << endl;
}



Measured memory_bytes: 3360
/*
Created on Thu Aug 27 21:32:39 2020

@author: roastedcoder

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
const int mod = 1e9+7;
const int INF = INT_MAX;
#define endl "\n"
#define append push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________



int main() {
	roastedcoder
	ll n, k; cin>>n;
	cin>>k;
	n = n-1;
	ll res = 0;
	for(int i = 0; i<n; i++) {
		ll a; cin>>a;
		k>a ? res += (k-a) : k = a;
	}
	cout<<res<<endl;
}

//__________________________________________________________________
/*
Sample Input:
20 12 6

Sample Output:
12

*/

Measured memory_bytes: 3588
#include <iostream>

const int N = 10;

int main(void) {
  int a[N] = {0};

  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
  }

  int three = 3;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (a[j] > a[i]) {
	int tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
      }
    }
  }

  for (int i = 0; i < three; i++) {
    std::cout << a[i] << std::endl;
  }
   
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int n, a[5][N];
int main()
{
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%d", &a[1][i]);
	for (i = 1; i <= n; i++) scanf("%d", &a[2][i]);
	for (i = 1; i <= 2; i++) {
		for (j = 1; j <= n; j++) {
			a[i][j] += max(a[i - 1][j], a[i][j - 1]);
		}
	}
    cout << a[2][n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <queue>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>
 
int x,y,z;
int n;
ll a,b,c;
struct node {
    ll a,b;
    bool operator<(const node& rhs) const {
        return (a-b)<(rhs.a-rhs.b);
    }
};
 
int main()
{
    ll csum=0;
    scanf("%d%d%d",&x,&y,&z);
    n=x+y+z;
    vector<node> vec;
    for (int i=0;i<n;i++) {
        scanf("%lld%lld%lld",&a,&b,&c);
        vec.pb({a-c,b-c});
        csum+=c;
    }
    sort(vec.begin(),vec.end());

    vector<ll> v1,v2;
 
    priority_queue<ll,vector<ll>,std::greater<ll>> pq;
    ll sum1=0;
    for (int i=0;i<y;i++) {
        pq.push(vec[i].b);
        sum1+=vec[i].b;
    }
    v1.pb(sum1);
    for (int i=y;i<y+z;i++) {
        sum1+=vec[i].b;
        pq.push(vec[i].b);
        sum1-=pq.top();
        pq.pop();
        v1.pb(sum1);
    }
 
    while (!pq.empty()) pq.pop();
    ll sum2=0;
    for (int i=0;i<x;i++) {
        pq.push(vec[n-1-i].a);
        sum2+=vec[n-1-i].a;
    }
    v2.pb(sum2);
    for (int i=y+z-1;i>=y;i--) {
        sum2+=vec[i].a;
        pq.push(vec[i].a);
        sum2-=pq.top();
        pq.pop();
        v2.pb(sum2);
    }
 
    reverse(v2.begin(),v2.end());
    ll mx=v1[0]+v2[0];
    for (int i=1;i<v1.size();i++) {
        mx=max(mx,v1[i]+v2[i]);
    }
    printf("%lld\n",mx+csum);
}

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

int main(int argc, const char * argv[]) {
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double a, b;
    cin >> a >> b;
    
    cout << int((a + b)/2 + 0.5) << endl;
}


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

int main(){
    //sanbeki
    int sanbeki[16];
    int i;
    sanbeki[0]=1;
    for(i=1; i<=15; i++){
        sanbeki[i] = 3*sanbeki[i-1];
    }
    //input nm
    int n,m;
    cin >> n >> m;

    while(n!=0){
        //input start
        int start=0;
        int kosu, bangou;
        cin >> kosu;
        for(i=0; i<kosu; i++){
            cin >> bangou;
            start += 0*sanbeki[bangou-1];
        }
        cin >> kosu;
        for(i=0; i<kosu; i++){
            cin >> bangou;
            start += 1*sanbeki[bangou-1];
        }
        cin >> kosu;
        for(i=0; i<kosu; i++){
            cin >> bangou;
            start += 2*sanbeki[bangou-1];
        }
        //bfs
        int val[sanbeki[n]];
        for(i=0; i<sanbeki[n]; i++){
            val[i]=-1;
        }
        queue<int> que;
        que.push(start);
        val[start]=0;
        int height[3];
        while(!que.empty()){
            int p=que.front();
            que.pop();
            height[0]=0;
            height[1]=0;
            height[2]=0;
            int p_sub=p;
            for(i=0; i<n; i++){
                height[p_sub%3]=i+1;
                p_sub = p_sub/3;
            }
            if(height[0]>height[1]){
                if(val[p+sanbeki[height[0]-1]]<0){
                    val[p+sanbeki[height[0]-1]]=val[p]+1;
                    que.push(p+sanbeki[height[0]-1]);
                }
            }else if(height[0]<height[1]){
                if(val[p-sanbeki[height[1]-1]]<0){
                    val[p-sanbeki[height[1]-1]]=val[p]+1;
                    que.push(p-sanbeki[height[1]-1]);
                }
            }
            if(height[1]>height[2]){
                if(val[p+sanbeki[height[1]-1]]<0){
                    val[p+sanbeki[height[1]-1]]=val[p]+1;
                    que.push(p+sanbeki[height[1]-1]);
                }
            }else if(height[1]<height[2]){
                if(val[p-sanbeki[height[2]-1]]<0){
                    val[p-sanbeki[height[2]-1]]=val[p]+1;
                    que.push(p-sanbeki[height[2]-1]);
                }
            }
        }
        //judge
        int sanbeki_max=0;
        for(i=0; i<n; i++){
            sanbeki_max += 2*sanbeki[i];
        }
        if((val[0]>=0&&val[0]<=m)||(val[sanbeki_max]>=0&&val[sanbeki_max]<=m)){
            if((val[0]>=0&&val[0]<=m)&&(val[sanbeki_max]>=0&&val[sanbeki_max]<=m)){
                cout << min(val[0],val[sanbeki_max]) << endl;
            }else if((val[0]>=0&&val[0]<=m)){
                cout << val[0] << endl;
            }else{
                cout << val[sanbeki_max] << endl;
            }
        }else{
            cout << -1 << endl;
        }

        //input nm
        cin >> n >> m;
    }
    return 0;
}


Measured memory_bytes: 59200
module mod_blue_and_red_balls
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: f(0:2000), invf(0:2000)
contains
  subroutine init(n)
    implicit none
    integer, intent(in) :: n
    integer :: i
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    invf(0) = 1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),md)
      invf(i) = inv(f(i))
    end do
    return
  end subroutine init
  integer(8) function perm(n,k)
    implicit none
    integer, intent(in) :: n, k
    perm = 0_8
    if (n.lt.0.or.k.gt.n) return
    perm = mod(f(n)*invf(n-k),md)
    return
  end function perm
  integer(8) function comb(n,k)
    implicit none
    integer, intent(in) :: n, k
    comb = mod(perm(n,k)*invf(k),md)
    return
  end function comb
  integer(8) function homo(n,k)
    implicit none
    integer, intent(in) :: n, k
    homo = comb(n+k-1,k)
    return
  end function homo
  function inv(n) result(y)
    implicit none
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = mod(n,md)
    b = md
    x = 0
    y = 1
    do while(b.ne.0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    do while (y.lt.0_8)
      y = y+md
    end do
    y = mod(y,md)
    return
  end function inv
end module mod_blue_and_red_balls
program blue_and_red_balls
  use mod_blue_and_red_balls
  implicit none
  integer :: n, k, i
  read(*,*) n, k
  call init(n)
  do i = 1, k
    write(*,'(i0)') mod(homo(i,k-i)*comb(n-k+1,i),md)
  end do
  stop
end program blue_and_red_balls

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

int main() {
  int X, N; cin >> X >> N;
  vector<bool> A(102);
  for (int i = 0; i < N; i++) {
    int p; cin >> p;
    A.at(p) = true;
  }
  int ans = 500;
  int diff = 500;
  for (int i = 0; i <= 101 ; i++) {
    if (A.at(i)) continue;
    if (diff > abs(X - i)) {
      ans = i;
      diff = abs(X - i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

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

    int V[N];
    int C[N];

    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }


    int c = 0;
    int p = 0;
    for (int i = 0; i < N; i++)
    {
        p = V[i] - C[i];

        if(0 < p) {
            c += p;
        }
    }

    cout << c << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	char s[100], t[100];
	scanf("%s %s", &s,&t);
	for (int i = 0; t[i] != '\0'; i++) {
		printf("%c", t[i]);
	}
	for (int j = 0; s[j] != '\0'; j++) {
		printf("%c", s[j]);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    int a;

    cin >> a;
    a = (a-1)/111;
    cout << (a+1)*111;

    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
A = LIST()
CNT = [0]*N

for i in range(N-1):
	CNT[A[i]-1] += 1

for i in range(N):
	print(CNT[i])

Measured memory_bytes: 33828
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: u32,
        B: u32,
        C: u32,
    }
    let hs:HashSet<u32> = vec![A,B,C].into_iter().collect();
    println!("{}",hs.len());
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    long long n, d;
    cin >> n >> d;
    cout << ceil(1.0 * n / (2 * d + 1));
    return 0;
}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
dp[i][j][k = その行で拾ったアイテム数]
i+1にいく時にkは0になる
*/

long long dp[3001][3001][4];
int grid[3001][3001];

int	main(void)
{
	int r, c, k;
	cin >> r >> c >> k;
	for (int i = 0; i < k; i++)
	{
		int r, c, v;
		cin >> r >> c >> v;
		r--; c--;
		grid[r][c] = v;
	}
	for (int i = 0; i <= r; i++)
	{
		for (int j = 0; j <= c; j++)
		{
			for (int m = 0; m < 4; m++)
			{
				if (i + 1 <= r)
				{
					dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][m]);
					if (m != 3) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][m] + grid[i][j]);
				}
				if (j + 1 <= c)
				{
					dp[i][j + 1][m] = max(dp[i][j + 1][m], dp[i][j][m]);
					if (m != 3) dp[i][j + 1][m + 1] = max(dp[i][j + 1][m + 1], dp[i][j][m] + grid[i][j]);
				}
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < 4; i++) ans = max(ans, dp[r][c][i]);
	cout << ans << endl;
	return (0);
}


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

int main(){
 int n,m;
 cin >> n >> m;
 if(n==m)cout << "Yes" << endl;
 else cout << "No" << endl;
 return 0;
}

Measured memory_bytes: 256