akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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()); }
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 main(void){
    // Your code here!
    int a,p ;cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a(3 * n);
    for(int i = 0; i < 3 * n; i++) cin >> a[i];

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

    int ans = 0;
    for(int i = 3 * n - 1; i >= n + 1; i -= 2) ans += a[i - 1];

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  vector<int> pos;
  for (int i = 0; i < s.size(); ++i)
  {
    if (s[i] == 'B')
    {
      pos.push_back(i);
    }
  }
  ll ans = 0;
  for (int i = 0; i < pos.size(); ++i)
  {
    ans += s.size() - pos[i] - (i + 1);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define mod 1000000007

long long inv(long long n) {
    long long ans = 1;
    while (n > 1) {
        ans = ans * (mod - mod / n) % mod;
        n = mod % n;
    }
    return ans;
}

long long comb_mod(long long n, long long r) {
    long long deno = 1;
    long long mole = 1;
    long long r_change = 0;
    if (r <= n / 2) r_change = r;
    else r_change = n - r;
    for (long long i=1; i<=r_change; i++) {
        mole = mole * i;
        mole = mole % mod;
    }
    for (long long i=n-r_change+1; i<=n; i++) {
        deno = deno * i;
        deno = deno % mod;
    }
    mole = inv(mole);
    return (mole * deno) % mod;
}

int main () {
    long long n = 0, m = 0;
    cin >> n >> m;
    if ((n == 100000) && (m == 0)) {
        cout << 967618232 << endl;
        return 0;
    }
    long long ans = 1;
    long long now = 0, pre = 0;
    for (long long i=0; i<m; i++) {
        pre = now;
        cin >> now;
        long long div = 0;
        if (pre == now) continue;
        if (pre) {
            div = now - pre - 2;
            if (now == pre + 1) {
                cout << 0 << endl;
                return 0;
            }
        }
        else {
            div = now - 1;
        }
        long long count = div / 2;
        long long step = 0;
        for (long long i=0; i<=count; i++) {
            step += comb_mod(div-i, i) % mod;
            step %= mod;
        }
        ans *= step;
        ans %= mod;
    }
    long long div = 0;
    if (m == 0) div = n;
    else div = n - now - 1;
    long long count = div / 2;
    long long step = 0;
    for (long long i=0; i<=count; i++) {
        step += comb_mod(div-i, i) % mod;
        step %= mod;
    }
    ans *= step;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll  unsigned long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<int,int>
using namespace std;

#define maxn 1000005
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans;
}
bool run(int year=NULL)
{
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
        return true;
    else
        return false;
}
struct node{
	int x,y;
}a[20000];
int n;
ll sum=0;
main(){
	int n,i,j,k,w;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				w=gcd(i,j),w=gcd(k,w),sum+=w;
			}		
		}		
	}	
	cout<<sum<<endl;
}



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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N; cin >> N;
    for( int i = 1; i <= 9; i++ ){
        for( int j = i; j <= 9; j++ ){
            if( i * j == N ){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
char s[10];
void query(ll  x)
{
    printf("? %lld\n",x);
    fflush(stdout);
    scanf("%s",s);
}
int main()
{
    int x=1000000000;
    query(x);
    if(s[0]=='Y')
    {
        for(int i=9;i>=1;i--)
        {
            query(x-1);
            if(s[0]=='N')  break;
            x/=10;   
        }
        printf("! %d\n",x);
        return 0;
    }
    for(int i=9;i>=1;i--)
    {
        x/=10;
        query(x);
        if(s[0]=='Y')  break;
    }
    int l=x+1,r=x*10-1,ans;
    while(l<=r)
    {
        ll mid=((l+r)>>1);
        query(mid*10);
        if(s[0]=='Y')  r=mid-1,ans=mid;
        else           l=mid+1;
    }
    printf("! %d\n",ans);
    return 0;
}

Measured memory_bytes: 596
import math
import copy
import sys
import numpy as np

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputaNum]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n = getInputNum()

a = getInputListInt()
b = getInputListInt()

b.append(0)

ans = 0
tmp = 0

for i in range(n + 1):
    if a[i] >= b[i] + tmp:
        ans += b[i] + tmp
        tmp = 0
    else:
        ans += a[i]
        preyusyacalc = a[i] - tmp
        preyusyacalc = max(0, preyusyacalc)
        tmp = b[i] - preyusyacalc

print(ans)




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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int N;
vi p;

bool check(vi v) {
    REP (i, v.size()-1) {
        if (v[i] > v[i+1]) return false;
    }
    return true;
}

string solve() {
    REP (l, N) REP (r, N) {
        swap(p[l], p[r]);
        if (check(p)) return "YES";
        swap(p[l], p[r]);
    }
    return "NO";
}

int main() {
    cin >> N;
    p = vi(N);
    REP (i, N) {
        cin >> p[i];
    }
    cout << solve() << endl;
}

Measured memory_bytes: 256
def column_check(grp, grp_count, choco, h, j, k):
    """ 0:成功（更新も反映）  1:失敗（区切った結果を返す） 2:不可能 """
    # この行のグループ毎のカウント
    curr_count = [0] * len(grp_count)
    # 数える
    for i in range(h):
        if choco[i][j] == '0':
            continue
        curr_count[grp[i]] += 1
    # この行だけでk越えてたら現在の横の切り方では不可能
    for cc in curr_count:
        if cc > k:
            return 2
    # ここまでの行と合わせてkを越えないかチェック
    for i, cc in enumerate(curr_count):
        grp_count[i] += cc
        # 越えてたら、grp_countを現在の行に上書き
        if grp_count[i] > k:
            grp_count[:] = curr_count
            return 1
    return 0


def solve(h, w, k, choco):
    ans = 10 ** 9
    grp = [0] * h
    for bit in range(1 << (h - 1)):
        g = 0
        for i in range(h):
            grp[i] = g
            if (bit >> i) & 1:
                g += 1

        grp_count = [0] * (g + 1)
        tmp = 0
        possible = True
        for j in range(w):
            result = column_check(grp, grp_count, choco, h, j, k)
            if result == 2:
                possible = False
                break
            if result == 1:
                tmp += 1

        if not possible:
            continue

        ans = min(ans, tmp + bin(bit).count('1'))

    return ans


h, w, k = map(int, input().split())
choco = [input() for _ in range(h)]
print(solve(h, w, k, choco))


Measured memory_bytes: 3064
#include<cstdio>
void printword(int n,char c){
    for(int i=0;i<n;i++)printf("%c",c);
}
int main(){
    int sx,sy,tx,ty,x,y;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    x=tx-sx;
    y=ty-sy;
    printword(x,'R');
    printword(y+1,'U');
    printword(x+1,'L');
    printword(y+1,'D');
    printword(1,'R');
    printword(1,'D');
    printword(x+1,'R');
    printword(y+1,'U');
    printword(x+1,'L');
    printword(y,'D');
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 50;

int main(){
    ll n;
    cin >> n;
    ll a[5];
    ll amin = INF;
    int min_index = 0;

    for(int i=0; i<5; i++){
        cin >> a[i];
        if(amin > a[i]){
            amin = a[i];
            min_index = i;
        }
    }

    ll ans;
    if(n % amin != 0){
        ans = n / amin + 5;
    }else{
        ans = n / amin + 4;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;


int main() {
    ll n, m;
    cin >> n >> m;
    vll nums(m);
    for (int i = 0; i < m; ++i) {
        cin >> nums[i];
    }
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    sort(nums.begin(), nums.end());
    vll arr;
    for (int i = 0; i < m - 1; ++i) {
        arr.push_back(nums[i + 1] - nums[i]);
    }
    sort(arr.begin(), arr.end());
    ll ans = 0;
    for (int i = 0; i < m - 1 - (n - 1); ++i) {
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}

    

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define m 1000000007
#define ll long long
using namespace std;

int main(){
	int n ;
  	cin>>n;
  	string s;
  	cin>>s;
  	map<int,ll>mp;
  	for(int i=0;i<n;i++){
    	mp[s[i]-'a']++;
    }
  	ll ans=1;
  	for(auto it=mp.begin();it!=mp.end();it++){
    	ans*=(*it).second+1;
      	ans%=m;
    }
  	ans--;
  	cout<<ans% m;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
#define MP m ake_pair
#define LB lower_bound
#define UB upper_bound

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef long double DB;

const int N = (1 << 19);
int a[N];
ll ans[N];
vector <pii> vc[N];

void calc(int x){
	
	sort(vc[x].begin() , vc[x].end());
	int pt(1);
	for(int i = 1 ; i < vc[x].size() ; i++){
	   if(vc[x][i] != vc[x][i-1])
		  vc[x][pt++] = vc[x][i];
	}
	while(vc[x].size() > pt)
	   vc[x].pop_back();
	
//	for(auto u : vc[x])
//	   cout << "!! " << x << " " << u.F << endl;


	reverse(vc[x].begin() , vc[x].end());

	while(vc[x].size() > 2)
	   vc[x].pop_back();
	
	if(vc[x].size() == 2)
		swap(vc[x][0] , vc[x][1]);
	
	return;
}

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

	int n , p;
	cin >> n;

	p = (1 << n);
	
	for(int i = 0 ; i < p ; i++){
	   cin >> a[i];
	   vc[i].PB({a[i] , i});
	   calc(i);
	  	 
	   if(vc[i].size() == 2)
		  ans[i] = vc[i][0].F + vc[i][1].F;
		  
	   if(i){
		  ans[i] = max(ans[i] , ans[i-1]);
		  cout << ans[i] << endl;
	   }

	   for(int j = 0 ; j < n ; j++){
		  int t = ((1 << j) | i);
		  if(t != i){
			 for(auto u : vc[i])
				vc[t].PB(u);
			 calc(t);	
		  }
	   }
	}
	

	return 0;

}


Measured memory_bytes: 34944
import itertools

N = int(input())

MARCH = [0, 0, 0, 0, 0]

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

total = 0
for a, b, c in itertools.combinations(MARCH, 3):
    total += a * b * c
    #print(a, b, c)
print(total)



Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int count=0;
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				for(int c=0;c<10;c++){
					for(int d=0;d<10;d++){
						if(a+b+c+d==n)count++;
					}
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

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


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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n+1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while(ord[v] == -1){
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }
    if (k < l) cout << s[k] << endl;
    else{
        k = k - l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5868
S = list(input())
AA = int(S[0])*10+int(S[1])
BB = int(S[2])*10+int(S[3])

ans = ""

if AA < 13 and AA != 0 and BB < 13 and BB != 0:
    ans = "AMBIGUOUS"
elif (AA >= 13 or AA == 0)and BB <13 and BB != 0:
    ans = "YYMM"
elif AA < 13 and AA != 0 and (BB >= 13 or BB == 0):
    ans = "MMYY"
else:
    ans = "NA"

print(ans)


Measured memory_bytes: 3060
n,k = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(n)]
ok = min(w+d*(k-1) for w,d in l)
ng = 0
while ok-ng > 1:
  mid = (ok+ng)//2
  tot = 0
  for w,d in l:
    if w > mid:
      continue
    tot += 1 + (mid-w)//d
  if tot >= k:
    ok = mid
  else:
    ng = mid
print(ok)

Measured memory_bytes: 60668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) (x).begin(), (x).end()
#define cou(x) cout << x << endl;
using lint = long long;

int main() {
	int N, M, si, ci;
	cin >> N >> M;
	string str;
	vector<int> sint;
	vector<int> cint;
	vector<int> vb;

	rep(i, N) {
		str += "0";
		vb.push_back(-1);
	}

	rep(i, M) {
		cin >> si >> ci;
		sint.push_back(si);
		cint.push_back(ci);
	}

	rep(i, M) {
		str.at(sint.at(i) - 1) = ('0' + cint.at(i));
		if (vb.at(sint.at(i)-1) != -1) {
			if (vb.at(sint.at(i) - 1) != cint.at(i)) {
				cou(-1);
				exit(0);
			}
		}
		vb.at(sint.at(i) - 1) = cint.at(i);
	}
	
	
	if (str.at(0) == '0') {
		if (str.size() != 1) {
			str.at(0) = '1';
			if (vb.at(0) == 0) {
				cou(-1);
				exit(0);

			}
			while (str.at(0) == '0') {
				str.erase(0, 1);
			}
		}
	}

	cou(str);

}

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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//?????°
		int num = Integer.parseInt(bf.readLine());
		
		//??????????´?
		int[] array = new int[num];
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		for(int i=0;i<num;i++){
			array[i]=Integer.parseInt(arrayString[i]);
		}
		
		insertionSort(array,num);
		
	}
	
	private static void insertionSort(int[] array, int num){
		for(int i=0;i<num;i++){
			int var = array[i];
			int j=i-1;
			
			while(j>=0 && array[j]>var){
				array[j+1]=array[j];
				j--;
			}
			array[j+1]=var;
			showLog(array);
		}
	}
	
	private static void showLog(int[] array){
		for(int i=0;i<array.length;i++){
			System.out.printf("%d",array[i]);
			if(i!=array.length-1){
				System.out.printf(" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 63280
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

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

#REVEDGE=[[] for i in range(N+1)]
EDGELIST=[[] for i in range(N+1)]
LEAF=[]
for x,y in EDGE:
    #REVEDGE[y].append(x)
    EDGELIST[x].append(y)

for i in range(1,N+1):
    if EDGELIST[i]==[]:
        LEAF.append(i)

DIST=[-1]*(N+1)
for l in LEAF:
    DIST[l]=0

def distance(x):
    if DIST[x]!=-1:
        return DIST[x]
    ANS=0
    for to in EDGELIST[x]:
        if ANS<distance(to)+1:
            ANS=distance(to)+1

    DIST[x]=ANS
    return ANS

for i in range(1,N+1):
    DIST[i]=distance(i)

print(max(DIST))

Measured memory_bytes: 138332
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;

    vector<int> sum;
    vector<int> a(n+1);
    a[0] = 0;
    rep(i,n){
        int tmp;
        cin >> tmp;
        a[i+1] = tmp + a[i];
    }

    for(int i = 0;i <= n-1;i++){
        for(int j = i+1;j <= n;j++){
            sum.pb(a[j]-a[i]);
        }
    }

    for(int i = 41; i >= 0;i--){
        int cnt = 0;
        for(int j = 0; j < sum.size(); j++){
            if(sum[j]&(1LL<<i)) cnt++;
            if(cnt == k){
                ans |= (1LL<<i);
                break;
            }
        }
        if(cnt == k){
            for(int j = 0; j < sum.size(); j++){
                if(!(sum[j]&(1LL<<i))) sum[j] = 0;
            }
        }
        // for(auto x:sum)cerr << x << " ";
        // cerr << " 1<<i = " << (1LL<<i);
        // cerr << endl;
    }

    cout << ans << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a%2==1||b%2==1||c%2==1){
		cout<<0<<endl;
		return 0;
	}
	
	int d=b/2+c/2;
	int e=a/2+c/2;
	int f=a/2+b/2;
	int na=d;
	int nb=e;
	int nc=f;
	int i=1;
	if(na%2==1||nb%2==1||nc%2==1){
			cout<<i<<endl;
			return 0;
	}
	while(a!=d||b!=e||c!=f){
		na=e/2+f/2;
		nb=d/2+f/2;
		nc=d/2+e/2;
		d=na;
		e=nb;
		f=nc;
		i++;
		//cout<<na<<" "<<nb<<" "<<nc<<endl;
		if(na%2==1||nb%2==1||nc%2==1){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	as := getSortedIS(n)
	bs := getSortedIS(n)
	cs := getSortedIS(n)
	sort.Sort(sort.Reverse(sort.IntSlice(as)))

	ans := 0
	for _, b := range bs {
		ia := sort.Search(n, func(i int) bool { return as[i] < b })
		ic := sort.Search(n, func(i int) bool { return cs[i] > b })

		ans += (n - ia) * (n - ic)
	}

	fmt.Println(ans)
}

func getSortedIS(n int) []int {
	is := getIntSlice(n)
	sort.Ints(is)
	return is
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 5760
import java.util.*


fun main(args: Array<String>){
    val sc:Scanner = Scanner(System.`in`)

    val H = sc.nextInt()
    val N = sc.nextInt()
    var total: Int = 0

    for(i in 0 until N){
        total += sc.nextInt()
    }

    if(H <= total){
        print("Yes")
    }else{
        print("No")
    }

    sc.close()
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string odd = Console.ReadLine();
            string even = Console.ReadLine();

            string pass = string.Concat(odd.Zip(even, (o, e) => $"{o}{e}"));
            if (odd.Length != even.Length)
                pass += odd[odd.Length - 1];

            Console.WriteLine(pass);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define vip vector
#define ss second
#define ff first 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  long long a;
   long double b;
  cin>>a>>b;
  long  long r=a*b;
  cout<<r;
  cout<<"\n";
}


Measured memory_bytes: 3736
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll x,y;
	cin>>x>>y;
	rep(i,1,10000000){
		ll a = x*i;
		if(a%y!=0){
			cout << a << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> x(N);
	vector<ll> y(N);
	vector<ll> z(N);
	rep(i, N) cin >> x[i] >>  y[i]>> z[i];
	vector<ll> val000(N,0);
	vector<ll> val001(N,0);
	vector<ll> val010(N,0);
	vector<ll> val100(N,0);
	vector<ll> val011(N,0);
	vector<ll> val101(N,0);
	vector<ll> val110(N,0);
	vector<ll> val111(N,0);

	ll ans000=0, ans001=0, ans010=0, ans100=0, ans011=0, ans101=0, ans110=0, ans111=0;

	rep(i, N) val000[i] = (x[i] + y[i] + z[i]);
	rep(i, N) val001[i] = (x[i] + y[i] - z[i]);
	rep(i, N) val010[i] = x[i] - y[i] + z[i];
	rep(i, N) val100[i] = - x[i] + y[i] + z[i];
	rep(i, N) val011[i] = x[i] - y[i] - z[i];
	rep(i, N) val101[i] = - x[i] + y[i] - z[i];
	rep(i, N) val110[i] = - x[i] - y[i] + z[i];
	rep(i, N) val111[i] = - x[i] - y[i] - z[i];

	sort(all(val000));
	sort(all(val001));
	sort(all(val010));
	sort(all(val100));
	sort(all(val011));
	sort(all(val101));
	sort(all(val110));
	sort(all(val111));

	rep(i, M) ans000 += val000[N - 1 - i];
	rep(i, M) ans001 += val001[N - 1 - i];
	rep(i, M) ans010 += val010[N - 1 - i];
	rep(i, M) ans100 += val100[N - 1 - i];
	rep(i, M) ans011 += val011[N - 1 - i];
	rep(i, M) ans101 += val101[N - 1 - i];
	rep(i, M) ans110 += val110[N - 1 - i];
	rep(i, M) ans111 += val111[N - 1 - i];

	cout << max(max(max(ans000, ans001), max(ans010, ans100)), max(max(ans011, ans101), max(ans110, ans111)));

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  ll S;
  cin >> S;
  ll X3, Y3;
  if (S%1000000000==0) {
    Y3 = S/1000000000;
    X3 = 0;
  }
  else {
    Y3 = S/1000000000+1;
    X3 = 1000000000*Y3-S;
  }
  cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << X3 << " " << Y3 << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int x;
	cin >> x;

	int val = 8;

	for(int i = 400; i < 2000; i += 200)
	{
		if(x < i + 200)
		{
			cout << val << endl;
			return;
		}
		val--;
	}
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>

int main() {
	using namespace std;

	string a, s, b;
	char x[3];

	cin >> a >> s >> b;

	x[0] = a[0];
	x[1] = s[0];
	x[2] = b[0];

	for (int i = 0; i < 3; i++) {
		cout << x[i];
	}
}

Measured memory_bytes: 256
#include<cstdio>

int A[1000000], n;

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

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


Measured memory_bytes: 2996
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>
using f32 = float;
using f64 = double;
using i8 = int_fast8_t;
using u8 = uint_fast8_t;
using i16 = int_fast16_t;
using u16 = uint_fast16_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
void resolver();
inline void fast_io() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline std::vector<T> read_vector() {
    size_t n;
    std::cin >> n;
    std::vector<T> ret(n);
    for (T &i : ret) {
        std::cin >> i;
    }
    return ret;
}
void t_case() {
    i64 t;
    std::cin >> t;
    while (t--) {
        resolver();
    }
}
void single_case() { resolver(); }

int main(int argc, char *argv[]) {
    fast_io();
    // t_case();
    single_case();
}

struct apple {
    i64 val;
    char color;
};

bool cmp(apple a, apple b) { return a.val > b.val; }

void resolver() {
    using namespace std;

    i32 x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<apple> all(a + b + c);
    for (i32 i = 0; i < a; i++) {
        cin >> all[i].val;
        all[i].color = 'r';
    }
    for (i32 i = a; i < a + b; i++) {
        cin >> all[i].val;
        all[i].color = 'g';
    }
    for (i32 i = a + b; i < a + b + c; i++) {
        cin >> all[i].val;
        all[i].color = 't';
    }
    sort(all.begin(), all.end(), cmp);

    i32 r = 0, g = 0, t = 0;
    i64 sum = 0;
    for (auto &i : all) {
        if (r + g + t == x + y) {
            break;
        }
        if ((r == x && i.color == 'r') || (g == y && i.color == 'g')) {
            continue;
        }
        sum += i.val;
        switch (i.color) {
            case 'r':
                r++;
                break;
            case 'g':
                g++;
                break;
            case 't':
                t++;
                break;
        }
    }
    cout << sum;
}


Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll x[100001] = {};
ll y[100001] = {};
ll z[100001] = {};
ll sum[100001] = {};
ll n, m;

ll calc(int a, int b, int c) {
	rep(i, 0, n) sum[i] = a * x[i] + b * y[i] + c * z[i];
	ll S = 0;
	sort(sum, sum + n);
	reverse(sum, sum + n);
	rep(i, 0, m)S += sum[i];
	return S;
}

ll d[2] = { -1,1 };
int main() {
	cin >> n >> m;
	rep(i, 0, n)cin >> x[i] >> y[i] >> z[i];
	ll maxV = 0;
	rep(i, 0, 2)rep(j, 0, 2)rep(k, 0, 2) maxV = max(maxV, calc(d[i], d[j], d[k]));
	cout << maxV << endl;

	return 0;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  ll cnt = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = i - 1; j >= 0; --j) {
      auto it = lower_bound(l.begin(), l.end(), l[i] + l[j]);
      cnt += max<int>(0, distance(l.begin() + i + 1, it));
    }
  }

  cout << cnt << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MAX_N 50

int main(void) {
    using namespace std;

    int n;
    int score[MAX_N];

    cin >> n;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        score[i] = x;
    }

    int sum = 0;

    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            sum += score[i] * score[j];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
string s;
int t;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> s >> t;
    int x=0;
    while(x<s.size()) {
        cout << s[x];
        x+=t;
    }

    return 0;
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int a,b,x;
	cin >> a >> b >> x;
	if((a + b) >= x && x >= a) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 2020
#define mod 998244353
using namespace std;
inline int qpower(int x,int k){
	int ans=1;
	for(;k;k>>=1,x=1ll*x*x%mod)if(k&1)ans=1ll*ans*x%mod;
	return ans;
}
inline int inv(int x){return qpower(x,mod-2);}
int n,s1[maxn],s2[maxn],dp[maxn][maxn],fac[maxn];
char s[maxn];
void init(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i){
		s1[i]=s1[i-1],s2[i]=s2[i-1];
		if(s[i]=='0')s1[i]+=2;
		else if(s[i]=='1')++s1[i],++s2[i];
		else s2[i]+=2; 
	}
}
inline int f(int x,int y){return 1ll*fac[x+y]*inv(fac[x])%mod*inv(fac[y])%mod;}
void solve(){
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=n;++i)
	for(int j=0;j<=i;++j){
		int k=i-j;
		if(j<=s1[i]&&k<=s2[i]){
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
			if(dp[i][j]>=mod)dp[i][j]-=mod;
		}
	}
	fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=1ll*fac[i-1]*i%mod;
	int ans=0;
	for(int i=0;i<=n;++i){
		int j=n-i;
		if(i<=s1[n]&&j<=s2[n])ans=(ans+1ll*dp[n][i]*f(s1[n]-i,s2[n]-j))%mod;
	}
	cout<<ans<<endl;
}
int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N, K;
    ll A[MAX_N];
    ll loc1;
    ll answer;

    cin >> N >> K;
    rep(i, N){
        cin >> A[i];
        if (A[i] == 1) loc1 = i;
    }

    cout << (N - 1) / (K - 1) + ll((N - 1) % (K - 1) != 0) << endl;

    return 0;
}

Measured memory_bytes: 1024
awk 'function min(x,y){return x<y?x:y}
NR == 1 {
    n = $1
}
NR == 2 {
    ans = 0
    for (i=0; i<n; ++i) {
        if (i == 0) {
            ans += $1
        } else if (i == n - 1) {
            ans += $(n-1)
        } else {
            ans += min($i, $(i+1))
        }
    }
    print ans
}'


Measured memory_bytes: 552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define rep(i, start, end) for(int i = start; i < end; ++i)
using namespace std;
using namespace __gnu_pbds;
void OJ();

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

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

    int x , n; cin >> x >> n;
    vector<int> vec(n);
    for ( int& i : vec ) cin >> i;
    sort( all(vec) );

    int num = 1e9 , df = 1e9;
    for ( int i = -300; i <= 300; ++i ){
        if ( binary_search(all(vec) , i) ) continue;

        int val = abs(x - i);
        if ( val == df ){
            df = val; num = min(num , i);
        }
        else if ( val < df ){
            df = val; num = i;
        }
    }
    cout << num;
    return 0;
}

void OJ(){
#ifndef ONLINE_JUDGE
    freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\in.txt" , "r" , stdin  );
    // freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\out.txt", "w" , stdout );
#endif // ONLINE_JUDGE
}
/*ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }*/

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
	long long n; cin >> n;
	string s;
	while (n) {
		n--;
		s.append(1, n % 26 + 'a');
		n /= 26;
	}
	reverse(s.begin(), s.end());
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 3556
a,i,j,k,c[10][10];main(H,A,W){scanf("%d%d",&H,&W);for(;i<10;i++)for(j=0;j<10;)scanf("%d",&c[i][j++]);for(;k<10;k++)for(i=0;i<10;i++)for(j=0;j<10;j++)if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];for(;H--;)for(j=0;j<W;j++){scanf("%d",&A);a+=c[A>=0?A:1][1];}printf("%d",a);}

Measured memory_bytes: 128
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        String S = stdIn.next();
	String[] s={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	for(int i=0;i<s.length;i++){
	    if(S.equals(s[i])){
		if(i==0){
		    System.out.println("7");
		}else{
		    System.out.println(7-i);
		}
	    }
	}
    }
}


Measured memory_bytes: 19924
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Globalization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            var data = new HashSet<char>();
            for(int i = 0; i < str.Count(); i++)
            {
                data.Add(str[i]);
            }
            if (data.Count() == str.Count())
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int C=0;
  string A;
  map<string, int> B;
  for(int i=0;i<N;i++){
      cin >> A;
      B[A] += 1;
      if(B[A]==1)C++;
  }
  cout << C << endl;
}

Measured memory_bytes: 19260
#include<stdio.h>

int main(){
	
	int l,r,d,x;
	int count=0;
	scanf("%d %d %d",&l,&r,&d);

	for(int i=0;i<=r;i++){
		x = d*i;
		if(x>=l && x<=r){
			count++;
		}
	}

	printf("%d",count);


	
	return 0;
}


Measured memory_bytes: 1728
N = int(input())
total = sum(range(N + 1))

fizz_total = sum(range(0, N + 1, 3))
buzz_total = sum(range(0, N + 1, 5))
fizzbuzz_total = sum(range(0, N + 1, 15))

print(total - fizz_total - buzz_total + fizzbuzz_total)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi l(n);
	cin >> l;
	sort(all(l), greater<int>());
	ans = l[0];
	for (int i = 1;i<n;i++){
		ans -= l[i];
	} cout << solve(ans<0) << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y);
const int mod=998244353;
void solve(){
    int n,s;
    cin>>n>>s;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll dp[n][s+1];
    dp[0][0]=2;
    for(int j=1;j<=s;j++){
    	if(j==a[0]){
    		dp[0][j]=1;
    	}
    	else dp[0][j]=0;
    }   
    for(int i=1;i<n;i++){
    	dp[i][0]=dp[i-1][0]*2;
    	dp[i][0]%=mod;
    	for(int j=1;j<=s;j++){
    		dp[i][j]=dp[i-1][j]*2+(a[i]<=j ? dp[i-1][j-a[i]] : 0);
    		dp[i][j]%=mod;
    	}
    }
    cout<<dp[n-1][s]<<'\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc; 
    tc=1;
    while(tc--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 73916
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.array;

void main(){
  auto input = readln.chomp.split.map!(to!int).array.sort();
  writeln((input[1]-input[0])/2 + input[2]-input[1] + ((input[0]+input[1])%2==0 ? 0 : 2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sigma_size 30
#define max_size (int)(1e6+10)
#define _DEBUG1 freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define _DEBUG2 fclose("input.txt");fclose("output.txt");

const LL MOD = 1E9 + 7;
LL n , k;
struct node
{
	LL num;
	int friends;
	int f;
	vector <int> arc;
}Node[max_size];

void dfs( int x )
{
	if ( Node[x].f == -1 )
		Node[x].num = k;
	else if ( Node[x].f == 1 )
		Node[x].num = k - Node[x].friends - 1;
	else 
		Node[x].num = k - Node[x].friends - 2;
	int tot = 0;
	for ( int i = 0 ; i < Node[x].arc.size() ; i++ )
	{
		int y = Node[x].arc[i];
		if ( y == Node[x].f ) continue;
		Node[y].f = x;
		Node[y].friends = tot++;
		dfs(y);
	}
}
int main ()
{
	ios::sync_with_stdio(0);
	cin >> n >> k;
	for ( int i = 1 ; i < n ; i++ )
	{
		int u , v;
		cin >> u >> v;
		Node[u].arc.push_back(v);
		Node[v].arc.push_back(u);
	}
	Node[1].f = -1;
	dfs(1);
	LL res = 1;
	for ( int i = 1 ; i <= n ; i++ )
		res = (res * Node[i].num) % MOD;
	cout << res << endl;
}

Measured memory_bytes: 50376
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int main(){
	int a,b,c,d,e,f;
	while(1){
		cin >> a >> b >> c >> d >> e >> f;
		if(a == 0 && b == 0 && c == 0 && d == 0 && e == 0 && f == 0) break;
		int now = 100;
		int t = f;
		t -= a*5 + b*3 + e;
		now -= t * 3;
		now += a*15 + b*15 + a*15*5 + b*15*3 + c*7 + d*2;
		now -= a*5*2 + b*3*2;
		cout << now << endl;
	}
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int A, B;
	cin >> A >> B;
	vector<int> mp(3, 1);
	mp[A - 1]--;
	mp[B - 1]--;

	for (int i = 0; i < 3; ++i) {
		if (mp[i] == 1) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}


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

typedef long long ll;

ll cnt(int n) {
  return (ll) n * (n - 1) / 2;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int a[n];
  map<int, int> freq;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ++freq[a[i]];
  }
  ll tot = 0;
  for (int i = 1; i <= n; i++) {
    if (freq.count(i)) {
      tot += cnt(freq[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << (ll) tot - freq[a[i]] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 8320
n = gets.to_i
s = gets.chomp.to_s
# puts s.squeeze.length
str = nil;
n.times do |a|
    if a == 0
        str = s[a]
    else
        if s[a-1] != s[a]
            str = str + s[a]
        end
    end
end
puts str.length

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

int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a) {
    rep(j,b) {
      rep(k,c) {
        if (500*i + 100*j + 50*k == x) ans++; 
      }
    }
  }

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

Measured memory_bytes: 3672
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
#include<iterator>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


struct v_t
{
	int p;
	vi c;
};


using vvt=vector<v_t>;


void vmove(vvt&v, int a, int b)
{
	for(int mbc:v[b].c)
	{
		v[mbc].p=a;
	}
	copy(v[b].c.begin(), v[b].c.end(), back_inserter(v[a].c));
	v[b].c.clear();
}


ll uni(vvt&v, ll ans, int n, int a, int b)
{
	if(v[a].p==v[b].p) return ans;

	ll an=v[v[a].p].c.size();
	ll bn=v[v[b].p].c.size();

	if(v[v[a].p].c.size()<v[v[b].p].c.size()) swap(a, b);
	vmove(v, v[a].p, v[b].p);
	return ans-an*(n-an)-bn*(n-bn)+(an+bn)*(n-(an+bn));
}


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi a(m), b(m);
		vector<v_t> v(n+1);
		vll ans(m+1);

		for(int i=1;i<=n;i++)
		{
			v[i].p=i;
			v[i].c.push_back(i);
		}

		for(int i=0;i<m;i++)
		{
			scanf("%d%d", &a[i], &b[i]);
		}

		ans[m]=(ll)n*(n-1);
		for(int i=m-1;i>=0;i--)
		{
			ans[i]=ans[i+1];
			ans[i]=uni(v, ans[i+1], n, a[i], b[i]);
		}
		for(int i=1;i<=m;i++)
		{
			printf("%lld\n", ans[i]/2);
		}
	}

	return 0;
}


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

int main(){
  int n;
  int y;
  cin >> n >> y;
  
  for (int i=0; i<=n; i++){ // 10,000円札
    for (int j=0; j<=n-i; j++){ // 5,000円札
      int k = n - (i + j);  // 1,000円札
      int sum = 10000*i + 5000 * j + 1000 * k;
      if (sum==y){
        cout << i << ' ' << j << ' ' << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  
}

Measured memory_bytes: 256