akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
typedef long long LL;
typedef pair<int,int>PII;
const LL inf = 1 << 30;
map<char,int>mp;
const int maxn = 1e4;
int n,m;
int main(){
	cin >> n >> m;
	if(n > m)
		cout << (n-1) << endl;
	else cout << n << endl;
	return 0;
}


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

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

    int r = n % 10;
    if(r == 3){
        cout << "bon" << endl;
    }
    else if(r == 0 || r == 1 || r == 6 || r == 8){
        cout << "pon" << endl;
    }
    else { cout << "hon" << endl;}


    return 0;
}

Measured memory_bytes: 3624
N,M=map(int,raw_input().split())
K=int(raw_input())
A=[]
B=[ [[0,0,0] for j in range(M+1)] for i in range(N+1)]
for i in range(N):
    A.append(raw_input())
for i in range(1,N+1):
    for j in range(1,M+1):
        c=A[i-1][j-1]
        B[i][j][0]=B[i-1][j][0]+B[i][j-1][0]-B[i-1][j-1][0]+(c=='J')
        B[i][j][1]=B[i-1][j][1]+B[i][j-1][1]-B[i-1][j-1][1]+(c=='O')
        B[i][j][2]=B[i-1][j][2]+B[i][j-1][2]-B[i-1][j-1][2]+(c=='I')
for k in range(K):
    a,b,c,d=map(int,raw_input().split())
    aj=B[c][d][0]-B[c][b-1][0]-B[a-1][d][0]+B[a-1][b-1][0]
    ao=B[c][d][1]-B[c][b-1][1]-B[a-1][d][1]+B[a-1][b-1][1]
    ai=B[c][d][2]-B[c][b-1][2]-B[a-1][d][2]+B[a-1][b-1][2]
    print aj,ao,ai
    

Measured memory_bytes: 191940
N, M = list(map(int, input().split())) # 整数
answer=[]
a = []
food_list=[]
for i in range(N):
    answer=list(map(int, input().split()))
    if i==0:
        food_list=answer[1:]
    else:
        like_food=[]
        for food in answer[1:]:
            if (food in like_food)==False:
                if (food in food_list)==True:
                    like_food.append(food)
        food_list=like_food
print(len(food_list))

Measured memory_bytes: 3064
import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    print('AC x {:}'.format(s.count('AC')))
    print('WA x {:}'.format(s.count('WA')))
    print('TLE x {:}'.format(s.count('TLE')))
    print('RE x {:}'.format(s.count('RE')))
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 16860
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c[4]={};
  cin >> a >> b;
  c[a]++,c[b]++;
  for(int i=1; i<=3; i++) {
    if(c[i]==0) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        //freopen ("in1.txt", "r", stdin);
        //freopen ("ans1.txt", "w", stdout);
    #endif
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << " " << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

num1 = Array.new(10, n+1)
num2 = Array.new(10){Array.new(10, n+1)}
num3 = Array.new(10){Array.new(10){Array.new(10, n+1)}}

(n-1).downto(0) {|i| num1[s[i].to_i] = i}

(n-1).downto(0) do |j|
    10.times do |i|
        num2[i][s[j].to_i] = j if num1[i] < j
    end
end

(n-1).downto(0) do |k|
    10.times do |j|
        10.times do |i|
            num3[i][j][s[k].to_i] = k if num2[i][j] < k
        end
    end
end

puts 1000 - num3.flatten.count(n+1)

Measured memory_bytes: 1916
#include <cstring>
#include <cstring>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <cstring>
#include <unordered_set>
#include <algorithm>
using namespace std;
typedef long long ll;
const int INF = 1e9;

typedef long long ll;

int main()
{
	int arr[3];
	for (int i = 0; i < 3; i++)
		cin >> arr[i];
	sort(arr, arr + 3);
	cout << arr[0] * arr[1]/2;
}

Measured memory_bytes: 256
n=io.read("*n")
s={}
for i=1,n do
	_=io.read(1)
	s[i]={}
	for j=1,n do
		s[i][j]=io.read(1)
	end
end
cnt=0
function func()
	for i=1,n do for j=1,n do
		if a[i][j]~=a[j][i] then return 0 end
	end end
	return n
end
for i=1,n do
	a={}
	for j=1,n do
		t=(j+i)%n+1
		a[j]={}
		for k=1,n do
			a[j][k]=s[t][k]
		end
	end
	cnt=cnt+func()
end
print(cnt)

Measured memory_bytes: 10112
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int A,B;
	scanf("%d%d",&A,&B);
	if(A+B>=10)puts("error");
	else printf("%d\n",A+B);
}


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

