akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,ans ,d;
    char b;

    while(cin>>a>>d>>b>>ans){
        d= d*100 + ans;
        ans = a*d;


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


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

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



int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a,&b,&c,&d);
    if(abs(a-c)<=d){
        printf("Yes");
    }else if((abs(a-b)<=d) && (abs(b-c)<=d)){
        printf("Yes");        
    }else{
        printf("No");
    }
    return 0;
}



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

int main() {
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> h(n);
  rep (i, n) cin >> h.at(i);
  sort(h.begin(), h.end());

  int64_t remaining = n - k;
  if (remaining <= 0) {
    cout << 0 << endl;
  } else {
    int64_t sum = 0;
    rep (i, remaining) {
      sum += h.at(i);
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll    long long int
#define ld    long double
#define pb    push_back
#define mp    make_pair
#define Maxn  1000007
#define ff    first
#define se    second
using namespace std;
 

int main() {
    vector <ll> vi;
    set<ll> s;
	ll n,i,mx=0,mx1=0,x,y,cnt=0;
	cin>>n;
	ll a[n+1];
	for(i=1;i<=n;i++){
	    cin>>a[i];
	    if(mx<a[i]){
	        mx=a[i];
	        x=i;
	    }
	}
//	cout<<mx<<" ";
	for(i=1;i<=n;i++){
	    if(mx==a[i]){
	       cnt++;
	    }
	}
	if(cnt>=2){
	    for(i=1;i<=n;i++){
	        cout<<mx<<endl;
	    }
	}
	else{
    	for(i=1;i<=n;i++){
    	    if(mx!=a[i]){
    	        if(mx1<a[i]){
    	            y=i;
    	            mx1=a[i];
    	        }
    	    }
    	}
    	for(i=1;i<=n;i++){
    	    if(i==x){
    	        cout<<mx1<<endl;
    	    }
    	    else{
    	        cout<<mx<<endl;
    	    }
    	}
	}
	
	
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<int>())
typedef long long ll;
#define len(s) s.length()

void solve() {
    ll n,k,ans;
    cin>>n>>k;
    vector<int> a(n+1),pos,v(n+1);
    rep(i,n)
    {
      cin>>a[i+1];
      v[i+1]=0;
    }
    int current=1;
    pos.pb(1);
    v[current]=-1;
    ll startpos,period;

    for(int i=1;i<=k; i++)
    {
      current=a[current];
      if(v[current])
      {
        v[current]=max(0,v[current]);
        startpos=v[current];
        period=i-startpos;
        break;
      }
      pos.pb(current);
      v[current]=i;
      if(i==k)
      {
          cout<<current;
          return;
      }
    }

    ans = pos[startpos + (k-startpos)%period];
    cout<<ans;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
      solve();

	  return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll k,a,b; cin >> k >> a >> b;
    ll ans=1;
    if(a-1>k){
        ans+=k;
    }else if(b-a > 2){
        if(ans < a){
            if(k>a-1){
                ans = a;
                k -= a-1;
            }
        }
        ans += (k/2)*(b-a);
        if(k%2==1) ans++;
    }else{
        ans += k;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int[] cnt = new int[1000000];

        for (int i=1; i<=n; i++) {
            int tmp = sc.nextInt()+1;
            cnt[tmp]++;
            cnt[tmp-1]++;
            cnt[tmp+1]++;
        }

        int ans = 0;

        for (int i=0; i<cnt.length; i++) {
            ans = Math.max(ans, cnt[i]);
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 62868
//It is made by Awson on 2018.2.3
    #include <bits/stdc++.h>
    #define LL long long
    #define dob complex<double>
    #define Abs(a) ((a) < 0 ? (-(a)) : (a))
    #define Max(a, b) ((a) > (b) ? (a) : (b))
    #define Min(a, b) ((a) < (b) ? (a) : (b))
    #define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
    #define writeln(x) (write(x), putchar('\n'))
    #define lowbit(x) ((x)&(-(x)))
    using namespace std;
    const int l1 = 10000000;
    const int l2 = 25500000;
    const int yzh = 1e9+7;
    void read(int &x) {
        char ch; bool flag = 0;
        for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
        for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
        x *= 1-2*flag;
    }
    void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
    void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }
     
    int s, f[l2+5];
     
    int quick_pow(int a, int b) {
        int ans = 1;
        while (b) {
    	if (b&1) ans = 1ll*ans*a%yzh;
    	a = 1ll*a*a%yzh, b >>= 1;
        }
        return ans;
    }
    int count1(int n) {
        int ans = 0, r = 0, cnt = 0;
        for (int i = 1; i < l1; i++) {
    	cnt -= f[i-1];
    	while (cnt+f[r+1] <= s && r < l2) cnt += f[++r];
    	if (cnt == s) ++ans;
    	if (r == l2) break;
        }
        return ans;
    }
    int count2(int n) {
        int lim = n/8, ans = lim;
        for (int t = 1; t <= lim; t++)
    	if (n%t == 0) {
    	    int len = n/t;
    	    (ans += (1ll*quick_pow(10, len-1)*9%yzh-t)%yzh) %= yzh;
    	}
        return ans;
    }
    void work() {
        for (int i = 1, r = 10, cnt = 1; i < l1; i++, i = r, r = r*10, cnt++)
    	for (int j = i; j < r; j++) f[j] = cnt;
        for (int i = l1; i <= l2; i++) f[i] = 8;
        read(s);
        writeln(((count1(s)+count2(s))%yzh+yzh)%yzh);
    }
    int main() {
        work();
        return 0;
    }

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    string ans = "AC";
    if(s[0] != 'A') ans = "WA";
    s[0] = 'a';
    int cnt = 0;
    for(int i=2;i<n-1;i++){
        if(s[i] == 'C'){
            s[i] = 'c';
            cnt++;
        }
    }
    if(cnt != 1){
        ans = "WA";
    }
    for(int i=0;i<n;i++){
        if(s[i] >= 'a' && s[i] <= 'z') continue;
        ans = "WA";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,B,C;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
	B=b;
	b=a;
	a=B;
	}
	if(a>c){
	C=c;
	c=a;
	a=C;
	}
	if(b>c){
	C=c;
	c=b;
	b=C;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}
	

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

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

int main(){

	stack<int> stk;
	string str;
	int c=0;
	int sum=0;
	while(cin>>str){
		for(int i=0;i<str.size();i++){
			if(isdigit(str[i])){
				stk.push(str[i]-'0');
			}
			else{
				int tmp=0;
				int digit=1;
				while(!stk.empty()){
					tmp += stk.top() * digit;
					stk.pop();
					digit *= 10;
				}
				sum+=tmp;
			}
		}

		int tmp=0;
		int digit = 1;
		while(!stk.empty()){
			tmp += stk.top() * digit;
			stk.pop();
			digit *= 10;
		}
		sum+=tmp;
	}

	cout << sum << endl;
}

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

using namespace std;
int main()
{
    int arr[3];
    int i;
    for( i=0;i<3;i++)
    {
        cin>>arr[i];
    }
    sort(arr, arr+3);
    i=0;
    int result=(arr[i+1]-arr[i])+(arr[i+2]-arr[i+1]);
    cout<<endl<<result;


}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
 int a,b,c,x,y,z;

 scanf ("%d %d %d", &a, &b, &c);


 if (a > b) {
	
    x = a;
    a = b;
    b = x;

}

 if (b > c) {
	y = b;
	b = c;
	c = y;
}
 if (a > b) {
	z = a;
	a = b;
	b = z;
}


 printf("%d %d %d\n", a, b, c);
 return 0;

}

Measured memory_bytes: 2700
// https://atcoder.jp/contests/abc148/tasks/abc148_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if (N % 2 == 0) {
        // 10 と 5 で割れる回数
        int sum = 0;
        int mul = 10;
        while (true) {
            sum += N / mul;
            mul *= 5;
            if (N / mul == 0) {
                break;
            }
        }
        cout << sum << endl;
    } else {
        cout << "0\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
//        if( A >= 10 || B >= 10){
//            System.out.println(-1);
//        } else {
//            System.out.println(A * B);
//        }
        System.out.println(A < 10 && B < 10 ? A * B: -1);
    }
}

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

using namespace std;

int main(void)
{
    char S[101];
    cin >> S;

    for (int i = 0; S[i] != '\0'; i++)
    {
        char c = S[i];
        if (i % 2 == 0)
        {
            if (!(c == 'R' || c == 'U' || c == 'D'))
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            if (!(c == 'L' || c == 'U' || c == 'D'))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=1;i<n;i++){
        map<char,int> mp;
        for(int j=0;j<i;j++){
            for(int k=i;k<n;k++){
                if(s[j]==s[k] && !mp.count(s[j])){
                    mp[s[j]]=1;
                }
            }
        }
        int tmp=mp.size();
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static long d(long sx,long sy,long gx,long gy)
        {
            return Math.Abs(gx - sx) + Math.Abs(gy - sy);
        }
      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var abcxy = Reads();
            var a = abcxy[0];
            var b = abcxy[1];
            var c = abcxy[2];
            var x = abcxy[3];
            var y = abcxy[4];
            var ans = long.MaxValue;
            for (int i = 0; i <= 2*Math.Pow(10, 5); i+=2)
            {
                var tmp = c * i + Math.Max(0,x - i / 2 )* a + Math.Max(0,y - i / 2) * b;
                if (ans > tmp) ans = tmp;
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
from collections import Counter
import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    a = Counter(map(int, input().split()))
    dp = [[[.0] * (n+1) for _ in range(n+1)] for _ in range(n+1)]
    for k in range(a[3]+1):
        for j in range(a[2]+a[3]-k+1):
            for i in range(n-j-k+1):
                if i + j + k == 0:
                    continue
                tmp = n
                if i > 0:
                    tmp += i * dp[i-1][j][k]
                if j > 0:
                    tmp += j * dp[i+1][j-1][k]
                if k > 0:
                    tmp += k * dp[i][j+1][k-1]
                dp[i][j][k] = tmp / (i+j+k)
    print(dp[a[1]][a[2]][a[3]])

if __name__ == '__main__':
    main()

Measured memory_bytes: 253704
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
 
//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;

//---------------------------------------------------TEMPLATES-------------------------------------------------------

void add_self(ll &a , ll b){
	a += b ;
	if(a>=MOD){
		a -= MOD ; 
	}
}

void sub_self(ll &a , ll b){
	a -= b ;
	if(a<0){
		a += MOD ; 
	}
}

void merge_self(vector<ll> &a , vector<ll> b){
	ll s = a.size() ;
	beg(i , s) a[i] += b[i] ;
}

void set_self(vector<ll> &a , ll n , ll s){
	beg(i , s) a[i] = n ;
}

ll factors(){

}

//---------------------------------------------------FUNCTIONS-------------------------------------------------------

void solve(){
	ll n , k;
	cin >> n >> k ;
	vector<ll> dp(k+1 , 0) , fake(k+1 , 0) ;
	dp[0] = 1 ;
	beg(j , n){
		ll candies ;
		cin >> candies ;
		for(ll i=k ; i>=0 ; --i){
			ll start = i+1 , end = i + min(candies , k-i) ;
			if(start <= end){
				add_self(fake[start] , dp[i]);
				if(end+1 <= k)
					sub_self(fake[end+1] , dp[i]);
			}
			/*for(ll j=1 ; j<=min(candies , k-i) ; j++){
				add_self(dp[i+j] , dp[i]) ;
			}*/	
		}
		ll pre = 0 ;
		for(ll i=0 ; i<=k ; i++){
			add_self(pre , fake[i]) ;
			add_self(dp[i] , pre) ;
			fake[i] = 0 ;
		}
	}
	cout << dp[k] << nl ;
}
//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}	

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

int main (){
	int n;
	int i=0;
	char str;
	cin>>n;
	while (i<n){
		cin>>str;
		if (str=='Y'){
			cout<<"Four"<<endl;
			return 0;
		}
	i++;
	}
cout<<"Three"<<endl;
return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int count = 0;

	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (500*i + 100*j + 50*k == X) {
					count++;
				}
			}
		}
	}

	cout << count << endl;
	return 0;
}

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

int main(){
    char a, b;
    char ans;

    cin >> a >> b;

    if( a=='H' ){

        if( b=='H' ){
            ans='H';
        }else if( b=='D' ){
            ans='D';
        }

    }else if( a=='D' ){

        if( b=='H' ){
            ans='D';
        }else if( b=='D' ){
            ans='H';
        }

    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define swap(a, b) {char tmp = a; a = b; b = tmp;}

int main(void)
{
	char s[4];
	char ball[3] = {1};
	int i;
	
	while (scanf("%s",s) != EOF){
		swap(ball[s[0] - 'A'], ball[s[2] - 'A']);
	}
	for (i = 0; i < 3; i++){
		if (ball[i] == 1){
			printf("%c\n", 'A' + i);
		}
	}
	
	return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;long long k,I,A,xy,x[2],fib[2],a,i;double D;int dp[3],h;int main(){cin>>k;a=sqrt(k)/16;xy=(long long)(2*sqrt(k-a-0.01))-1;A=(xy+2)*(xy+2)/4;I=(xy+1)*(xy+1)/4+1;D=1.0*(A+I)/2;if(k<=D){x[1]=(k-I)*2;}else{x[1]=(A-k)*2+1;}x[0]=xy-x[1];
for(h=0;h<2;h++){
if(x[h]<3){fib[h]=x[h]+1;}
else{
dp[0]=1;dp[1]=2;dp[2]=3;
for(i=3;i<=x[h];i+=3){
dp[0]=(dp[1]+dp[2])%M;
dp[1]=(dp[2]+dp[0])%M;
dp[2]=(dp[0]+dp[1])%M;
}
fib[h]=dp[x[h]%3];
}
}
cout<<(fib[0]*fib[1])%M<<endl;}

Measured memory_bytes: 3092
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <set>
#include <string.h>
#include <functional>

using namespace std;
int v[102];
int m[102];
int main()
{
    while(true){
        int n,w;
        cin>>n>>w;
        if(n==0)
            break;
        int ma=0;
        int ma2=0;
        memset(m,0,sizeof(m));
        for(int i=0;i<n;i++){
            cin>>v[i];
            m[v[i]/w]++;
            ma=max(ma,v[i]/w);
            ma2=max(ma2,m[v[i]/w]);
        }
        double ans=0;
        for(int i=0;i<=ma;i++){
            ans+=(double)(ma-i)*m[i]/ma/ma2;
            //cout<<(double)(ma-i)*m[i]/ma/ma2<<endl;
        }
        ans+=0.01;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int M; cin >> M;
    vec d(M), c(M);
    REP(i, M) cin >> d[i] >> c[i];
    int s = 0, n = 0;
    REP(i, M){
        s += d[i] * c[i];
        n += c[i];
    }
    int ans = (s - 1) / 9 + n - 1;
    Out(ans);

    return 0;
}


Measured memory_bytes: 3456
N = gets.to_i
S = N.times.map { gets.chomp }

counter = Hash.new(0)
maxV = 0

S.each do |s|
  counter[s] += 1

  maxV = counter[s] if maxV < counter[s]
end

puts counter.select { |s, cnt| cnt == maxV }.keys.sort


Measured memory_bytes: 53620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;cin >> a >> b;

    for (int c=1;c<=3;c++) {
        if ((a*b*c)%2 == 1){
            cout << "Yes" << endl;
            return 0;
        } 
    }

    cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define emp emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n;
int main()
{
		FAST
		cin>>n;
		pair<string,pair<ll,ll>>A[n];	
		FOR(i,0,n){
			cin>>A[i].f>>A[i].s.f;A[i].s.s=i;
		}
		sort(A,A+n,[](pair<string,pair<ll,ll>> x, pair<string, pair<ll,ll>> y) { if(x.f!=y.f)return x.f<y.f; else return x.s.f>y.s.f; });
		FOR(i,0,n){
			cout<<A[i].s.s+1<<'\n';
		}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[200010], B[200010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B, B + N, greater<int>());
	if (B[0] == B[1]) {
		for (int i = 0; i < N; i++) {
			cout << B[0] << endl;
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			if (A[i] == B[0]) cout << B[1] << endl;
			else cout << B[0] << endl;
		}
	}
}


Measured memory_bytes: 3200
fun main(args:Array<String>) {
    val qhsd = readLine()!!.split(" ").map { it.toInt() }
    val n = readLine()!!.toLong()
    val singleLitre = listOf(qhsd[0]*4, qhsd[1]*2, qhsd[2]).min()!!
    val doubleLitre = Math.min(singleLitre*2, qhsd.last())
    val ans = Math.min(singleLitre*n, n/2*doubleLitre + (n%2)*singleLitre)
    println(ans)
}

Measured memory_bytes: 38820
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k, a[N], dep[N], L[N], R[N], dfc, pa[17][N];
int bit[N];
inline void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i & -i;
	}
}
inline int sum(int i) {
	int res = 0;
	while (i > 0) {
		res += bit[i];
		i -= i & -i;
	}
	return res;
}
pair<int, int> ar[N];
vector<int> G[N];
void dfs(int u, int depth) {
	dep[u] = depth;
	L[u] = ++dfc;
	ar[dfc] = make_pair(dep[u], u);
	for (int v : G[u]) {
		dfs(v, depth + 1);
	}
	R[u] = dfc;
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int ans = (a[1] != 1);
	pa[0][1] = 0;
	for (int i = 2; i <= n; i++) {
		G[a[i]].push_back(i);
		pa[0][i] = a[i];
	}
	for (int i = 1; i < 17; i++)
		for (int u = 1; u <= n; u++)
			pa[i][u] = pa[i - 1][pa[i - 1][u]];
	dfs(1, 0);
	sort(ar + 1, ar + 1 + n);
	for (int _ = n; _ >= 1; _--) {
		int u = ar[_].second;
		if (dep[u] <= k) break;
		if (sum(L[u])) continue;
		ans++;
		int v = u;
		for (int i = 0; i < 17; i++) if ((k - 1) >> i & 1) v = pa[i][v];
		add(L[v], 1);
		add(R[v] + 1, -1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 23296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    ll N,K;
    cin >> N >> K;
    // ll tmp=N+1,min = N;
    // while(min < tmp){
    //     tmp = min;
    //     min = llabs(K -tmp);
    // }
    // cout << tmp << endl;
    ll tmp = N%K;
    if(tmp < K-tmp){
        cout << tmp << endl;
    }else{
        cout << (K-tmp) << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define REP(i, n) for(int i=0;i<(int)n;++i)
#define FOR(i, c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef ll Weight;

struct Edge {
    int src, dst;
    Weight weight;

    Edge(int src, int dst, Weight weight) :
            src(src), dst(dst), weight(weight) {}
};

bool operator<(const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

const ll INF = 1e18;


#define RESIDUE(s, t) (capacity[s][t]-flow[s][t])

Weight maximumFlow(const Graph &g, int s, int t) {
    int n = g.size();
    Matrix flow(n, Array(n)), capacity(n, Array(n));
    REP(u, n) FOR(e, g[u]) capacity[e->src][e->dst] += e->weight;

    Weight total = 0;
    while (1) {
        queue<int> Q;
        Q.push(s);
        vector<int> prev(n, -1);
        prev[s] = s;
        while (!Q.empty() && prev[t] < 0) {
            int u = Q.front();
            Q.pop();
            FOR(e, g[u]) if (prev[e->dst] < 0 && RESIDUE(u, e->dst) > 0) {
                    prev[e->dst] = u;
                    Q.push(e->dst);
                }
        }
        if (prev[t] < 0) return total; // prev[x] == -1 <=> t-side
        Weight inc = INF;
        for (int j = t; prev[j] != j; j = prev[j])
            inc = min(inc, RESIDUE(prev[j], j));
        for (int j = t; prev[j] != j; j = prev[j])
            flow[prev[j]][j] += inc, flow[j][prev[j]] -= inc;
        total += inc;
    }
}

Graph g;

void add(int a, int b, int f) {
    g[a].push_back(Edge(a, b, f));
    g[b].push_back(Edge(b, a, 0));
}

int main() {
    int N, M;
    string U;
    cin >> N >> M;
    cin >> U;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    g.resize(N + 2);
    int ss = g.size() - 1;
    int tt = g.size() - 2;

    for (int i = 0; i < N; i++) {
        int l = U[i] == 'L' ? 0 : A[i];
        int r = U[i] == 'R' ? 0 : A[i];
        add(ss, i, l);
        add(i, tt, r);
    }
    for (int i = 0; i < M; i++) {
        int S, T, B;
        cin >> S >> T >> B;
        --S, --T;
        if (S > T) swap(S, T);
        add(S, T, B);
    }

    cout << maximumFlow(g, ss, tt) << endl;

}


Measured memory_bytes: 6732
import bisect
N, M = map(int, input().split())

L = [[] for i in range(N)]
D = []

for i in range(M):
    p, y= map(int, input().split())
    L[p-1].append(y)
    D.append([p,y])

for i in range(N):
    L[i].sort()

for i in range(M):
    ans = str(D[i][0]).zfill(6)+ str(bisect.bisect_left(L[D[i][0]-1], D[i][1])+1).zfill(6)
    print(ans)

Measured memory_bytes: 76320
import java.lang.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner stdId = new Scanner(System.in);
        int a = stdId.nextInt();
        int b = stdId.nextInt();
        
        System.out.println(a*b+" "+(a*2+b*2));

    }
}

Measured memory_bytes: 26300
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  char c;
  for(int i = 0;i < S.length();i++){
    c = S[i];
    if((c+N) > (65+25)){
      cout << (char)(c+N-26);
    }
    else{
      cout << (char)(c+N);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
//var=var%(1000000007);
#define mod 1000000007

int dp[21][1<<21];
int solve(int arr[][21],int &n,int visit,int ind)
{  if(ind==n)
    {
        return 1;
    }
    if(dp[ind][visit]!=-1)
      return dp[ind][visit];

    int var=0;
    for(int i=0;i<n;i++)
    { if(arr[ind][i]==1 && (((visit&(1<<(i)))==0)))
        { int num=visit|(1<<i);
                //cout<<ind+1<<" "<<i+1<<endl;
            var=( (var%mod)+(solve(arr,n,num,ind+1)%mod) )%mod;


        }
    }

     dp[ind][visit]=var;
     return var;
}
signed main()
{ int n;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;

int arr[21][21]={0};
memset(arr,0,sizeof(arr));
memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];


    int ans=0,z=0;

    ans=solve(arr,n,z,0);

    cout<<ans<<endl;
}


Measured memory_bytes: 347708
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		int sum = 0;
		for (int i = 1; i < 1000000000; i++) {
			sum += i;

			if (X <= sum) {
				System.out.println(i);
				return;
			}
		}
	}

	public static class Pair {
		private int key;
		private int value;

		public Pair(int key, int value) {
			super();
			this.key = key;
			this.value = value;
		}

		public int getKey() {
			return key;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

		@Override
		public String toString() {
			return "{" + key + ", " + value + "}";
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  P(s.substr(0,(int)s.size()-8));
  return 0;
}


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

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

  llint h;
  cin >> h;
  llint ans = 0, cnt = 0;
  while (0 < h) {
    h /= 2;
    ans += pow(2, cnt);
    cnt++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, A[333][333];

  bool M[333][333];

  memset(M, 0xff, sizeof(M));

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    for (int j = 0; j < N; j ++)
      std::cin >> A[i][j];

  for (int i = 0; i < N; i ++)
    for (int j = i + 1; j < N; j ++)
      for (int k = 0; k < N; k ++)
        if (k != i && k != j) {
          int l = A[i][k] + A[k][j];
          
          if (l < A[i][j]) {
            std::cout << -1 << std::endl;

            return 0;
          }
          else if (l == A[i][j]) {
            M[i][j] = M[j][i] = false;
          }
        }

  long long s = 0;

  for (int i = 0; i < N; i ++)
    for (int j = i + 1; j < N; j ++)
      if (M[i][j])
        s += A[i][j];

  std::cout << s << std::endl;

  return 0;
}


Measured memory_bytes: 768
#include <cstdio>
 
char grid[105][105];
int good[105][105];
 
int main()
{
    int H, W;
    scanf("%d %d", &H, &W);
    for(int h = 0; h < H; h++)
        scanf("%s", grid + h);
 
    good[0][0] = (grid[0][0] == '#')? 1 : 0;
 
    for(int step = 1; step <= H + W - 2; step++)
    {
        for(int h = 0; h <= step; h++)
        {
            int w = step - h;
            if(h > H || w > W) continue;
 
            if(!h)
            {
                good[h][w] = good[h][w - 1];
                if(grid[h][w] == '#')
                {
                    ++good[h][w];        
                    if(grid[h][w - 1] == '#') --good[h][w];
                }
            }
            else if(!w)
            {
                good[h][w] = good[h - 1][w];
                if(grid[h][w] == '#')
                {
                    ++good[h][w];      
                    if(grid[h - 1][w] == '#') --good[h][w];
                }
            }
            else
            {
                int up = good[h - 1][w];
                if(grid[h][w] == '#')
                {
                    ++up;        
                    if(grid[h - 1][w] == '#') --up;
                }
 
                int left = good[h][w - 1];
                if(grid[h][w] == '#')
                {
                    ++left;     
                    if(grid[h][w - 1] == '#') --left;
                }
 
                good[h][w] = (up < left)? up : left;
 
            }
        }
    }
 
    printf("%d", good[H - 1][W - 1]);
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))


def query(lamps):
    counts = [0] * n
    for idx, power in enumerate(lamps):
        start, end = idx - power, idx + power
        if start < 0:
            start = 0
        counts[start] += 1

        if end >= n-1:
            continue
        counts[end+1] -= 1

    now = 0
    for idx, count in enumerate(counts):
        now += count
        lamps[idx] = now


def full_check(counts, full):
    for count in counts:
        if count == full:
            continue
        else:
            return False

    return True


for _ in range(k):
    query(A)
    if full_check(A, n):
        break

print(*A)


Measured memory_bytes: 119012
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);  
    int n,m;
    cin>>n>>m;
    cout<<(n*n-n+m*m-m)/2;  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, M; cin >> N >> M;
    //vector<ll> A(N); repp(i,0,N) cin >> A[i];
    priority_queue<ll> q;
    repp(i,0,N) {
        ll a; cin >> a;
        q.push(a);
    }
    repp(i,0,M) {
        ll p = q.top() / 2; q.pop();
        q.push(p);
    }
    ll sum = 0;
    repp(i,0,N) {
        sum += q.top(); q.pop();
    }
    cout << sum << endl;

}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int a, b, ans; cin >> a >> b;
    ans = 0;

    repp(i, a, b+1){
        string s = to_string(i); int l = s.length();
        bool f = true;
        rep(j, l){
            if(s[j] != s[l-1-j]) f = false;
        }
        if(f) ans++;
    }

    out(ans);
}

Measured memory_bytes: 3760
#include<stdio.h>
int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b)
	{
		printf("a < b\n");
	}
	if(a>b)
	{
		printf("a > b\n");
	}
	if(a==b)
	{
		printf("a == b\n");
	}
	
	return 0;
	
}

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

using namespace std;

#define MAX_N 155
#define MAX_K 15
#define INF (1<<29)
typedef pair<int, int> pii;

struct State {
    int dng, x, y, m;
    State(){}
    State(int dng, int x, int y, int m) :
        dng(dng), x(x), y(y), m(m) {}

    bool operator < (const State &s) const {
        return dng > s.dng;
    }
};

int main()
{
    int N, M, K, x, d;
    while (cin >> N >> M, N) {
        vector<pii> G[MAX_N];
        for (int i = 0; i < N; i++) {
            cin >> K;            
            for (int j = 0; j < K; j++) {
                cin >> x >> d; 
                G[i].push_back(pii(x, d));
            }
        }
        G[N].push_back(pii(0, 0));
        
        int dn[MAX_N][MAX_K][MAX_N];
        for (int i = 0; i < MAX_N; i++) {
            for (int j = 0; j < MAX_K; j++) {
                for (int k = 0; k < MAX_N; k++) {
                    dn[i][j][k] = INF;
                }
            }
        }
        
        priority_queue<State> Q;
        for (int i = 0; i < 2; i++) {
            int size = G[i].size();
            int nm = (i == 1 ? M - 1 : M);
            for (int j = 0; j < size; j++) {
                Q.push(State(0, j, i, nm)); 
                dn[i][j][nm] = 0;
            }
        }
                
        while (!Q.empty()) {
            State s = Q.top(); Q.pop();
            int y = s.y, x = s.x, m = s.m;
            int dng = G[y][x].second;
            x = G[y][x].first;
            if (y == N) {
                cout << s.dng << endl;
                break;
            }

            for (int i = 1; i <= 2; i++) {
                int ny = y + i;
                if (ny > N) continue;                
                for (int j = 0; j < (int)G[ny].size(); j++) {
                    int nx = G[ny][j].first, nd = G[ny][j].second;
                    int nm = (i == 2 ? m - 1 : m);
                    int ncost = s.dng + (ny < N ? (dng + nd) * abs(x - nx) : 0);

                    if (nm >= 0 && ncost < dn[ny][j][nm]) {
                        dn[ny][j][nm] = ncost;
                        Q.push(State(ncost, j, ny, nm));
                    }
                }
            }
           
        }
    }
    return 0;
}

Measured memory_bytes: 6356
import Control.Monad
import Control.Applicative
import Debug.Trace
import System.IO

data Tree = Branch Tree Tree | Leaf
          deriving (Eq)
instance Show Tree where
  show (Branch l1 r1) = "("++show l1 ++ ","
                        ++show r1 ++ ")"
  show Leaf = ""

main :: IO ()
main = do
  ss <- (map words . lines) <$> getContents
--  mapM_ (print . map toTree . drop 1) ss
  mapM_ (print . solve) ss
--s <- getLine
--  print (toTree s)

solve :: [String] -> Tree
solve (q:s1:s2:_) = if q == "u" then union' t1' t2'
                    else inter' t1' t2'
  where
    t1' = toTree s1
    t2' = toTree s2
    union' t1 t2 =
      case (t1, t2) of
        ((Branch l1 r1),(Branch l2 r2)) ->
          Branch (union' l1 l2) (union' r1 r2)
        (_, Leaf) -> t1
        (Leaf, _) -> t2
    inter' t1 t2 =
      case (t1, t2) of
        ((Branch l1 r1), (Branch l2 r2)) ->
          Branch (inter' l1 l2) (inter' r1 r2)
        (_, _) -> Leaf
        
toTree :: String -> Tree
toTree str = fst $ go str
  where
    go :: String -> (Tree, String)
--    go [] = (Leaf, [])
    go (s:ss)
      | s == '(' = let (l, _:ss') = go ss
                       (r, _:ss'') = go ss' in
                     (Branch l r, ss'')
      | s == ',' = (Leaf, s:ss)
      | s == ')' = (Leaf, s:ss)

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a-b>c) cout<<0<<endl;
    else cout<<c-(a-b)<<endl;
}

Measured memory_bytes: 256