akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

ll n;
ll a[3], b[3];

//きちんと場合分けしないと、ループが２重のうえ、後半で値が大きくなっていてTLEする
//ループには細心の注意を払うべし

ll calc(vector<ll> buy, vector<ll> sell, ll m) {
    if(buy.size() == 0) return m;
    if(buy.size() == 1) {
        ll rem = m;
        ll p = m / buy[0];
        ll r = m % buy[0];
        return p * sell[0] + r;
    }
    if(buy.size() == 2) {
        ll res = m;
        for(ll x = 0; x * buy[0] <= m; x++) {
            ll rem = m - x * buy[0];
            ll p = rem / buy[1];
            ll r = rem % buy[1];
            res = max(res, x * sell[0] + p * sell[1] + r);
        }
        return res;
    }
    if(buy.size() == 3) {
        ll res = m;
        for(ll x = 0; x * buy[0] <= m; x++) {
            for(ll y = 0; y * buy[1] <= m - x * buy[0]; y++) {
                ll rem = m - x * buy[0] - y * buy[1];
                ll p = rem / buy[2];
                ll r = rem % buy[2];
                res = max(res, x * sell[0] + y * sell[1] + p * sell[2] + r);
            }
        }
        return res;
    }
}

void solve() {
    cin >> n;
    rep(i, 3) cin >> a[i];
    rep(i, 3) cin >> b[i];

    vector<ll> buy, sell;
    rep(i, 3) {
        if(a[i] < b[i]) {
            buy.pb(a[i]);
            sell.pb(b[i]);
        }
    }
    n = calc(buy, sell, n);

    buy.clear(); sell.clear();
    rep(i, 3) {
        if(b[i] < a[i]) {
            buy.pb(b[i]);
            sell.pb(a[i]);
        }
    }
    n = calc(buy, sell, n);

    cout << n << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
using namespace boost::multiprecision;

int main(){

    int k,x;
    cin >> k >> x;

    if(k * 500 >= x){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
  char s[100];
  char s1[100]="ABC";
  int i=0;
  int flag=0;
  scanf("%s",s);
  while(s[i]!='\0' && s1[i]!='\0'){
    if(s[i]!=s1[i]){
      flag=1;
      break;
    }
    i++;
  }
  if(flag==1){
    printf("ABC");
  }else if(flag==0){
    printf("ARC");
  }
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
using namespace std;
typedef long long ll;
const int MAX_N = 7 + 100000;
///----------------------------------------------
int dig[MAX_N];
int main() {

    //freopen ( "xx.in" ,  "r" , stdin );

    ///read
    int n,m; cin>>n>>m;
    rep(i,1,n+1) scanf("%d",&dig[i]);

    ///work
    ll ans=0;
    rep(i,1,n+1) if (dig[i]+dig[i-1]>m) {
        ans+=dig[i]+dig[i-1]-m;
        dig[i]=m-dig[i-1];
    }
    cout << ans;

}


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

int main() {
  int n, a_score = 0, b_score = 0;
  cin >> n; vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  rep(i, n) {
    if (i % 2) b_score += a.at(i);
    else a_score += a.at(i);
  }
  cout << a_score - b_score << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstring>
#include <cctype>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
const int cap = 1001;
int N, w, s;
int64_t v;
int64_t dp[20001];
tuple<int, int, int64_t> T[cap];

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) {
        scanf(" %d %d %" SCNd64, &w, &s, &v);
        T[i] = make_tuple(w, s, v);
    }
    sort(T + 1, T + N + 1, [](tuple<int, int, int64_t> &x, tuple<int, int, int64_t> &y) {
        return get<0>(x) + get<1>(x) < get<0>(y) + get<1>(y);
    });
    
    int upper = get<0>(T[N]) + get<1>(T[N]);
    fill(dp, dp + upper + 1, 0);
    for (int i = 1; i <= N; ++i)
        for (int j = get<0>(T[i]) + get<1>(T[i]); j >= get<0>(T[i]); --j)
            dp[j] = max(dp[j], dp[j - get<0>(T[i])] + get<2>(T[i]));

    int64_t ans = *max_element(dp + 1, dp + upper + 1);
    printf("%" PRId64 "\n", ans);
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b;
  cin>>a>>b;
  int ans=0;
  rep(i,a,b+1){
    string s=to_string(i);
    int c=1;
    int n=s.size();
    rep(i,0,n){
      if(s[i]!=s[n-1-i]){
        c=0;
      }
    }
    ans+=c;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t;

int main()
{
	fast;
	ll a,b,c,d;
	cin>>a>>b>>c;
	ll x=fabs(b-c);
	if(x%2==1)
		cout<<"Borys";
	else
		cout<<"Alice";
}



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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; a++) {
    int rem = X - a * 500; // 残金
    // 区間の上端 - 区間の下端
    res += max(0, min(rem / 100 + 1, B + 1)) - max(0, min((rem - (C - 1) * 50) / 100, B + 1));
  }
  cout << res << endl;

  return 0;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+1==c){
    cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 256
a, b, m = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

sums = []
for i in range(m):
    m_list = list(map(int, input().split()))
    sum = a_list[m_list[0]-1] + b_list[m_list[1]-1] - m_list[2]
    sums.append(sum)

mins = min(a_list) + min(b_list)
sum_min = min(sums)
print(min(sum_min, mins))

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

void fnInput(string& rsNum, bool& rbRslt)
{
  int nDigit, nInfSiz;
  cin >> nDigit >> nInfSiz;
  rsNum.resize(nDigit, ' ');

  rbRslt = true;

  for (int i = 0; i < nInfSiz; i++)
  {
    int nPos, nNum;
    cin >> nPos >> nNum;

    if (nPos == 1 && nNum == 0 && nDigit > 1)
      rbRslt = false;
    else if (rsNum[nPos - 1] == ' ')
      rsNum[nPos - 1] = '0' + nNum;
    else if (rsNum[nPos - 1] != '0' + nNum)
      rbRslt = false;
    else
      continue;
  }
  return;
}
  
string fnNumstrGet(string sNum)
{
  for (int i = 0; i < sNum.size(); i++)
    if (sNum[i] == ' ')
      if ( !i )
        if (sNum.size() == 1) sNum[i] = '0';
        else                  sNum[i] = '1';
      else                    sNum[i] = '0';

  return sNum;
}
  
int main()
{
  string sNum;
  bool bRslt;

  fnInput(sNum, bRslt);
  if (!bRslt)
    cout << "-1" << endl;
  else
    cout << fnNumstrGet(sNum) << endl;

  return 0;
}

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

#define MAX_NO 2000000
#define MAX_VALUE 10000

int A[MAX_NO + 5];
int B[MAX_NO + 5];
int C[MAX_VALUE + 5] = { 0 };
int n, k = 0;

void CountingSort();

int main()
{
	int i;
	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		scanf("%d", &A[i]);
		if (A[i] > k) k = A[i];
	}
	CountingSort(n);
	for (i = 1; i <= n - 1; i++) printf("%d ", B[i]);
	printf("%d\n", B[i]);
}

void CountingSort() {
	int i;
	for (i = 1; i <= n; i++) C[A[i]]++;

	for (i = 1; i <= k; i++) C[i] += C[i - 1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
}




Measured memory_bytes: 17352
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n,m;
int fa[maxn],ran[maxn];
struct Edge{
	int l,r,w;
}pp[maxn];
bool cmp(const Edge &a,const Edge &b)
{
	return a.w<b.w;
}
void init(int size)
{
	for(int i=0;i<=size;i++)
		fa[i]=i,ran[i]=0;
}
int Find(int x)
{
	return fa[x]==x?x:Find(fa[x]);
}
void Union(int x,int y)
{
	int fx=Find(x),fy=Find(y);
	if(ran[x]>=ran[y]){
		ran[fx]+=ran[fy];
		fa[fy]=fx;
	}
	else {
		ran[fy]+=ran[fx];
		fa[fx]=fy;
	}
}
int main()
{
	int cnt=0,ans=0;
	cin>>n>>m;
	init(n);
	for(int i=1;i<=m;i++)
	{
		cin>>pp[i].l>>pp[i].r>>pp[i].w;
	}
	sort(pp+1,pp+1+m,cmp);
	for(int i=1;i<=m;i++)
	{
		if(Find(pp[i].l)!=Find(pp[i].r)){
			Union(pp[i].l,pp[i].r);
			ans+=pp[i].w;
		}
		if(cnt==n-1)break;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4360
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    k=INT()
    ct=0
    for i in range(7):
        if a>=b:
            b=2*b
            ct+=1
        else:
            break
    for i in range(7):
        if b>=c:
            c=2*c
            ct+=1
        else:
            break
    
    if ct<=k:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

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

int main() {
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  long long max = 0;
  long long i;
  for (i = 0; i < a; i++) {
    if (i == k) {
      cout << max << endl; 
      return 0;
    }
    max++;
  }
  
  for (i = a; i < a + b; i++) {
    if (i == k) {
      cout << max << endl; 
      return 0;
    }
  }

  for (i = a + b; i < a + b + c; i++) {
    if (i == k) {
      cout << max << endl;  
      return 0;
    }
    max--;
  }

  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
ll fact[200005];
#define eps 1e-9
#define INF 1e18
#define N 200005
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll a,b,n; cin>>a>>b>>n;
        ll x;
        if(b==1){
        	cout<<"0";
        	return 0;
        }
        if(n<b)x=n;
        else x=b-1;
        x=(a*x)/b-a*(x/b);
        cout<<x;
        return 0;
}


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

int main( int argc, char *argv[] )
{
int x;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> x;
	if( x < 1200 )
		cout << "ABC" << endl;
	else
		cout << "ARC" << endl;

	return 0;
}




Measured memory_bytes: 256
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
clis=[]
al=0
k_score=0
def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  clis.append(tmp)
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
uu=product((0,1),repeat=h+w)
for bits in uu:
  idd=[]
  coll=[]
  for i in range(h):
    if bits[i]==1:idd.append(i)
  
  for i in range(w):
    if bits[i+h]==1:coll.append(i)
  
  s=al
  if not coll:
    for x in idd:s-=idxs[x]
  elif not idd:
    for y in coll:s-=cols[y]
  else:
    for x in idd:s-=idxs[x]
    for y in coll:s-=cols[y]
    for x in idd:
      for y in coll:
        s+=clis[x][y]
        
  if s==k:k_score+=1
    
print(k_score)

Measured memory_bytes: 9176
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    for(let i = 1; i<=9;i++){
        for(let j = 1;j<=9; j++){
            if(i*j == n){
                console.log("Yes")
                return
            }
        }
    }
    console.log("No")
}
Main()


Measured memory_bytes: 29544
/*  Bismillahir Rahmanir Rahim  */

#include <bits/stdc++.h>

using namespace std;

const int N = 105;

string str;
int n, cr[N], nx[N];

int get(char c){
	memset(cr, 0, sizeof(cr));
	int flag = 0;
	for(int i = 1; i <= n; ++i){
		if(str[i] == c) flag = 1, cr[i] = 1;
	}
	if(!flag) return n;
	int siz = n;
	while(1){
		flag = 0;
		for(int i = 1; i <= siz; ++i){
			if(cr[i] == 0) flag = 1;
		}
		if(!flag) return n - siz;
		--siz;
		for(int i = 1; i <= siz; ++i){
			nx[i] = (cr[i] | cr[i+1]);
		}
		for(int i = 1; i <= siz; ++i) cr[i] = nx[i];
	}
}

int main(){
	cin >> str;
	n = str.size();
	str = "#" + str;
	int ret = n;
	for(char c = 'a'; c <= 'z'; ++c){
		ret = min(ret, get(c));
	}
	cout << ret << endl;
	return 0;
}



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

int memo[105][105] = {0};
vector<pair<int, int>> edge[105];
int n, m;

int solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) memo[i][j] = 100000000;
  for(int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    edge[a].push_back(make_pair(b, c));
    memo[a][b] = memo[b][a] = c;
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        memo[i][j] =
            min(memo[i][j], memo[i][k] + memo[k][j]);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < edge[i].size(); ++j)
      if(memo[i][edge[i][j].first] < edge[i][j].second)
        ++ans;
  return ans;
}

Measured memory_bytes: 256
N,M=map(int,input().strip().split())
AB=[list(map(int,input().strip().split())) for _ in range(N)]
AB.sort()

num=0
money=0
i=0
while num<M:
    num+=AB[i][1]
    money+=AB[i][0]*AB[i][1]
    if i<N-1 and num<M:
    	i+=1

money+=AB[i][0]*(M-num)

print(money)

Measured memory_bytes: 27288
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define drep(i,cc,n) for(int i=cc;i>n;--i)

typedef long long ll;
using namespace std;
int main() {
    int n;
    cin>>n;
    int b[n-1];
    int a[n];
    int ans=0;

    rep(i,0,n-1){
        cin>>b[i];
    }

    ans = b[0];
    rep(j,1,n-1){
        ans += min(b[j-1],b[j]);
    }
    ans += b[n-2];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  N = int(input())
  dic = {}
  for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    if (a,b) in dic:
      dic[(a,b)] += 1
    else:
      dic[(a,b)] = 1
  #print(dic)
  ans = 0
  for i in range(1,10):
    for j in range(1,10):
      if (i,j) in dic and (j,i) in dic:
        ans += dic[(i,j)]*dic[(j,i)]
  print(ans)
    

if __name__ == '__main__':
  main()

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

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

int check_triangle(int a, int b, int c){
    int tmp;
    if(b < c)
        swap(&b,&c);
    if(a < b)
        swap(&a,&b);
    if(a*a == b*b + c*c)
        return 1;

    return 0;
}
    
            
int main(void){
    int i;
    int N;
    int *data;

    scanf("%d",&N);
    data = (int*)malloc(sizeof(int)*N*3);
    if(data == NULL)
        exit(1);
    for(i=0;i<N;i++){
        scanf("%d %d %d",&data[3*i],&data[3*i+1],&data[3*i+2]);
    }
    for (i=0;i<N;i++){
        if(check_triangle(data[3*i],data[3*i+1],data[3*i+2]) == 1){
            printf("YES\n");
        }
        else
            printf("NO\n");
    }
    return 0;
}
        

Measured memory_bytes: 1724
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    XY = [[] for _ in range(N)]
    for i in range(N):
        A = int(input())
        XY[i] = [list(map(int, input().split())) for _ in range(A)]

    max_H = 0
    for i in range(2**N):
        bin = format(i, '015b')[::-1]
        ok = True

        for j in range(N):
            for x, y in XY[j]:
                if bin[j] == '1' and y != int(bin[x - 1]):
                    ok = False
                    break
                else:
                    continue
                break
        if ok:
            H = sum(int(x) for x in bin)
            max_H = max(max_H, H)
    print(max_H)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,k,jenis=0,occ[200005]={},lebih,ans;
priority_queue <int> temp;
int main()
{
	jenis=0;
	scan(n,k);
	for(int i=1;i<=n;i++)
	{
		int input;
		scan(input);
		occ[input]++;
		if(occ[input]==1)
			jenis++;
	}
	for(int i=1;i<=n;i++)
		if(occ[i])
			temp.push(-occ[i]);
	lebih=jenis-k;
	while(lebih>0)
	{
		ans+=abs(temp.top());
		temp.pop();
		lebih--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2168
package main

import "fmt"

func main() {
	var n, x, c uint16
	for {
		fmt.Scanln(&n, &x)
		c = 0
		if n == 0 && x == 0 {
			break
		}
		for i := uint16(1); i <= n; i++ {
			for j := i + 1; j <= n; j++ {
				for k := j + 1; k <= n; k++ {
					if i+j+k == x {
						c++
					}
				}
			}
		}
		fmt.Println(c)
	}
}



Measured memory_bytes: 1120
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int N): par(N) {
        for (int i=0;i<N;i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> X(100010), Y(100010), Z(100010);
    for (int j=0;j<M;j++) {
        cin >> X[j] >> Y[j] >> Z[j];
        X[j]--;
        Y[j]--;
    }

    UnionFind tree(N);
    for (int j=0;j<M;j++) {
        tree.unite(X[j], Y[j]);
    }
    int cnt = 1;
    for (int i=0;i<N;i++) {
        if (!tree.same(0,i)) {
            tree.unite(0,i);
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

long long MOD = 998244353;

//O(log n)
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    long long N, M, K;
    cin >> N >> M >> K;
    long long sum = 0;
    long long i;
    for(i=0; i<=K; i++){
        sum = (sum + (COM(N-1,i)*modpow(M-1,N-i-1,MOD))%MOD)%MOD;
    }
    sum = (M*sum)%MOD;
    cout << sum << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 15644
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int N = 1e5+5;
int a[N];

int main()

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;

    cout << max(a*b, c*d);

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		String[] t = saori.nextHayami().split("");
		int count = 0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals(t[i])){
				count++;
			}
		}
		System.out.println(count);

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  string s,t;
  cin>> s>>t;
  int ans =0;
  for(int i=0; i<3;i++){
    if(s[i]==t[i]){
      ans ++;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    cin>>n;
    bool prime;
    vector<int> arr;
    int x;
    int a;
    vector<int> primes;
    for (int i=2;i<=n;i++){
        a=0;
        prime=true;
        for (int j:primes){
            if (i%j==0){
                prime=false;
                break;
            }
        }if (!prime)continue;
        primes.emplace_back(i);
        x=n;
        while (x>1){
            a+=x/i;
            x/=i;
        }arr.emplace_back(a);
    }
    unsigned long long p=1;
    for (int i:arr){
        p=(p*(i+1))%1000000007;
    }cout<<p<<endl;
    return 0;
}

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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B;

    cin >> A >> B;

    if (A < 1 || B < 1 || A > 9 || B > 9)
    {
        cout << -1;
    }
    else
    {
        cout << A * B;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque
import sys
try:
    from typing import List
except ImportError:
    pass

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    G = [[] for _ in range(N)]  # type: List[List[int]]
    for Ai, Bi in zip(A, B):
        Ai -= 1
        Bi -= 1
        G[Ai].append(Bi)
        G[Bi].append(Ai)

    ans = [-1] * N
    ans[0] = 0
    q = deque([0])
    while q:
        s = q.popleft()
        for t in G[s]:
            if ans[t] >= 0:
                continue
            ans[t] = s
            q.append(t)

    if -1 in ans:
        print(NO)
        return

    print(YES)
    for ansi in ans[1:]:
        print(ansi + 1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51020
//
// [解法]
// この問題は、AとBの両方を隣接頂点として持つ頂点だけに限定して考えてもよいことがわかる
// （なぜなら、クヌースがそのような頂点に到達してしまった場合、次にAまたはBに進めといわれても進めなくなってしまうから、
//   最初からクヌースはそこに行けないとしてしまってもよい）
// なので、「隣接頂点にAまたはBを持たない頂点」を消す、という処理を繰り返せばよい。
// 具体的には、最初にn点全てをチェックして消すべき頂点をリストアップした後、
// 消すべき頂点を消す→その隣りを次回に削除すべき候補かチェックすべきリスト(queue)にためておく
// ということを繰り返せばよい。（計算量も頂点の数＋エッジの数程度ですむ）
//
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[200005];

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);
    scanf("%s", str);

    vector<vector<long> > z(n);

    long i,j;
    for(i=0; i<m; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        z[a-1].push_back(b-1);
        z[b-1].push_back(a-1);
    }

    queue<long> que;
    for(i=0; i<n; i++) {
        long a=0, b=0;
        for(j=0; j<z[i].size(); j++) {
            if(str[z[i][j]]=='A') a++;
            else                  b++;
        }
        if(a==0||b==0) {
            que.push(i);
        }
    }

    vector<long> flag(n, 0);
    while( !que.empty() ) {
        long i = que.front();
        que.pop();

        if(flag[i]) continue;

        long a=0, b=0;
        for(j=0; j<z[i].size(); j++) {
            if(!flag[z[i][j]]) {
                if(str[z[i][j]]=='A') a++;
                else                  b++;
            }
        }
        if(a==0||b==0) {
            flag[i]=1;
            for(j=0; j<z[i].size(); j++) {
                if(!flag[z[i][j]]) {
                    que.push( z[i][j] );
                }
            }
        }
    }

    for(i=0; i<n; i++) {
        if(flag[i]==0) {
            printf("Yes\n"); return 0;
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 14080
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
inline bool CMP1(char a,char b)
{
	return a<b;
}
inline bool CMP2(char a,char b)
{
	return a>b;
}
int main()
{
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end(),CMP1);
	sort(t.begin(),t.end(),CMP2);
	if(s<t) printf("Yes");
	else printf("No");
	return 0;
}

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

void checkint(int N,int*Sn,int*Tn){
  int i;
  int flag=0;
  for(i=0;i<N;i++){
    if(Sn[i]!=Tn[i]){
      flag=flag+1;
    }
  }
  if(flag==0){
    printf("Yes");
  }else{
    printf("No");
  }
}
    

void sortchar(int N,int*S,int*Sn){
  int i,k;
  int count=1;
  int R[1000];
  for(i=0;i<1000;i++){
    R[i]=0;
  }
  
  for(i=0;i<N;i++){
    k=S[i];
    if(R[k]==0){
      Sn[i]=count;
      R[k]=count;
      count=count+1;
    }else{
      Sn[i]=R[k];
    }
  }
}

int main(){
  char S[300000];
  char T[300000];
  scanf("%s",S);
  scanf("%s",T);
  int N;
  N=strlen(S);
  int i;
  int Sm[N];
  int Tm[N];
  for(i=0;i<N;i++){
    Sm[i]=(int)S[i];
    Tm[i]=(int)T[i];
  }
  
  int Sn[N];
  int Tn[N];
  sortchar(N,Sm,Sn);
  sortchar(N,Tm,Tn);
  checkint(N,Sn,Tn);
  //printf("%d",'a');
  return 0;
}

  


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<int>l;
	int n, m;
	while (cin >> n >> m){
		if (n == 0 && m == 0)break;
		int k[1001];
		for (int i = 0; i < n; i++){
			cin >> k[i];
		}
		sort(k, k + n);
		int sum = 0;
		for (int i = 0; i < n; i++)
			if (n % m != i % m)sum += k[i];
		l.push_back(sum);
	}
	for (int i : l) {
		cout << i << endl;
	}
	char c;
	cin >> c;
}

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

int main(){
  int K,N;
  cin>>K>>N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin>>A.at(i);
  }
  multiset<int> B;
  for (int i=0; i<N-1; i++){
    B.insert(A.at(i+1)-A.at(i));
  }
  B.insert(A.at(0)+K-A.at(N-1));
  B.erase(B.find(*max_element(B.begin(),B.end())));
  cout<<accumulate(B.begin(),B.end(),0)<<endl;
}

Measured memory_bytes: 13532
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 998244353
#define INF 10000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll par[maxn], child[maxn];

ll fp(ll a){
    while(par[a] != a){
        par[a] = par[par[a]];
        a = par[a];
    }
    return a;
}
void join(ll x, ll y){
    ll px = fp(x), py = fp(y);
    if(px != py){
        par[px] = py;
        child[py] += child[px];
    }
}

void solve(){

    ll n, m, k;
    cin >> n >> m >> k;
    for(ll i = 0; i <= n; i++) {
        par[i]  =i; child[i] = 1;
    }

    ll fd[m][2], fo[k][2], ans[n+1];
    for(ll i = 0 ; i  < m; i++){
        cin >> fd[i][0] >> fd[i][1];
        join(fd[i][0], fd[i][1]);
    }
    for(ll i = 0 ; i  < k; i++){
        cin >> fo[i][0] >> fo[i][1];
    }
    for(ll i = 1; i <= n; i++)
        ans[i] = child[fp(i)] - 1;
    for(ll i = 0 ; i < m; i++){
        ans[fd[i][0]]--; ans[fd[i][1]]--;
    }
    //for(ll i = 1; i <= n; i++)cout << ans[i] << " ";
    for(ll i = 0 ; i < k; i++){
        if(fp(fo[i][0]) == fp(fo[i][1]))
        {ans[fo[i][0]]--; ans[fo[i][1]]--;}
    }
    for(ll i = 1; i <= n; i++)cout << ans[i] << " ";

}

int main()
{
    fast();
    int t= 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 6272
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        int i,j;
        long long a,b,c,d;
        long long ll;
        int n;
        c=0;
        scanf("%lld",&n);
        scanf("%lld",&a);
        scanf("%lld",&b);
        for(i=2;i<n;i++){
                scanf("%lld",&ll);
                c = c^ll;
        }
        d=a+b;
        if(((d-c)%2)!=0){
                printf("-1\n");
                return 0;
        }
        long long e;
        long long f;
        e=(d-c)/2;
        f=d-e;
        for(i=40;i>=0;i--){
                if(((e>>i)%2 == 0) && ((f>>i)%2 == 1)){
                        if(e+(1ull<<i) <= a){
                                e=e+(1ull<<i);  
                        }
                }
        }
        //printf("%lld\n",e);
        if(e<=0 || e>a){
                printf("-1\n");
                return 0;
        }

        if( (e^(d-e)) != c){
                printf("-1\n");
                return 0;
        }
        printf("%lld\n",a-e);
        return 0;
}
                


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

    int A, B;
    cin >> A >> B;
    cout << ((A * B) % 2 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    input = input.split('\n')[1].split(' ').map(n => Number(n));
    var count = 0;
    var execute = (array) => {
        var min = Math.min(...array);
        if ( min !== 0) {
          array = array.map((el) => el - min);
          count += min;
        }
        if (array.every(el => el === 0)){
            return ;
        }
        var index = array.indexOf(0);
        var newArray = array.splice(0,index);
        if (newArray.length !== 0) {
          execute(newArray);
        }
        array.shift();
        if (array.length !== 0) {
          execute(array);
        }
    }
    execute(input);
    console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

const int N = 1005;
string s[N];
int h, w;
const int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int d[N][N];

bool ok(int i, int j) {
  return 0 <= i and i < h and 0 <= j and j < w and s[i][j] == '.' and d[i][j] == -1;
}

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

  memset(d, -1, sizeof(d));
  cin >> h >> w;
  int sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  --sx, --sy, --fx, --fy;
  for (int i = 0; i < h; ++i) cin >> s[i];
  using state = tuple<int, int, int>;
  deque<state> q;
  q.emplace_back(sx, sy, 0);
  while (!q.empty()) {
    auto [x, y, dd] = q.front();
    q.pop_front();
    if (d[x][y] != -1) continue;
    d[x][y] = dd;
    for (int i = 0; i < 4; ++i) {
      int nx = x + dx[i], ny = y + dy[i];
      if (ok(nx, ny)) q.emplace_front(nx, ny, dd);
    }
    for (int i = -2; i <= 2; ++i) {
      for (int j = -2; j <= 2; ++j) {
        int nx = x + i, ny = y + j;
        if (ok(nx, ny)) q.emplace_back(nx, ny, dd + 1);
      }
    }
  }
  cout << d[fx][fy];

  return 0;
}


Measured memory_bytes: 9232
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
l=[1]+[0 for _ in range(n+5)]
if m==0:a=[200000]
for x in range(n):
    if x<a[0]:
        l[x+1]+=l[x]
        l[x+2]+=l[x]
    if x==a[0]:
        if len(a)>=2:a.pop(0)
        else:a[0]=200000
print(l[n]%(10**9+7))

Measured memory_bytes: 468200
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
using namespace std;
string S,P,res,tmp;
long long F[3500][3500];
int main()
{
    //freopen("LCS.INP","r",stdin);
    cin>>S;
    cin>>P;
    for (int i=0;i<=S.size()-1;i++)
        for (int j=0;j<=P.size()-1;j++)
        {
            if (S[i]==P[j]) F[i+1][j+1]=F[i][j]+1;
            else F[i+1][j+1]=max(F[i+1][j],F[i][j+1]);
        }
    int i=S.size(),j=P.size();
    while (i>0 && j>0)
    {
        if (S[i-1]==P[j-1] && F[i][j]>0)
        {
            res+=S[i-1];
            i--;
            j--;
        }
        else if (F[i-1][j]==F[i][j])
            i--;
        else j--;
    }
    tmp=res;
    j=res.size()-1;
    if (j+1>1)
    {
        for (int i=0;i<=res.size()-1;i++)
        {
            res[i]=tmp[j];
            j--;
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 84224
A, B, C, D = map(int, input().split())
t_q, t_d = divmod(C, B)
a_q, a_d = divmod(A, D)
t_eq = t_q if t_d == 0 else t_q + 1
a_eq = a_q if a_d == 0 else a_q + 1
if t_eq <= a_eq:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9108
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
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;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(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(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int x,a,b; cin >> x >> a >> b; x-=a;
    out(x%b);

    return 0;
}

Measured memory_bytes: 256
# Problem: https://atcoder.jp/contests/abc085/tasks/abc085_b
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(riceCakesList):
    result = 0
    # print("LIST={}".format(riceCakesList))
    # algorithm
    result = len(set(riceCakesList))
    return result
if __name__ == "__main__":
    N = II()
    DI = list()
    for _ in range(N):
        DI.append(II())
    print("{}".format(solver(DI)))


Measured memory_bytes: 3064
N, M = list(map(int, input().split()))
cnt = [0] * N
for i in range(M):
    a, b = list(map(int, input().split()))
    cnt[a - 1] = cnt[a - 1] + 1
    cnt[b - 1] = cnt[b - 1] + 1

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


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

int main() {
  string s;
  vector<int> alf(26,0);
  cin >> s;
  for(int i = 0;i < s.size();i++){
    alf[s[i] - 'a']++;
  }
  for(int i = 0;i < 26 ;i++){
    if(alf[i] == 0){
      cout << (char)('a' +i) << endl;
      return 0;
    }
  }
  cout << "None"<< endl;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main(void)
{
	int w;
	char s[100001];
	scanf("%s%d", s,&w);
	for (int i = 0; i < strlen(s); i += w) {
		printf("%c", s[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;



public class Main{

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n=scanner.nextInt();
    int k=scanner.nextInt();
    int num=0;
    double ans=0;
    int flg=0;

    for(int i=1;i<=n;i++){
      flg=0;
      double nn=1/(double)n;
        num=i;
        while(num<k){
          flg++;
          num*=2;
        }
        for(int j=0;j<flg;j++){
          nn*=0.5;
        }
        ans+=nn;
        
    }
    System.out.printf("%.12f\n",ans);
  }
}


Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    a.push_back(x);
    sort(a.begin(), a.end());
    vector<int> dif(a.size() - 1);
    rep(i, dif.size()) {
        dif.at(i) = a.at(i + 1) - a.at(i);
    }
    int ans = dif.at(0);
/*    if (dif.size() == 2) {
        cout << dif.at(1) - dif.at(0) << endl;
        return 0;
    }*/
    for (int i = 1; i < dif.size(); i++) {
        ans = gcd(ans, dif.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
typedef long long T;

// gcd
LL gcd(LL a, LL b) {
	while(b){
		auto t=a%b;
		a=b;
		b=t;
	}
	return a;
}

//lcm
LL lcm(LL a, LL b) {return a/gcd(a,b)*b;}

// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
LL modinv(LL a, LL m){
	LL x,y;
	gcdex(a,m,x,y);
	if(x<0){
		x+=m;
	} else if(x>=m){
		x-=m;
	}
	return x;
}
const long long M = 998244353;
const int L=1e6+1;

LL w[L];
LL cnt[L];
void solve(long long N, std::vector<long long> A){
	LL sum=0;
	for(int i=1;i<L;i++){
		w[i]+=modinv(i,M);
		w[i]%=M;
		for(int j=i*2;j<L;j+=i){
			w[j]+=M-w[i];
			w[j]%=M;
		}
#if 0
		if(i<=6){
			cerr << i << ": " << w[i] << endl;
			LL v=0;
			for(int j=1;j<=i;j++){
				if(i%j==0){
					v+=w[j];
				}
			}
			cerr << v*i%M << endl;
		}
#endif
	}

	for(auto a:A){
		cnt[a]++;
		sum+=M-a;
		sum%=M;
	}

	for(int i=1;i<L;i++){
		LL s=0;
		for(LL j=i;j<L;j+=i){
			s+=j*cnt[j];
		}
		s%=M;
		s*=s;
		s%=M;
		s*=w[i];
		s%=M;
		/*
		if(s>0){
			cerr << i << ", " << s << endl;
			cerr << i << ":: " << s << endl;
		}
		*/
		sum+=s;
		sum%=M;
	}
	//cerr << sum << endl;
	sum*=modinv(2,M);
	sum%=M;
	//cout << sum << endl;
	printf("%lld\n", sum);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 17408
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	var a, b, c, d int64
	fmt.Sscan(getNextString(scanner), &a)
	fmt.Sscan(getNextString(scanner), &b)
	fmt.Sscan(getNextString(scanner), &c)
	fmt.Sscan(getNextString(scanner), &d)

	lcd := c * d / gcd64(c, d)

	ans := b - a + 1

	ans -= b / c
	ans -= b / d
	ans += b / lcd
	ans += (a - 1) / c
	ans += (a - 1) / d
	ans -= (a - 1) / lcd

	fmt.Fprintln(writer, ans)
	writer.Flush()
}
func gcd64(m, n int64) int64 {
	if n == 0 {
		return m
	}
	return gcd64(n, m%n)
}

Measured memory_bytes: 640