int main(){
    int n;
    cin >> n;
    int day[n];
    
    for (int i = 0; i < n; i++){
        cin >> day[i];
    }
    
    for (int i = n-1; i >= 0; i--){
        cout << day[i];
        
        if (i==0){
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}
        

Measured memory_bytes: 1160
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    int N,p[100010],cn=0,ite=0;
    cin>>N;
    rep(i,0,N)cin>>p[i];
    while(ite<N-1){
        if(p[ite]==ite+1&&p[ite+1]==ite+2){
            p[ite+1]=122222;
            ite+=2;
            cn++;
        }
        else if(p[ite]==ite+1){
            p[ite+1]=122222;
            ite++;
            cn++;
        }
        else ite++;
    }
    if(p[N-1]==N)cn++;
    cout<<cn<<endl;
}






Measured memory_bytes: 640
#include<vector>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int n,k,sum=0;
	vector<int> v;
	cin>>n;
	v.push_back(0);
	for(int i=1;i<=n;i++){
		cin>>k;
		v.push_back(k);
	}
	k=0;
	for(int i=1;i<v.size();i++){
		sum+=max(k,v[i])-min(k,v[i]);
		k=v[i];
	}
	sum+=max(k,0)-min(k,0);
	int j=1;
	while(j<v.size()-1){
		int cnt=sum;
		cnt-=max(v[j],v[j-1])-min(v[j],v[j-1]);
		cnt-=max(v[j],v[j+1])-min(v[j],v[j+1]);
		cnt+=max(v[j+1],v[j-1])-min(v[j+1],v[j-1]);
		cout<<cnt<<endl;
		j++;
	}
	int cnt=sum;
		cnt-=max(v[j],v[j-1])-min(v[j],v[j-1]);
		cnt-=max(v[j],0)-min(v[j],0);
		cnt+=max(0,v[j-1])-min(0,v[j-1]);
		cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1784
#include<stdio.h>
int main(void){
  int A,B,C,c;
  scanf("%d %d %d",&A,&B,&C);
  c=0;
  while(B>=A){
    B-=A;
    c++;
  }
  if(c>=C){
    c=C;
  }
  printf("%d",c);
  return 0;
}

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

typedef long long int ll; 
ll a[200010],b[200010];
ll asum[200010],bsum[200010];

int main(void)
{
	ll n,m,k;
	cin >> n >> m >> k;

	a[0]=0,asum[0]=0;
	for(ll i=1;i<=n;i++)
	{
		cin >> a[i];
		asum[i]=asum[i-1]+a[i];
	}

	b[0]=0,bsum[0]=0;
	for(ll i=1;i<=m;i++)
	{
		cin >> b[i];
		bsum[i]=bsum[i-1]+b[i];
	}

	ll j = m,ans=0;
	for(ll i=0;i<n+1;i++)
	{
		if(asum[i]>k)
			break;

		while(asum[i]+bsum[j]>k && j>=0)
			j--;
		ans = max(ans,i+j);
	}
	cout << ans <<endl;



	return 0;
}


Measured memory_bytes: 9844
void main() {
    int n = readln.chomp.to!int;
    int cnt;
    for (int i = 1; i <= n; i += 2) {
        int divisor;
        for (int j = 1; j * j <= i; j += 2) {
            if (i % j == 0) {
                ++divisor;
                if (j * j != i) ++divisor;
            }
        }
        if (divisor == 8) ++cnt;
    }
    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

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

    for (int i = 0; i < S.size(); i++)
    {
        if ((i % 2 == 0 && S[i] == 'L') || (i % 2 != 0 && S[i] == 'R'))
        {
            cout << "No" << endl;
            return 0;
        }
        
    }
    cout << "Yes" << endl;    
  return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 2; a * i % b != a % b; i++) {
        if (a * i % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std ;
int N , ptr , res ;
int A [100000];
int main ()
{

scanf ( "%d", &N );
for ( int i =0; i < N ; i++) scanf ( "%d", &A[i]);
sort (A, A + N );
while ( ptr < N )
{
int cc = A [ptr] , f = 0;
while ( ptr < N && A [ ptr ]== cc ) f++ , ptr++;
res += f%2;
}
printf ( "%d\n" ,res );
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0):n(n_),bit(n_+1){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
	int lower_bound(T k)//k<=sum(ret)
	{
		if(k<=0)return 0;
		int ret=0,i=1;
		while((i<<1)<=n)i<<=1;
		for(;i;i>>=1)
			if(ret+i<=n&&bit[ret+i]<k)k-=bit[ret+=i];
		return ret+1;
	}
};
main()
{
	int N,Q;
	cin>>N>>Q;
	BIT<long>P(N);
	for(int i=0;i<N;i++)
	{
		int a;cin>>a;P.add(i+1,a);
	}
	for(int i=0;i<Q;i++)
	{
		int t,l,r;cin>>t>>l>>r;
		if(t==0)
		{
			P.add(l+1,r);
		}
		else
		{
			cout<<P.sum(r)-P.sum(l)<<endl;
		}
	}
}


Measured memory_bytes: 8212
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin>>n;
  vector<ll> dp(n+2, 0);
  dp[0] = 1;
  for(int i=1; i<=n; i++){
    for(int j=3; j<=n; j++){
      if(i-j>=0)
        dp[i] += dp[i-j];
      dp[i] %= mod;
    }
  }
  cout<<dp[n]<<"\n";
  return 0;
}

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

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

	int N;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> A,B,C;

	cin >> N;

	for(i=0;i<N;i++){
		cin >> tmp;
		A.push_back(tmp);
	}
	
	for(i=0;i<N;i++){
		cin >> tmp;
		B.push_back(tmp);
	}
	
	for(i=0;i<N-1;i++){
		cin >> tmp;
		C.push_back(tmp);
	}

	for(i=0;i<N-1;i++){
		counter+=B[A[i]-1];
		if(A[i]==A[i+1]-1){
			counter+=C[A[i]-1];
		}
	}
	counter+=B[A[N-1]-1];
	
	answer=counter;
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define timepass 1073741824
#define MAXN 200000 + 5
#define LOGN 20
#define over ((1ll << 32))
using namespace std;
#define N 2005
 
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int ll 
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define sp(a , x) cout << fixed << setprecision(a) << x << endl; 
#define siz(temp) (ll)temp.size()
#define len(temp) (ll)temp.length()
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define pi acos(-1)
#define con continue
#define endl "\n"
#define w(q) while(q--)
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace7(a, b, c, d, e, f , g) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | "<< #g <<": "<<g<<endl
#define trace8(a, b, c, d, e, f , g , h) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | " << #g <<": "<< g <<" | "<<#h<< ": " << h << endl
 
typedef pair<int , int> pii;
typedef pair<int , pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;
 
signed main()
{
    FAST;
    string s , t;
    cin >> s >> t;
    int ans = 0;
    ans = (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]);
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n, cards[4][13] = {0}, vn;
	char vw, ow[] = { 'S', 'H', 'C', 'D' };
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> vw >> vn;
		switch (vw){
		case 'S':
			cards[0][vn-1] = 1;
			break;
		case 'H':
			cards[1][vn-1] = 1;
			break;
		case 'C':
			cards[2][vn-1] = 1;
			break;
		case 'D':
			cards[3][vn-1] = 1;
			break;
		}
	}
	for (int i = 0; i < 13; i++){
		if (cards[0][i] != 1){
			cout << 'S' << " " << i + 1 << endl;
		}
	}
	for (int i = 0; i < 13; i++){
		if (cards[1][i] != 1){
			cout << 'H' << " " << i + 1 << endl;
		}
	}
	for (int i = 0; i < 13; i++){
		if (cards[2][i] != 1){
			cout << 'C' << " " << i + 1 << endl;
		}
	}
	for (int i = 0; i < 13; i++){
		if (cards[3][i] != 1){
			cout << 'D' << " " << i + 1 << endl;
		}
	}
	/*for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			if (cards[i][j]!=1)
			cout << ow[i] << " " << j + 1 << endl;
		}
	}*/
}
/*
S 1
S 2
H 3
H 4
H 5
H 6
H 7
H 8
H 13
C 1
C 9
C 10
D 2
D 3
D 4
D 13

S 1
S 2
H 3
H 4
H 5
H 6
H 7
H 8
H 13
C 1
C 9
C 10
D 2
D 3
D 4
D 13

*/


Measured memory_bytes: 3072
#include <stdio.h>
#include <limits.h>

#define MAX 200000

int main() {
  int n;
  long value[MAX];
  long prof;
  long min_prof = LONG_MAX;
  long max_prof = LONG_MIN;

  scanf("%d", &n);
  if(n < 2 || n > 200000) {
    printf("Error: n is out of range");
    return -1;
  }

  for(int i = 0; i < n; i++) {
    scanf("%ld", &value[i]);
    if(value[i] < 1 || value[i] > 10e9) {
      printf("Error: value[i] is out of range");
      return -1;
    }
  }

  for(int i = 0; i < n; i++) {
    // check max
    if((max_prof < value[i] - min_prof) && i >= 1) {
      /* printf("## %ld, %ld", value[i], min_prof); */
      max_prof = value[i] - min_prof;
    }
    // check min
    if(value[i] < min_prof) {
      min_prof = value[i];
    }
    /* printf("min: %ld\n", min_prof); */
    /* printf("max: %ld\n", max_prof); */
  }
  printf("%ld\n", max_prof);
}

Measured memory_bytes: 2588
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,d;
    cin>>n>>d;
    if(n>=10)
    {
        cout<<d<<endl;
    }
    else
        cout<<d+100*(10-n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=10010010;
const double PI=3.141592653589;


int main(){
  int x,a; cin>>x>>a;
  if(x<a)
  cout<<0<<endl;
  else if(a<=x)
  cout<<10<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
	
	int n,k,x,y;
	
	scanf("%d %d %d %d", &n, &k, &x, &y);
	
	int total = 0;
	
	while(n--){
		if(k > 0){
			total += x;	
		}
		else{
			total += y;
		}
		k--;
	}
	
	printf("%d\n", total);
	
	return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int chmin = INT_MAX;
  for (int i = 0; i < n; ++i) {
    int cnt = 0, t;
    cin >> t;
    while ((t & 1) == 0) {
      cnt++;
      t >>= 1;
    }
    chmin = min(chmin, cnt);
  }
  cout << chmin << "\n";
}


Measured memory_bytes: 256
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        d = 4 * h * n - N * (n + h)
        if d <= 0:
            continue
        if (N * h * n)%d == 0:
            print(h,n,(N * h * n)//d)
            exit()

Measured memory_bytes: 3060
n = int(input())
lis = list(map(int, input().split()))
maxL = max(lis)+1
t = [0] * maxL
lis.sort()
for k in lis:
    t[k] += 1
    if t[k] == 1:
        for p in range(k * 2, maxL, k):
            t[p] += 2
print(t.count(1))


Measured memory_bytes: 32252
#include <stdio.h>
#include <set>
#include <algorithm>
using namespace std;
const int N=1e5+10;
int main(){
    int n,a[N];
    long long int ans=0;
    set<int> s;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n);
    for(int i=1;i<=a[n-1];i++)if(a[n-1]%i==0)s.insert(i);
    for(int i=0;i<n;i++)ans+=*s.lower_bound(a[i])-a[i];
    printf("%lld\n",ans);
}


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

int main() {
	int i, j, N, A, B, out, O=0;
	char tmp[10001] = {0};
	scanf("%d%d%d", &N, &A, &B);
	for (i=1; i <= N ;i++) {
		sprintf(tmp, "%d", i);
		out = 0;
		for (j=0;j<strlen(tmp);j++) {
			out += tmp[j]-'0';
		}
		if (out >= A && out <= B) {
			O += i;
		}
	}
	printf("%d\n", O);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
typedef long long LL;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    LL x, y; cin >> x >> y;
    cout<<(abs(x-y) <= 1 ? "Brown" : "Alice")<<endl;

    cout<<flush;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int  A, B, C;
    cin >> A >> B >> C;

    int count = 0;
    for (int i = 0; i < B; i++){
        if (A*i % B == C){
            count++;
        }
    }
    
    if (count > 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;


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

    int m = 1;
    for(int b = 2; b <= 100; b++){
        int b_temp = b*b;
        while(b_temp <= n){
            m = max(m, b_temp);
            b_temp *= b;
        }
    }
    cout << m << endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007  # type: int

N = int(readline())
adj = [[] for _ in range(N)]
for _ in range(N - 1):
    x, y = [int(a) - 1 for a in readline().split()]
    adj[x].append(y)
    adj[y].append(x)


def solve(node, parent):
    w, b = 1, 1
    for nxt in adj[node]:
        if nxt != parent:
            w1, b1 = solve(nxt, node)
            w *= w1 + b1
            w %= MOD
            b *= w1
            b %= MOD
    return w, b


if __name__ == "__main__":
    print(sum(solve(0, -1)) % MOD)


Measured memory_bytes: 99800
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
 
int main(){
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
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()
ans = 0
for i in range(1, N):
    # print(i)
    ans += (N - 1) // i
print(ans)


Measured memory_bytes: 27284
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int ans = 1e9;
    repd(i, -100, 101) {
        int cost = 0;
        rep(j, N) {
            cost += (a[j] - i) * (a[j] - i);
        }
        chmin(ans, cost);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main()
{
  int n;
  std::string s1, s2;
  std::cin >> n;
  std::cin >> s1 >> s2;
  
  for (int i = 0; i < n; i++)
  {
    std::cout << s1[i] << s2[i];
  }
  return 0;
}


Measured memory_bytes: 256
import math as mt
#import numpy as np

def ro(n):
  return mt.floor(mt.sqrt(n))
def ya():
  print("Yes")
  return
def na():
  print("No")
  return


x,n=map(int,input().split())
if n>0:
  lis=list(map(int,input().split()))
  lis.sort()
#n=int(input())
#s=input()
kai=1

while 1:
  if n==0:
    break
  if not x in lis:
    break
  x-=kai
  kai+=1
  if not x in lis:
    break
  x+=kai
  kai+=1
print(x)

Measured memory_bytes: 9192
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){

//        string[] input = ReadLine().Split(' ');
        int a =   int.Parse(ReadLine());
        if(a ==1){
            WriteLine("Hello World");
        }else{
            int b =   int.Parse(ReadLine());
            int c =   int.Parse(ReadLine());
            WriteLine(b+c);
        }
    }
}


Measured memory_bytes: 11092
# include <stdio.h>

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

Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

import operator
class SegmentTree:
    def __init__(self, size, default, op = operator.add):
        self.size = 2**size.bit_length()
        self.dat = [default]*(self.size*2)
        self.op = op

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.op(self.dat[i*2], self.dat[i*2+1])

    def add(self, i, x):
        i += self.size
        self.dat[i] = self.op(self.dat[i], x)
        while i > 0:
            i >>= 1
            self.dat[i] = self.op(self.dat[i], x)

    def get(self, a, b = None):
        if b is None:
            b = a + 1
        l, r = a + self.size, b + self.size
        res = None
        while l < r:
            if l & 1:
                if res is None:
                    res = self.dat[l]
                else:
                    res = self.op(res, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                if res is None:
                    res = self.dat[r]
                else:
                    res = self.op(res, self.dat[r])
            l >>= 1
            r >>= 1
        return res

def solve():

    n,d,a = LI()
    p = LIR(n)
    ans = 0
    p.sort()
    X = [p[i][0] for i in range(n)]
    s = SegmentTree(n,0)
    for i in range(n):
        x,h = p[i]
        j = bisect.bisect_left(X,x-2*d)
        if i != j:
            su = s.get(j,i)
            h -=  s.get(j,i)
        if h > 0:
            l = x
            k = math.ceil(h/a)
            ans += k
            s.update(i,k*a)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 134948
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/arc098/submissions/2567315
// 正答者の解答を勉強する.
#include <bits/stdc++.h>
using namespace std;

// Disjoint Set Union.
class dsu{
public:
    vector<int> p;
    int n;
    
    dsu(int _n) : n(_n){
        p.resize(n);
        iota(p.begin(), p.end(), 0);
    }
    
    inline int get(int x){
        return (x == p[x] ? x : (p[x] = get(p[x])));
    }
    
    inline bool unite(int x, int y){
        x = get(x);
        y = get(y);
        if(x != y){
            p[x] = y;
            return true;
        }
        return false;
    }
};

int main(){
    
    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);
    vector<int> a(N), b(N);
    for(int i = 0; i < N; i++) scanf("%d %d", &a[i], &b[i]);
    
    // 2. グラフ構築.
    vector<vector<int>> graph(N);
    for(int i = 0; i < M; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    
    vector<int> add(N);
    iota(add.begin(), add.end(), 0); // 0 ～ N - 1 を 代入.
    sort(add.begin(), add.end(), [&](int i, int j){ return a[i] - b[i] < a[j] - b[j]; });
    
    // 3. Disjoint Set Union.
    dsu d(N);
    vector<long long> sum_b(N);
    vector<long long> ans(N);
    for(int i = 0; i < N; i++){
        sum_b[i] = b[i];
        ans[i] = max(a[i], b[i]);
    }
    
    // 4. ゲームのクリアが可能となる最小の初期の所持金W を 計算.
    vector<int> was(N, 0);
    for(int i : add){
        set<int> s;
        for(int j : graph[i]) if(was[j]) s.insert(d.get(j));
        for(int j : s){
            sum_b[i] += sum_b[j];
            d.unite(j, i);
        }
        if(!s.empty()){
            long long best = (long long) 1e18;
            for(int j : s){
                long long sum_b_without = sum_b[i] - sum_b[j];
                long long cur = max(ans[j] + sum_b_without, a[i] + sum_b_without - b[i]);
                best = min(best, cur);
            }
            ans[i] = best;
        }
        was[i] = 1;
    }
    
    // 5. 出力 ～ 後処理.
    printf("%lld\n", ans[d.get(0)]);
    return 0;
}

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

#define dbg(help) cerr << #help << " = " << (help) << endl;
#define int  long long
#define endl "\n"

using namespace std;

void boot_up() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif
    cout.setf(ios::fixed); cout.precision(4);
}

const int INF = 1e18, maxn = 3e5 + 1;

signed main() {
    boot_up();

    string s;
    cin >> s;
    int i = 0; 
    char c;
    vector<char> t;
    while (i < 4) {
        c = s[i];
        while (i < 4 && c == s[i]) {
            i++;
        } 
        t.push_back(c);
    }

    // dbg(i)

    if (t.size() < 4) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

#define MOD 1000000007
typedef long long ll;

int main(){
  ll i, n, k, ans=0;
  scanf("%lld%lld",&n,&k);
  //N+1個の中からk個選ぶとき…{N+(N-1)+…+(N+1-K)}-{0+1+…+K-1}+1(=KN-k(k-1)/2-k(k-1)/2+1)通りある
  //これをkがN+1になるまで足す
  for(i=k;i<n+2;i++){
    ans += i*n-i*i+i+1;
    ans = ans%MOD;
  }
  printf("%lld",ans);
}
    
  
  
   

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

int main(){
  long long N,cnt=0,sum=0,minA=1000000001;
  cin >> N;
  
  for(int i=0;i<N;i++){
    long long a;
    cin >> a;
    sum += abs(a);
    minA = min(minA,abs(a));
    if(a<0) cnt++;
  }
  
  if(cnt%2==0) cout << sum << endl;
  else cout << sum - minA*2 << endl;
  return 0;
}


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

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

    if (A - K >= 0) {
      cout << A - K << ' ' << B;
    }
    else if (B - (K - A) >= 0 ) {
      cout << 0 << ' ' << B - (K - A);
    }
    else if (B - (K - A) < 0 ) {
      cout << 0 << ' ' << 0;
    }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, X;
    cin >> N >> X;

    struct Test {
        ll b, l, r;
    };
    vector<Test> tests(N);
    for (ll i = 0; i < N; i++) {
        cin >> tests[i].b >> tests[i].l >> tests[i].r;
    }
    sort(tests.begin(), tests.end(), [&](Test& lhs, Test& rhs) {
        ll lv = (X - lhs.b) * lhs.r + lhs.b * lhs.l;
        ll rv = (X - rhs.b) * rhs.r + rhs.b * rhs.l;
        return lv > rv;
    });
    vector<ll> score(N);
    for (ll i = 0; i < N; i++) {
        score[i] = (X - tests[i].b) * tests[i].r + tests[i].b * tests[i].l;
    }
    vector<ll> score_sum(N + 1, 0);
    for (ll i = 0; i < N; i++) {
        score_sum[i + 1] = score_sum[i] + score[i];
    }

    ll default_sum = 0;
    for (ll i = 0; i < N; i++) {
        default_sum -= tests[i].b * tests[i].l;
    }

    ll ok = X * N, ng = -1;
    while (ok != ng + 1) {
        ll mid = (ok + ng) / 2;

        ll a = mid / X;
        ll b = mid % X;

        bool flag = false;
        for (ll i = 0; i < N; i++) {
            ll curr_sum = default_sum;

            //iを除いた上位a個の和
            curr_sum += (i >= a ? score_sum[a] : score_sum[a + 1] - score[i]);

            //iからb個選ぶ
            curr_sum += tests[i].l * min(tests[i].b, b);
            curr_sum += tests[i].r * (b - min(tests[i].b, b));

            if (curr_sum >= 0) {
                flag = true;
                break;
            }
        }

        (flag ? ok = mid : ng = mid);
    }

    cout << ok << endl;
}

Measured memory_bytes: 4096
s = input()
t = input()

flag = 0
count = 0
rest_s = s
n = len(s)

for w in t:
  if w not in s:
    flag = 1
    print(-1)
    break

if flag == 0:
  for w in t:
    index = rest_s.find(w)
    #print(index)
    if (index != -1):
      if (rest_s != s):
        count += (index+1)
      else:
        count += (index)
      rest_s = s[count%n+1:]
    else:
      index = s.find(w)
      count = (count // n + 1) * n + index
      rest_s = s[count%n+1:]
    #print(index, count)
  print(count+1)


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

	int N, M; cin >> N >> M;
	if (M==N) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#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
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);
    int sum = 0;
    rep(i, N)
    {
        sum += a.at(i);
    }
    if (sum >= H)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

const int MAXN = 1e5 + 21;

int a[MAXN], b[MAXN];
int n;
long long ans;
pair <int, int> c[MAXN];

int main() {
	ios_base::sync_with_stdio;
	cin.tie();
	cout.tie();
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		c[i].first = a[i] + b[i];
		c[i].second = i;
	}

	sort(c, c + n);

	for (int i = n - 1; i >= 0; i -= 2)
		ans += a[c[i].second];
	for (int i = n - 2; i >= 0; i -= 2)
		ans -= b[c[i].second];
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;
#define Maxn 200000
int tmp[Maxn+5];
struct Person{
	int l,r;
	friend bool operator <(Person p,Person q){
		if(p.l==q.l){
			return p.r<q.r;
		}
		return p.l<q.l;
	}
}a[Maxn+5];
priority_queue<int,vector<int>,greater<int> > q;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].l,&a[i].r);
	}
	sort(a+1,a+1+n);
	int h=1,len=0;
	for(int i=1;i<=n;i++){
		q.push(a[i].r);
		if(h<=a[i].l){
			h++;
		}
		else{
			tmp[++len]=q.top();
			q.pop();
		}
	}
	sort(tmp+1,tmp+1+len);
	int ans=0,t=m;
	for(int i=len;i>0;i--){
		if(t>=h&&t>=tmp[i]){
			t--;
		}
		else{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3192
#include<iostream>

using namespace std;

static const int N = 100;

int main() {
  int M[N][N];

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }

  int u, k, v;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--; // to 0 origin
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--; // to 0 origin
      M[u][v] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) {
        cout << " ";
      }
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}


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

int main(){
	string s;
	cin >> s;
	long long ans = 0, sl = s.length()-1;
	for(long long i = sl; i >= 0; i--){
		if(s[i] == 'B'){
			ans += sl - i;
			sl--;
		}
		//cout << ans << " ";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
        while(true){
                int n,number[1000000],k;
                long long int num=0,max=-1000000000;
                cin >> n >> k;
                if(n+k==0)      break;
                for(int i=0 ; i<n ; i++ )
                        cin >> number[i];
                for(int i=0 ; i<n-k ; i++ ){
                        num=0;
                        for(int j=0 ; j<k ; j++ ){
                                num+=number[i+j];
                        }
                        if(max<num)
                                max=num;
                }
                cout << max << endl;

        }
        return 0;
}

Measured memory_bytes: 3484
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

list_ = [a,b,c,d,e,k]
flag = False
for factor_1 in list_:
  for factor_2 in list_:
    if abs(factor_1 - factor_2) > k:
      flag = True
    else:
      continue
if flag == True:
  print( ":(" )
else:
  print("Yay!")

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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
const ll INF=1e17L+5;const int mod=1e9+7;
int solve(ll mx,ll n,vector<ll> l,ll k,ll i){
    ll cnt=0;
    if(i==0)return 0;
    f(j,0,n)cnt+=(l[j]-1+i)/i -1;
    return cnt<=k ? 1 : 0;
    
}

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

    ll n,k,mx=0;cin>>n>>k;
    vector<ll> a(n);
    f(i,0,n){cin>>a[i];mx=max(mx,a[i]);}
    ll l=-1,r=mx;
    while(l<r-1){
        ll m=l+(r-l)/2;
        if(solve(mx,n,a,k,m)){
            r=m;
        }
        else l=m;
    }
    cs(r);
    
    

  }


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 110;

int n,a[N],cnt;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            for(int k=j+1;k<=n;k++)
                if( a[i] != a[j] && a[i] != a[k] && a[j] != a[k] && a[i]+a[j] > a[k] && a[i]+a[k] > a[j] && a[j]+a[k] > a[i] )
                    cnt++;

    printf("%d\n",cnt);
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpp;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pair<int, int>> vpp;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define all(n) (n).begin(), (n).end()
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void out(Arg1&& arg1) {
    cout << arg1 << '\n';
}

template <typename Arg1, typename ...Args>
void out(Arg1&& arg1, Args&& ...args) {
    cout << arg1 << ' ';
    out(args...);
}


template <typename T>
void outarr(vector<T> arr) {
    for (int i = 0; i < arr.size() -1; ++i) cout << arr[i] << ' ';
    cout << arr.back() << '\n';
}

template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    map<int, int> count;
    for (int i = 0; i < n -1 ; ++i) {
        int boss; cin >> boss;
        count[boss] += 1;
    }

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

    return 0;
}



Measured memory_bytes: 13048
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll Q, H, S, D;
ll N;

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

  cin >> Q >> H >> S >> D;
  cin >> N;
  
  ll one = INFINT, two = INFINT;

  one = min(Q*4, one);
  one = min(H*2, one);
  one = min(S, one);

  two = min(one*2, two);
  two = min(D, two);

  if (one*2 <= two) {
      cout << N * one << endl;
  } else {
      if (N%2 == 0) {
          cout << (N/2) * two << endl;
      } else {
          cout << (N/2) * two + one << endl;
      }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=15;
int d[N][N],dp[1<<N][N],a[1<<N],n,m,ans,sum;
void chmax(int &a,int b){if(a==-1||a<b)a=b;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		u--;
		v--;
		d[u][v]=d[v][u]=w;
		sum+=w;
	}
	memset(dp,-1,sizeof(dp));
	for(int s=0;s<(1<<n);s++)
		for(int i=0;i<n;i++)
			if(s&(1<<i))
				for(int j=i+1;j<n;j++)
					if(s&(1<<j))
						a[s]+=d[i][j];
	dp[1][0]=0;
	for(int s=1;s<(1<<n);s++)
	{
		for(int i=0;i<n;i++)
		{
			if(dp[s][i]==-1)
				continue;
			for(int j=0;j<n;j++)
			{
				if(s&(1<<j))
					continue;
				if(!d[i][j])
					continue;
				chmax(dp[s|(1<<j)][j],dp[s][i]+d[i][j]);
			}
			int k=(((1<<n)-1)^s)|(1<<i);
			for(int t=k;t;t=(t-1)&k)
				chmax(dp[s|t][i],dp[s][i]+a[t]);
		}
	}
	for(int s=0;s<(1<<n);s++)
		ans=max(ans,dp[s][n-1]);
	printf("%d\n",sum-ans);
	return 0;
}

Measured memory_bytes: 2304
n = int(input())
a = [0,0,0,0]
for i in range(n):
  s = input()
  if s=="AC":
    a[0] += 1
  elif s=="WA":
    a[1] += 1
  elif s=="TLE":
    a[2] += 1
  else:
    a[3] += 1
print("AC x ",end="")
print(a[0])
print("WA x ",end="")
print(a[1])
print("TLE x ",end="")
print(a[2])
print("RE x ",end="")
print(a[3])


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<k;i++)
    ans+=a[i];
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3636
cnt=0
def insertion_sort(A, g):
    global cnt
    N=len(A)
    for i in range(g,N):
        v=A[i]
        j=i-g
        while j>=0 and A[j]>v:
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v
def shell_sort(A):
    G=[]
    i=1
    while i<=len(A):
        G.append(i)
        i=i*3+1
    G=G[::-1]
    for g in G:
        insertion_sort(A, g)
    return G
N=int(input())
A=[int(input()) for _ in range(N)]
G=shell_sort(A)
print(len(G))
print(*G)
print(cnt)
for a in A:
    print(a)


Measured memory_bytes: 45516
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector< int > s(n), t(m);
  for (int i=0; i<n; ++i) cin >> s[i];
  for (int i=0; i<m; ++i) cin >> t[i];
  vector< vector< ul > > dp(n+1, vector< ul >(m+1, 0)), dps(n+1, vector< ul >(m+1, 0));
  dp[0][0] = 1;
  for (int i=0; i<=n; ++i) dps[i][0] = 1;
  for (int i=0; i<=m; ++i) dps[0][i] = 1;
  ul mod=1e9+7;
  for (int i=0; i<n; ++i) {
    ul sum = 0;
    for (int j=0; j<m; ++j) {
      if (s[i]==t[j]) dp[i+1][j+1] = dps[i][j];
      sum += dp[i+1][j+1];
      dps[i+1][j+1] = dps[i][j+1] + sum;
      dp[i+1][j+1]%=mod;
      dps[i+1][j+1]%=mod;
    }
  }
  cout << dps[n][m] << endl;
  return 0;
}


Measured memory_bytes: 62976
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N]; 
for(int i = 0;i < N;i++){
a[i] = sc.nextInt();
}
Arrays.sort(a);
int sumA = 0;
int sumB = 0;
for(int i = N-1;i >= 0;i = i-2){ sumA += a[i];}
for(int i = N-2;i >= 0;i = i-2){ sumB += a[i];}
System.out.println(sumA - sumB);
}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

long long n, m, a, b, s, x;

int main(){

    cin >> n >> m;

    vector<long long> v;

    vector<pair<long long, long long> > g;

    for(long long i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
    }

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



    for(long long i = 0; i < m; i++){
        cin >> a >> b;
        g.push_back(make_pair(b, a)); //value, amount
    }
    
    sort(g.rbegin(), g.rend());

    for(long long i = 0; i < n; i++){
        if(x >= m){
            break;
        }
        if(g[x].second < 1){
            x++;
        }
        if(v[i] < g[x].first){
            v[i] = g[x].first;
            g[x].second--;
        }
    }

    for(long long i = 0; i < n; i++){
        s += v[i];
    }

    cout << s;

 
}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out


Measured memory_bytes: 3188